unixhome has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks: My next question is as follows: In the following:
if (1../^$/) { do this ; }
How can I write the same if I am testing something other than $_ like $not_default? Thanks

Replies are listed 'Best First'.
Re: Help with range operator
by ikegami (Patriarch) on May 15, 2006 at 19:57 UTC
    if (1 .. $not_default =~ /^$/) { do this ; }

      OTOH I think he really wants

      if (1 .. $not_default eq '') { do this ; }

      or even

      if (1 .. !$not_default) { do this ; }

        Well, it's either
        if (1 .. $not_default eq '')
        or
        if (1 .. $not_default eq "\n")
        depending on whether he chomps or not (if $_ is coming from a file as I suspect).

    A reply falls below the community's threshold of quality. You may see it by logging in.