Code Comments
Programming Forum and web based access to our favorite programming groups.How will I get the file name when I do an inline edit like this: perl -i.orig -pe '$_ =3D <filename> $_' filename How would I get the file name in <filename>? Thanks, Rex
Post Follow-up to this messageWell, I did try that with $ARGV[0], but to no avail. Yes, I had posted a = POC. Here is the true code that would not print the file-name. What am I = doing wrong? perl -pe '$_ =3D "$ARGV[0] \t $_"' trace.txt -----Original Message----- From: Jose Alves de Castro [mailto:jac@natura.di.uminho.pt]=20 Sent: Wednesday, September 22, 2004 12:40 PM To: Arul, Rex Cc: beginners@perl.org Subject: Re: Inline Edit -- File name On Wed, 2004-09-22 at 15:24, RArul@newenergyassoc.com wrote: > How will I get the file name when I do an inline edit like this: >=20 > perl -i.orig -pe '$_ =3D <filename> $_' filename That won't compile, but I believe you're posting something like a proof of concept rather then code... If I get this correctly, you're looking for the $ARGV variable. Check out: perldoc perlvar > How would I get the file name in <filename>? >=20 > Thanks, > Rex --=20 Jos=E9 Alves de Castro <cog@cpan.org> http://natura.di.uminho.pt/~jac
Post Follow-up to this messageThanks for the help.=20 This works: perl -pe '$_ =3D "$ARGV \t $_"' trace.txt =20 This doesn't: perl -pe '$_ =3D "$ARGV[0] \t $_"' trace.txt =20 perldoc perlvar says that $ARGV must be used for command-line processors and in array-context as @ARGV for running scripts. Thanks, once again. -----Original Message----- From: Arul, Rex=20 Sent: Wednesday, September 22, 2004 1:27 PM To: 'jac@natura.di.uminho.pt' Cc: beginners@perl.org Subject: RE: Inline Edit -- File name Well, I did try that with $ARGV[0], but to no avail. Yes, I had posted a POC. Here is the true code that would not print the file-name. What am I doing wrong? perl -pe '$_ =3D "$ARGV[0] \t $_"' trace.txt
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.