Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
$rs is a reference, and in the double-quotes, its value gets printed out, as requested -- what Perl interprets your print as :"print the value of $rs, then the string "->fields(0)->value"...

Believe it or not, this is Working as Advertised, but it's one of the gotchas when dealing with objects (and, more generally, references).

My usual way of getting around this is to either use :

printf "The username is %s\n", $rs->fields(0)->value;

or print out a list:

print "The username is ", $rs->fields(0)->value, "\n";

There's another way where you can just wrap the whole thing in a set of double-quotes, but I always forget the syntax of it ... (print "@{ [ $obj->method ] }", but (a) it looks nasty (b) it will confuse you and (c) It looks REALLY NASTY =). I think the only reason it's there is to scare people about Perl syntax ... >=)

Philosophy can be made out of anything. Or less -- Jerry A. Fodor

In reply to Re: Weird Results From MS-SQL Value by arturo
in thread Weird Results From MS-SQL Value by enoch

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2022-08-13 18:56 GMT
Find Nodes?
    Voting Booth?

    No recent polls found