Perl6 How do I do something in BEGIN and END for the $ * IN pipeline?

There are special BEGIN and END patterns in awk that allow you to do something before and after you type inputs. What are the equivalent functions in perl6? For example:

cat someFile | perl6 -ne '{do something before reading input} 
                          {do something else with input}
                          {do something last after all inputs read}'

      

Thank!

lisprog

+3


source to share


1 answer


END say 'end';
say 'middle';
BEGIN say 'begin';

      

displayed:



begin
middle
end

      

See Phasers .

+3


source







All Articles