473,738 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to print out intended text - just prints out the contents of .pl file.

Markus
6,050 Recognized Expert Expert
I'll leave out the annoying 'i'm a newbie' speech and get to the point: i'm a newbie at perl ;)

First thing i ever wrote in perl and it doesnt work.

I'm using xampp as my localhost - with perl installed on that. When i run this (http://localhost/mysql.pl) it just prints out the contents of the file and not an array if the databases...

Enlighten me, oh gods of perl
Expand|Select|Wrap|Line Numbers
  1. #!"C:\xampp\perl\bin\perl.exe"
  2.  
  3. # PERL MODULE WE WILL BE USING
  4. use Mysql;
  5.  
  6. # HTTP HEADER
  7. print "Content-type: text/html \n\n";
  8.  
  9. # MySQL CONFIG VARIABLES
  10. $host = "localhost";
  11. $database = "...";
  12. $tablename = "...";
  13. $user = "...";
  14. $pw = "...";
  15.  
  16. # PERL MYSQL CONNECT
  17. $connect = Mysql->connect($host, $database, $user, $pw);
  18.  
  19. # LISTDBS()
  20. @databases = $connect->listdbs;
  21. foreach $database (@databases) {
  22.     print "$database<br />";
  23. }
  24.  
Jan 6 '08 #1
5 1876
numberwhun
3,509 Recognized Expert Moderator Specialist
I'll leave out the annoying 'i'm a newbie' speech and get to the point: i'm a newbie at perl ;)

First thing i ever wrote in perl and it doesnt work.

I'm using xampp as my localhost - with perl installed on that. When i run this (http://localhost/mysql.pl) it just prints out the contents of the file and not an array if the databases...

Enlighten me, oh gods of perl
Expand|Select|Wrap|Line Numbers
  1. #!"C:\xampp\perl\bin\perl.exe"
  2.  
  3. # PERL MODULE WE WILL BE USING
  4. use Mysql;
  5.  
  6. # HTTP HEADER
  7. print "Content-type: text/html \n\n";
  8.  
  9. # MySQL CONFIG VARIABLES
  10. $host = "localhost";
  11. $database = "...";
  12. $tablename = "...";
  13. $user = "...";
  14. $pw = "...";
  15.  
  16. # PERL MYSQL CONNECT
  17. $connect = Mysql->connect($host, $database, $user, $pw);
  18.  
  19. # LISTDBS()
  20. @databases = $connect->listdbs;
  21. foreach $database (@databases) {
  22.     print "$database<br />";
  23. }
  24.  
If it is printing the contents of the Perl file, instead of executing it, then either the web sever you are using is setup to ONLY execute .cgi files, or not setup to serve CGI at all. You need to figure that out.

Regards,

Jeff
Jan 7 '08 #2
Markus
6,050 Recognized Expert Expert
Ahh, thought so. -_-

danke
Jan 7 '08 #3
eWish
971 Recognized Expert Contributor
Since you are a complete newbie, now is the time to learn good coding practices :).

CGI.pm
Declare your variables
Pragmas strict & warnings

Also bookmark perldoc.perl.or g

--Kevin
Jan 7 '08 #4
Markus
6,050 Recognized Expert Expert
Since you are a complete newbie, now is the time to learn good coding practices :).

CGI.pm
Declare your variables
Pragmas strict & warnings

Also bookmark perldoc.perl.or g

--Kevin
I'm on it!

Just as soon as i can get this xampp / perl thing sorted ¬_¬
Jan 7 '08 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
I'm on it!

Just as soon as i can get this xampp / perl thing sorted ¬_¬
Ok, first, from the xampp page, here is the link that shows where the configuration files are located. You will specifically need the one for apache.

Once you have that, then you can follow the apache configuration for configuring cgi.

Personally though, I would first try changing the extension of my perl script to ".cgi" instead of ".pl" and see if it is already configured for that.

Regards,

Jeff
Jan 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2333
by: lawrence | last post by:
I'm probably missing something obvious, but I'm unable to write a file with this function. I've used my FTP software to set permissions to 777 on all the files in question. I've tried r, r+, w, and w+ as possible ways of opening the files. The first fopen is trying to create a file where none exists. It fails (thought I've set dir permissions to 777 as well). How can I create a file? There error messages print back the full input, so...
5
13382
by: MouseHart | last post by:
I've written a simple program in VB 6.0 to list all my MP3 files. To show them on the screen I used an MSFlexGrid named TextGrid (which is not associated with any table or text file) in the following code run by a button (the files are all in the format "Artist - Name Of Song" in their directories, which is why the code looks for a dash): Private Sub Command1_Click() Dim dashplace%, length% For I% = 0 To File1.ListCount FLIName =...
4
2188
by: Julie Siebel | last post by:
Apologies...I'm sure this has been asked before, but I can't seem to come up with the correct Google search terms. While my problem is with stylesheets, the errors are being caused by my javascript, so this seemed a more appropriate place to post. I'm using a media=print style sheet to do a version of a web page that I am building. Currently, I'm working on the IE version. I have an HTML page and 2 style sheets which all validate...
7
2636
by: Ron | last post by:
Hi All, Is it possible to have Access print a report, identical to one that would print to a printer, only print to a "standard" text file? I can't find it in help and when I try to just print to a file (in the printer selection screen of the print routines) it gives me a file named what I wanted, but is just garbage. Can't read it. TIA ron
15
1380
by: Jim B. Wilson | last post by:
Am I nuts? Or only profoundly confused? I expected the this little script to print "0": class foo(int): def __init__(self, value): self = value & 0xF print foo(0x10) Instead, it prints "16" (at least on python 2.4.4 (Linux) and 2.5 (Wine).
1
1640
by: eqiz | last post by:
I'm looking for a way to print stuff from my program. I have searched and searched for a way to print and the only thing I have found is PrintFORM which only takes a picture of the form and prints it in image quality which is really really bad quality. Is there any way to print the text off my form the way it looks and everything? Like how PrintForm prints but instead printing the text in "text quality" and the images in image quality? Im...
3
3161
by: twibblej | last post by:
Hello, I have a function which currently prints the contents of an object to the console. I want pass the function an arguement so that instead of always printing the object to the console it. a) prints contents of object to console or b) prints contents of object to file depending what input the print function is given. Now, I know I can just pass the function an open file to print to. What can I pass instead of an...
12
3538
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to print the report three times, but do not know how
16
4523
by: raylopez99 | last post by:
I am running out of printing paper trying to debug this...it has to be trivial, but I cannot figure it out--can you? Why am I not printing text, but just the initial string "howdy"? On the screen, when I open a file, the entire contents of the file is in fact being shown...so why can't I print it later? All of this code I am getting from a book (Chris Sells) and the net. The solution is to be found in the fact that stringbuilder is...
0
8968
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.