home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!gatech!psuvax1!atlantis.psu.edu!barr
- From: barr@pop.psu.edu (David Barr)
- Subject: Perl bug regarding ($foo,@bar)=&func();
- Message-ID: <u==1Hzt0ub@atlantis.psu.edu>
- Sender: news@atlantis.psu.edu (Usenet)
- Organization: Penn State Population Research Institute
- Date: Sat, 02 Jan 93 20:55:26 GMT
- Lines: 44
-
- $RCSfile: perl.c,v $$Revision: 4.0.1.7 $$Date: 92/06/08 14:50:39 $
- Patch level: 35
-
- In the following code, case 1 will work, while case 2 will seg fault.
- (Thanks to Bill Fenner for writing this sample code based on one of my
- messes)
-
- Is there a fix for this?
-
- #!/usr/bin/perl
- #
-
- &recurse(1);
-
- sub recurse {
- local($level)=@_;
- local(@foo);
-
- print "Level $level...\n";
- #
- # Case 1 works.
- # @foo=&getstuf($level); # case 1
- # $junk=shift(@foo); #
- #
- # Case 2 seg faults when we go to recurse
- ($junk,@foo)=&getstuf($level); # case 2
- #
- print join(" ",@foo),"\n";
- foreach $i (@foo) {
- print "About to call recurse($i)...\n";
- &recurse($i);
- }
- }
-
- sub getstuf {
- local($level)=@_;
-
- ("junk",($level > 5) ? () : (($level+1) x $level));
- }
-
- --Dave
- --
- System Administrator, Population Research Institute barr@pop.psu.edu
- #define ENOTTY 25 /* Not a typewriter */
-