oddness in quotes (PerlMagick)

M

myicq

I have done some experimenting with Perl Magick and
unicode.

I have found a very strange thing with quotes. Can someone explain the
following:


# this will fail, resulting in output
# of literal string \x{0416}
# using SINGLE quotes

$image->Annotate(
font=>'arial.ttf',
text=>'\x{0416}');


# this will work
# resulting in a single character
# using DOUBLE quotes

$image->Annotate(
font=>'arial.ttf',
text=>"\x{0416}"
);


My question is: I thought Perl did not differ between single and double
quotes, as long as used consistently in a string.

Btw, using Windows version of Perl and GM.
 
P

Peter Makholm

myicq said:
I have found a very strange thing with quotes. Can someone explain the
following:

'perldoc perlop' can explain it. Read the part starting with 'Quote
and Quote-like Operators'.
My question is: I thought Perl did not differ between single and double
quotes, as long as used consistently in a string.

No, double quotes interpolates while single quotes doesn't. Escape
sequences are only available in quote constructs that
interpolates. (most of them are also available in translitterations
but that is not relevant here)

//Makholm
 
U

Uri Guttman

m> My question is: I thought Perl did not differ between single and
m> double quotes, as long as used consistently in a string.

where did you learn that? have you ever used interpolation in a perl
string? it would make little sense to have both quote do the same thing.

and as someone else pointed out, it is easy to look up quotes in the
docs.

uri
 
T

T

Peter Makholm said:
'perldoc perlop' can explain it. Read the part starting with 'Quote
and Quote-like Operators'.

THANK YOU for the detailed answer. Guess I learned an important lesson
or two.. and first of all: RTFM before asking.

Thank you again, also to other people that replied.

My bad
 
A

A. Sinan Unur

I thought Perl did not differ between single and double
quotes, as long as used consistently in a string.

perldoc perlop

esp. "Quote and Quote-like Operators"

Sinan
 
M

Michele Dondi

My question is: I thought Perl did not differ between single and double
quotes, as long as used consistently in a string.

You thought wrong! See

perldoc perlop


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top