Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • @numerics = map {/^\d + /?$_:()} ;

    The ? and : are working together here.

    For teh full details look up the perlvar man page and search for "Conditional Operator" and then Ternary operator "?:"

    The expression /^\d + / ? $_ : ()

    is equivalent to:

    if (/^\d + /){
    } else {

    Translated to english:

    "If $_ starts with a digit give me $_ otherwise give me the empty list ()"
    • Thank you. Another thing I am not used to yet is that Perl allows operations to be jammed together. I would have expected /^d + / ? $_ : (); In the languages I am familiar with that spacing makes a difference. It would be an error to write like that!