Hi, The script below doesn't print anything.I just modified the code to add to two functions "warning_entry" and "error_entry".I want them to put in a switch case and based on the user input I want I one of them to execute but currently the below script doesn't print anything.Can someone pls help on how to add a switch case and why is nothing get printed?

#!/usr/bin/perl -w use strict; use warnings; use Spreadsheet::WriteExcel; use List::MoreUtils qw( uniq ); open my $line, '<', 'file.log' or die 'Cannot open file'; my $cr_line; my $i = 1; my ($is_an_error_entry,$is_a_warning_entry); my $resolution_link; my (%seen_cr,%seen_match,%seen_link) ; my ($crline,$Buggyfile,$resolutionlink,$match); #subroutine for errors sub error_entry { print "in error entry";#not getting printed my $workbook = Spreadsheet::WriteExcel->new("errors.xls"); my $worksheet = $workbook->addworksheet("Error"); if ($match =~ /Error:/) { $is_an_error_entry = 1; next LINE; } if ($match =~ /https?:/) { if ($is_an_error_entry) { ($resolution_link) = $match =~/(https?:\S+?)[.]?\s/; } } } #subroutine for warnings sub warning_entry { my $workbook = Spreadsheet::WriteExcel->new("warnings.xls"); my $worksheet = $workbook->addworksheet("warnings"); if ($match =~ /Warning:/) { $is_a_warning_entry = 1; } if ($match =~ /https?:/) { if ($is_a_warning_entry) { ($resolution_link) = $match =~/(https?:\S+?)[.]?\s/; } } # -------------------------------------------------------------------- +---- # MAIN SCRIPT # # -------------------------------------------------------------------- +---- while ( $match = <$line> ) { if ( $match =~ /CR:/ ) { $cr_line = (split /:\s*/, $match)[1]; chomp $cr_line; $is_an_error_entry = 0; } #need a switch here #1.error entry #2.warning entry print "DEBUG";#no gettting printed error_entry(); warning_entry(); if ( $match =~ /Perforce path:/ ) { if ($is_an_error_entry) { $match = (split /:\s*/, $match)[1]; chomp $match; if ( ($cr_line) and ( !$seen_cr{$cr_line}++ ) ) { $crline = $cr_line; } print $crline, $match, $resolution_link, "\n"; $worksheet->write( $i, 0, $crline ); $worksheet->write( $i, 1, $match ); $worksheet->write( $i, 2, $resolution_link ); $i++; } $cr_line = ''; $crline = ''; $resolution_link = ''; } } }

In reply to Why is my script not printing anything?and how to add a switch case in perl by iphone

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.