Hellena has asked for the wisdom of the Perl Monks concerning the following question:

I get some code It works but don't understan this part !$dump_done...
my $dump_done = 0; foreach my $line(keys %results){ if ($results{$line} == 1 and !$dump_done) { print Dump($post); $dump_done = 1; } }

Replies are listed 'Best First'.
Re: What this mean !$var ?
by roboticus (Chancellor) on Feb 19, 2013 at 14:22 UTC

    Hellena:

    The !$varname construct is the ! operator followed by the variable $varname. The ! operator is logical negation--but I pronounce it mentally as "not". So your line of code, in my head, reads as: "if $results{$line} is 1 and not $dump_done then...".

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      Aha understand now it mean: if $results{$line} is 1 and not $dump_done then expression is true for firs element cose not $dump_done = 0 and for next element expression is false cose not $dump_done = 1 Am I right?

        Hellena:

        Yes, that's right.

        ...roboticus

        When your only tool is a hammer, all problems look like your thumb.

Re: What this mean !$var ?
by Anonymous Monk on Feb 19, 2013 at 14:16 UTC