Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

qq function with variables

by Baz (Friar)
on Oct 24, 2004 at 15:49 UTC ( [id://402042]=perlquestion: print w/replies, xml ) Need Help??

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

Hi all,

I want to print the following -
Seán Connery
with the following code
my $f = "\x{0301}"; $html = qq( <html>Sea$fn Connery<html> ); print html;
But perl sees $fn not $f, what should I do?
Cheers,
Barry.

Replies are listed 'Best First'.
Re: qq function with variables
by Golo (Friar) on Oct 24, 2004 at 15:53 UTC
    <html>Sea${f}n Connery<html>
    should do.
      Indeed it does, thanks.
Re: qq function with variables
by bobf (Monsignor) on Oct 24, 2004 at 16:12 UTC

    You need to tell perl where the variable name stops and where the rest of the text begins, using curlies. Without such a distinction in the example below, "$var12" could mean either $var12 or the value given by join( '', $var1, '2' ).

    use strict; use warnings; my $var1 = 'one'; my $var12 = 'twelve'; print "$var12\n"; # prints 'twelve' print "${var1}2\n"; # prints 'one2'

    This is discussed in perldata, "Scalar value constructors".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://402042]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found