Front page | perl.beginners |
Postings from February 2002
RE: Reg Exp help
Thread Previous
From:
Jeff 'japhy' Pinyan
Date:
February 26, 2002 06:58
Subject:
RE: Reg Exp help
Message ID:
Pine.GSO.4.21.0202260956570.19152-100000@crusoe.crusoe.net
On Feb 26, Daryl J. Hoyt said:
>If there is only one of the lines |GRP| this will work. Otherwise I would
>push the lines into a an array instead of a variable.
>
>@Out = `$Cmd`;
>$WhatFollowsGRP = "";
>
>foreach my $line (@Out)
>{
> if($line =~ /|GRP|/)
You need to escape those |'s. They're special to a regex.
> {
> $line =~ s/|GRP|//;
Whenever I see if (/foo/) { s/foo//; ... }, I suggest it be shortened to
if (s/foo//) { ... } It's less work.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Thread Previous