in reply to get a certain number of words from a line
Update: Changed the 2nd snippet above so it doesn't depend on an obscure bug in 5.8.0. For the record you should use array references instead of list refs.$_=$l="how now brown cow hay is for horses oats are for goats mary lit +tle lamb"; #maybe a little inefficient, but no temp variables, all one line ($f,$b)=(join('',(split)[0..10]), join('',(split)[11..15])); #is there a better way to compose functions? golfers? ($f,$b)=map {join('',(split(/\s+/,$l))[@$_])}([0..10],[11..15]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: get a certain number of words from a line
by Roy Johnson (Monsignor) on Jun 15, 2004 at 18:10 UTC | |
by sleepingsquirrel (Chaplain) on Jun 15, 2004 at 18:26 UTC | |
by Roy Johnson (Monsignor) on Jun 15, 2004 at 19:10 UTC | |
by sleepingsquirrel (Chaplain) on Jun 15, 2004 at 20:02 UTC | |
by sleepingsquirrel (Chaplain) on Jun 15, 2004 at 20:39 UTC | |
by Roy Johnson (Monsignor) on Jun 15, 2004 at 21:29 UTC | |
|