Hello,

Can anyone answer why--in a one-liner using the "-pe" flag--the s///
and tr/// functions do not require a "." (dot) preceding the function
call? Clearly adding a "." (dot) before either one results in an error
(code below). Also, adding a ".=" (dot-equals) sign before the either
the s/// or the tr/// function results in an error (code below).
Additionally, I would like to know if this is a related-or-different
issue compared to the question I posted earlier this week.

Any explanation or assistance appreciated,

Thank you, Bill.

mbook:~ homedir$ cat demo1.txt
this is a test,
I love Unix,
I like Linux too,
mbook:~ homedir$

mbook:~ homedir$ perl6 -pe 's/love|like/admire/; ' demo1.txt
this is a test,
I admire Unix,
I admire Linux too,
mbook:~ homedir$ perl6 -pe '.s/love|like/admire/; ' demo1.txt
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
------> .s/love|like/admire/;
    expecting any of:
        prefix
        term
mbook:~ homedir$ perl6 -pe '.=s/love|like/admire/; ' demo1.txt
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
------> .=s/love|like/admire/;
    expecting any of:
        prefix
        term
mbook:~ homedir$

mbook:~ homedir$ perl6 -pe 'tr/aeiou/12345/;' demo1.txt
th3s 3s 1 t2st,
I l4v2 Un3x,
I l3k2 L3n5x t44,
mbook:~ homedir$ perl6 -pe '.tr/aeiou/12345/;' demo1.txt
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
------> .tr/aeiou/12345/;
    expecting any of:
        prefix
        term
mbook:~ homedir$ perl6 -pe '.=tr/aeiou/12345/;' demo1.txt
===SORRY!=== Error while compiling -e
Missing required term after infix
at -e:1
------> .=tr/aeiou/12345/;
    expecting any of:
        prefix
        term
mbook:~ homedir$

Reply via email to