awk vs perl

awk -F "|" '{print $2$3$4 upto $30}' file1 > file2

Same logic, i want to write it in perl

I tried

#!/bin/usr/perl 
my $line;
open FH, "<file1" or die " Can't open file $!";
open FH1, ">file2" or die "Can't open file ";
while (<FH1>){
    $line = (split /\|/,$_)[1,2,3,4....];
    print FH2 $line;
}
close(FH1);
close(FH2);

It didn't work like awk, what i want..
Please guide me
please tell which one is good in speed and performance in a a large file

in perl it is more simple than your awk & perl codes:-

perl -nalF'\|' -e '$"="|" ; print "@F[1..29]" ;'  infile.txt

:p:p:p

could you Please tell how it's work. It's very complex but may be effective. Someone please help me to understand this code

See 'man perlrun', and check out the options -n -a -l -F and -e.

$" is also known by its long name $LIST_SEPARATOR (see 'man perlvar'), which explains a lot I guess :wink:

'[1..29]' is an array slice, and selects all specified elements. '1..29' is a range of all integers between and including 1 and 29.

Hope that helps...