There has got to be an easier way in perl to get a certain number of words from a line in a string than my code below. Could anyone quickly help me out?
Thanks,
js.
$_="2003-12-20 22:13:58 11 12.37.2.215 407 TCP_DENIED 4294968543 93 GE +T http ping.180solutions.com http://ping.180solutions.com/ - N ONE - -"; @F=split(/\s+/); foreach $i (0 .. 10){ $front.="$F[$i] "; } foreach $i (11 .. 15){ $back.="$F[$i] "; } print "\nFRONT=$front"; print "\nBACK=$back";
20040615 Edit by Corion: Changed title from 'subword'
In reply to get a certain number of words from a line by js1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |