________________________________
From: Tony Esposito [mailto:[email protected]]
Sent: Monday, August 24, 2009 13:20
To: Shawn H. Corey; Wagner, David --- Senior Programmer Analyst
--- CFS
Cc: Beginners Perl
Subject: Re: one liner in Windows to replace string
I am happy that it works with double quotes BUT now, when I try
to get all files in a directory with a certain extension, the following
does not work ...
perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\*.txt
Tony,
This becomes dependent upon what shell you are running
under. If I run your command minus \ on \* under my Korn shell, it pulls
in all the times. What I did was substitute s/// to print and it gave me
all the files I wanted. My command was;
perl -p -e 'print' *.aapl001q.txt
But when I run under cmd32.exe, then it does not work and I get
the following error:
Can't open *.aapl001q.txt: Invalid argument.
If you have access to the Perl CookBook, it has several ways
of replicating the glob type feature within the script itself. You can
use keyword glob or <> as in @list = <*.txt> or @list = glob("*.txt").
You can also hand on a readdir and use grep to pull what you want into a
array.
Some thoughts...
If you have any questions and/or problems, please let
me know.
Thanks.
Wags ;)
David R. Wagner
Senior Programmer Analyst
FedEx Freight Systems
1.719.484.2097 Tel
1.719.484.2419 Fax
1.408.623.5963 Cell
http://fedex.com/us
does not like th leading * in the file name when I try to pull
all .txt files ...
Help again.
________________________________
From: Shawn H. Corey <[email protected]>
To: "Wagner, David --- Senior Programmer Analyst --- CFS"
<[email protected]>
Cc: Tony Esposito <[email protected]>; Beginners Perl
<[email protected]>
Sent: Monday, 24 August, 2009 12:57:27
Subject: Re: one liner in Windows to replace string
Wagner, David --- Senior Programmer Analyst --- CFS wrote:
> I ran under windows with what Tony sent, both the cmd and
a korn
> shell and both worked and updated as expected..
>
> If you have any questions and/or problems, please let
me know.
> Thanks.
What version of Windows? The last time I used Windows was XP
and it would see single quotes as:
perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\test.txt
which, of course, don't work.
-- Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
-- To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/