in reply to Re: Command Parsing
in thread Command Parsing

This is definitely what I am trying to do and the script works great. However would it be possible to only extract the numbers returned and assign each one to a variable so I can format them in the order I need. Example
print "AGC:$1 APC:$2 OAC:$3" and so on.
I really do appreciate the help on this, I'm trying to learn perl scripting in my spare time and I'm sure my question shows as a newbie. Thanks

Replies are listed 'Best First'.
Re^3: Command Parsing
by 2teez (Vicar) on Apr 25, 2012 at 17:43 UTC

    Why not? To pick out the numbers, you could do this:

    my @arr_data; while (<>) { chomp; if (m/.+?(\d+?).?$/s) { push @arr_data, $1; } } my @assign_var = qw[AGC APC OAC CGA GAC CPA ACP CAO ACO BGH PHY ENG MA +T]; # assumed parameters my %hash_val; @hash_val{@assign_var} = @arr_data; print $_, ":", $hash_val{$_}, $/ foreach sort keys %hash_val;

    Please note that the assumed parameter could also be gotten from within the while loop, it really depend on what you have to work with.
    Hopes this helps