The question is how the statement:
return @some_array;
would not return all array values like return $a, $b $c... etc?
Because the subroutine is called in SCALAR context and the context affects the return value(s). A list (like $a, $b, $c) called in SCALAR context would return the last element of the list. You can use the wantarray operator to determine what context the subroutine was called in.
I got the error!
What error did you get?
my @connection = &trim($conn[0]); if (system("iwconfig wlan0 essid $connection[0] key s:$pawd " ) ) {
Now you are calling trim in LIST context but you appear to only need the first element of the returned list. Perhaps you should only return the first element if that is all you require:
sub trim { my ( $tr ) = @_; return ( split /"/, $tr )[ 0 ]; }
In reply to Re^3: arch linux small app in perl
by jwkrahn
in thread arch linux small app in perl
by heatblazer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |