Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: fall through switch/case in perl

by Velaki (Chaplain)
on Sep 06, 2004 at 23:50 UTC ( [id://388884]=note: print w/replies, xml ) Need Help??


in reply to fall through switch/case in perl

If you really want the case statement, there are many ways of doing it, as per the Programming Perl, a.k.a. the "Camel" book.

However, I think the following might be more what you need.

print substr("abcdefghij",10-$var),"\n";

Hope that helped,
-v
"Perl. There is no substitute."

Replies are listed 'Best First'.
Re^2: fall through switch/case in perl
by Pragma (Scribe) on Sep 07, 2004 at 19:31 UTC
    print splice @{[a..j]}, -$var

    or better yet:

    print( (a..j)[-$var..-1] )

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 22:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found