in reply to How can one create a text file in the subfolder of a folder?

The problem is

map {mkdir $_; chdir $_;} @folders;

that you don't chdir back to where you came from.

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

Replies are listed 'Best First'.
Re^2: How can one create a text file in the subfolder of a folder?
by supriyoch_2008 (Monk) on Apr 22, 2017 at 13:23 UTC

    Hi Shmem,

    Thank you for your suggestion.

    With kind regards,

    supriyoch_2008

      Thank you for your suggestion.

      You're welcome. But what I wrote wasn't a suggestion - it was telling you where the problem is.
      But since you thank me for a suggestion, here is one:

      use Cwd; my $cwd = getcwd(); ... map {mkdir $_; chdir $_;} @folders; chdir $cwd;
      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      Or:

      map {mkdir $_; chdir $_;} @folders; my $output="z.txt"; open (my $fh,">",$output) or die "Cannot open file '$dirname/$output'. +\n";

      That, of course, assumes your code doesn't have other assumptions about the current folder.

      Much better to use File::Path, Path::Tiny or similar module.