title: Run a perl script with Python on multiple files at once in a folder
body: <p>This is my perl script at the moment:</p>
  
  <pre><code>#!/usr/bin/perl
  use open qw/:std :utf8/;
  use strict;
  use warnings;
  
  if (defined $ARGV[0]){
  my $filename = $ARGV[0];
  my %count;
  
  open (my $fh, $filename) or die "Can't open '$filename' $!";
  while (&lt;$fh&gt;)
  {
          $count{ lc $1 }++ while /(\w+)/g;
  }
  close $fh;
  
  my $array = 0;
  
  foreach my $word ( sort { $count{$b} &lt;=&gt; $count{$a} } keys %count)
  {
      print "$count{$word} $word\n" if $array++ &lt; 10;
  }
  
  }else{
  print "Please enter the name of the file: ";
  my $filename = ($_ = &lt;STDIN&gt;);
  
  my %count;
  
  open (my $fh, $filename) or die "Can't open '$filename' $!";
  while (&lt;$fh&gt;)
  {
          $count{ lc $1 }++ while /(\w+)/g;
  }
  close $fh;
  
  my $array = 0;
  
  foreach my $word ( sort { $count{$b} &lt;=&gt; $count{$a} } keys %count)
  {
      print "$count{$word} $word\n" if $array++ &lt; 10;
  }
  }
  </code></pre>
  
  <p>And this is my Python script at the moment:</p>
  
  <pre><code>#!/usr/bin/env python3
  import os
  
  perlscript = "perl " + " perlscript.pl " + " /home/user/Desktop/data/*.txt " + " &gt;&gt; " + "/home/user/Desktop/results/output.txt"
  os.system(perlscript)
  </code></pre>
  
  <p><strong>Problem</strong>: When there are multiple txt-files in the data folder the script only runs on one file and ignores all the other txt-files. Is there a way to run the perlscript on all the txt-files at once?  </p>
  
  <p><strong>Another problem:</strong> I'm also trying to delete the txt-files with the os.remove after they have been executed but they get deleted before the perlscript has a chance to execute.</p>
  
  <p>Any ideas? :) </p>