[tpm] eliminating columns from tab delimited files
mike at stok.ca
Fri Apr 18 04:29:59 PDT 2008
On 18-Apr-08, at 6:45 AM, Alex Mackinnon wrote:
> 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]
DB<3> x (split /\t/, $s, -1)[0, 9]
> > 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
Mike Stok <mike at stok.ca>
The "`Stok' disclaimers" apply.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the toronto-pm