I wrote a sync program between some folders.The requirement was that one folder needs to contain just the files from the directories and sub directories present in the three input folders and needn't carry over the directory structure.

For ease I decided to just copy the files recursively using file::find.Here is the program.

#!usr/bin/perl use strict; use File::Find; use File::Copy; my @location=("\\\\network1\\pics","\\\\network1\\fonts","\\\\network1 +\\forms"); my $new_location="\\\\network1\\Sol"; foreach my $location(@location){ find(\&force_move,$location); } sub force_move(){ my $file=$_; print "copying $File::Find::file from $File::Find::dir\n"; copy($file,$new_location) or warn "$!" ; } print "Hey , I am done!!!!"; sleep(2);
My problem is that this code works beautifully when i try using local folders.But if it is folders on the network, it doesn't give me any output as in it compiles, executes without any problems and shows the prompt again, but no files are copied. Could any one tell me what I can do to rectify this? Thanks Sandhya

UPDATE

It works now. I have no clue what changed the behavior.And it didn't work when i had $file::Find::file .I instead just used $file that is assigned t the current value of $_. I used just the mapped network drive in the path and am printing out the file names so that i can figure out if it works or not.

thanks

Sandhya

In reply to file::find problems accessing files on a network by smanicka

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.