perl

Search for occurrences of contents of a file in another file

Hi, I want to search the contents of files in a directory for words present in files in another directory. Is there a better way to do it than the following? (By better mean memory usage wise) More specifically: folder 1 has several files, each file has several lines of text. folder 2 has several files, each file has several words, ea...

Find Tags in website HTML's

I'm using Perl. I have the tag, for example: "XYZ_PKM_HTML" I would like to be able to provide a base url, for example: www.example.com and the to get the HTML page (not necessarily the main page, thats easy) where this tag appears. is it possible? any idea? (or already made modules, looked on cpan, there were some interesting stuff, bu...

How can I use the parameter `tests` after declaration in Perl's Test::More?

from perldoc -f use syntax of the function use: use Module VERSION LIST use Module VERSION use Module LIST use Module use VERSION but in this case: use Test::More tests => 5; (it sets number of tests to 5) What is data type of the expresion tests => 5? Is it LIST or something else? How can I use this parame...

How can I remove duplicates and sorting at the same time in Perl?

Hi Everyone, I have an array of this kind @uniqarr = qw(error 0 goodrecordno:6123, error 0 goodrecordno:6143, error 1 goodrecordno:10245, error 1 goodrecordno:10678, error 1 goodrecordno:10698, error 2 goodrecordno:16245, error 2 goodrecordno:16123); I want the o/p as error 0 goodrecordno:6123 error 1 goodrecordno:10245 error 2 go...

HTTP Streaming with Apache, Perl, and jQuery?

I'm trying to prepare a proof of concept for a page that will take a file that a user chooses, process it, and return it, all the while reporting on the status of the process. I thought the best solution for this may be HTTP streaming, however I can only get it working in Firefox (not Chrome or IE8.) load.js $(function() { var...

Rails or Django style routing in Perl

I have grown accustomed to the way Rails maps a route or the Django uses regex on a route (I am not expect in Django, but this is what I have heard how it does it's routing) and how they use the style of permalinks to access a particle web page. Is it possible to do the same thing in Perl? ...

Perl Compare dates with MySQL

I'm struggling to figure out how to compare MySQL dates with current system time using perl. I have a script that runs on a cron job that will send notification if the current system date/time is past the date/time of a returned record: An application displays a table view: EventId Device Location CC: 123 something B...

Perl function name clash

I'm in a situation where a module I'm using has a function that's name is exactly the same as one in my own module. When I try to call the function in my module (OO Perl, so $self->function) it's calling the function from the other module instead. I've already got around it by renaming my function but as a matter of interest, is there a...

Why doesn't Perl's strict warn about an undeclared $a?

Can someone please explain to me the below code. This behavior has been like this for a while (tested on 5.8.5, 5.8.8, 5.10.1, 5.12.2) so there must be a reason behind it? $ perl -M5.012 -E '$aa=2' Global symbol "$aa" requires explicit package name at -e line 1. $ perl -M5.012 -E '$a=2' Thanks. ...

How do I run a Perl script with ActivePerl?

I just recently installed ActivePerl 5.12.2.1202 on my Windows XP in C:/Perl. I am new to Perl scripting. I just want to run a Perl program which contains one print statement, which I saved in Notepad with the name ex.pl. How can I run this Perl program? Can I use an editor for typing a Perl script other than Notepad? How do I use Act...

Basename quirks - what are they

The documentation for File::Basename says NOTE: "dirname()" and "basename()" emulate the behaviours, and quirks, of the shell and C functions of the same name. See each function's documentation for details. What are these quirks? ...

can we source a shell script in perl script

can we source a shell script in the perl script?? Example: Program 1: cat test1.sh #!/bin/ksh DATE=/bin/date program 2: cat test2.sh #!/bin/ksh . ./test1.sh echo `$DATE` Program 3: cat test3.pl #!/usr/bin/perl ### here I need to source the test1.sh script print `$DATE`' How to source the shell in perl to get the date printed ...

which language (python/perl/tcl) on linux doesn't need to install the third-party libs?

When deploy java app on linux, we don't need to install anything, all third-party libs are jar files and we only update classpath in script file. But java needs jre which is quite large. So is there any other language supported by linux can do that? By default our server only support perl/python/tcl, no gcc available, sigh. ...

How can I encrypt and decrypt passwords in a Perl CGI program?

Am new to Perl CGI, using ActivePerl, SQLite DB, Apache server and Windows. I have an entry form in which their are fields like Id, Name, Password and so on. Whenever anybody makes a new entry then whatever they enter into password field that should be encrypted and get stored in database. The next time when that same user enters the ...

How do I make a Perl "array of arrays of hashes"?

I think what I need is an Array of Array of Hash, but I have no idea how to make that. Can Perl do that? And if so, how would the code look like? ...

Threads application terminates unexpectedly

I have little scraping application and trying to add multithreading to it. Here is code (MyMech is WWW::Mechanize subclass used to process HTTP errors): #!/usr/bin/perl use strict; use MyMech; use File::Basename; use File::Path; use HTML::Entities; use threads; use threads::shared; use Thread::Queue; use List::Util qw( max sum ); my $...

Creating a Combobox in HTML

Actually I have a CGI form which consists of textfields and I need a combobox in which I can enter my own data dynamically. May be it seems very silly question but I am new to cgi-perl as well as HTML so no idea what to do. Here is my form: #!C:\perl\bin\perl.exe use CGI; use CGI qw/:standard/; use CGI::Carp qw(warningsToBrowser fatal...

Running a perl script on windows without extension

Hello I am trying to find a way to register the files with extension .pl as executables. I spent some time on the web looking for a solution, but I couldn't find anything. What I can do: I made a script, let's call it myscript.pl I can run it like this : perl myscript.pl [my script parameters] Now since the file is associated with pe...

When to use $sth->fetchrow_hashref, $sth->fetchrow_arrayref and $sth->fetchrow_array?

I know that: $sth->fetchrow_hashref returns a hashref of the fetched row from database, $sth->fetchrow_arrayref returns an arrayref of the fetched row from database, and $sth->fetchrow_array returns an array of the fetched row from database. But I want to know best practices about these. When should we use fetchrow_hashref and when s...

record separator of different length

I understand that the following script would print out line(s) separated by '--' (2 dashes), but how can I use it when there are many '-' (dashes). Many thanks in advance. { local $/ = "--\n"; while (<>) { chomp; print; } } ...