On Nov 22, 7:57 pm, [EMAIL PROTECTED] (Avinashsuratkal) wrote: > On Nov 22, 2:22 pm, [EMAIL PROTECTED] (Avinashsuratkal) > wrote: > > > > > > > On Nov 22, 2:27 am, [EMAIL PROTECTED] (Yitzle) wrote: > > > > On Nov 21, 2007 11:28 AM, avinashsuratkal <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > I have the following log and my requirement is to capture the block > > > > from one "-->" symbol to another. and put it in other file, using > > > > perl. > > > > > --------------------------------- > > > > --> Checking Server Hostname <-- > > > > --------------------------------- > > > > Server Hostname: xxxxxxxxx > > > > --------------------------------------- > > > > --> Checking Authentication Domain <-- > > > > --------------------------------------- > > > > Server is authenticating against: xxxxxxxxx > > > > > -------------------------------------- > > > > --> Validating DNS Server Entries <-- > > > > -------------------------------------- > > > > Servers should conform to global ANYCast Standard > > > > > Thanks > > > > Avinash > > > > You mean you want to turn the above input into somthing like this? > > > ------------------------------------- > > > Checking Server Hostname > > > Checking Authentication Domain > > > Validating DNS Server Entries > > > ------------------------------------- > > > > $ perl -e 'while(<>){print "$1\n" if /-->(.*)<--/; }' inputFile > > > > outputFile- Hide quoted text - > > > > - Show quoted text - > > > Hi Yitzle, > > > Thank you for the reply... > > > I want my output to be entered temporary in /tmp/output for further > > processing. > > > --> Checking Server Hostname <-- > > --------------------------------- > > Server Hostname: xxxxxxxxx > > > Thanks.- Hide quoted text - > > > - Show quoted text - > > Hi, > > In short I need to read the text between 2 lines, which can be > incorporated in the perl script, but not a one-liner. > > Thanks,- Hide quoted text - > > - Show quoted text -
Hi, I figured out the below code and it worked. my $file = '/tmp/log.txt'; open FILE, $file or die $!; while (<FILE>) { print if /PATERN1/ .. /PATERN2/; } close FILE; But now I want to put the output of "print if /PATERN1/ .. /PATERN2/;" into a file. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/