I'm creating an XML file using Perl and XML::Simple module. I successfully create the XML file, but the problem is I am having <opt> </opt> tag for each my tags. I am looking for any option which we can aviod the <opt> </opt> tag. I can't do the post-processing to remove the tag. because the file size is huge.
Example :
<opt>
<per...
I am having a lot of IDs and I want to store them for a temporary purpose and need to search that record for some operation. Which data structure is good for this operation in Perl? Should I use a hash or an array, or is there any other module I could use to do this efficiently?
The records are 4343, 34343, 34343, 2323, 232, ....
...
Good day!
I have a code here that uses the blowfish_PP algorithm from Crypt::Blowfish_PP to encrypt a password.
I've provided a sample "key" variable for a start (though
I will make a function later that will increment key every time I
use it), but for now this is what I've got:
use Crypt::Blowfish_PP;
$key = "12345678";
$$plaintextB...
What is the difference of doing \1 as opposed to $1 if any, or are they interchangeable in all situations.
Example:
s/([a-z]+),afklol/$1,bck/;
#against
s/([a-z]+),afklol/\1,bck/;
They both give the same result but is there any difference?
...
Code:
%a = ( 1 => "ONE" ,
2 => "TWO" ,
3 => " Three", );
$test_value = 1 ;
foreach $key (sort(keys %a)) {
if ($key == $test_value ) {
print $a{$key};
}
}
I just want to achieve the same operation in very short way. Is there any shortcut for this?
...
I have a Perl module that I have declared some constants:
use constant BASE_PATH => "/data/monitor/";
In live operation the constant will never change but I wish to be able to modify it
in my unit tests, e.g. to set it to ~/project/testdata/. Is there a way do do this
without having to use "non-constants"?
Could I possibly use Test:...
I am having issues getting the -e and -d file test operators to work reliably.
Listings 1 and 2 are in the same directory, on an NTFS Windows XP SP 3 system. However, Listing 2 insists that a directory exists(it doesn't), and Listing 1 gets it right. Listing 2 is part of the main program.
Also, interesting, my logger routine is refusin...
I am using Perl's Net::Telnet module to access an application available over telnet.
I am using $telnet->waitfor() and $telnet->print() methods to determine the form received and submit appropriate data. One of the forms has two options - "Find" and "Cancel".
In a terminal, I can just hit TAB to choose "Cancel" and ENTER. But within ...
My Perl application uses resources that become temporarily unavailable at times, causing exceptions using die. Most notably, it accesses SQLite databases that are shared by multiple threads and with other applications using through DBIx::Class. Whenever such an exception occurs, the operation should be retried until a timeout has been re...
With Perl, what is an easy way to handle different development versus production libs paths? I want to use my local box path for testing, but when I launch I want it to automatically point to the production lib path.
...
I understand that Perl's OO model is rather primitive; it is, in most respects, essentially a namespace hack.
Nevertheless, I wonder if it is possible to create something like an "interface?" My goal is to have a base class from which others are extended whose principal purpose is to make mandatory the implementation of certain method...
I want to convert an OpenOffice Impress Presentation file and convert it to HTML or JPEG.
I have found a few examples, but they appear to be broken. I would like to do it, in a way that it does not matter what version of OpenOffice is installed, and I do not want to bundle any interop dlls with my application. Therefore, I am looking fo...
%a = ( "KEY" => {
"p1" => 1 , [1223],
"p1" => 2 , [2323],
"p1" => 3 , [2353],
}
);
I want to generate a structure like this. I have tried with this code:
@array = ( 1223 , 2323 ,2353 );
$count = 0;
foreach my $i (@array) {
$a{"KEY"} => { "p1" ...
I want to merge the multiple XML files into single XML file in Perl.
File 1 :
<r1>
<searchpath>
<dir>/usr/bin</dir>
<dir>/usr/local/bin</dir>
<dir>/usr/X11/bin</dir>
</searchpath>
</r1>
FILE 2 :
<r2>
<user login="grep" fullname="Gary R Epstein" />
<user login="stty" fullname="Simon T Tyson" />
</r2>
Mer...
I am attempting to develop a service that contains numerous client and server sockets (a server service as well as clients that connect out to managed components and persist) that are synchronously polled through IO::Select. The idea was to handle the I/O and/or request processing needs that arise through pools of worker threads.
The sh...
I'm guessing it's not a Perl compatible regular expression, since there's a special kind of grep which is specifically PCRE. What's grep most similar to?
Are there any special quirks of grep that I need to know about? (I'm used to Perl and the preg functions in PHP)
...
$var = pack "C2", 0x20, 0x30;
seems to work well enough, but now how do I address the elements of the array? Make changes to elements? In-place if possible. The pack/unpack semantics are not very friendly.
Currently I'm using substr($var, $index, 1, substr($var, $index, 1) + 10) to add 10 to elements in-place.
And for intializers, i...
I have a text file that has data wrapped between tags. The tags are:
<title>
<url>
<pubDate>
So, the entries look like this:
<title>title 1</title>
<url>url 1</url>
<pubDate>pubDate 1</pubDate>
<title>title 2</title>
<url>url 2</url>
<pubDate>pubDate 2</pubDate>
<title>title 3</title>
<url>url 3</url>
<pubDate>pubDate 3</pubDa...
OK, so this is so simple but for the life of me I can't figure out why the code below doesn't work.
I'm trying to simply write a CGI script that creates sequentially numbered files. I'm using a counter (stored in a separate file) to keep track of the last ordinal used, and then generating a unique filename using sprintf. The uniquel...
I'm developing a relatively small application to talk to PostgreSQL, and wanted to get some feedback on how far is too far to go with regards to protecting against SQL injection.
The application is in Perl and does not use any ORM modules (just DBI). The SQL statements are constructed in the typical fashion with placeholders:
my $sql ...