No strict and no warnings means that you are not alerted to the mistake of passing the bareword names to which_element_is().
use strict; use warnings; my @array = qw /fred barney betty dino wilma pebbles bamm-bamn/; my $result = which_element_is ("dino", @array); sub which_element_is { my ($what, @array) = @_; foreach (0 .. $#array) { if ($what eq $array[$_]) { print "$_\n"; return $_; } } print "99\n"; -1; } print "Item $result is $array[$result]\n"
Always use strict and warnings. Always.
In reply to Re: print problem
by hippo
in thread print problem
by yueli711
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |