usmrguru has asked for the wisdom of the Perl Monks concerning the following question:

Dear Programmers, I am very much new to Perl program and using this in survey software tool called Sawtooth. In one of the simple programming I return a image. The specific function '%GraphicsPath()%' is a native script form Sawtooth. It fetches the path of images loaded from the root folder.
[%Begin Unverified Perl if(QUESTIONNAME() =~ /byo/i) { return "<img src=\"\[%GraphicsPath()%\]A42.png\" alt=\"\" border=\"0\" + width=\"240\">"; } End Unverified%]

Currently the image path from program is

http://domainname.com/1403/cgi-bin/GraphicsPath()A42.png

Actually it should be...

http://domainname.com/1403/graphics/A42.png Can any one help me solving this problem? Thanks, Guru

Replies are listed 'Best First'.
Re: Image path is going wrong
by InfiniteSilence (Curate) on Apr 24, 2014 at 15:36 UTC

    If you want to call a function inside of a string you need to either use a weird syntax or break up the string and concatenate,

    perl -e 'sub foo{return qq|xoxoxox|}; print qq|happy @{[&foo]} !|;' happy xoxoxox ! # or perl -e 'sub foo{return qq|xoxoxox|}; print qq|happy |. &foo . q~!~;'

    Celebrate Intellectual Diversity