The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl Script issue. What am I doing wrong? SkySmart Shell Programming and Scripting 14 03-19-2009 05:22 PM
perl script to print to values in rows and columns nogu0001 Shell Programming and Scripting 3 02-22-2009 04:30 PM
Perl script to match a pattern and print lines ammu Shell Programming and Scripting 6 12-22-2008 04:26 AM
Perl Script Issue - Please Help * Thanks!!! jroberson Shell Programming and Scripting 8 11-03-2008 03:47 AM
perl - why is the shell script executed before the print command? mjays Shell Programming and Scripting 3 09-21-2007 06:49 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-09-2009
man man is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 13
Perl script issue: print

Can someone tell me what I'm doing wrong with my perl script? I am new to Perl. This isn't even the final script, I'm just testing to see if it will print the directories with the files in it. For some reason my output is only printing the 1st, 6th, and last entries of the @sub_dir array. Each of the sub_dir folders has 4 test files in it (Test1-4.txt).

My intent is to ultimately copy multiple files from source to destination--since perl won't let me do it as easily as in shell. TIA


Code:
#!perl.exe

use strict;
use File::Copy;

my @sub_dir = ("sqr","src","user","nvision","winword","crw","excel","maint","projects","scripts","data");
my $source = "C:\\Test";
my $destination = "C:\\Test2";

foreach (@sub_dir) 
   {
   my $dir1 = glob($source . "\\" . $_ . "\\*");
   my $dir2 = glob($destination . "\\" . $_);
   
   print "$dir1\n";
   }


Here is my output:

C:\Scripts>perl refresh_test.pl
C:\Test\sqr\Test1.txt
C:\Test\sqr\Test2.txt
C:\Test\sqr\Test3.txt
C:\Test\sqr\Test4.txt

C:\Test\crw\Test1.txt
C:\Test\crw\Test2.txt
C:\Test\crw\Test3.txt
C:\Test\crw\Test4.txt

C:\Test\data\Test1.txt
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0