Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2019-07-17 10:52 GMT
Find Nodes?
    Voting Booth?

    No recent polls found