Simply check the return value from system().
prints 0 on this 'ere system if I quit 'more' by hitting q, 2 if I quit by hitting control-C, 35072 if I kill-9 the 'more' process, and 36608 if I kill -15. The exact values returned may differ slightly from one implementation of 'more' to another, but you're probably safe if you assume that 0 means the user hit q and non-zero means that 'more' terminated for some other reason - just don't try to portably determine what that other reason was!$ perl -e 'print system("some thing|more")."\n"'
In reply to Re: How to know whether user terminates system("$cmd|more") with q or not?
by DrHyde
in thread How to know whether user terminates system("$cmd|more") with q or not?
by PerlOnTheWay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |