Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Data::Table - empty values - avoid warnings

by GertMT (Friar)
on Oct 24, 2007 at 20:23 UTC ( #647003=note: print w/replies, xml ) Need Help??


in reply to Re: Data::Table - empty values - avoid warnings
in thread Data::Table - empty values - avoid warnings

thanks for your reply. I'm a bit puzzled with the regex.
((defined($_->[0]) && $_->[0] =~ m/^\d+$/) ? $_->[0] : 0)

Am I correct if I assume that here $_ is defined as 'one single digit or maybe a few digits (d+, no spaces and stuff like that in between the digits) and then if this is not the case it should be a 0 (zero)? Never used this ternary operator and just want to make sure that's what it is.
thanks

Replies are listed 'Best First'.
Re^3: Data::Table - empty values - avoid warnings
by Anonymous Monk on Oct 25, 2007 at 05:31 UTC
    Am I correct if I assume that here $_ is defined as 'one single digit or maybe a few digits ...

    No, $_ is array reference not a scalar. $_ is not being tested for simple number-ness, but the deferenced value, $_->[0], is. Other than that, you are correct in your reading about which value is eventually going to be added.

    - parv

      Oh, but a array reference is a scalar, if only a special type of it.

      No, $_ is array reference not a scalar.

      That was rather thoughtless of me. First sentence should have been: "No, $_ is array reference (not a simple value)."

      -parv

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://647003]
help
Chatterbox?
[1nickt]: kgb not quite as simple as ... and ...; are interchangeable. There are edge cases, shown in perlsyn.
[1nickt]: Hm well actually I guess it's not the trailing semi-colon that's at issue there, it's disambiguation between the ellipsis and the binary flip-flop
[1nickt]: Although the example given does not produce an error as stated, on my perl.
[1nickt]: perl -wE 'say for map { ... } 1..3;' # "Unimplemented at -e line 1" ... <c>perlsyn says that should throw a syntax error...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2017-11-18 19:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?