Hello,
Can someone please help that how value of p is coming out as 1 through 17.
My understanding is p should be equal to $. (line number) and it should be printed from 3 to 19 rather 1 to 17.Thanks in advance!
#!/usr/bin/perl ##use warnings; while(<>){ if($p=3..1) { print "p is $p\n"; } }
When i run the same code on a file that has fifteen lines, it returns following
p is 1
p is 2
p is 3
p is 4
p is 5
p is 6
p is 7
p is 8
p is 9
p is 10
p is 11
p is 12
p is 13
p is 14
p is 15
p is 16
p is 17
Also what is difference when i have $p=3..1 vs ($p=3)..1 in if statement above
In reply to flip flop operator and if statement by iThunder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |