RE: incorrect output



Geetha Weerasooriya wrote:

: When I turn on the " use warnings " it gives the warning '
: Use of uninitialized value in numeric ne(!=) at .....
: line 37, <FILE> line..
:
: Here line 37 is" if (@line != ()) {"


In this case, perl will use the scalar value of @line,
which is a count of its elements.

# Try this:

if ( @line != 0 ) {

# Or this:

if ( @line ) {

HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.

.



Relevant Pages

  • Re: $NF for perl
    ... although I have been programming in Perl for about five years now). ... perception to ignore the "scalar". ... Is the "context clarification" ... No other language, except natural languages, makes use of it to quite ...
    (comp.lang.perl.misc)
  • Another Perl datatype headache ( scalars $, hashes %, and arrays @ )
    ... many other Perl books from O'Reilly and online references. ... Usually, I use scalar @array; ... I still don't know how to declare arrays using only '$' instead of '@' ... Is it possible to write scripts using only '$' instead of other ...
    (perl.beginners)
  • Re: Out of memory!, while extending scalar with vec()
    ... do with accessing a scalar variable with vec.. ... When I run the program with n=28 (perl 5.8.8, linux), I ... extending $$vec, ... $ gdb ./perl ...
    (perl.beginners)
  • Re: IEEE NaN screwed up?
    ... > yes it does help, because I now know that I need BigFloat, but the perl ... > would if the string were NA. ... A scalar in Perl can be a string, ... CUR = 2 ...
    (comp.lang.perl.misc)
  • Re: How does a scalar know what it is?
    ... Does it need to carry this baggage ... >> Think of it as the scalars carrying around a pointer to the baggage ... (This statement equates a perl scalar to an SV.) ... Perl as a pointer to a C structure of type SV". ...
    (comp.lang.perl.misc)