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 the absence of further info, I'd have to suspect a bad build then.

Looking at this further, I am a bit confused as to what the if line does anyway. When I saw it, I thought it was a smart way to test all the values in @user_geg for definedness, but I just ran the following script:

#! perl -w use strict; my @test = ( 0,1,2,3,4,5,6,7,8,9); print 'OK'.$/ if defined( @test[0 .. $#test] ); $test[5] = undef; print 'OK'.$/ if defined( @test[0 .. $#test] ); @test[0 .. $#test] = (undef, undef, undef, undef, undef, undef, undef, + undef, undef, 1); print 'OK'.$/ if defined( @test[0 .. $#test] ); $test[$#test] = undef; print 'OK'.$/ if defined( @test[0 .. $#test] ); __END__ # Output C:\test>test.pl OK OK OK C:\test>

But as you can see, the only value being tested is the last value. Which makes sense as an array slice is just a list, and a list in a scalar context is just its last value. Which means that the test is equivalent to

if ( $user_geg[$#user_geg] ) {...}

That means that your change to $#user_geg-1 is testing the last but one value, which strongly suggests that the last value is undefined?

My only suggestion is to preceed the if with print defined $user_geg[27]; and see what you get? But if you are seeing output from print $user_geg[27];, it should be defined!

Sorry I can't suggest better.


Well It's better than the Abottoire, but Yorkshire!

In reply to Re: Re: Re: defined array question by BrowserUk
in thread defined array question by toadi

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 having a coffee break in the Monastery: (6)
As of 2024-04-23 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found