rajsai28 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I have a directory called archive under that directory i have some files


I need to read each file from the archive directory and need to perform some unix commands on those files


some of the unix commands which i need to perform on files are as follows

wc, tail, gunzip and unzip on files



Directory:archive

files:

orig_file_Jun13.dat.gz

Check_Jun13.dat

Check1_Jun13.dat

sub zPrivateSub { my $dir = $OUTPUT_DIR; my $pattern = 'Jun'; opendir( DIR, $dir ); my @files = grep( /$pattern/, readdir(DIR) ); closedir(DIR); foreach my $file (@files) { if ($file=~ m/orig/) { print "$file\n"; my $lcmd = system("wc -l Check_Jun13.dat Check1_Jun13.dat"); my $lcmd = system("gunzip -c orig_file_Jun13.dat.gz|tail -1"); } else { print "NO\n"; } } }
as i am new to perl scripting, please help me, i am getting error when i run


this code wc: cannot open Check_Jun13.dat

wc: cannot open Check1_Jun13.dat 0 total

Replies are listed 'Best First'.
Re: Reading file from the directory
by Anonymous Monk on Jun 05, 2013 at 14:04 UTC
Re: Reading file from the directory
by ww (Archbishop) on Jun 05, 2013 at 14:16 UTC

       ... for details, run the search at ?node_id=3989;BIT=want%20a%20pony.


    If you didn't program your executable by toggling in binary, it wasn't really programming!

Re: Reading file from the directory
by blue_cowdawg (Monsignor) on Jun 05, 2013 at 14:20 UTC
        I want to write a perl script to perform the below steps in scripts.

    So.. what have your attempted to do? I'm seeing a disturbing pattern begin to emerge in your posts with respect to what you ask. This is not a code writing service.

    If you start writing code and something blows up I and many other Monks here will be glad to help you sort it all out.

    I noticed you just joined the Monastery today. Welcome aboard. Here are a few links for you to check out:

    If you follow the philosophies documented in those pages you'll have a much better experience at Perl Monks.

    Again, welcome aboard


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg