Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix "perl is not recognized" on Windows?

Tags:

windows

perl

I've set up a log file to pick up MySQL slow queries.

I've been unable to parse the file however. Linux makes this task seem very simple. In tutorials it seems as easy as:

 $ mysqldumpslow -s c -t 10

In Windows however, I'm not sure how you run Perl, located in: G:\xampp\perl\bin with the Perl Script mysqldumpslow.pl, located in: G:\xampp\mysql\scripts

I've tried to enter:

G:\xampp\mysql\scripts\perl mysqldumpslow -s c -t 10

The command prompt returns something like "perl is not recognized".

like image 454
rrrfusco Avatar asked Jan 25 '10 02:01

rrrfusco


2 Answers

Errm, you are using the wrong paths.

If perl.exe is located in G:\xampp\perl\bin and the mysql script in G:\xampp\mysql\scripts, you need:

> G:\xampp\perl\bin\perl G:\xampp\mysql\scripts\mysqldumpslow.pl -s c -t 10.

Of course, that's a very roundabout way of doing things, so instead, add perl to your PATH, and cd into the correct directory and then run it:

> set PATH=G:\xampp\perl\bin\;%PATH%  // Note: This can be added in the
                                      // System Control Panel.
> cd /d G:\xampp\mysql\scripts
> perl mysqldumpslow.pl -s c -t 10

Or even better, add perl to your known filetypes.

  1. Go to Explorer -> Tools -> Folder Options -> File Types.
  2. Click 'New', type pl for the extension field. Click Ok.
  3. Find PL in your list, click Advanced. Under Actions, click 'New'.
  4. For Action type open, for 'Application used to perform action' type:

    G:\xampp\perl\bin\perl.exe -w "%1" %*

  5. Click Ok.

Now you can just run the script as:

> mysqldumpslow.pl -s c -t 10

As you would in Linux.

Quick note: Adding .pl files as known file types is roughly equivalent to Unix people adding

#!/usr/bin/perl -w

to the start of every perl script. In Windows you only need to add it once.

Second note: The -w turns on Warnings in the perl interpreter. You can leave out the -w if you wish.

like image 84
Alex Budovski Avatar answered Sep 30 '22 13:09

Alex Budovski


I fixed this error by using the command:

set PATH=C:\perl\bin;%PATH%
like image 43
Parikshit Avatar answered Sep 30 '22 14:09

Parikshit