[NTLUG:Discuss] Perl pattern matching problem
Victor Brilon
victor at victorland.com
Mon May 1 23:01:36 CDT 2006
On May 1, 2006, at 10:51 PM, Douglas Scott wrote:
> I have an odd problem with some Perl code.
>
[ snip ]
> my ($Order, $Count);
>
> foreach my $Spec ( <LIST> )
> {
> chomp $Spec;
> ($Order, $Count) = split /\t/, $Spec;
> $Count = sprintf "%04d", $Count;
> print "$Order, $Count\n";
> foreach my $Line ( @Model )
> {
> $Line =~ s/<stno>/$Order/g;
> $Line =~ s/<pc>/$Count/g;
> print $Line;
> }
> }
2 observations:
1) Where is the @Model array defined?
2) Since you never reinitialize $Order and $Count inside the loop, if
the split() returns nothing, you're picking up the values from the
last iteration through the loop.
Victor
More information about the Discuss
mailing list