SPUG: A more complicated question
Pommert, Daniel
Daniel.Pommert at verizonwireless.com
Fri Jan 11 10:39:19 CST 2002
Ken is right. My solution, posted earlier, lacked the chmod command on the
file. (It also lacked a closing quote, but that was obvious...)
Also, I should have made a better choice about directory permissions than
using the file's permission. Garrett, this is a point in which your problem
is under-specified. Your meta-data file does not say what the directory
permissions should be. Perhaps your umask() is the best choice.
-- Daniel Pommert
Verizon Wireless
-----Original Message-----
From: Ken McGlothlen [mailto:mcglk at artlogix.com]
Sent: Thursday, January 10, 2002 4:03 PM
To: garrett esperum
Cc: spug-list at pm.org
Subject: Re: SPUG: A more complicated question
"garrett esperum" <shamonsflame at hotmail.com> writes:
| The meta-data file contains information about multiple data files. There
are
| hundreds of rows with six columns each in the meta-data file. Each file
has
| it's own row of meta information. A rows column is as follows:
|
| Column 1 = file name
| Column 2 = file type
| Column 3 = file location
| Column 4 = file owner
| Column 5 = file permissions
| Column 6 = currently unused optional column
|
| These columns are seperated by a single tab. [...]
| I want to execute the creation.pl file to read the meta-data file and
create
| a "mirrored file environment" from the meta-data information. I need help
| with the following tasks:
|
| 1) How do I process each column of every row? How do I grab one row, split
it
| up at every tab, and copy the correct file into it's correct directory
with
| its correct permissions?
use File::Copy;
open( F, "metadata.yabble" );
while( <F> ) {
chomp;
my( $fn, $ftype, $floc, $fown, $fperm, $optional ) = split( /\t/ );
copy( $fn, $floc );
chmod( $fperm, "$floc/$fn" );
}
close( F );
| 2) How do I create variables for each piece of the split row?
Already answered above.
| Like how do I create a variable for the directory path column and then go
and
| create that directory path from that variable if it doesn't already exist?
use File::Copy;
use File::Path;
open( F, "metadata.yabble" );
while( <F> ) {
chomp;
my( $fn, $ftype, $floc, $fown, $fperm, $optional ) = split( /\t/ );
mkpath( $floc ) unless( -d $floc );
copy( $fn, $floc );
chmod( $fperm, "$floc/$fn" );
}
close( F );
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/
More information about the spug-list
mailing list