Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: RE question...yup, another one ;)

by btrott (Parson)
on May 26, 2001 at 23:26 UTC ( [id://83532]=note: print w/replies, xml ) Need Help??


in reply to RE question...yup, another one ;)

Okay... well, since you don't want a direct answer, I will give you an answer in a black box that you don't have to read, and then I will give you a clue.

A regex is *way* too big a tool for this job.

print $_ % 10, "\n" for 0..300;

Here's your hint: think of a mathematical operator that might do what you want here. It's in perlop, under Multiplicative Operators.

Replies are listed 'Best First'.
Re: Re: RE question...yup, another one ;)
by Anonymous Monk on May 27, 2001 at 00:31 UTC
    For the solution above, btrott, I believe you have it wrong. What happens when you get to 300? It prints 3000. Not the desired result; but I think I see where you are going with this. . . so here goes a quick attempt.
    print $_ . "-->" . $_ % 10 for 0..300
      It doesn't print 3000 when I run the program. Your solution that you posted looks exactly the same as mine, except you print out the $_ and the '-->'. What is the difference?

      What version of perl are you running where it prints 3000?

        My mistake. In the black box your % looked like *.
      3000? doh!

      "Argument is futile - you will be ignorralated!"

Log In?
Username:
Password:

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

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

    No recent polls found