Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: Flipin good, or a total flop?

by bart (Canon)
on Jan 25, 2006 at 22:25 UTC ( #525583=note: print w/replies, xml ) Need Help??

in reply to Re: Flipin good, or a total flop?
in thread Flipin good, or a total flop?

If you're really interested on whether the start condition and/or end condition were triggered, there's another way: using variables to capture the test results. Like this:
if((my $start = /start/) .. (my $end = /end/)) { ...
Later, you simply have to test the boolean value of $start and $end:
print "First time\n" if $start; print "Last time\n" if $end;
but only in the if BLOCK, of course (lexical scope for the variables).

Replies are listed 'Best First'.
Re^3: Flipin good, or a total flop?
by ysth (Canon) on Jan 26, 2006 at 03:25 UTC
    I'm pretty sure that works the same way
    my $i = 13 if $expr;
    does, and is not to be trusted to continue to do what you mean.

    No, maybe I'm wrong. Hmm.

    Update: as long as you don't modify $start or $end except in cases where they were already set, I think you can count on this continuing to work, even if the my $foo if bar thing is "fixed". But I'd expect that if a warning is added for the my $foo if bar thing, that you'd get the warning with your code also.

      bar() if my $foo;
      is different from
      my $foo if bar(); # don't do this!

      The first case is equivalent to

      if (my $foo) { # $foo is lexically scoped to this block bar(); }
      just like how
      for my $foo (@foo) { # $foo is lexically scoped to this block baz(); }

      So if ((my $start =~ /start/) .. (my $end =~ /end/)) is perfectly happy.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://525583]
[Corion]: Meh. I need to find myself a better "programming" feed than r/programming (which is just HackerNews reposts and advertisements, very little code). Maybe I should select a list of links that I liked on r/programming and then google for ...
[Corion]: ... an aggregator site that also listed (ideally) all of these links once. And maybe also have an exclude list to blacklist some of the most spammy links that the site may have never mentioned at all

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2017-07-24 13:19 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (354 votes). Check out past polls.