Is there a way to make a perl one-liner into a bash function?
#!/bin/bash
# ~/.bashrc:
stopwatch() {
perl -wE 'for (reverse 1..(shift)-1) {system q!clear!;open FIGLET,q!|figlet -f banner -c!;printf FIGLET "%2d:%02d",$_/60,$_%60;sleep 1}' "$1"
}
source
-ing ~/.bashrc
complains as follows:
- unexpected EOF while looking for matching `''
- syntax error near unexpected token `reverse'
- and so on..
Usual shell wrapping works of course, but here I try to have a bash alias/function invoking perl.
There must be a way without needing to create a brand new *.pl
file. Much appreciated!
You may try to run bash and perl script together in this way as well. Moreover in your case -E is where I doubt. perl -e always works but perl -E didn't work in perl 5.8.8
See the code of combining perl with bash