1851668 Members
4008 Online
104061 Solutions
New Discussion

Re: perl question

 
Jeff Picton
Regular Advisor

perl question

Hi all

Can anyone explain what the print statement below means :-

print "print \q\q\(${tab}before $1 loop line $ct\)\;${marker}\n)";

Cheers

Jeff
4 REPLIES 4
Rodney Hills
Honored Contributor

Re: perl question

Looks like it generating a print statmement for another language. ${tab}, $1, $ct, and ${marker} will be replaced with whatever their current values are. The \n before the ) is odd, since it will put the ) on the next line. The \q\q would generate 2 " marks.

What else do you need explained?

-- Rod Hills
There be dragons...
H.Merijn Brand (procura
Honored Contributor

Re: perl question

For *my* perl's it does do nothing, since \q is *NOT* a recognized escape

--8<--- xx.pl
use strict;
use warnings;

my $tab = "\t";
"some string match on some pattern" =~ m/(match)/;
my $ct = "CT";
my $marker = "##";

print "print \q\q\(${tab}before $1 loop line $ct\)\;${marker}\n)";
-->8---

lt09:/tmp 127 > perl xx.pl
Unrecognized escape \q passed through at xx.pl line 11.
Unrecognized escape \q passed through at xx.pl line 11.
print qq( before match loop line CT);##
)lt09:/tmp 128 >

the qq() operator acts as double quoted strings, and the generated string reminds me of postscript if that is of any help

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Rodney Hills
Honored Contributor

Re: perl question

You're right about the \q (I think I'm remembering some other system), but without the warn/restrict you just get a "q".

Now that you mention it it does kind of look like postscript code...

-- Rod Hills
There be dragons...
harry d brown jr
Honored Contributor

Re: perl question

It's producing perl code:

perl -e '$tab=TAB;$one=DOLLARONE;$ct=CT;$marker=MARKER;print "print \q\q\(${tab}
before $one loop line $ct\)\;${marker}\n)";'

print qq(TABbefore DOLLARONE loop line CT);MARKER

what else is the program doing?

live free or die
harry
Live Free or Die