Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Directory Structure.

by GotToBTru (Prior)
on Mar 31, 2017 at 12:53 UTC ( #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
Node Status?
node history
Node Type: note [id://1186614]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2020-10-01 14:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (14 votes). Check out past polls.

    Notices?