title: Perl - search a word and print rest of line into variables
body: <p>I have an easy question. How can I make perl read a file, search for a specific word, and then if it finds a match, I want to print the rest of the line into individual variables.</p>
  
  <p>The ascii file (called "region_list" that I wish to search contains has 3 lines:</p>
  
  <p>hawaii 40 5 -140 -180</p>
  
  <p>samoa -5 -25 -165 165</p>
  
  <p>pacific 70 -65 290 110</p>
  
  <p>Here's the code I have so far, but it doesn't seem to be working:</p>
  
  <pre><code>#!/usr/bin/perl -w
  #
  # Required Libraries
  use Date::Calc qw(:all);
  use Date::Manip;
  use Math::Trig;
  use warnings;
  use Time::Local;
  use POSIX 'strftime';
  use lib '/usr/bin';
  use Cwd qw();
  
  my @region = ("hawaii", "samoa", "pacific");
  
  open my $listreg1, "$BIN_DIR/region_list" or die "Could not open: $!";
  
    ($reg2,$max_lat, $min_lat, $max_lon, $min_lon) = split(" ",$listreg1);
  
  
     if ($region eq $reg2) {
              print "LUCREG $region $reg2 $max_lat, $min_lat, $max_lon, $min_lon \n";
      }
  
  
  
  close $listreg1;
  </code></pre>