Here is the detailed Problem statement and my approach: config.txt contains 2 section DIR and FILE. DIR has list of directory path and FILE section has file path I need to read the file line by line and check if each line is a file +or a directory. It is required to copy the entire directory content to source director +y. Similarly mentioned file needs to be copied to source directory I need to use robocopy to copy large files.The program is working for +copying file but not for copying directory. For this i thought to split the last part of directory path and attach + this to source path inorder to copy using robocopy. the syntax of robocpy command is robocopy $target_file $source_dir_mod ## here target_file=C:\shyam\di +r1 and i need to get source_dir_mod=C:\sundar\directory1\dir1 Then I can copy dir1 to the source directory [DIR] C:\shyam\dir1 [FILE] C:\shyam\output.txt $\ = "\n" ; $, = "\t" ; #$|=1; use strict; use warnings; use POSIX qw[ _exit ]; use MIME::Lite; use Sort::External; use Net::Ping; use Win32::DriveInfo; my $source_dir = `pwd`;#C:\sundar\directory my $source_dir_mod; my $file_config = "config.txt"; my $sym = '\\' ; open FH_config, "$file_config" or die "$!"; while (my $line = <FH_config>) { chomp $line; next if $line eq ""; if (($line eq "[DIR]") or ($line eq "[FILE]")) { #print "no action"; } else { my $target_file = $line; #print $target_file; if (-d $target_file) { print("it is directory"); (my $path,my $file) = $target_file =~ m|^(.*[/\\]) +([^/\\]+?)$|; $source_dir_mod = join '',$source_dir,$sym,$file; print ($source_dir_mod); `robocopy $target_file $source_dir_mod`; #print "$path"; ##C:\shyam #print "$file"; ##dir1 } elsif(-f $target_file) { print("is a file"); (my $path,my $file) = $target_file =~ m|^(.*[/\\]) +([^/\\]+?)$|; #print "$path"; ##C:\shyam #print "$file"; ##output.txt `robocopy \/Z $path $source_dir $file`; } else { print("no action"); } } } close FH_config;

In reply to Re^2: concatenation of variables resulting in 2 seperate lines by rkshyam
in thread concatenation of variables resulting in 2 seperate lines by rkshyam

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.