in reply to RE: Re: something about improving code...
in thread something about improving code...

Even that has a simpler plan:
my ($START, $STOP) = qw(START STOP); while (<DATA>) { $where = /$START/../$STOP/; if ($where and $where > 1 and $where !~ /E0/) { print "PRINTING\n"; } else { print "not printing"; } } __END__

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
(jcwren) RE: RE: RE: Re: something about improving code...
by jcwren (Prior) on Jun 28, 2000 at 03:51 UTC
    Even more terse:
    use strict; my ($START, $STOP) = qw(START STOP); while (<DATA>) { my $where = /$START/../$STOP/; print (($where and $where > 1 and $where !~ /E0/) ? "PRINTING\n" : " +not printing"); } __END__
    --Chris

    Updated: to use 'use strict;'. merlyns will work also with this. -w, however, makes both unhappy.
      I didn't know we were golfing... :-)
      my ($START, $STOP) = qw(START STOP); while (<DATA>) { print (($where = /$START/../$STOP/ and $where !~ /^1$|E/) ? "PRINTIN +G" : "not printing"; }

      -- Randal L. Schwartz, Perl hacker

        Just because it's lying wide open... You've got a syntax error, ((close your parens :)

        And because I can't help this either... ( not simpler, just uglier... or is it? )

        my ($START, $STOP) = qw(START STOP); print( do {$_ = /$START/../$STOP/; $_ && $_ !~ /^1$|E/} ? "PRINTING\n" + : "not printing\n") while <DATA>;
        Enjoy!
        --
        Casey