Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!cae780!muir From: muir@cae780.csi.com (David Muir Sharnoff) Newsgroups: comp.lang.perl Subject: perl bug: print "$#_ @_" clobbers $_[0] at start of function Message-ID: <11247@cae780.csi.com> Date: 23 Feb 91 00:29:49 GMT Reply-To: muir@csi.com (David Muir Sharnoff) Organization: Comdisco Systems Inc., Foster City, CA Lines: 41 Unless I'm sadly mistaken, the following code should not produce the following output: config: Perl 3.044 and 4.0Beta, SunOS 4.0.3, Sun4, sun cc, yacc, perl malloc. ----- code ---- #!/usr/bin/perl $run_new{'BDE'} = ' SPW1000-S4'; $run_new{'SDE'} = ' SPW1000-S4'; $run_new{'SPB'} = ' SPW1000-S4'; @foo = &killer(values(%run_new)); sub killer { print "bsplit.i[0] = '$_[0]'.\n"; print "bsplit.i[1] = '$_[1]'.\n"; print "bsplit.i[2] = '$_[2]'.\n"; print "ASPLIT1: ($#_) @_.\n"; print "bsplit.i[0] = '$_[0]'.\n"; print "bsplit.i[1] = '$_[1]'.\n"; print "bsplit.i[2] = '$_[2]'.\n"; } ------ output ------ bsplit.i[0] = ' SPW1000-S4'. bsplit.i[1] = ' SPW1000-S4'. bsplit.i[2] = ' SPW1000-S4'. ASPLIT1: (2) SPW1000-S4 SPW1000-S4 SPW1000-S4. bsplit.i[0] = ''. bsplit.i[1] = ' SPW1000-S4'. bsplit.i[2] = ' SPW1000-S4'. ------ Is this portable? $a = " Jru tankohrstec\n rlhpe,ae"; %a = (0..26,0..26); grep (print ((split(//,$a))[$_]),keys(%a)) -- David Muir Sharnoff. "RISC is about one year ahead" muir@csi.com (415) 358-3664 (415) 644-0441 Comdisco Systems Inc. 919 East Hillsdale Blvd, Foster City, CA 94404