in reply to Re: hash/array
in thread hash/array
Bad form! When yer dealing with a newbie, it's best to show off those things in canonical form:open FILE , "< /home/you/your.file";
And as long as we're being picky, the extra indirection with the reference isn't needed. And that join gives an extra tab. And some more code-bumming... (UNTESTED!)open FILE, "/home/you/your.file" or die "Cannot open: $!";
There!#!/usr/bin/perl -w use strict; my %data; open FILE , "home/you/your.file" or die "Cannot open: $!"; # extract data and store it in a hash of tables while( <FILE> ) { @_=split; $data{$_[0]} = [ @_ ]; } close FILE; foreach( keys %data) { print join("\t" , @{$data{$_}}), "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 3: hash/array
by tilly (Archbishop) on Jan 26, 2001 at 05:40 UTC | |
by malaga (Pilgrim) on Jan 26, 2001 at 10:34 UTC | |
by eg (Friar) on Jan 26, 2001 at 13:01 UTC | |
by Anonymous Monk on Jan 26, 2001 at 23:17 UTC | |
by tilly (Archbishop) on Feb 02, 2001 at 10:36 UTC | |
| |
by malaga (Pilgrim) on Feb 01, 2001 at 02:29 UTC | |
| |
by malaga (Pilgrim) on Feb 02, 2001 at 23:23 UTC |