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

?
  • Comment on Re^8: open(), go away with bad way, or fail with the right way?

Replies are listed 'Best First'.
Re^9: open(), go away with bad way, or fail with the right way?
by karlgoethebier (Abbot) on Jun 02, 2019 at 18:25 UTC

    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

      I didn't provide the example and you are indeed nitpicking and totally missing the point.

      Something like

      { local $x = $x; ... }
      Is valid, useful and well documented code.