#usr/bin/perl use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new("vrrp.xls"); my $worksheet = $workbook->add_worksheet(); $worksheet->write ("A1", 'Device'); $worksheet->write ("B1", 'Interface Name'); $worksheet->write ("C1", 'VRID'); $worksheet->write ("D1", 'State'); $worksheet->write ("E1", 'Primary ip address'); $worksheet->write ("F1", 'VRRP Address'); my $row = 2; my $line = ''; my $device; open inFile, '<', 'svrrp.txt' or die "Couldn't open svrrp.txt: $!"; while (! eof inFile) { $line .= ' ' . <inFile>; chomp $line; next if ! ($line =~ /logging\sto\sDevice\s(.*?)\s+/i) and ! eo +f inFile; my $nextDevice = $1; next if ! ($line =~ /Interface\s(.*?)\s+/i) ; my $nextInterface = $1; #next if ! ($line =~ /Interface\s(.*?)\s+/i) ; #my $nextInterface = $1; { if ($line=~ m[ (?=.*? nterface \s+ (\S+) ) (?=.*? VRID \s+ (\ +S+) ) (?=.*? State: \s+ (\S+ +) ) (?=.*? Primary\saddress: \s+ (\S+) +)]smx) { $worksheet->write("A$row", "$device"); $worksheet->write("B$row", "$1"); $worksheet->write("C$row", "$2"); $worksheet->write("D$row", "$3"); $worksheet->write("E$row", "$4"); my (@ip)=($line=~m/number addresses(?:.*?) +((?:\d{1,3}\.){3}\d{1,3})/gsi); print "The addresses are: ". join("\n",@ip +)."\n\n"; print " end\n\n"; $worksheet->write("F$row", join("\n",@ip) +); ++$row; } else { print "no match found\n" + ; } print "$device,$Interface,$1, $2, $3, $4 \n"; } $Interface = $nextInterface; ++$row; $device = $nextDevice; $line = " "; } close inFile; $workbook->close();
can you figure out what is the problem in this ?

In reply to Re^6: just another search program by sunny
in thread just another search program by sunny

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.