deibyz has asked for the wisdom of the Perl Monks concerning the following question:
I've noticed a weird behavior of a very simple loop with a warn statement.
#!/usr/bin/perl use strict; use warnings; for my $f (qw(a b)){ print $f; warn "."; }
This code runs as expected an produces thew following output:
. at test.pl line 7. . at test.pl line 7. ab
However, if I don't put an argument to warn:
#!/usr/bin/perl use strict; use warnings; for my $f (qw(a b)){ print $f; warn ; }
I get the following output:
Warning: something's wrong at test.pl line 7. Warning: something's wrong at test.pl line 7. a1
Notice the "1" instead of "b".
Any ideas about this behavior?
My perl version:
$ perl -v This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange warn behavior in loop
by wazoox (Prior) on Jul 16, 2007 at 12:09 UTC | |
by blazar (Canon) on Jul 17, 2007 at 10:21 UTC | |
|
Re: Strange warn behavior in loop
by moritz (Cardinal) on Jul 16, 2007 at 11:21 UTC | |
|
Re: Strange warn behavior in loop
by rpanman (Scribe) on Jul 16, 2007 at 11:20 UTC | |
|
Re: Strange warn behavior in loop
by johngg (Canon) on Jul 16, 2007 at 11:06 UTC | |
|
Re: Strange warn behavior in loop
by betterworld (Curate) on Jul 16, 2007 at 13:40 UTC | |
|
Re: Strange warn behavior in loop
by ikegami (Patriarch) on Jul 16, 2007 at 14:41 UTC |