oddness in quotes (PerlMagick)

oddness in quotes (PerlMagick)

am 12.11.2007 07:17:31 von 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.

Re: oddness in quotes (PerlMagick)

am 12.11.2007 07:25:17 von Peter Makholm

myicq writes:

> 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

Re: oddness in quotes (PerlMagick)

am 12.11.2007 07:30:41 von Petr Vileta

myicq wrote:
> 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}
This IS string but you meant character, right?

> text=>'\x{0416}');
This is string AS IS

> text=>"\x{0416}"
This is unicode character

> My question is: I thought Perl did not differ between single and
> double quotes, as long as used consistently in a string.
You thought bad ;-) Perl diifer between single and double quoutes. Single
quoutes say "this is string as you see it" but souble quoutes say "Evauluate
all between quotes".
So run this example:

my $text = 'ABC';
print 'This is text: $text\n';
print "This is text: $text\n";

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)

Re: oddness in quotes (PerlMagick)

am 12.11.2007 07:53:09 von Uri Guttman

>>>>> "m" == myicq writes:

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

--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org

Re: oddness in quotes (PerlMagick)

am 12.11.2007 11:02:13 von t

Peter Makholm wrote in news:87sl3casky.fsf@hacking.dk:

> myicq writes:
>
>> 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'.

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

Re: oddness in quotes (PerlMagick)

am 12.11.2007 16:33:13 von 1usa

myicq wrote in news:Xns99E64A2A164C0myicqgmxnet@
212.242.40.162:

> 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


--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines:

Re: oddness in quotes (PerlMagick)

am 12.11.2007 23:42:50 von Michele Dondi

On 12 Nov 2007 06:17:31 GMT, myicq wrote:

>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
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^ ..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,