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

Re: fall through switch/case in perl

by jeffa (Bishop)
on Sep 07, 2004 at 18:50 UTC ( [id://389171]=note: print w/replies, xml ) Need Help??


in reply to fall through switch/case in perl

I don't think i have seen this one yet, although it is close in spirit to demerphq's solution:

use strict; no warnings; my @array = reverse 'a' .. 'j'; my $var = shift() - 1; print join '', reverse @array[0..$var];

Update: one-liner for the heck of it

perl -le"@_=reverse a..j;print join'',reverse@_[0..shift()-1]" 5

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: fall through switch/case in perl
by Pragma (Scribe) on Sep 07, 2004 at 19:59 UTC
    perl -le "print((a..j)[-shift..-1])" 5

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-19 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found