http://qs321.pair.com?node_id=11119540


in reply to Learning Programming, desperately need to know what information is contained in scalar variables

If no value is assigned to a scalar variable, it contains undef.

The example in the book doesn't want to show you what undef is, though. You should experiment with assigning various values to the variables and running the comparison, e.g.

my $alice = 'Alice'; my $bob = 'Bob'; say "Catastrophic crypto fail!" if $alice eq $bob;

and

my $alice = 'bob'; my $bob = reverse $alice; say "Catastrophic crypto fail!" if $alice eq $bob;

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re: Learning Programming, desperately need to know what information is contained in scalar variables
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Learning Programming, desperately need to know what information is contained in scalar variables
by Anonymous Monk on Jul 20, 2020 at 08:35 UTC
    Thank you very, very, very much! <3

      ... the book doesn't want to show you what undef is... Actually it does. And probably choroba meant something different and I quoted him wrong. But I’m pretty sure that he doesn’t worry 🤪😎 Hint: Don’t just copy examples from this splendid book. Invent your own. Play and have fun. Good «trivial examples» are pure fun and hard to figure out... 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

        > and I quoted him wrong

        Yes, you did. I said "The example in the book" (emphasis mine, but at a later time), by which I meant that particular example. The book definitely mentions undef somewhere.

        map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
        I see, thank you. I have another question,in this piece of code say "Catastrophic crypto fail!" if $alice eq $bob; what value is $alice eq $bob producing?