On Nov 22, 6:57 am, [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,
You're not very clear in your question, but my understanding is that you want the line of text following /-->(.*)<--/ #!/usr/bin/perl use strict; use warnings; my $last_line; while(my $current_line = <DATA>) { if ($last_line && $last_line =~ /^-+$/) { print $current_line unless $current_line =~ /-->.+<--/; } $last_line = $current_line; } __DATA__ --------------------------------- --> 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/