SPUG: A more complicated question

Ward Kaatz wardk at wardk.org
Thu Jan 10 20:37:54 CST 2002


Randal Schwartz also solved this problem in the Linux Magazine I picked up last night (Jan 2002).  I am pretty sure his homepage has links to all the articles and code that he publishes on paper. worth a look.

stonehenge.com

On Thu, Jan 10, 2002 at 04:02:40PM -0800, Ken McGlothlen wrote:
> "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