[tpm] eliminating columns from tab delimited files

Mike Stok mike at stok.ca
Fri Apr 18 04:29:59 PDT 2008


On 18-Apr-08, at 6:45 AM, Alex Mackinnon wrote:

> Sinner!
>
> I agree use awk but in Perl use split and take a slice of the array.
> ($firstcolumn, $tenth) = (split (/\t/, $string_with_tab))[0,9];

If you want to do this then beware of split's behaviour of eliminating  
empty fields on the right, if undef vs '' matter to you:

   DB<1> $s = "1\t2\t\t4\t\t\t7\t\t\t\t\t\t"

   DB<2> x (split /\t/, $s)[0, 9]
0  1
1  undef
   DB<3> x (split /\t/, $s, -1)[0, 9]
0  1
1  ''



>
>
>
>
>
>
>
> > Date: Thu, 17 Apr 2008 16:43:05 -0400
> > From: sfryer at sourcery.ca
> > To: tpm at to.pm.org
> > Subject: Re: [tpm] eliminating columns from tab delimited files
> >
> > On Thu, Apr 17, 2008 at 04:05:44PM -0400, Omid Gulban wrote:
> > > does anyone have a quick way of eliminating certain columns from  
> a tab-delimited file.
> >
> > I know it's not very Perl'ish, but have you considered using `awk`?
> > We all love Perl, but sometimes it's overkill. Beyond that, unless
> > you're experiencing performance issues, I don't see any reason not
> > to do it the way you described.
> >
> > Cheers,
> > --
> > Shaun Fryer
> > cl: 905-920-9209
> > _______________________________________________
> > toronto-pm mailing list
> > toronto-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/toronto-pm
>
>
> Sign in to Windows Live Messenger, and enter for your chance to win  
> $1000 a day—today until May 12th. Visit SignInAndWIN.ca  
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm

-- 

Mike Stok <mike at stok.ca>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/toronto-pm/attachments/20080418/5fa00aec/attachment-0001.html 


More information about the toronto-pm mailing list