I have been working in a Perl script to read log files, but none of the people at work
want to use it as it requires run it from CLI, Im looking to integrate my Perl code which mainly
reads a txt file and produces and output (Already more than 2,000 lines) into a GUI which can be used with Windows or MAC PCs,
Example:
my perl script:
#./perl -i myfile
# HELLO this is the output!
Instead I want users to run the App and give them the chance to upload file and a Run button.
Thanks!
Then you can either write a web based frontend or use a GUI library such as Tk, Wx or Gtk.
Run as a CGI script which should ouput as HTML. For more you use template system like Template tool kit
In my experience, Tk is the most cross-platform GUI framework for Perl. It is very primitive (both in looks and API), but it works as expected almost everywhere with minimal fuss. Even with Gtk, I found there were some combinations of platforms and Perl deployments that just wouldn't work.
If you want to go the CGI route, try POEx::HTTP::Server. This will run a small web server within Perl without needing all the configuration of a full web server like Apache.
Related
I have written a simple Lua script that reads from and writes to an XML database. I want to use it as CGI, eventually returning data to display in a web page, but when, for testing purposes, I go straight to the script in a browser, it blows up on require("socket.http") with a 500 Internal Server Error and it apparently can't find the Lua socket library when run in a browser.
I haven't used CGI in years and I'm very new at Lua, so thanks for any assistance.
it apparently can't find the Lua socket library when run in a browser.
I assume your script is using socket.http. If so, you need to make luasocket (both its binary libraries and Lua files) available to your script. My suggestion is to make it work when you run it locally, before you try to make it run as a CGI script. You'll need to either get a pre-compiled luasocket for your platform or compile and install it yourself. You'll then need to use LUA_PATH and LUA_CPATH in your script to reference the locations of Lua (PATH) and binary (CPATH) files.
I want to run a Perl script online, but I don't know how.
In PHP you need to start with <?php, so do you have to start with something like that in Perl?
And does Apache automatically recognize Perl? Or do I have to upload Perl and let it point to it using #!/path/to/perl?
Can I use print() to display HTML?
In PHP you need to start with <?php, so do you have to start with something like that in Perl?
There are frameworks (such as Mason) which work like that, but it is more typical to have a standard Perl program which outputs the page.
And does Apache automatically recognize Perl?
Apache doesn't automatically recognise any kind of server side programming.
Or do I have to upload Perl and let it point to it using #!/path/to/perl?
You would need to have Perl installed on the server. You would generally start a script that way (but not necessarily, e.g. if you were using mod_perl), but would have to configure the server to recognise it as an executable and run it (just as you have to configure the server to recognise files ending with .php as scripts to run with PHP).
Can I use print() to display HTML?
Yes.
You should probably start by looking at the question Web Programming For The Non-Web Programmer (in Perl).
Must you use Apache? If not here is an alternative to consider.
I have found that the built-in servers and templating engine in the Mojolicious framework work very naturally for inline Perl within HTML. The tags are of the form <%== but work the same way. Also it has good documentation and examples to get you going.
Edit: It seems that there are ways to use Apache with Mojolicious too, see http://search.cpan.org/perldoc?Mojolicious::Guides::Cookbook, though the built-in servers have worked well for me, with FAR less (ie no) configuration.
Apache HTTP doesn't automatically understand Perl or PHP for that matter. For PHP to work, you have to have the Apache httpd module called something like mod_php.so or libphp5.so installed. However, since many websites use PHP in this manner, this Apache httpd module is normally installed.
Just as you need mod_php in order to use PHP in Apache's httpd web server, you need to do is make sure your web server is using mod_perl if you want to use Perl in a similar manner.
You'll need to build and install mod_perl which can be tricky -- especially if you don't control the machine the server is on.
The other way to use Perl is to use what's known as CGI-Perl. This is much easier to setup, but it is also much more dangerous since it can lead to someone being able to run unauthorized programs on your Apache httpd server.
In this case, you need to set up a CGI-BIN directory, and configure Apache httpd. This is fairly simple. Once you do that, you put all of your Perl scripts into the _CGI_BIN_ directory. In this case, your Perl scripts will have to handle all of the communication between your web server and the web client and handle all displays. Fortunately, it's not too difficult in perl since Perl gives you the basic modules to do this.
I have a really trivial perl script that I would like to distribute to a number of clients who are not very computer savvy. They are all running Windows XP or above. Furthermore, it is safe to assume that they do not have Perl installed on their systems.
I'm looking for a Perl module or other solution that would allow me to do the following:
The application should auto start upon login and minimize to the system tray until the user expands it by clicking on the system tray icon.
When expanded from the system tray the application should provide a simple Windows GUI to the script. The GUI is super trivial: a status line showing the status of the application and a "Do stuff" button that will trigger the processing of the applications business logic.
Windows-style ideally wizard based installation. I'd like to be able to able to distribute an [application-name]-install.exe that would guide the user through the installation. Perl plus dependencies should be installed behind the scene.
Are there any Perl GUI toolkits and/or installation tools that would help me achieve these things?
Win32::SysTray
Win32::GUI
PAR::Packer provided executable wrapped into NSIS
There are many more ways to do it. I think these modules will get you started most easily.
I am using perlapp from ActiveState to compile scripts into self-contained exe. It is commercial, but did not have problems I sometimes ran into with PAR/pp.
When I need to package more than just .exe (database drivers, configuration, templates, etc), quick installer can be made with InnoSetup.
PLDelphi is a Perl project hosted on CPAN. I am currently working on a Delphi application and I am investigating the possibility of adding Perl scripting support and read about PLDelphi.
Ideally, I'd like my application to not require Perl to be installed. PLDelphi claims to support this:
To use PLDelphi from your Delphi
application without need to install
Perl you will need this files in the
main diretory of your application:
PLDelphi.dll - The PLDelphi
library that loads the Perl
interpreter. PLDelphi.pm - Perl
side of PLDelphi. Perl56.dll -
The Perl library in case that you have
Perl built dynamic. PLDelphi_dll.pas -
PLDelphi classes and DLL wrapper.
lib/* - A Perl lib directory with basic .pm files (strict, warnings, etc...)
I am aware of RemObjects PascalScript and embedding Python in Delphi, but in this instance, I am interested primarily in Perl support.
Has anyone used PLDelphi with success? Or have you found other ways to execute Perl scripts from Delphi without the full Perl installation available locally?
EDIT:
To be more clear, I found 1 potential solution and that is using PLDelphi. However, I'd like to know if anyone has used it (last updated in 2004) before, and how well it worked.
I'm also interested in hearing about any other options for embedding a Perl interpreter with Delphi.
You could use Windows Script Host (which comes with VBScript and JScript by default) and install PerlScript from ActiveState.
Sadly PLDelphi isn't updated for XE3 or 64 bits there for won't work with Perl 5.16
I was really looking for a solution that didn't require installing anything on the client. It appears that PLDelphi is not working with ActivePerl 5.10...so I don't believe there is a ready solution to embedding Perl within a Delphi application.
What does it mean when I access my Perl script via URL, but when I do, the source code is printed on the screen?
Does this mean that Perl isn't properly set up? I'm using Apache on Fedora.
This means your webserver isn't set up to execute the script at that url. What server are you using?
It could also mean you are putting the Perl script in the wrong folder. The cgi-bin folder is still widely used as the folder where CGI scripts should be stored and run from. Other folders may just open the file and read it as text, similar to an HTML document, instead of running the document as code. But it can also mean the server is just not setup properly to run Perl scripts or other types of server-side scripts.
This means that you probably aren't doing what your server is expecting. Usually servers expect either that every file in a CGI directory is an executable, or that files with a certain extension are executable and it can serve any other file as its content.
Figure out which file extension your server expects your CGI program to use.
Ovid's CGI Course may help you (if you use CGI of course)