in reply to how to match and assign?

split is probably the easiest way to go here.

my @values = split /\|/, $var; if ($values[4] eq $var) { # Values matched. # Use value in $values[10] } else { # values didn't match. }
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me

Replies are listed 'Best First'.
Re: Re: how to match and assign?
by frankus (Priest) on Apr 24, 2001 at 14:13 UTC

    /me assumes that $/=undef is being applied, to allow all the file to be sucked into the variable $var.
    /me also assumes that $var is subsequently being reused to store the matching criteria?

    Or am I being dumb?

    --
    
    Brother Frankus.
      /me assumes that $/=undef is being applied, to allow all the file to be sucked into the variable $var.

      Er... no. The original poster mentioned line at a time processing. Assume the following code around my previous snippet:

      while (defined($var = <FILE>)) { # code here }
      /me also assumes that $var is subsequently being reused to store the matching criteria?

      Wasn't very clear exactly what the original poster wanted to do with the results, so I left it deliberately vague :)

      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me