Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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 ( #696174=note: print w/replies, xml ) Need Help??


in reply to Re^2: 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?

$_ = <<'}';

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
.......

Replies are listed 'Best First'.
Re^4: Can't happen bug follow-up -- Can an if/else be bypassed?
by kyle (Abbot) on Jul 08, 2008 at 14:44 UTC

    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://696174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2021-10-23 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?