Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Dear PerlMonks,
I'm translating some python(2) code into perl, and I'm hoping there are some bilingual sorts who can help. (It's an interesting poetry writing program that I don't think I can begin to understand until I at least have it in a language I understand. Plus I'm hoping it'll run faster in Perl. Otherwise I wouldn't be undertaking this labor of love. :-p ) One of the biggest headaches is translating Python's list range expressions into equivalent Perl array expressions. In Python you can write: In Perl, using List::Util qw/head tail/, the equivalent is: Of course, most of the time the code contains a variable, not a hard-coded 3. And then my solution breaks on head(-$p, @a) and tail(-$p, @a) when $p is 0. Is there a CPAN module that might support python-like specification of array ranges in a concise manner? In reply to Converting python list range expressions to perl by ibm1620
|
|