On Thu, Jan 15, 2009 at 3:22 PM, Chanan Berler <[email protected]> wrote: > Hi All, > > I am wondering if there is a difference between: > The last one I believe I know the answer, empty string still defined, but I > sure wanna clear view..:-) > PS: will use strict / warning will make a difference ?
This question implicates you for not using strict. Use strict. :-) > do_somthing if ($legend); This is a good test if you don't know anything about $legend. It won't cause a warning when $legend is undefined. You may omit the parentheses here, BTW. > or > > do_something if (defined($legend)); This will do_something when $legend is zero or the empty string. > or > > do_something if ($legend == ""); Run this and read the warning. It should be valuable to you. If you really want string comparison, use eq, not ==. > > another question: > is there a difference between > > @arr = (); > > And > > @arr; "@arr" on a line of its own doesn't mean anything (except to give away that you aren't using strict). @arr = () clears the array (sets it to length zero). my @arr and my @arr = () are equivalent. > Since both of them showed nothing when trying to do this: > print "Yea" if (@arr); > > > thanks > Chanan > > _______________________________________________ > Perl mailing list > [email protected] > http://perl.org.il/mailman/listinfo/perl > -- Gaal Yahas <[email protected]> http://gaal.livejournal.com/ _______________________________________________ Perl mailing list [email protected] http://perl.org.il/mailman/listinfo/perl
