Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Can't happen bug follow-up -- Can an if/else be bypassed?

by ursus (Acolyte)
on Jul 05, 2008 at 20:32 UTC ( [id://695746]=note: print w/replies, xml ) Need Help??


in reply to Re: Can't happen bug follow-up -- Can an if/else be bypassed?
in thread Can't happen bug follow-up -- Can an if/else be bypassed?

True, but that's not bypassing an if/else. Rather, it's creating a string that happens to contain the words 'if' and 'else'.
  • Comment on Re^2: Can't happen bug follow-up -- Can an if/else be bypassed?

Replies are listed 'Best First'.
Re^3: Can't happen bug follow-up -- Can an if/else be bypassed?
by why_bird (Pilgrim) on Jul 08, 2008 at 08:21 UTC
    $_ = <<'}';

    Eh? That's the left shift operator, right? How does that code work?

    from perlop:

    'Binary "<<" returns the value of its left argument shifted left by the number of bits specified by the right argument. Arguments should be integers.'
    but how does it let you fiddle with the if..else statement? (I'm not very good at 'non-obvious' code..)


    thanks! why_bird

    ........
    Those are my principles. If you don't like them I have others.
    -- Groucho Marx
    .......

      In this case, the << marks a here-doc, and '}' is the marker. This is equivalent:

      $_ = <<'END_OF_STRING'; if ($some_condition) { return $X; } else { return $Y; END_OF_STRING die "not reached";

      You can find here-docs documented in perlop.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://695746]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-25 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found