Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: $1[ (or "Does an array @1 exist in Perl ? - Yes!")

by davido (Cardinal)
on Oct 11, 2017 at 15:52 UTC ( [id://1201171]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -E 'our @array = (1,2,3); *1=\@array; say for @1;'
    1
    2
    3
    
  2. or download this
    # $1 will be undef, so not relevant to the pattern. [0] will be a sing
    +le-character character class, so matches "0".
    perl -E 'our @array = (1,2,3); *1=\@array; say for @1; say "yes" if "0
    +" =~ m/.?${1}[0]/;'
    ...
    2
    3
    yes
    
  3. or download this
    # $1[0] is seen as interpolation, placing the value of "1" into the re
    +gexp, which matches with the "1" in our target string.
    perl -E 'our @array = (1,2,3); *1=\@array; say for @1; say "yes" if "1
    +" =~ m/.?$1[0]/;'
    ...
    2
    3
    yes
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1201171]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-18 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found