Re: perl or sed s/// problem

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matt Graham
Date:  
To: Main PLUG discussion list
Subject: Re: perl or sed s/// problem
From: David <>
> line="password    requisite     /lib/security/$ISA/pam_cracklib.so
> newline="password required /lib/security/$ISA/pam_cracklib.so 
> I need to maintain whitespace

>
> perl -p -i -e s/"$line"/"$newline"/ file
>
> That tosses out all kinds of errors


Modern regexp engines allow you to use an arbitrary char as the pattern
delimiter. If I've got slashes in my patterns, I tend to use # as the
delimiter, which allows you to avoid Leaning Toothpick Syndrome. Other people
may use | . # is visually distinctive and not as common as / in some
string-replace contexts, though:

perl -p -i -e 's#"$line"#"$newline"#' file

--
Matt G / Dances With Crows
The Crow202 Blog: http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see




---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss