Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

In a word, context. Try it like this:

$self->log(LOGDEBUG, 'EDIT_USER: '. Dumper( { state => 'db_user', usr_id => $self->client->param( 'usr_id' ), edit_usr_id => scalar( $self->client->param( 'edit_usr_id' ) ) +, mode => $self->client->param( 'mode' ) } ) );

Assuming that produces the desired result, the problem is that in your first example, you are calling $self->client->param( 'edit_usr_id' ) in a list context, whereas in your second example it is called in a scalar context.

self->client->param( .. ) probably finishes something like:

sub param { ... return unless exists ... return ...; }

That is to say, it executes a bare return statement if the parameter does not exist. In a scalar context, a bare return will assign undef to the scalar (lvalue). In a list context, it will return the 'empty list' (usually denoted by ()), but when an empty list is incorporated into a larger list, it is folded to nothing. Essentially, it disappears. Eg:

Perl> sub x{ return };; Perl> @b = ( 1,2,'a', x(), 5, 6 );; Perl> print "@b";; 1 2 a 5 6 Perl> @b = ( 1,2,'a', scalar( x() ), 5, 6 );; Perl> print "@b";; Use of uninitialized value in join or string at (eval 13) line 1 1 2 a 5 6

In the former, sub x() is called in a list context, so the return statement returns the empty list and that get folded and disappears making no contribution to the state of @b.

In the latter, it is called in a scalar context, so it returns undef, which causes the 4th element of @b to take the value undef.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: mysterious hash ref result by BrowserUk
in thread mysterious hash ref result by ftumsh

Title:
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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-28 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found