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 ./generate.pl line 379, near "mkdir"

Replies are listed 'Best First'.
Re: Why am unable to create another directory using perl?
by Athanasius (Archbishop) 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)