Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: do 45-47 to array 45,46,47

by Lawliet (Curate)
on Jul 01, 2013 at 12:39 UTC ( [id://1041837]=note: print w/replies, xml ) Need Help??


in reply to do 45-47 to array 45,46,47

Problem: You are given the input string "88-99", and you need to output each number from 88 to 99, inclusive.

$ perl -E'my ($lower, $upper) = split(/-/, pop); say for $lower .. $up +per' 88-99 88 89 90 91 92 93 94 95 96 97 98 99

The key here is the range (..) operator. From perldoc, the range operator returns a list of values counting (up by ones) from the left value to the right value.

Replies are listed 'Best First'.
Re^2: do 45-47 to array 45,46,47
by Hossein (Acolyte) on Jul 01, 2013 at 12:53 UTC
    Thank you :) /Hossein

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found