A third option:
print "Value of code is @{[$res->code]}";
-Paul
> -----Original Message-----
> From:
> IMCEANOTES-Ian+20Stewart_Great+20Lakes_AirTouch+40AIRTOUCH+5FC
> ONNECT@BAM
> .com
> [mailto:IMCEANOTES-Ian+20Stewart_Great+20Lakes_AirTouch+40AIRT
> OUCH+5FCON
> [EMAIL PROTECTED]]
> Sent: Thursday, February 22, 2001 4:24 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: interpolating $obj->varname in strings
>
>
> Two options I can think of:
>
> 1) Pass a list to the print statement:
>
> print "Value of code is: ", $res->code;
>
> 2) use printf():
>
> printf("Value of code is: %s", $res->code);
>
>
>
> HTH,
> Ian
>
>
>
> From: Bennett Haselton <[EMAIL PROTECTED]> on
> 02/22/2001 03:57
> PM
>
> To:
> [EMAIL PROTECTED]@SMTP@JVEXCHANGE
> cc:
> bcc:
>
> Subject: interpolating $obj->varname in strings
>
> I like being able to write
>
> print "Value of var is: $var\n";
>
> but with variable names like or $res->code, if you try to do
>
> print "Value of code is: $res->code\n";
>
> you get:
> Value of rescode is: HTTP::Response=HASH(0x176517c)->code
>
> I can do
> print "Value of code is: " . $res->code . "\n";
> but that gets pretty messy and error-prone in a long string with
> lots of
> interpolated variables.
>
> On the other hand, if you do:
> print "Value of var is: $hash->{'var'}\n";
> then it works properly.
>
> I suspect that the reason that 'print "$res->code\n";'
> doesn't work
> is
> because "code" is not really a member variable name,
> and is actually
> a
> function call that returns a value. But it's still
> annoying. Is
> there any
> easier way to interpolate those variables in strings?
>
> Maybe this sounds lazy, but if I program perl for
> another few years,
> then
> over the long run this will save me typing '" . ' and ' . "'
> hundreds of
> times -- almost enough keystrokes to justify writing
> this message :)
>
> -Bennett
>
> [EMAIL PROTECTED] http://www.peacefire.org
> (425) 649 9024
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
>
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users