in reply to Read in a file containing the criteria for a program when it runs
(EDIT: add chomp)#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @filter; <>; # read one line from the file/stdin while (<>) { # read other lines chomp; # remove "\n" from the end of the line push @filter,[(split /\t/,$_)]; # create an array of the line by spli +tting it by <TAB>, make a reference of it and push the reference to t +he @filter array } @filter = sort { $a->[4] <=> $b->[4] } @filter; # sort the array by 5t +h element of embedded arrays print Dumper \@filter;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Read in a file containing the criteria for a program when it runs
by dkhalfe (Acolyte) on Jul 18, 2012 at 18:37 UTC | |
by aitap (Curate) on Jul 18, 2012 at 18:59 UTC | |
by dkhalfe (Acolyte) on Jul 18, 2012 at 19:14 UTC | |
by aitap (Curate) on Jul 18, 2012 at 19:38 UTC | |
by dkhalfe (Acolyte) on Jul 18, 2012 at 20:07 UTC |