Richard L. Grubb wrote: > >Is there any way (or maybe I should say, How many ways are there) in >Perl to get a subroutine to recognize >a null argument? > >For instance, I would like subroutine sample below to >print out > >1 > >2 > >or > >1 >NULL >2 > >Instead, it prints > >1 >2 > >- ----------------- perl code snippet ----------- >&sample(1.0,,2.0); > >sub sample >{ > foreach (@_) > { > print "$_ \n"; > } >} > $x = "1.0,,2.0"; &sample; sub sample { @x = split(/,/, $x); foreach $i (0..$#x) { if($x[$i]) { $x=int($x[$i]); print "$x\n"; } else { print "NULL\n"; } } } __END__ David Seay http://www.mastercall.com/g-s/ ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org