Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re6: Memory Use/Garbage Collection: Java vs Perl

by John M. Dlugosz (Monsignor)
on Sep 03, 2002 at 15:25 UTC ( #194793=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Re: Memory Use/Garbage Collection: Java vs Perl
in thread Memory Use/Garbage Collection: Java vs Perl

Am I correct in my (I'm not sure if it's a memory of something I read somewhere, or an assumption I have formed) that Perl will fold string constants?

Apparently it does not.

perl -MO=Deparse,-q -e"print qq(I am $x\n) . 'and fold this?'"
it taken as
print(('I am ' . $x . "\n") . 'and fold this?');
not print('I am ' . $x . "\nand fold this?").

—John

Replies are listed 'Best First'.
Re: Re6: Memory Use/Garbage Collection: Java vs Perl
by jsprat (Curate) on Sep 03, 2002 at 20:55 UTC
    True, but

    perl -MO=Deparse,-q -e "print 'Hello, ' . 'World'"

    Is parsed as

    print 'Hello, World'; -e syntax OK

    Apparently, the example you gave was more complex than the parser wanted to deal with.

    Update Added -q, as John pointed out below...

      You forgot the -q, so the string folding is done by Deparse's formatting, totally hiding what you were trying to detect.

      Trying it with, it seems that's still indeed working. A few other quick tests, and it seems that the presence of interpolation prevents the merging, rather than merging the tail-end piece as you would expect.

      Any perl hacker want to comment?

      —John

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://194793]
help
Chatterbox?
[LanX]: the local newspaper deletetd an image form 2009 ... ts
[marinersk]: It's not even a decade old. What were they thinking?
LanX angry
[LanX]: will delete Darmstadt now

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2017-05-29 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?