in reply to mkdir in loop - overwrite danger?
A bit more Perlish:
#!/bin/perl use strict; use warnings; use File::Path qw(make_path); my $txt = "txt"; my @files = glob("*$txt"); foreach my $filename (@files) { my ($seq, $nr, $mol, $dir, $step, $type) = (split /[._]/, $filename)[1..6]; print "name of file: $filename \n\n"; make_path("~/folder1/$mol/$dir"); }
Update: corrected typo (thanks poj!). Updated again to use glob instead of ls.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: mkdir in loop - overwrite danger?
by afoken (Chancellor) on Dec 22, 2015 at 22:36 UTC | |
by GotToBTru (Prior) on Dec 23, 2015 at 13:15 UTC |