photo
Jordan Sissel
geek

Tue, 03 Feb 2004

Array enumeration in perl

I got bored and thought this atleast marginally useful:

my @foo = qw(just another perl monkey);
my $x = 0;
print join("\n",map { $x++ . ": $_" } @foo);

The output is:

0: just
1: another
2: perl
3: monkey
If you don't know how to use map() then learn, it makes doing large operations on hashes or arrays brutally simple.

Comments: 0 (view comments)
Tags:
Permalink: /geekery/99
posted at: 09:40

Search this site

Navigation

Metadata

Home About Resume My Code (SVN)

Articles

ARP Security Dynamic DNS with DHCP OpenLDAP+Kerberos+SASL PPP over SSH SSH Security: /bin/false Week of Unix Tools Work Efficiency

Projects

fex firefox tabsearch firefox urledit grok keynav liboverride newpsm (FreeBSD) nis2ldap pam_captcha poor man's backup Solaris audio utility xboxproxy xdotool xmlpresenter xpathtool misc scripts

Presentations

Yahoo! Hack Day '08 Yahoo! Hack Day '06 Unix Essentials Vi/Vim Essentials SSH Tunneling (Video)

Tag Cloud

Calendar

< February 2004 >
SuMoTuWeThFrSa
1 2 3 4 5 6 7
8 91011121314
15161718192021
22232425262728
29      

Friends

BarCamp Kent Brewster Tantek Çelik John Resig Wesley Shields Tyler Shields

Technorati