Hi, Everyone!

In my, "I don't want to be a newbie anymore!" quest I've been going through the Llama book. It's taught me a lot! I understand what /^\\[d-m_](\w)*\s/i means now. That's a big change. I also understand that I'd probably never need *that* search....

Wasted time aside, there were a few things I ran into that don't do what I thought they should do. Can someone tell me why?

This first question has to do with code trying to write (1..9).0 seven times in a row; making a column heading, so to speak. This first bit doesn't work:
my @step=(1..9); push (@step, 0); my $step; foreach (@step) { $step . $_; } print ($step x 7);
but this does:
my @step=(1..9); push (@step, 0); my @stepCount=(1..7); foreach (@stepCount) { print @step; }
yet they look like they should do the same thing. Why don't they?

The next bit of Why_Doesn't_it_do_It code is supposed to check for one of two strings, and make sure that it prints three times. Merlyn will probably recognize some of the arguments:
my $what = "fred|barney"; while (<>) { chomp; if ($_ =~ ($what){3}) { print "It's in there.\n"; } else { print "Not there.\n"; } }
doesn't do what this does:
my $what = "(fred|barney){3}"; while (<>) { chomp; if ($_ =~ $what) { print "It's in there.\n"; } else { print "Not there.\n"; } }

Yet to my don'tBeANewbieAnymore eyes it looks like the first code is basically the same as the second, if = means "=". Can someone tell me what's the real difference between the two bits of code?

Thanks. Cheers!
-p
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

In reply to I'm reading a book! It's given me more questons! by Petras

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.