<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: perl question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050123#M813232</link>
    <description>And this is cargo-cult programming.&lt;BR /&gt;&lt;BR /&gt;# perl -MFile::Find -e'find (sub { .... }, &lt;FOLDERS&gt;)'&lt;BR /&gt;&lt;BR /&gt;# man File::Find&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn&lt;/FOLDERS&gt;</description>
    <pubDate>Sat, 16 Aug 2003 07:51:47 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2003-08-16T07:51:47Z</dc:date>
    <item>
      <title>perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050121#M813230</link>
      <description>Dear Perl gurus,&lt;BR /&gt;&lt;BR /&gt;   I have typical problem with perl scripting. The requirement is I need to copy files and sub-dirs from one unix staging area(1) to another unix staging area(2) provided staging area(2) do not have the same file and sub-dir. The sub-dir in staging area(1) might have sub-dir's within and again you can copy them when staging area(2) do not have them. To do this check I wrote a small subroutine in perl which checks for files and sub-dir's at top level. Then I am using the same subroutine within to check for sub-dirs within sub-dir in staging area(1). This logic is not working at all. If any of guys provide me some insight on how to use the variables perl subroutine or some logic.  Thanks in adv. &lt;BR /&gt;&lt;BR /&gt;Here is the subrouting I am using.&lt;BR /&gt;sub xfer_subdir_and_files {&lt;BR /&gt;my ($input_source_dir, $input_target_dir) = @_ ;&lt;BR /&gt;my (@fl_list, $ind_dir, $ind_fl);&lt;BR /&gt;&lt;BR /&gt;if ( -d $input_source_dir ) {&lt;BR /&gt;#  Find list of files&lt;BR /&gt;@fl_list = `cd $input_source_dir; ll|grep -v \"^d\"|grep -v \"total\"|awk \'{pri&lt;BR /&gt;nt \$9}\'`;&lt;BR /&gt;foreach $ind_fl (@fl_list) {&lt;BR /&gt; chop($ind_fl);&lt;BR /&gt; if ( -f "$input_target_dir/$ind_fl" ) {&lt;BR /&gt;  `echo "Copy failed as the following file already exists in target" &amp;gt;&amp;gt; $xfer_fail_log`;&lt;BR /&gt;  `echo "$input_source_dir/$ind_fl" &amp;gt;&amp;gt; $xfer_fail_log`;&lt;BR /&gt;                     } &lt;BR /&gt;else {&lt;BR /&gt;  `cp -p $input_source_dir/$ind_fl $input_target_dir/` ;&lt;BR /&gt;  `echo "Copy successed for following file" &amp;gt;&amp;gt; $xfer_success_log`;&lt;BR /&gt;  `echo "$input_source_dir/$ind_fl" &amp;gt;&amp;gt; $xfer_success_log`;&lt;BR /&gt;     } #end else-if ( -f $input_target_dir/&lt;BR /&gt;                                } #end foreach &lt;BR /&gt;#  Find list of directories&lt;BR /&gt;@dir_list = `cd $input_source_dir; ll|grep \"^d\"|awk \'{print \$9}\'`;&lt;BR /&gt;&lt;BR /&gt;#  Find list of directories&lt;BR /&gt;@dir_list = `cd $input_source_dir; ll|grep \"^d\"|awk \'{print \$9}\'`;&lt;BR /&gt;foreach $ind_dir (@dir_list) {&lt;BR /&gt;chop($ind_dir) ;&lt;BR /&gt;  if ( -d "$input_target_dir/$ind_dir" ) {&lt;BR /&gt;# call xfer_subdir_and_files sub-routine again.&lt;BR /&gt;     &amp;amp;xfer_subdir_and_files("$input_source_dir/$ind_dir","$input_target_dir/$ind_dir") ;&lt;BR /&gt;     `echo "Copy failed as the following dir already exists in target" &amp;gt;&amp;gt; $xfer_fail_log`;&lt;BR /&gt;     `echo "$input_source_dir/$ind_dir" &amp;gt;&amp;gt; $xfer_fail_log`;&lt;BR /&gt;                               } #end if ( -d &lt;BR /&gt;  else {&lt;BR /&gt;     `cp -Rp $input_source_dir/$ind_dir $input_target_dir`;&lt;BR /&gt;     `echo "Copy successed for following dir" &amp;gt;&amp;gt; $xfer_success_log`;&lt;BR /&gt;     `echo "$input_source_dir/$ind_dir" &amp;gt;&amp;gt; $xfer_success_log`;&lt;BR /&gt;       } #end else-if ( -d "$input&lt;BR /&gt;                             }#end foreach &lt;BR /&gt;                            } #end if ( -f&lt;BR /&gt;else {&lt;BR /&gt;die "\n ERROR: $input_source_dir is not valid source dir \n";&lt;BR /&gt;     } #end else-if ( -f $input_source_dir )&lt;BR /&gt;                          } #end sub</description>
      <pubDate>Fri, 15 Aug 2003 22:11:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050121#M813230</guid>
      <dc:creator>Kris_5</dc:creator>
      <dc:date>2003-08-15T22:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050122#M813231</link>
      <description>&lt;BR /&gt;Is PERL required? As much as love it, I still go with tried and true:&lt;BR /&gt;&lt;BR /&gt;find /top/of/area1 -xdev -depth | cpio -pdmx /top/of/area2&lt;BR /&gt;&lt;BR /&gt;This will only copy all new stuff from area1 to area2... I think. Check the man pages.&lt;BR /&gt;&lt;BR /&gt;I'd work with your code if I had time, but I'm in the middle of storage migration.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 16 Aug 2003 02:38:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050122#M813231</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2003-08-16T02:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050123#M813232</link>
      <description>And this is cargo-cult programming.&lt;BR /&gt;&lt;BR /&gt;# perl -MFile::Find -e'find (sub { .... }, &lt;FOLDERS&gt;)'&lt;BR /&gt;&lt;BR /&gt;# man File::Find&lt;BR /&gt;&lt;BR /&gt;Enjoy, have FUN! H.Merijn&lt;/FOLDERS&gt;</description>
      <pubDate>Sat, 16 Aug 2003 07:51:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050123#M813232</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2003-08-16T07:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050124#M813233</link>
      <description>Assuming you still want to hand code this (vs. using a&lt;BR /&gt;module as previously suggested), there's a lot of&lt;BR /&gt;Perl-ification to be done here.&lt;BR /&gt;&lt;BR /&gt;To get the list of files in a subdirectory, use&lt;BR /&gt;opendir/readdir/closedir:&lt;BR /&gt;&lt;BR /&gt;opendir(DIR, $dir) or die;&lt;BR /&gt;@files = readdir(DIR);&lt;BR /&gt;closedir(DIR);&lt;BR /&gt;&lt;BR /&gt;foreach $file (@files) {&lt;BR /&gt;  next if ($file eq '.' or $file eq '..');&lt;BR /&gt;  print "working on file $dir/$file\n" if (-f "$dir/$file");&lt;BR /&gt;  ...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Since Perl5 "chop" is pretty much obsolete.  Use "chomp"&lt;BR /&gt;instead.  The "&amp;amp;" on subroutine names is also unnecessary&lt;BR /&gt;in Perl5.&lt;BR /&gt;&lt;BR /&gt;Finally, please consider using Perl's "print" instead of spawning&lt;BR /&gt;a shell just to do an "echo":&lt;BR /&gt;&lt;BR /&gt;open(FILE, "&amp;gt;$xfer_fail_log") or die;&lt;BR /&gt;print(FILE "...\n");&lt;BR /&gt;close(FILE);&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Aug 2003 17:00:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/3050124#M813233</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2003-08-18T17:00:33Z</dc:date>
    </item>
  </channel>
</rss>

