Title: perl sed like operations was RE: [Perl-unix-users] perl equivalent to "cut"
Thanks for all the excellent examples, I learned a whole lot more than I bargained for.
I am currently working on converting korn scripts that I have written over to PERL
for the experience. The
It is shorter, but this is better if you might have = in your value:
echo "BLAH=VALUE ONE" | perl -pe 's/.*?=//'
echo "BLAH=KEY=VALUE" | perl -pe 's/.*?=//'
--- Begin Message ---
I wrote:
> echo "BLAH=VALUE ONE" | perl -anF'=' -e "print pop(@F)"
This is shorter:
echo "BLAH=VALUE ONE" | perl -pe
I wrote:
> echo "BLAH=VALUE ONE" | perl -anF'=' -e "print pop(@F)"
This is shorter:
echo "BLAH=VALUE ONE" | perl -pe "s/.*=//"
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Title: Message
another
way:
echo "BLAH=VALUE
ONE" | perl -anF'=' -e "print pop(@F)"
-Original Message-From: Markham, Richard
[mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003
1:54 PMTo:
[EMAIL PROTECTED]Subject: [Perl-unix-users]
perl equivalent to "cut"
how
Title: perl equivalent to "cut"
I'd do something like this
$string = "BLAH=VALUE ONE";
($string) = $string =~ m/=(.+)$/;
print "$string\n";
or
$string = "BLAH=VALUE ONE";
(@string) = split m/=/, $string;
print "@string[1]\n";
Matthew Schneider System Administrator / Programmer SKLD Inform