develooper Front page | perl.beginners | Postings from February 2002

RE: Reg Exp help

Thread Previous
Jeff 'japhy' Pinyan
February 26, 2002 06:58
RE: Reg Exp help
Message ID:
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
RPI Acacia brother #734
** 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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About