SPUG: test directory and then create

ced at carios2.ca.boeing.com ced at carios2.ca.boeing.com
Wed Jan 9 17:14:11 CST 2002


>I am using solaris 2.6 and perl 5.6.1.
>I have an external file that has multiple directory names 
>listed in it. The directory names in this file are seperated 
>by a tab. I want to read this external file and I want to test 
>to see if each of these directories exists. If these directories 
>don't exist I want to create them. If they do exist I don't want 
>to do anything.  How do I do this in PERL? How do I do the dir 
>test? And how do I perform the loop?

A quick 'n dirty solution:

perl -F\\t -lane '! -e $_ && mkdir $_ for @F' ext_file
  
(slight mods needed for non-Unix)

Rgds,
--
Charles DeRykus

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     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