Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: variables /interpolations inside PPI::Token::Quote::Double quoted string

by Cow1337killr (Monk)
on Sep 06, 2016 at 03:54 UTC ( #1171226=note: print w/replies, xml ) Need Help??


in reply to variables /interpolations inside PPI::Token::Quote::Double quoted string

The input:

my $foo = $bar; print "hi $foo\n"; print 'hi ', $foo, "\n";

...stored in very-easy-print-interpolation2.pl

Run, thusly:

ppi_dumper very-easy-print-interpolation2.pl

ppi_dumper is in App-PPI-Dumper.

The output:

PPI::Document PPI::Statement::Variable PPI::Token::Word 'my' PPI::Token::Whitespace ' ' PPI::Token::Symbol '$foo' PPI::Token::Whitespace ' ' PPI::Token::Operator '=' PPI::Token::Whitespace ' ' PPI::Token::Symbol '$bar' PPI::Token::Structure ';' PPI::Token::Whitespace '\n' PPI::Statement PPI::Token::Word 'print' PPI::Token::Whitespace ' ' PPI::Token::Quote::Double '"hi $foo\n"' PPI::Token::Structure ';' PPI::Token::Whitespace '\n' PPI::Statement PPI::Token::Word 'print' PPI::Token::Whitespace ' ' PPI::Token::Quote::Single ''hi '' PPI::Token::Operator ',' PPI::Token::Whitespace ' ' PPI::Token::Symbol '$foo' PPI::Token::Operator ',' PPI::Token::Whitespace ' ' PPI::Token::Quote::Double '"\n"' PPI::Token::Structure ';'

This demonstrates that PPI does not handle interpolation in a print statement very well, but a print statement with a list does work.

Replies are listed 'Best First'.
Re^2: variables /interpolations inside PPI::Token::Quote::Double quoted string
by Anonymous Monk on Sep 06, 2016 at 06:55 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1171226]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2023-09-29 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?