I have a script in which I am using foreach in two diff ways
I am doing a last; in the very first loop So each time the variable $t should be assigned only once.
But you can see the results dont match.
#!/usr/bin/perl use strict; use warnings;
my @alpha = qw(a b c d );
my $t="";
foreach ( @alpha ){
$t=$_;
last;
}print "Value of t is '$t'\n";
# OUTPUT: Value of t is 'a'$t="";
foreach $t ( @alpha ){
last;
}
print "Value of t is '$t'\n";
# OUTPUT: Value of t is ''exit 0;
Not that it is a big problem for me , In my actual script I just have avoided the second format and my problem is solved. But the puzzle is, How does $t get reset in the foreach
Thanks Ram
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
