lonewolf28 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I am a newbie trying to wrap my head around perl. when i was trying out a piece of code which searches a target number from the given number.I'm getting an error when i run this piece of code.
sub search { my ( $number, $target ) = @_; foreach my $i ( 0 .. $#$number ) { return $i if $i == $target; } return; } print search (100,50);
what is wrong with this code ? Thanks and happy new year 2015.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can't use string ("100") as an ARRAY ref while "strict refs" in use at ./divide_con_210.pl line 19.
by jmmitc06 (Beadle) on Jan 02, 2015 at 01:43 UTC | |
|
Re^2: Can't use string ("100") as an ARRAY ref while "strict refs" in use at ./divide_con_210.pl line 19.
by LanX (Saint) on Jan 01, 2015 at 23:45 UTC | |
|
Re^2: Can't use string ("100") as an ARRAY ref while "strict refs" in use at ./divide_con_210.pl line 19.
by GrandFather (Saint) on Jan 02, 2015 at 08:27 UTC | |
by lonewolf28 (Beadle) on Jan 02, 2015 at 14:37 UTC | |
|
Re^2: Can't use string ("100") as an ARRAY ref while "strict refs" in use at ./divide_con_210.pl line 19.
by Anonymous Monk on Jan 02, 2015 at 02:39 UTC |