Hello,

I'm just maintain this odd script.
On the code;
  foreach my $val (@{$$code{"1"}}) {
I think $val is lexical but in the 2nd call of test_val
the data is changed.
I don't want it.
I must code like;
    my $val2 = $val;
    $val2 =~ s/^0+//;
to avoid the changing.

I cann't understand why?

#!/usr/bin/perl
use strict;
print "TEST1 start...\n";
my %code;
push @{$code{"1"}}, "01";
push @{$code{"1"}}, "02";
push @{$code{"1"}}, "03";

for (1..2) { test_val($_, \%code) }

sub test_val {
  my $p = shift;
  my $code = shift;
  print "test_val p=$p\n";
  foreach my $val (@{$$code{"1"}}) {
    print "val=$val\n";
    $val =~ s/^0+//;
    print "val=$val\n";
  }
}

__END__


C:>TEST1.pl
TEST1 start...
test_val p=1
val=01
val=1
val=02
val=2
val=03
val=3
test_val p=2
val=1
val=1
val=2
val=2
val=3
val=3

Regards,
H.T.
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to