in reply to Re^2: Empty string checking in output
in thread Empty string checking in output

... the in array @output doesn't contain anything but ... the else block is not executing ...

... because, contrary to what you think, the  @output array contains something. Try printing/dumping the contents of the array. Also, what code are you actually running?

>perl -wMstrict -le "my @output = (); ;; if (@output) { print qq{true clause: array not empty}; } else { print qq{false clause: array empty}; } " false clause: array empty

Replies are listed 'Best First'.
Re^4: Empty string checking in output
by Kumar Mantri (Novice) on Aug 17, 2011 at 09:12 UTC

    yes,i executed the block of code above its printing "true clause: array not empty" but how to find exactly what is there in that?i wrote dis code to check a configuration in cisco devices.

      One way (there are many 'data dumpers'). Note: you must pass a reference to the array to the Dumper function.

      >perl -wMstrict -le "use Data::Dumper; my @output = qw(1 2 foo); print Dumper \@output; " $VAR1 = [ '1', '2', 'foo' ];

      See Data::Dumper.

        Thank you,let me learn and try this..i just want to ask one question ,is there any mistake in my code regarding about not executing the else block?