i can break it down a bit...#!/usr/bin/perl -w use strict; use File::Basename; use File::Copy; my @sourceD = "i:/tmp"; my @targetD = "c:/temp"; move @{$_} foreach map { [ "$sourceD/$_", "$targetD/$_" ] } map {basen +ame $_} <$sourceD/*.pl>;
~the end <$sourceD/*.pl> is the glob. this creates a list of files.
~the first map (working backwards) map {basename $_} gets the basename of the files, in a list
~the second map map { [ "$sourceD/$_", "$targetD/$_" ] } creates a list of anonymous arrays with the source path/filename, and target path/filename
~the foreach lets us iterate over each member in the list of anonymous arrays
~the funny looking @{$_} takes the anonymous array reference in $_ and evaluates it as an array, which is fed to move.
err... i didn't check the output of move, either...
~Particle
In reply to Re: Globbing and Moving Together
by particle
in thread Globbing and Moving Together
by Kevman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |