Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: How to write the perl script for the following linux command?

by finddata (Sexton)
on Mar 14, 2017 at 12:14 UTC ( #1184536=note: print w/replies, xml ) Need Help??


in reply to Re: How to write the perl script for the following linux command?
in thread How to write the perl script for the following linux command?

The above command will find the source location and fetches for (*.csv files) and store the same directory structure at destination.
  • Comment on Re^2: How to write the perl script for the following linux command?

Replies are listed 'Best First'.
Re^3: How to write the perl script for the following linux command?
by Corion (Pope) on Mar 14, 2017 at 12:15 UTC

    So, what Perl code did you write, for example using the modules I mentioned already, and how does it fail to do what you need?

      my $sorce_direcrtory = $input_dir; my $new_directory = $output_dir; opendir(my $dh, $sorce_direcrtory) || die; while(readdir $dh) { if($_ =~ /.csv/){ copy("$sorce_direcrtory/$_", "$new_directory/$_"); } } closedir $dh;
      error: Use of uninitialized value in pattern match (m//)

        Usually, Perl also outputs the exact line number where the warning occurs. What line number does your code output?

        I find it unlikely that opendir would succeed but then readdir should return undef.

        Let me recommend to you, again, File::Find, which makes iterating over a directory tree somewhat easier.

        What is exact and complete error message ?

        poj

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1184536]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2020-01-18 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?