while(<>)
{
if(/string1/ .. /string2/)
{
print;
}
}
####
string1
.....
string2
####
#!/usr/bin/perl -w
use strict;
my (@desc, @data, @new);
while(<>)
{
chomp;
if(($_ eq "Description:") .. ($_ eq "Data:"))
{
push @desc, $_;
next unless $_ eq "Data:";
}
# if you have another tag
if(($_ eq "Data:") .. ($_ eq "NewTag:"))
{
push @data, $_;
next unless $_ eq "NewTag:";
}
# and so on until the last tag
push @new, $_;
}
shift @desc; # get rid of "Description:" from front.
pop @desc if @data; # get rid of "Data:" as last element.
shift @data; # get rid of "Data:" from front.
pop @data if @new; # get rid of "NewTag:" as last element.
shift @new; # get rid of "NewTag:" from front.
print "desc: @desc\n";
print "data: @data\n";
print "new: @new\n";
####
if(($_ eq "NewTag:") .. ($_ eq "Somethingelse:"))
{
...
}
####
NewTag: # sets the third flip flop to true
...
Description: # sets the first flip flop to true
...
Somethingelse: # is a data line for Description
....
Data: # now the first flip flop will be
.... # false and the second true
NewTag: # sets second flip flop to false
.....
..... # these get given to the third
..... # option finally.
####
if(/$date1/../$date2/)
{
}