Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Why am unable to create another directory using perl?

by finddata (Sexton)
on Mar 15, 2017 at 05:58 UTC ( #1184644=perlquestion: print w/replies, xml ) Need Help??

finddata has asked for the wisdom of the Perl Monks concerning the following question:

#TO Keep .html files in separate folder## chdir $output_dir; mkdir 'html',0755; `find . -name '*.html' | cpio -pdm html` mkdir 'files',0755; `cp -r html files`
error: yntax error at ./ line 379, near "mkdir"

Replies are listed 'Best First'.
Re: Why am unable to create another directory using perl?
by Athanasius (Bishop) on Mar 15, 2017 at 06:13 UTC

    Hello finddata,

    Although backticks enclose a system command, the backtick construct itself still constitutes a Perl command, and so must terminate in a semicolon (unless it’s the last command in a block):

    ... `find . -name '*.html' | cpio -pdm html`; # ^ mkdir 'files',0755; ...

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Is it possible to copy files without directory structure?
      chdir $output_dir; mkdir 'html',0755; `find . -name '*.html' | cpio -pdm html`; chdir $output_dir; mkdir 'htmlfiles',0755; `cp -r html htmlfiles`;
      Here it copies along with directory structure
        What about files in different directories that have the same name?
        (Most prevalent probably index.html)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1184644]
Approved by Athanasius
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2020-01-24 03:44 GMT
Find Nodes?
    Voting Booth?