Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Curious about executing within quotes? 2

Status
Not open for further replies.

ejaggers

Programmer
Feb 26, 2005
148
US
Since Perl has many ways to do things, can you execute something in quotes?

i.e. print “I am curious about executing”, &ThisFunction(), “within quotes\n”;

Works fine, but is there a way to do this:
print “I am curious about executing &ThisFunction() within quotes\n”;
 
printf("I am curious about executing %s within quotes\n", &ThisFunction());

maybe

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Yes, although it can make code harder to read and maintain. Here is one example:

Code:
print "I am curious about executing @{[ThisFunction()]} within quotes\n";

sub ThisFunction {
    return "a function";
}

That is pretty much straight out of the perl FAQs:






------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Yeah KevinADC, you're right about harder to maintain, but I figured there was a way.....Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top