in reply to file creation
Well, it will work if the directory structure exists, so you will have to write something like:
#!/bin/perl -w use strict; my $fileName = "dir1/dir2/dir3/filename.txt"; create_dirs( $fileName); open (LIST, ">$fileName"); sub create_dirs { my $filename= shift; my $dir; while( $filename=~ m{(/?[^/]+)(?=/)}g) { $dir .= $1; next if( -d $dir); mkdir( $dir) or die "cannot create $dir: $!"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: file creation
by rob_au (Abbot) on Jan 31, 2002 at 13:47 UTC | |
|
Re: Re: file creation
by gav^ (Curate) on Jan 31, 2002 at 16:44 UTC |