> I know I can write an if() clause to match every possible case, but I'm
> wondering if there is a more general approach that would allow me to
> dynamically match a varying number of extra columns within a single
> expression.

You could shove all the data points into one parenthetical group in
the first regex and then process them inside the if statement.
Something like:

my $line = 'HGYPG5    M1_LG       OT   0.00E+00   2.00E-08  amps      1.000E-06
4.000E-11    2.000E-11    6.000E-11    4.000E-11    8.000E-11';
$line =~ s/[\r\n]/ /g; #line wrap

# ... is everything else that i'm too lazy to type ;)
if ($line =~ /^...(?:amps|volts)((?\s+[.0-9eE+-]+)+)$/) {
  # last backref contains all data points
  my (..., $datapoints) = (..., $6);
  my @datapoints = split //, $datapoints;
  # process based on (scalar @datapoints)
}

HTH,
Dave

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to