NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Why? (Score:1)
I don't really see why this is bad (feel free to show me the errors of my ways, heh). Why should whether PHP behaves like Perl have any bearing on its merits as a language? I'm always happy to listen to the arguments against PHP, and there are some good ones, but this seems a bit trivial to me.
In addition, PHP's implementation makes more sense in this case, especially since it is consistent with other PHP functions. If explode() returns an array, I can be confident that I always get an array, and the eleme
Re:Why? (Score:3, Informative)
Here's what I was doing. I had a string of codes that looked like this: "2 4 7". So I expected to be able to do:
However, if $str is empty, instead of going thru the loop zero times, which is what I would expect, I go through once and now have an error because "" is not in my $lookup array. Instead, I have to do this:Zero/empty is a perfectly valid construct. explode() et all should support it.--
xoa
Reply to This
Parent
Re:Why? (Score:1)
Your example makes a lot more sense, and I think I understand your complaint better now. :-)
I guess that I've never encountered this type of situation, because I am usually dealing with data that originates from the user. As such, I would be checking what's in $str (or checking each element in $codes) to make sure that it's a valid key for $lookup.
You might prefer to do this:
The @ will suppress errors, sin
It's like grep, but not (Score:2, Funny)
broquaint out