#!/usr/bin/perl

# example of reading from 
# the end of a file in perl,
# after the data marker.

my $save = "";
while (my $line = <DATA>){
  chomp($line);
  print " the data is '$line' \n";
  if ( $line =~ /- - -/ ){
    go_look_at($save);
    $save = "";
  }
  else {
    $save = $save . " : " . $line;
  }
}

sub go_look_at {
  my ($text) = @_;
  print " go_look_at got '$text' \n";
  my %hash = split( /:/, $text );
  print_hash(%hash);
}

sub print_hash {
  my (%h) = @_;
  print " made a hash : \n";
  for my $key (keys %h){
    print " $key => '" . $h{$key} . "'\n";
  }
}

__DATA__

  name : mary
  age  : 43
- - - - 

  name : joe
  age  : 16
- - - -

  name : mike
  age  : 24
- - - -
