Somehow I had it my mind that perl would recognize an incoming variable to a sub routine like:
sub test($var) As $_ if there was only one element to @_, But I see from testing that, no, not true. These three methods below all work. Perhaps there are others. if ( -f "@_" ) (my $fname) = @_; if ( -f $fname ) if ( -f $_[0] ) The way in use in script below works... quotations around "@_", so the content is passed rather than the element count. And the ways that are commented out also work. Is there some other way that is normally used? Or are the three shown above all acceptable? What is the preferred way to recognize the variable being passed in this test example? ------- --------- ---=--- --------- -------- cat ./fncInterp.pl #!/usr/local/bin/perl use strict; use warnings; my $fname = './tst'; checkvar($fname); sub checkvar { # (my $fname) = @_; # if ( -f $fname ){ # if ( -f $_[0] ){ if ( -f "@_" ){ print "<@_> is here\n"; }else{ print "<@_> was not found\n"; } } ------- --------- ---=--- --------- -------- output: ./fncInterp.pl <./tst> is here -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/