Hello t-rex,
Welcome back to the Monastery :)
Fellow Monks have provided you with solution(s). Just for fun a way to load multiple files:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; my @array; while (<>) { chomp; next unless /^node*/; # skip lines that do not start with string +node my @tmp = split / /; push @array, $tmp[1]; } continue { close ARGV if eof; $hash{$ARGV} = [ @array ]; } print Dumper \%hash; __END__ $ perl test.pl in.txt in2.txt $VAR1 = { 'in2.txt' => [ '0', '0', '0', '8', '8', '8', '250', '250', '250', '251', '251', '251', '252', '252', '252', '253', '0', '0', '0', '8', '8', '8', '250', '250', '250', '251', '251', '251', '252', '252', '252', '253' ], 'in.txt' => [ '0', '0', '0', '8', '8', '8', '250', '250', '250', '251', '251', '251', '252', '252', '252', '253' ] };
Hope this helps, BR.
In reply to Re: extracting value in a string after checking value after colon ':'
by thanos1983
in thread extracting value in a string after checking value after colon ':'
by t-rex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |