On Wednesday 13 April 2005 6:30 pm, JupiterHost.Net wrote:
> Anish Kumar K wrote:
> > Hi All
>
> Hello,
>
> > The code gives strange error
> >
> > $subject = I get some value from the function
> >
> >  if ($subject eq '' || !defined $subject)
> >  {
> >          Some operation
> > }
> >
> > Operation `eq': no method found, left argument in overloaded package
> > XML::LibXML::NodeList, right argument has no overloaded magic at test.pl
> >
> >
> > why the strange error is coming. I could print the value of
> > $subject......Isn;t it treated as a string.....
>
> Hmm, show the entire code (w/ strict and warnings) as it works fine:
>
> $ perl -e 'if ($subject eq "" || !defined $subject) {print "no
> subject\n";}' no subject
> $
>
> or (w/ strict & warnings)
>
> $ perl -mstrict -we 'my $subject;if (!defined $subject || $subject eq
> "") {print "no subject\n";}'
> no subject
> $

You changed the quotes in the orginal example:

bash-2.05b$ perl -e 'if ($subject eq "" || !defined $subject) {print "no 
subject\n";}'
no subject

bash-2.05b$ perl -e 'if ($subject eq '' || !defined $subject) {print "no 
subject\n";}'
syntax error at -e line 1, near "eq  ||"
Execution of -e aborted due to compilation errors.


It seems '' is not the same as "". Any idea why?



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to