in reply to Action based on Character recieved from STDIN
Something like this:
[ ~/tmp ] $ perl -wle 'use strict; { local $/ = \1; while (<>) { print + "Char: ", $., " is ", $_ } }' qwerty Char: 1 is q Char: 2 is w Char: 3 is e Char: 4 is r Char: 5 is t Char: 6 is y Char: 7 is [ ~/tmp ] $
Update:
See this excellent article which discusses the special variables used here.
Also note that the 'l' in -wle sets $\.
Regards,
PN5
|
|---|