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: Question on a perlsub statement.
    ... print "scalar context...\n"; ... Here's how I thought how Perl should've ... Perl provides a list context to the rhs. ... The way it does work is pretty much the only way list assignment ...
    (comp.lang.perl.misc)
  • 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: Perl scalars as numbers or character strings
    ... It's not the syntax you're having trouble with, ... Perl doesn't have strongly typed variables the way the languages you ... A scalar holds one data value, such as a string or a number. ...
    (comp.lang.perl.misc)
  • Re: Perl scalars as numbers or character strings
    ... It's not the syntax you're having trouble with, ... Perl doesn't have strongly typed variables the way the languages you ... A scalar holds one data value, such as a string or a number. ...
    (comp.lang.perl.misc)