in reply to Read in a file containing the criteria for a program when it runs
#!/usr/bin/env perl use strict; use warnings; my @filter; my $line = <DATA>; #open (my $ffile, '<','filterfile') or die "cannot open filterfile: $! +"; #my $line = <$ffile>; #while ($line = <$ffile>) { while ($line = <DATA>) { chomp $line; my ($col,$rel,$val,$foa,$ord) = split /\s+/,$line; $filter[$ord] = [ $col,$rel,$val,$foa ]; } for my $ord (1 .. 3) { print "$ord:\n", "\tcol: " ,$filter[$ord]->[0],"\n", "\trsh: " ,$filter[$ord]->[1],"\n", "\tvalue: " ,$filter[$ord]->[2],"\n", "\tf_o_a: " ,$filter[$ord]->[3],"\n\n"; } __DATA__ column relationship value filter_or_append order a <= 0.3 filter 1 b = abc append 3 c <= 0.3 filter 2
Each element of @filter is a reference to an anonymous array which contains values: [...].
Produces:
1: col: a rsh: <= value: 0.3 f_o_a: filter 2: col: c rsh: <= value: 0.3 f_o_a: filter 3: col: b rsh: = value: abc f_o_a: append
|
|---|
| 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 17:22 UTC | |
by brx (Pilgrim) on Jul 18, 2012 at 21:34 UTC | |
|
Re^2: Read in a file containing the criteria for a program when it runs
by BillKSmith (Monsignor) on Jul 18, 2012 at 16:55 UTC | |
by brx (Pilgrim) on Jul 18, 2012 at 17:18 UTC |