Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Directory Structure.

by duyet (Friar)
on Apr 01, 2017 at 09:39 UTC ( [id://1186666]=note: print w/replies, xml ) Need Help??


in reply to Directory Structure.

There are already good responses with creating the dirs, but on Unix system you can do the following:
`mkdir -p VEHICLES/{CARS,BIKES}`
which yields:
$ tree VEHICLES/ VEHICLES/ |-- BIKES |-- CARS 2 directories, 0 files

Replies are listed 'Best First'.
Re^2: Directory Structure.
by AppleFritter (Vicar) on Apr 01, 2017 at 09:59 UTC

    When doing this, keep in mind that using backticks (``) or the qx// quote-like operator, the command provided is passed through the shell (/bin/sh, whatever THAT really is) and subject to all the usual shell magic. This may be a problem if you're not expecting it, and a security issue if you're passing user input to the shell.

    In order to avoid the shell, use system instead and pass a list:

    #!/usr/bin/perl # ... system ("mkdir", "-p", map { "$dir/$_" } @files);
      if you're passing user input to the shell

      if youre passing data from untrusted sources unlaundered into the shell (see perlsec) is both more general and to the point. If I'm the user - whom I mostly trust - there's nothing wrong with my data. Except if there is, of course.

      </nitpick>

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

        If I'm the user - whom I mostly trust - there's nothing wrong with my data.

        DO you trust yourself?

        I trust myself to not try and actively exploit or sabotage my own systems. I do not trust myself to always get things right -- coding defensively and making things fail gracefully, avoiding unexpected and potentially dangerous behavior, is a good thing!

        Avoiding the shell (unless you have a good reason not to) is like useing strict. Yes, I trust myself, but I know I'm not perfect, so I'd rather have that extra safety net.

        (There's also the question of whether whoever is at the terminal, logged in as you, is ACTUALLY you, but in my case that's a lesser concern.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-26 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found