in reply to •Re: Array: inserting what isn't there
in thread Array: inserting what isn't there

Merlyn, I'm quite the newbie, and have only dipped my monastic toe into the pond of REGEX and haven't touched reading files at all, so this looks like a great place for me to learn something. ;)

A few weeks ago there was a math challenge posted (sorry I don't remember the node ID) about finding the shortest intiger that contained all the successive intigers from 0000 to 9999. In this particular problem, if the file contained only the number sequence "12345" would /^(\d+)/ pick up 12, 34, 45, 234, or even 12345 as .found elements? Why or why not? Coming from a programing language that isn't as text based as Perl (hey, I forgot to mention the language name!) I find regexes useful and a little difficult to wrap my brain around, even after RTFM a few times (okay, after reading the Indigo Perl version of the friendly manual!). Thanks for any insight.

Looking to learn!
Petras.
Don't worry about people stealing your ideas. If your ideas are any good, you'll have to ram them down people's throats.

-Howard Aiken
  • Comment on Re^2: Array: inserting what isn't there

Replies are listed 'Best First'.
•Re: Re^2: Array: inserting what isn't there
by merlyn (Sage) on May 31, 2003 at 16:31 UTC
    A simple test shows that "12345" =~ /^(\d+)/ matches the entire string, as predicted. I'm not sure why you find that mysterious. {grin} I have a book that spends three chapters talking about regular expressions, if you need that level of instruction.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Oh, I'm finding the whole world outside of the Java bubble to be mysterious, and pretty freaking simpler! Yet having only about 20 minutes a month to spend on playing with learning Perl makes me sort of a perpetual newbie, so I've always got something to learn.

      Thanks for the book recomendation. Can I borrow a copy? ;)

      Cheers!
      Petras

      Don't worry about people stealing your ideas. If your ideas are any good, you'll have to ram them down people's throats.

      -Howard Aiken