New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shift fails for 0 #343
Comments
From mbc502@sbe1351.swissptt.chThe "shift" function fails when the item shifted is 0. This is illustrated #!/usr/bin/perl -w @list = (-2,-1, 0, 1); The output on my machine is: list element = -2 Site configuration information for perl 5.00503: Configured by root at Wed Feb 9 11:38:32 MET 2000. Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Locally applied patches: @INC for perl 5.00503: Environment for perl 5.00503: |
From [Unknown Contact. See original ticket]MBC502 wrote:
while (0) won't execute anything. while (defined($elt = shift @list)) { ... } or something similar. -- |
From [Unknown Contact. See original ticket]Right you are. Thanks for setting me straight. NHA Norman Azadian; naz@ascom.ch; tel: +41 31 999-3223 (fax: -1019) On Thu, 5 Aug 1999, Rainer J. H. Brandt wrote:
|
From [Unknown Contact. See original ticket]shift isn't failing. You're testing whether the result Probably you should use foreach() instead of while shift. --tom |
From [Unknown Contact. See original ticket]Surely the only way to tell when the list is empty is to look at $#list or @list = (-2, -1, undef, 0, 1); You can't distinguish between the undef returned becaus the list is empty Mike On Thu, 5 Aug 1999, Rainer J. H. Brandt wrote:
-- |
From [Unknown Contact. See original ticket]
I keep expecting someone is going to propose that exists $a[$i] means $#a >= $i --tom, who's kidding. |
From [Unknown Contact. See original ticket]On Thu, 5 Aug 1999, Tom Christiansen wrote:
Can you expect retroactively? :-) Date: Fri, 31 Oct 1997 11:55:09 -0700 (MST) It seems like it would be handy if exists worked on arrays as well as Thoughts? -joseph -- |
From [Unknown Contact. See original ticket]On Thu, Aug 05, 1999 at 11:09:27AM -0700, "Tom Phoenix" wrote:
How about? # Either replace element $i, or append to array... to go along with: { mark (also <half> kidding) -- One ring to rule them all, one ring to find them, one ring to bring them all http://mark.mielke.cc/ |
From [Unknown Contact. See original ticket]Tom Christiansen writes:
I think this might be useful in some situations. Note that exists Ilya |
From [Unknown Contact. See original ticket]On Thu, Aug 05, 1999 at 01:55:25PM -0600, Tom Christiansen wrote:
For the same purpose exists $foo{bar} exists ;-), and for whatever Ilya |
From [Unknown Contact. See original ticket]
To what purpose? --tom |
From [Unknown Contact. See original ticket]
See change below. I think you wanted to test the length of [user1@hoho0 test]$ cat test.pl @list = (-2,-1, 0, 1); |
Migrated from rt.perl.org#1174 (status was 'resolved')
Searchable as RT1174$
The text was updated successfully, but these errors were encountered: