in reply to Re: Trying to use Spreadsheet::WriteExcel. What could be the problem?
in thread Trying to use Spreadsheet::WriteExcel. What could be the problem?

Hi yes. Interface is always have form Interface name1, Interface name2 ....Interface name10 cann you figure it out where i did mistake ?
  • Comment on Re^2: Trying to use Spreadsheet::WriteExcel. What could be the problem?

Replies are listed 'Best First'.
Re^3: Trying to use Spreadsheet::WriteExcel. What could be the problem?
by CountOrlok (Friar) on Feb 15, 2006 at 15:01 UTC
    Here is a sample of what a cleaner (in my opinion) version of your code should look like:
    #... my @lines = (); open my $inFile, '<', 'svrrp.txt' or die "Couldn't open svrrp.txt: $!" +; my $currIface = ""; while (<$inFile>) { chomp; if (my $iface = ($_ =~ /^Interface\s(\w+)$/) { processlines($currIface, @lines); $currIface = $iface; @lines = (); } push @lines, $_; } processlines($currIface, $lines); # to process last interface block #... sub processlines() { my $iface = shift; return unless $iface; # declare any vars foreach (@_) { # do your pattern matching here } # print your findings }
    You can expand on this to make it suit you.

    -imran