Not sure if this will help, but something like this would work... foreach ( `ls -d1 $source/06/*` ) { # each line of output goes into $_ @group = split(m|/|, $_); # split out filename parts $pcgname = pop(@group); # gets filename $bu = pop(@group); # gets the 06 part
# do something with the current $bu and $pcgname } - Alan -----Original Message----- From: Johnson, Shaunn [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 12:44 To: [EMAIL PROTECTED] Subject: parse out parts of dir / files / Howdy: I'm having problems trying to parse out part of a directory into variables. I start with this: [snip script] /usr/local/bin/perl -w use diagnostics; my $dest="/i/'Depression Management'/Mailing/dec2002_iso_images"; # Where is data coming from? my $source="/i/'Depression Management'/Mailing/Dec2002"; foreach $group ( split(/\n/,`ls -d1 $source/06/*`) ) { print $group, "\n"; } [/snip script] And this is the results: [snip results] /i/Local Test Dir/Mail/December2002/06/first workgroup (emi).pdf /i/Local Test Dir/Mail/December2002/06/prof arrange (test).pdf . . . . . . [/snip results] What I want is to parse out the path into 3 variables: [broken logic] foreach my $group ( split(/\n/,`ls -d1 $source/0*/*`) ) { ($bu, $pcgname)=($group =~ m/$source\/(0\d)\/(.*)/i); [/broken logic] How can I split $group in to $source, any number (06 in this example) and any file name listed after that (which will most likely include white spaces in the names)? In the above, I thought I was only getting the digit and everything else into the TWO variables (but I guess not) ... Thanks for any suggestions! -X -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]