How can I create binary trees in Perl?
How do can I create binary trees in Perl? ...
How do can I create binary trees in Perl? ...
I have a commercial program that takes input from a delimited text file and stores that data in a MySQL database. I am writing a Perl script that essentially removes the need for the commercial program and uploads the data directly to the database. However, I am unsure in which tables the commercial program stores all the data. There ...
I'm aware of %~dp0, which represents the fully expanded directory that contains the batch script, but what I'm looking for is either: a method to invoke the batch script from Perl in such a manner that allows me to use the batch script without modification and have all directories in it be in relation to the batch script location a sin...
I'm writing a Perl script to run through and grab various data elements such as: 1253592000 1253678400 86400 6183.000000 1253764800 86400 4486.000000 1253851200 36.000000 86400 10669.000000 1253937600 0.000000 86400 9126.000000 1...
I'm iterating through a list of links on a page, creating a URI object for each. When the URI object is created, I don't know whether the URL has a scheme, so when I later call $uri->host(), I will sometimes get Can't locate object method "host" via package "URI::_generic" at -e line 1. because the URI object is of type URI::_generic,...
I'm trying to set up a large-ish project, written in Perl. The IBM MakeMaker tutorial has been very helpful so far, but I don't understand how to link all the modules into the main program. In my project root, I have MANIFEST, Makefile.PL, README, a bin directory, and a lib directory. In my bin directory, I have my main script (Main.p...
my $hash_ref = { one => { val => 1, name => 'one' }, three => { val => 3, name => 'three'}, two => { val => 2, name => 'two' }, }; I would like to sort $hash_ref such that a foreach would order them by $hash_ref->{$key}->{'val'} one two three Any suggestions? ...
I have several scripts that I supply to users as tools for their engineering projects. These scripts contain a lot of duplicated code. I want to extract this code and maintain it in a set of modules. However, in order for this to work, the users would have to install these modules. I don't want to have to tell my users to "make install",...
I want to uninstall a package in Solaris, say NewPackage. For that I am using the command: pkgrm NewPackage It will display all the steps in the STDOUT and at the end it will give the message that the package is uninstalled successfully. If i want to uninstall the same package in a Perl program how do I redirect the STDOUT messages ...
Got a text file that looks like: 200.0 250.0 300.0 350.0 400.0 162:02:10 017:01:56 017:08:18 011:16:22 008:40:18 580.0 600.0 620.0 640.0 660.0 004:04:01 001:47:27 007:25:29 017:44:53 003:07:34 Trying to parse out lines 1 & 3 as "values", and lines 2 & 4 as "times". My code: if($line =~ /^...
Can anyone provide syntax to create a table trigger preferably with DBI's do() method. It doesn't seem to like me putting everything on one line. Not sure what i'm doing wrong. Here's what I've got: $dbh->do("CREATE TABLE image(img_id integer primary key, md5sum text, path text, name text, date DATE)"); $dbh->do("CREATE TRIGGER insert_i...
Hi, I wonder if Perl performs common subexpression elimination? And what kind of optimisations are done? ...
My local system and remote server is configured with ssh key exchange. and I want to get the XML files from the remote system with the NET::FTP packages. Can you suggest a way to do the file transfer with Net::FTP package, but without a password? ...
I need to buff out a line of text with a varying but large number of whitespace. I can figure out a janky way of doing a loop and adding whitespace to $foo, then splicing that into the text, but it is not an elegant solution. ...
Hi, I am currently adding some unit tests to some legacy code and I find myself with the need to override an open function. The live code looks something like this. if ( !open( F, $filetoopen) ){ # do stuff with <F> } What I want to do is make sure that "F" contains a file handle that I have provided from my tests rather than wha...
I am trying to write new XS module for Perl. I have tested by following XS module writing instruction and it is working fine. I am not able to understand how to I write new method for XS I have a package called Agent. I want to be able to something like this: my $agent_object = new Agent; ...
I have a very simple online ordering app in Perl. The user fills in a form, and when they submit, my app inserts the info into a mySql database, then redirects them to PayPal to complete the payment. The problem is that the database does not have any information about whether they actually completed the payment. I end up having to man...
Question: What is considered to be "Best practice" - and why - of handling errors in a constructor?. "Best Practice" can be a quote from Schwartz, or 50% of CPAN modules use it, etc...; but I'm happy with well reasoned opinion from anyone even if it explains why the common best practice is not really the best approach. As far as my o...
I was wondering how can I add a newline character (i.e. /n or <br>) after X number of characters. For example, let's say I have a perl variable $message ="aaaaabbbbbcccccdd". I want to add a newline character after every 5 characters to this variable. So when I print the variable in html it will display: aaaaa bbbbb ccccc dd What...
Is that possible? I'm writing a web-admin interface for a network-system. I need to listen to a specific UDP port and show it in browser. Can I do that in javascript? Also; any other ideas are welcomed. early-edit: Here's another idea: I have php and perl support at server-side. JS can call a php script to start listening, which will a...