Not sure what I am doing wrong but my subroutine is only returning the
value on varible. I would like it to return both $end and $start for
the correct parameter I am passing.

Thank you for your help.

#!/usr/bin/perl
use warnings;
use strict;

my %apcHash = (
  M   => { "start" => 1,
             "end"   => 299, },
  O   => { "start" => 900,
             "end"   => 983, },
  L   => { "start" => 871,
             "end"   => 899, },
  I   => { "start" => 801,
             "end"   => 850, },
);

sub getMarketCells {
  my $val = shift;
  foreach my $k ( keys %apcHash ) {
    my($start, $end) = @{$apcHash{$k}}{qw/start end/};
    return($start, $end) if $val eq $k;
  }
  return "";
}

$apc = "O";
my $test = getMarketCells($apc);
print $test,"\n";

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to