P
Prabh
Hello all,
I'm trying to print a section of a text file which has the following
contents.
===========================
..
..
..
Files Section:
{
File1:
{
Description1
Size1
Date1
}
File2:
{
Description2
Size2
Date2
}
}
..
..
===========================
In here, I want to print the contents of "File Section".
I tried the following:
#!/usr/local/bin/perl
use strict ;
use warnings;
open(FDL,"file.txt") or die "Can't open file.txt: $!\n" ;
while(<FDL>)
{
chomp ;
print "$_\n" if ( /^Files Section/ .. /\}/ ) ;
}
close(FDL) ;
====================================
This only prints the contents till the first occurence of the closing
brace, i.e., till Date1 of the first file1.
How do I tell it to "print till the closing brace of Files Section,
not just the first occurence of }"?
2. Also, whats the closest Perl-equivalent module/package for Java's
Velocity to readin a well-formatted file, because file.txt is always
of a standard format.
Thanks for your time,
Prabh
I'm trying to print a section of a text file which has the following
contents.
===========================
..
..
..
Files Section:
{
File1:
{
Description1
Size1
Date1
}
File2:
{
Description2
Size2
Date2
}
}
..
..
===========================
In here, I want to print the contents of "File Section".
I tried the following:
#!/usr/local/bin/perl
use strict ;
use warnings;
open(FDL,"file.txt") or die "Can't open file.txt: $!\n" ;
while(<FDL>)
{
chomp ;
print "$_\n" if ( /^Files Section/ .. /\}/ ) ;
}
close(FDL) ;
====================================
This only prints the contents till the first occurence of the closing
brace, i.e., till Date1 of the first file1.
How do I tell it to "print till the closing brace of Files Section,
not just the first occurence of }"?
2. Also, whats the closest Perl-equivalent module/package for Java's
Velocity to readin a well-formatted file, because file.txt is always
of a standard format.
Thanks for your time,
Prabh