if($filecontents =~ /\*\sdisks/){ my @matchsect = /\*\sdisks/; print "@matchsect\n\n"; } #### if ($filecontents =~ /\*\sdisks/) { # delete everything up to the first occurrence # of "* disks" $filecontents =~ s/^.*?\*\sdisks//; print "$filecontents\n\n"; }