in reply to Re^2: open(), go away with bad way, or fail with the right way?
in thread open(), go away with bad way, or fail with the right way?

"...This allows things like..."

Yes and no:

#!/usr/bin/env perl use strict; use warnings; use feature qw(say);; my $foo = 'Bar': my $foo = $foo x 2; say $foo; __END__

Perl allows it generously but then it complains about  "my" variable $foo masks earlier declaration in same scope at ./foo.pl line 8..

Iznogoud. But in a block it works flawless - no surprise:

KARL : { my $foo = $foo x 2; say $foo; }

But why the effort? You could say $foo x= 2; which results in BarBar. If this is what you wanted. What i assume.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Replies are listed 'Best First'.
Re^4: open(), go away with bad way, or fail with the right way?
by Anonymous Monk on Jun 01, 2019 at 18:00 UTC
    "But why the effort?"

    It's only a demo. If you read the thread, it would be obvious.

      "...only a demo..."

      Even (or especially) a demo should compile without warnings. And masked variables may lead to pain in the ass (old saying).

      "...read the thread..."

      I have read the thread. Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

        No, I do not defend this as a coding practice -- I'm just trying to elucidate how Perl works.