Home > Archive > PERL Beginners > September 2004 > Inline Edit -- File name
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Inline Edit -- File name
|
|
| RArul@newenergyassoc.com 2004-09-22, 3:57 pm |
| 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
| |
| RArul@newenergyassoc.com 2004-09-22, 8:58 pm |
| 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
-----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
| |
| RArul@newenergyassoc.com 2004-09-22, 8:58 pm |
| Thanks 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
|
|
|
|
|