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

No, I do not defend this as a coding practice -- I'm just trying to elucidate how Perl works.
  • Comment on Re^6: open(), go away with bad way, or fail with the right way?

Replies are listed 'Best First'.
Re^7: open(), go away with bad way, or fail with the right way?
by karlgoethebier (Abbot) on Jun 01, 2019 at 23:11 UTC
    “...elucidate...“

    Sure, I know. But probably even Perl has a dark side?

    «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

      ?

        O.K. Some might say that this is nitpicking. But anyway. I just wanted to elucidate that Perl has some features that may cause trouble if not used with some discipline.

        Compare this:

        #!/usr/bin/env perl use strict; use warnings; use feature qw(say);; my $foo = qq(bar); __END__

        It works like a charm. Nothing special.

        But in some other languages like in my new useless favorite waste of time something similar doesn't even compile:

        package main func main() { foo := "bar" }
        ./prog.go:4:2: foo declared and not used Go build failed.

        You need to say something like:

        package main import "fmt" func main() { foo := "bar" fmt.Println(foo) }
        bar Program exited.

        The same applies for importing and not using a module or declaring/assigning a variable twice in the same scope, like in the example you provided.

        This is no judgement. But everything has it's price - even flexibility.

        Best regards, Karl

        P.S.: Where you ever forced to search for orphaned variables in a large Perl code base?

        «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