#!/bin/perl -w use strict; open (DATA, "text.txt") || die "Can't access test\n"; #each element in the array is a single line my @data = ; close(DATA); #vars to manipulate the data my $line=""; my @description = (""); my $found = "false"; #while it is not the end of the file while($line = shift @data){ chomp $line; if($line =~ "DESCRIPTION"){ $line = shift @data; chomp $line; while(!($line =~ "END")){ if(!($line =~ ";")){ push @description, $line; } $line = shift(@data); chomp $line; } print "[",@description, "]\n"; #if there's going to be more descriptions in the same file #then we can clear the array and keep going through the #file until we run out of lines. Otherwise @description #will continue to accumulate strings #@description = (""); } } if($found eq "false"){ #then we didn't find a description #add it here }