http://qs1969.pair.com?node_id=696174


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.