Perl Newbie...need help (working on Windows)

Hi,
I am just learning perl and am stuck on my first simple script...

When i installed perl on c:/Perl it came with some example files....like this one:

------------------crash.cgi-------------------------------
#!/Perl/bin/perl


use CGI::Carp qw(fatalsToBrowser);

# This line invokes a fatal error message at compile time.
foo bar baz;
-------------------------------------------------

Which runs perfectly....


but when I make a slight change like this


------------------crash.cgi-------------------------------
#!/Perl/bin/perl

print "My first perl script";
-------------------------------------------------

It refuses to run, instead i get "Internal Server Error...blah blah blah"

What am i doing wrong?

Thanks!
fab_man_007Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
The

use CGI::Carp qw(fatalsToBrowser);

line directs any fatal errors to the browser.  Without it, you get a "500 internal server" error and you have to look for the error in the web server logs.
fab_man_007Author Commented:
update:

It works via the command line...and if i modify the program slightly like so:

use CGI ':standard';
print header;
print "Hello, World...\n";


I copied the above from another script....but no idea what it means....

help please....
TintinCommented:
Note that your script needs to also output a HTTP header, eg:

#!/Perl/bin/perl
print "Content-Type: text/plain\n\n";
print "My first perl script";

I'd always leave in the

use CGI::Carp qw(fatalsToBrowser);

while you are developing/debugging.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

fab_man_007Author Commented:
Hi Tintin,
I guess we were both writing at the same time....

I am learing perl from here: http://perldoc.perl.org/perlintro.html
and there it tells me just type

print "whatver you want here";

and it will show in the browser, but thats not happening....unless I do that "use CGI -:standard';


I come from a php side and i thought this would be simple or the same to learn.... :-(
fab_man_007Author Commented:
I think i have guessed it, unlike php....PERL needs to be told the content type before it will display....

Thanks for your help, sorry about the low points but I figured i will be needing quite a few questions here.. :-)
TintinCommented:
Note that the perlintro you were reading mentions nothing about output to a browser.  Remember Perl is a general purpose language whereas PHP is designed for web pages.  Therefore, you need to tell Perl if you are outputting HTTP headers or not.

The lines:

use CGI ':standard';
print header;

use the standard Perl CGI module and the 'print header', prints out a HTTP header, which depending on your version of Perl, will be the same as writing:

print "Content-Type: text/html; charset=ISO-8859-1\n\n";
fab_man_007Author Commented:
Cool, Thanks m8!
fab_man_007Author Commented:
I have come accross another problem and would appreciate your expert help there too if possible:
http://www.experts-exchange.com/Web/Web_Languages/CGI/Q_21787395.html

Thanks in advance
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.