开发者

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

开发者 https://www.devze.com 2022-12-18 04:24 出处:网络
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 simpl开发者_开发百科e. In tutorials it seems as easy as:

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 simpl开发者_开发百科e. 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".


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.


I fixed this error by using the command:

set PATH=C:\perl\bin;%PATH%


if your Perl interpreter perl.exe is located in G:\xampp\perl\bin, then use G:\xampp\perl\bin\perl.exe. For convenience of calling your Perl interpreter from anywhere , you can add the path G:\xampp\perl\bin into your PATH environment variable. To call your Perl script, try this

c:\> G:\xampp\perl\bin\perl.exe G:\xampp\mysql\scripts\mysqldumpslow.pl
0

精彩评论

暂无评论...
验证码 换一张
取 消