in reply to Re: oneliner cat like capability
in thread oneliner cat like capability

I see what I did wrong or why it works the way I have. However, why is it important to have the 'n' or 'p' before the 'e'? Thank you for the help.

Replies are listed 'Best First'.
Re^3: oneliner cat like capability
by AnomalousMonk (Archbishop) on Oct 29, 2019 at 23:33 UTC
    ... why is it important to have the 'n' or 'p' before the 'e'?

    Per perlrun, the  -e switch expects source text to follow, either with or without a space. The switch sequence  -en means that Perl is trying to execute "n". The effect of this is made more clear with strictures enabled (see strict):

    c:\@Work\Perl\monks>perl -wMstrict -en "print" foo get_bar() Bareword "n" not allowed while "strict subs" in use at -e line 1. Execution of -e aborted due to compilation errors. c:\@Work\Perl\monks>perl -wMstrict -ep foo get_bar() Bareword "p" not allowed while "strict subs" in use at -e line 1. Execution of -e aborted due to compilation errors.

    Update: See jwkrahn's example here of  -pe1 which gives  -e the source 1 (that's a digit 1) to evaluate within the source code framework established by the  -p switch.


    Give a man a fish:  <%-{-{-{-<

Re^3: oneliner cat like capability
by choroba (Cardinal) on Oct 29, 2019 at 21:09 UTC
    It's not important. You can write the loop yourself:
    perl -e 'print while <>' -- dataoutput.txt

    It's just helpful: if you want to iterate over the input and print always, use -p; if you want to iterate but not print, use -n; otherwise, use neither.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]