in reply to Re: search pattern and arrays
in thread search pattern and arrays

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: search pattern and arrays
by toolic (Bishop) on Jan 25, 2008 at 19:43 UTC
    but i forgot how to create a new thread...
    If you want to ask a new question, unrelated to this thread, go to Seekers of Perl Wisdom.
    what does this mean? print qq{$1}
    Read Quote and Quote like Operators. qq is like using double-quotes. So it is similar to
    print "$1"

    Double-quotes allow interpolation of variables. So, if the variable $1 has the value "foo", then "foo" will be printed. $1 is a special variable which is set upon a successful regular expression match (see perlre).

Re^3: search pattern and arrays
by apl (Monsignor) on Jan 25, 2008 at 19:42 UTC
    To start a new thread:
    • Click on Seekers of Perl Wisdom (at the upper right hand corner of your screen).
    • When the new page appears, go to the bottom of the page.
    • Populate the Add your Question title and message boxes.
    • Preview, Preview, Preview, create
    To answer your questions:
    • Get the string stored in $1; use it as the key into a hash named %qq; print the value of that hash element. There should only be one value, by definition.
    • Revised:Get the number stored in $1; use it as the index into an array named @qq; print the value of that array element. There should only be one value, by definition.
    • Try this (though, since this is either homework or an exam, I may be playing with your head. Good luck...):
      if ( /^(\d*).+(\d*)$/ ) { # $1 containing the starting numeric string, if any. # $2 contains the terminating numeric string, if any. }


    Thanks to toolic was proving that my eyesight is every bit as bad as I fear...
      a hash named %qq
      I don't think so. The OP asked about qq{$1}, not $qq{$1}.
        Are those parens? They looked like curly braces to me. Thanks for the heads up.

        (Or I could say sssshhhhh, I'm messing up his homework...)
      thanks apl

      Mercury.