Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Directory Structure.

by GotToBTru (Prior)
on Mar 31, 2017 at 12:53 UTC ( [id://1186614]=note: print w/replies, xml ) Need Help??


in reply to Directory Structure.

The problem is relative versus absolute paths. You create directory VEHICLES, move to it, and in the first loop you create directory CARS and then move to it. But the chdir $dir statement tries to move to VEHICLES->CARS->VEHICLES which of course doesn't work. You need to change the value in your chdir statement to an absolute path. Perhaps something like:

use strict; use warnings; my @files=qw/CARS BIKES/; chomp(my $home = `pwd`); my $dir = 'VEHICLES'; mkdir ($dir); chdir ($dir); foreach my $file(@files) { mkdir $file; chdir $file; chdir "$home/$dir"; }

See here if you aren't familiar with chomp.

But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1186614]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-03-28 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found