Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

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?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (1)
As of 2023-09-21 22:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found