Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Quiz 2 (for newbies only)

by Eureka_sg (Monk)
on May 12, 2001 at 22:06 UTC ( [id://79962]=perlmeditation: print w/replies, xml ) Need Help??

phew! The previous one was answered so fast. : )
I should have specified (for newbies only).
Experts, pls skip this node.

Seems that there are always many newbies lurking around but never had the chance to post replies; either the question was too tough or the masters were too finger-ready.
So I thought I would post some simple questions for newbies to share their knowledge with other newbies as well.

Question: 1..9 and 1-9 both means 1,2,3,4,5,6,7,8,9. So what's the difference between them?

Replies are listed 'Best First'.
Re: Quiz 2 (for newbies only)
by dailylemma (Scribe) on May 12, 2001 at 22:53 UTC
    1..9 can be used to represent 1,2,3,4,5,6,7,8,9 in a for loop, but 1-9 will be evaluated as -8 in this context.

    On the other hand, 1-9 can be used in regexes for the same purpose
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

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

    No recent polls found