Try this:
open(FILE, "/home/file.txt") or die "Can't open file\n";
while(){
if (/(\d+)\s+(\w+).+?$/){
print "$1\t$2\n";
}
}
This implies that your line have numbers, then a space, then a word, then anything
else, and you just want the numbers, then a
convert any awk script to perl directly by using a2p
like
echo '{print $1,$2}' | a2p
Chang Ming Huei wrote:
> Hi all:
>
> I want to use perl to do something like a awk script as following:
>
> cat file.txt | awk '{print $1,$2}'
>
> How can I do it ?
>
--
To unsubscribe