print statement creates key in hash with reference to empty array??

D

Dr.Ruud

Abigail schreef:
[why Deparse keeps {} for a single statement]

$ perl -le 'my $x = "foo"; if (1) {my $x = "bar"} print $x'
foo

$ perl -le 'my $x = "foo"; my $x = "bar" if 1; print $x'
bar

$ perl -le 'my $x = "foo"; 1 and do {my $x = "bar"}; print $x'
foo

$ perl -le 'my $x = "foo"; 1 and my $x = "bar"; print $x'
bar

Thanks for the examples. Yes, lexical dependencies should make the {}
stay.

I benchmarked "if (1) {print}" against "print if 1", and the speed of
the first was less, but less than 5% so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top