Hi all, below is the code that I've written. The first step is to unzip the files and later on convert them to csv files. So the question is, how to use Getopt to get to the final output without outputting the unzipped files? Now when I run the script, the clock.sum.rpt.txt and import.clock.rpt.txt will be produced. How to sort of hide them?

use strict; use warnings; use Getopt::Long qw(GetOptions); use IO::Uncompress::Gunzip qw(gunzip $GunzipError); #Unzip .gz files into .txt files # In command line run # perl getOptsLong -orig <file1_name> -new <file2_name> #GetOptions( # 'orig = s'=> $input_1 # 'new = s' => $input_2 # 'out = s' => $outfile_2 #); my $input_1 = "clock.sum.rpt.gz"; my $output_1 = "clock.sum.rpt.txt"; gunzip $input_1 => $output_1 or die"gunzip failed:$GunzipError\n"; my $input_2 = "import.clock.rpt.gz"; my $output_2 = "import.clock.rpt.txt"; gunzip $input_2 => $output_2 or die "gunzip failed:$GunzipError\n"; #Convert to cvs open my $infile_1, "<", $output_1 or die $!; open my $outfile_1, ">", "clock.sum.rpt.csv" or die $!; #$header_1 = "Clock,Sinks,Buffers,Cells,Slew,Path,Vio,Area"; my $lines_1; while(<$infile_1>){ if(/(\w+|\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+.\d+)\s+(\d+.\d+)\s+(\ +d+)\s+(\d+.\d+)/g){ tr/ /,/s; print $outfile_1 "$_"; $lines_1 = $_; }else{ #$lines_1 = $_; #warn "WARN: This line does not follow the normal output pattern, +"; } } #print $outfile_1 $header_1; print $outfile_1 "$lines_1\n"; close $output_1; close $outfile_1; open my $infile_2, "<", $output_2 or die $!; open my $outfile_2, ">", "import.clockrpt.csv" or die $!; my $lines_2; #my @columns_2 = ('Clock','Time','Waveform','Types','Sources'); while(<$infile_2>){ if(/(\w+)\s+(\d+.\d+)\s+(.\d+\s+\d+.\d+.)\s+/g){ tr/ /,/s; print $outfile_2 "$_"; $lines_2 = $_; }else{ #$lines_2 .= $_; #warn "WARN: This line does not follow the normal output pattern, +"; } } #print $outfile_2 "@columns_2\n"; print $outfile_2 "$lines_2\n"; close $output_2; close $outfile_2;

In reply to How to use Getopt? by chaney123

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.