Prasanthi Tenneti wrote:
> 
> Iam unable to debug this code.
> pls help me.
> here is the code :
> 
> [snip code]
> 
> If build1 is found it should print next 3 lines (or till space comes)
> 
> for ex build.txt file :
> build1
> rpm_1;
> rpm_2;
> qwe_3;
> 
> build2
> qwe-1;
> asd_2;
> asd_3;
> 
> if I selected build1 ,it should print rpm_1 to qwe_3


Here is one way to do it:

#!/usr/bin/perl -w
use strict;

print 'Select which build you want to enter: ';
chomp( my $build = <STDIN> );

{
local $/ = '';
my $found;
open FILE, 'build.txt' or die "cannot open 'build.txt': $!";
while ( <FILE> ) {
    if ( /^\Q$build\E\n(.*)\n$/s ) {
        $found = "You selected $build\n$1";
        last;
        }
    }
print $found ? $found : "$build is not found\n";
}

__END__


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to