#!/usr/bin/perl my $xml=qq{ http://www.buzzhumor.com Funny Videos http://www.marapets.com/arcade.php Games }; $xml=~s/\s+//g; $xml=~s/(.*?)<\/Links>/$1/m; my @links; use Data::Dumper; while($xml=~s/(.*?)<\/Link>//){ my $temp={}; for('URL','Text','BeforeText','AfterText'){ ($temp->{$_})=$1=~m/<$_>([^<]+)<\/$_>/; } push @links,$temp; } print Dumper(@links); print "$xml\n";