How can my Perl code catch Ctrl+D? -


chomp($input = <>); 

how know whether $input ctrl+d?

you know have reached eof when undef <>, in case chomp hiddening it.

the usual perl idiom read until eof follows:

while(<>) {   chomp;   # whatever want line in $_   # ... } 

Comments

Popular posts from this blog

python - Why doesn't list have safe "get" method like dictionary? -

razor - Is this a bug in WebMatrix PageData? -

sql server - Stored procedure -