69 420 1970
69 420 1970

Reputation: 191

What's the role of "* *" in this Perl script?

I have this shell script:

eval{print "Just ";} * * {print "Another ";} * * {print "Perl ";} * * {print "Hacker\n";}

and more variants:

@${print "Just ";} * * {print "Another ";} * * {print "Perl ";} * * {print "Hacker\n";}
$${print "Just ";} * * {print "Another ";} * * {print "Perl ";} * * {print "Hacker\n";}
do{print "Just ";} * * {print "Another ";} * * {print "Perl ";} * * {print "Hacker\n";}
$#{print "Just ";} * * {print "Another ";} * * {print "Perl ";} * * {print "Hacker\n";}

What does * * do? (It also works if I change * * to & &.)

Upvotes: 2

Views: 116

Answers (1)

ysth
ysth

Reputation: 98398

The first * of each pair is multiplication; the second is a glob dereference. So nothing very useful.

With & & the first is bitwise and and the second is a subroutine dereference (and call). I don't know why using the canonical true value (returned by print) as a code ref and calling it doesn't error; I would have expected &{!0} to error like &{"1"} does with Undefined subroutine &main::1; instead it seems to be a no-op.

Upvotes: 3

Related Questions