in reply to Re: How to test for a new line
in thread How to test for a new line

aaahhhh for any one else who may want to know how to do this I got it to work by doing this

$myvar1 == "\n"

BadMojo
mford@badmojo.biz
www.badmojo.biz

!=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-!
When something works but shouldn't thats BADMOJO baby.

Replies are listed 'Best First'.
Re^3: How to test for a new line
by dragonchild (Archbishop) on May 13, 2005 at 15:10 UTC
    Try 'eq' and you'll be better off.

    Oh - turn on warnings. You'll have found you're not doing what you think you're doing.


    • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
    • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
Re^3: How to test for a new line
by Fletch (Bishop) on May 13, 2005 at 15:10 UTC

    That's only working because whatever's in $myvar1 and "\n" both happen to evaluate to 0 in a numeric context. You really meant eq; see perldoc perlop.

    Update: Now if what you really mean is "is it a blank line with nothing but whitespace" you probably want $myvar1 =~ /^\s*$/

      if ($tfcont1 eq \n) nor if ($tfcont1 eq "\n") works any ideas?

      BadMojo
      mford@badmojo.biz
      www.badmojo.biz

      !=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-!
      When something works but shouldn't thats BADMOJO baby.