Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by Lawliet (Curate)
on Jul 01, 2013 at 12:39 UTC ( #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
Node Status?
node history
Node Type: note [id://1041837]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2018-11-18 07:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (205 votes). Check out past polls.

    Notices?