2

I am immersing myself into the world of Perl for the first time. I figured the easiest way was to integrate using notepad++, which is my preferred editor. I went ahead and installed the ActiveState self extracting installer. I then pointed NppExec to my perl directory by typing:

perl "$(FULL_CURRENT_PATH)"

As a script "Run Perl", saved, then added a macro using this procedure

http://paul.atc.informatica.gsf.nl/resources/Perl_with_Notepad.pdf

I can run Perl scripts using the perl compiler. However, perldoc does not work erroring with:

Can't locate object method "perldoc" via package "perldoc" (perhaps you forgot to load "perldoc"?) at C:\Users...

This is because my perldoc and compiler are actually in c:\perl\bin (or whatever)

How do I switch the file path to point to the right directory? Thank you so much. I am a complete noob at this.

Edit: To add more information, perldoc works fine if i call

perldoc perldoc

using the command prompt. It does not work when i write a script in notepad++ and attempt to complile. Both the cmd prompt and notepad++ will compile scripts correctly.

pacman326
  • 35
  • 1
  • 7
  • did you add 'perldoc' as an function-key shortcut? – Len Jaffe Jun 24 '13 at 19:00
  • No I did not. I tried testing this by typing perldoc perldoc. That's when I got the error. When I typed the same into a cmd prompt it worked as expected. – pacman326 Jun 24 '13 at 19:01
  • and by typing, you mean at a CMD prompt? – Len Jaffe Jun 24 '13 at 19:01
  • @LenJaffe Yes, it works under a windows cmd prompt. If i try to do it as a .pl script in notepad++ it does not. I can compile in both notepad++ and windows cmd prompt. – pacman326 Jun 24 '13 at 19:03
  • I'm unfamiliar with notepad++, can you provide more detail about it not working as a notepad++ script please. – Len Jaffe Jun 24 '13 at 19:20
  • When I try to compule a script using perldoc I get the following error in the console: NPP_EXEC: "Run Perl" c:/perl/bin/perl "perl_intro.pl" Process started >>> Can't locate object method "perldoc" via package "perldoc" (perhaps you forgot to load "perldoc"?) at perl_intro.pl line 1. <<< Process finished. (Exit code 255) ================ READY ================ – pacman326 Jun 24 '13 at 19:33
  • and perl_into.pl just says 'perldoc perldoc'? – Len Jaffe Jun 24 '13 at 21:08
  • `perldoc` is not a Perl function. It is a command line program that finds the correct piece of documentation from installed modules and displays it (usually on a console). You can't use it in a Perl script. (`perldoc perldoc` is parsed as indirect object syntax, trying to invoke a method called `perldoc` on the string `"perldoc"`, therefore looking for a package called `perldoc`, which doesn't exist. The command should work fine when executed in a shell (e.g. cmd)). – amon Jun 24 '13 at 21:15

1 Answers1

3

Perldoc is not a part of the Perl language. It is a program that is part of the core distribution. You'll likely find a perldoc.bat in your ActivePerl install if you look for it.

So that's why:

 perldoc perldoc

works from the command line (because that's how it is intended to be invoked. But fails miserably when you ask Perl to execute 'perldoc' command. It tries valiantly to find a method, defined somewhere in all of the modules that have been included, but finding none, tells you so.

So if you want to write a Perl program to execute perldoc, you could use something like this:

  print `perldoc perldoc`

But you're much better off using a bat file, or its equivalent in your version of windows.

Len Jaffe
  • 3,442
  • 1
  • 21
  • 28
  • Okay that makes more sense. So I guess it's like when I type "help math" in MATLAB in the command window? Anyways, I will just leave a command window open from now on. Thanks! – pacman326 Jun 24 '13 at 21:23
  • You're welcome..and welcome to Perl. All your dreams will now come true :-) – Len Jaffe Jun 24 '13 at 21:32