in reply to extracting from text

You Have it here
use strict; use warnings; my $contents; my $hi_from; my $hi_to; my $bye_from; my $bye_to; open (FH,"filename") or die ("Can't open"); while(<FH>) { chomp($_); $contents.=$_; } ($hi_from=$contents)=~s/hi:\s+(\d*)/$1/; $hi_from=$1; ($hi_to=$contents)=~s/(hi:\s+)(?!.*hi:)(.*\d+)(?=.*bye:)/$2/; ($hi_to=$2)=~s/\d+//; $hi_to=~s/.*\s(\d+)/$1/; ($bye_from=$contents)=~s/bye:\s+(\d*)/$1/; $bye_from=$1; ($bye_to=$contents)=~s/(bye:\s+)(?!.*bye:)(.*\d+)/$2/; ($bye_to=$2)=~s/\d+//; $bye_to=~s/.*\s(\d+)/$1/; print "\n\n\nHi From: $hi_from\n"; print "Hi to: $hi_to\n"; print "Bye from: $bye_from\n"; print "bye to: $bye_to\n";
First I am reading from the file and creating a flat-string of the file contents.Then I go about doing a lot of regexe's to ensure we get what we want!!
Sorry if you find the regexe's difficult.It will help you learn a lot of things about regexe's, if you can decipher it!!

The world is so big for any individual to conquer