Most perl scripts I write start like this:
#!/usr/bin/perl use strict; use warnings; #maybe the GPL or some other stuff...Additionally it's always required to set the "x flag" via chmod - all in all quite annoying.
np() {
gplfile=~/Dokumente/gpl.txt
if [ $# -eq 0 ]
then
echo "filename required..."
return
fi
if [ -e "$1" ]
then
echo "file already exists!"
return
fi
touch "$1" || { echo "can't touch $1" ; return ; }
echo "#!/usr/bin/perl" >> "$1"
if [ "$2" = "gpl" ] && [ -e "$gplfile" ]
then
cat "$gplfile" >> "$1"
fi
echo "" >> "$1"
echo "use strict;" >> "$1"
echo "use warnings;" >> "$1"
echo "use 5.10.0;" >> "$1"
echo "use feature 'say';" >> "$1"
echo "" >> "$1"
chmod 700 "$1"
[ $EDITOR ] || EDITOR=vim
$EDITOR "$1"
}