Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Files. Where To Save On Windows. 2

Status
Not open for further replies.

macallan12y

Technical User
Nov 24, 2007
13
US
Hi,
I am new to programing. I hope that I have found the right place.

I have installed Activeperl and I can run the sample program but I can not run any of my own programs.

My first question is, does it matter where on C: I save my programs?

Thank You!
 
By the way. I wrote my program with word, saved it with Unicode encoding and saved the file to my desk top.
 
try a simple script in notepad/wordpad

#!c:/perl/bin/perl.exe
print "Hello World!\n";

and see if that works.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
I will try that. Does it matter where I save it?

Thanks.
 
I tried it.

I copied the program from the above post and pasted it into an open notepad page. I saved the page as: example2

When I tired to open it with Perl, I got the following response:

'example2'is not recognized as an internal or external command, operable program or batch file.

C:\Perl\eg>
 
it does not matter where you save perl scripts on your disk. But it is easy to create a folder where you will store perl programs, something like:

c:\myperl

then you run programs from that folder:

perl c:\myperl\scriptname.pl

but you can run them from any folder as long as you use the full path or change directory to where the script is and use just the name of the script.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Well, I am beginning to better understand how my computer works but it still isn't working.

I created a new file and named it myperl. I placed it in the perl folder.

The path is:

C:\perl\myperl

When I try to open example2.pl (see above) I still get the following message:
'example2 is not recognized as an internal or external command, operable program or batch file.

This is only day two of this for me so I am about as green as they get but I am thinking that the problem is likely with the files themselves and not the program because an example that came with the program opens fine.

By the way, thank you for the prompt responses. They have been appriciated.

 
Drive:\path program parameter

this is the normal convention for running programs on most OS's

Drive -> indicates the drive
path -> indicates directory path
program -> the program you're trying to run, in this case perl
parameter -> the argument you're passing to the program, in this case the name of your script
Code:
C:\Documents and Settings\Paul\>path
PATH=[COLOR=red]C:\Perl\bin\;[/color]C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Pro
gram Files\WinSCP3\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Prog
ram Files\Sonic\MyDVD;;C:\Program Files\Sonic\MyDVD;C:\Program Files\Microsoft S
QL Server\80\Tools\Binn\;E:\Program Files\Common Files\GTK\2.0\bin

in this case the path to the perl executable is in mys system path so the OS can find it easily, without me having to specify it, otherwise I'd have to specifically name the path to the executable
Code:
C:\Documents and Settings\Paul\>[COLOR=red]perl [/color] [COLOR=green]myscript.pl[/color]
In red we have the program, and in green the name of the script we wish to run as a parameter to the perl program. FWIW, any subsequent parameters would be passed to the ARGV array of the perl script.

HTH

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Thanks Paul. That makes sense but my simple programs are not running even when I specify the path.

The example program that downloaded with Activeperl does run, though.

So, I am wondering if I am having a text editing problem. Is there a simple way be sure that my files are not only "findable" but readable?

By the way, I am saving them as Unicode. I also tried saving them as ASCII via the plain text option and that didn't solve the problem either.

Thanks!
 
Have you tried doing them in notepad?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
I want to isolate the problem.

Can I type simple programs directly into perl and thereby bypass the file finding step?

Can I download a simple to use an online text editor that is quite robust or open programs directly from the web and use an online text editor exclusively?

Thanks!
 
First of all, don't ever program using Word. It's a text editor you need, not a word processor. Notepad is the simplest Windows-based text editor, so you can use that for the moment.

One problem people sometimes come across in Windows is that they have known file extensions hidden. This means that you can end up with a file that looks like it's called "test.pl" whereas it's actually called "test.pl.txt". When you're on the command line, navigate to the directory containing your Perl script and run the "dir" command. Examine the output to make sure your file is called what you think it's called.
 
Ishnid,

I followed your instructions and yes, they do have .txt following .pl

What do you think that should I do to determine if this is the problem and how might I fix it?

Thanks.
 
Okay, I can see that I need to remove the .txt from the end of the file names because with it, the files are not run; rather, the files are opened.

So, I am sorry to be asking such rudimentary questions but how do I change the settings such that .txt is no longer automatically added to the end of my notepad files?

Thanks.
 
I think that I am getting close. I have been selecting "all files" instead of .txt when saving notepad files. I am also saving in Unicode.

I get the following error message:
panic: utf16_to_utf8: odd bytelen 47 at C:\Perl\myperl\example3.pl line1.

What does this error message mean?

And thanks for all of the help so far. This place is great!
 
Yea! I got it to work!

I saved as "Unicode big endian" rather than "Unicode". I don't know what the difference between these two formats are but it is working now.

Thanks for all of the help everyone!
 
have a look for notepad++ on google, it's free, and a lot more powerful than notepad

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I'm so glad we've got some windows experts around here.

star for Paul and ishnid.

-M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top