Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: Re: Perl string manipulation - September 19, 1998 at 15:43:41

You are here: irt.org | BBS | Re: Perl string manipulation [This BBS is closed]

Posted by Jason Nugent on September 19, 1998 at 15:43:41:

In Reply to: Re: Perl string manipulation posted by Jason Nugent on September 19, 1998 at 14:52:30:


: if ($string =~ s/ (?=|[^|]+\+-+\+\|\[^|]+ |$)\|\w+\|\+-+\+\| ([^|]+) \|$/$1/)
: {
: $string = $1;
: }
: else {$string = "default value"; }

Just want to clear up something - I don't need the s/// operator in there:
if ($string =~ / (?=|[^|]+\+-+\+\|\[^|]+ |$)\|\w+\|\+-+\+\| ([^|]+) \|$/)
{
$string = $1;
}
else {$string = "default value"; }

since I'm doing an assignment based on a match afterward anyway.

The other version still works, though, although the s/// is not necessary.

Jason
Follow-ups:

You are here: irt.org | BBS | Re: Perl string manipulation [This BBS is closed]

©2018 Martin Webb