Function call inside Quotes? 
Author Message
 Function call inside Quotes?

In situations like this:

my $word = "some text " . length($y) . " more text"; # 1 syntax

Obviously, if I do the following, I won't be the same as in #1 above:

my $word = "some text length($y) more text"; # 2 syntax

My question is: Is there some way to use the #2 syntax, with maybe some
special character before the call to length, so that perl knows to treat
it as a function call, as in #1? Or do I have to stick to #1?

Thanks.

--
www.MainFrameForum.com - USENET Gateway



Wed, 27 Apr 2005 21:16:04 GMT  
 Function call inside Quotes?

Quote:

> my $word = "some text length($y) more text"; # 2 syntax

> My question is:

Frequently Asked.

You should check the Perl FAQ *before* posting to the Perl newsgroup.

Quote:
> so that perl knows to treat
> it as a function call

          ^^^^^^^^

   perldoc -q function

      "How do I expand function calls in a string?"

--
    Tad McClellan                          SGML consulting

    Fort Worth, Texas



Wed, 27 Apr 2005 22:19:48 GMT  
 Function call inside Quotes?

: In situations like this:
:
: my $word = "some text " . length($y) . " more text"; # 1 syntax
:
: Obviously, if I do the following, I won't be the same as in #1 above:
:
: my $word = "some text length($y) more text"; # 2 syntax
:
: My question is: Is there some way to use the #2 syntax, with maybe some
: special character before the call to length, so that perl knows to treat
: it as a function call, as in #1?

Yup.




Thu, 28 Apr 2005 04:58:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Calling C function inside Perl script

2. interpolating a function call in double quotes

3. calling perl inside a system call with meta-characters

4. substituting for matches not inside quotes?

5. Comma delimited fields with line returns inside a double quote

6. Avoiding split matching inside quotes?

7. $x{$y} inside double quotes in print problem

8. Comma delimited fields with line returns inside a double quote

9. expanding variable inside double quotes

10. split on comma except when embedded inside quotes

11. newbie: Quote character inside a literal srting?

12. how to pass a function name to a function, and have it call it

 

 
Powered by phpBB® Forum Software