while($_ = <stdin>){print "I saw $_" ;} #when this code, is run user is asked for the cmd line input. After entering cmd line input, when enter is pressed, " I saw input" is printed on screen and after that when ctrl+z is pressed cursor goes back to directory.
"C:\perlfiles>perl test1.pl
cat
I saw cat"
In case of array
while(@_= <stdin>){print " I saw @_" ;} #when this code, is run user is asked for the cmd line input. After entering cmd line input, when enter is pressed, " I saw input" is printed on screen and after that when ctrl+z is pressed cursor goes back to cmd line for input rather than going back to directory, like in case of $_.
"C:\perlfiles>perl test.pl
hi
there
how
r
u
^Z
I saw hi
there
how
r
u"
My confusion is, ctrl+z is used to exit input from cmd line, so why does it not exit cmd line input in case of array input? I have to use ctrl+c to go to dir level. But in case of scalar input, I could exit using ctrl+z.