hi,
I'm a complete newbie at perl and was hoping somebody might be able to help me a problem I'm having.
Here is the code:
sub get_partnumber
{
my ($file, $ref) = @_;
my $pn;
print "$ref\t";
while (<$file>)
{
print "$ref\n";
if ($_ =~ /$ref/)
{
/([0-9]{9}|T[0-9]{8})/; #get the part number
$pn= $1;
}
else
{
$pn = 0;
}
}
return $pn;
}
I thought at first that this is a scope problem, and that the $ref variable wasn't available within the while loop. However, itseems that the code isn't going into the while loop at all. I can't think of any reason for this. Can somebody suggest a way to fix it?
Thanks in advance, Jo
I'm a complete newbie at perl and was hoping somebody might be able to help me a problem I'm having.
Here is the code:
sub get_partnumber
{
my ($file, $ref) = @_;
my $pn;
print "$ref\t";
while (<$file>)
{
print "$ref\n";
if ($_ =~ /$ref/)
{
/([0-9]{9}|T[0-9]{8})/; #get the part number
$pn= $1;
}
else
{
$pn = 0;
}
}
return $pn;
}
I thought at first that this is a scope problem, and that the $ref variable wasn't available within the while loop. However, itseems that the code isn't going into the while loop at all. I can't think of any reason for this. Can somebody suggest a way to fix it?
Thanks in advance, Jo