#!/usr/bin/perl my ($x,$a)=(0,1); if ($a || $x++) { print “foon”; } print “$x”; At last, it will print 0 because, during the evaluation of if statement, since $a = 1, the next part of ‘or’ wont be evaluated. So $xContinue reading… Evaluation of if statements
Category: Programming
$_ will hold the reference, not the copy of variable
#!/usr/bin/perl @list=qw(one two three); foreach(reverse @list) { print “$_n”; $_=”foo”; } print “$list[0]n”; Finally it will pring ‘foo’ not ‘one’. Because $_ isn’t a copy of the list element, it’s a reference. Modifying it will change the list.
Disable wildcard epansion in Bash shell
set -f This disables the wildcard expansion in bash shell. Example: $ ksh $ ls -c Tom t tt ufaq $ set -f $ echo t* will output t*