I have a script that works on different clients, and need to SCP files to different hosts. Depending on the combination of client & server, I may need to use password authentication or public key authentication. I cannot really know in advance which one to use.
There are 2 CPAN libraries for SCP that I use:
Net::SCP: works with public...
I've got the following Perl code which makes a DBI call:
my $artsql = q{ *** SNIP A BUNCH OF SQL ***
where a.article_id != ?
and at.type_name != 'List Element' -- don't get list children
and aw.flowstate = 'Published'
and a.visible_as_article = 1 }
...
I have multiple text files, which are simple reports, that must be reviewed and validated by users. I would like to pull the report into an html div element then add form fields at absolutely positioned locations.
For example, the report may have monthly sales by sales rep:
Jan Feb Mar
13 9 11
I want the user to see t...
I want to push a reference to a hash. By that I mean I want to push a reference to a new hash that is a shallow copy of the hash I am given.
How do I create the shallow copy?
...
I have installed Perl from source into /usr/local, and adjusted my path accordingly, following brian d foy's suggestion here.
I'm sure I'm missing something, but, now I'm trying to install stuff with the 'cpan' command and it's failing because it can't write to /usr/local. I have to use sudo, which feels wrong to me. Should CPAN stuff g...
I'm a complete noob in all of this, but sometime ago I wrote a little script in Perl to parse an RSS feed. It starts like this:
use strict;
use XML::RSS::Parser;
use Data::Dumper;
my $url = "http://www.livenation.co.uk/Venue/159/Southampton-Guildhall-tickets/RSS";
my $parser = XML::RSS::Parser->new();
my $feed = $parser->parse_uri($url)...
I'm working on a Perl script which is called from a server side include on an Apache 2 server. The script is displaying the generic "Internal Server Error" page rather than showing me the actual error. When I check the Apache error log, I see these messages:
unable to include "/foobar/index.pl" in parsed file /home/foouser/domains/foosi...
I'm very new to Perl, and I have absolutely no idea how to approach this. We have an old Perl application which previously used Apache auth; we'd like to replace this with a cookie based form-style authentication. I understand that this is very case-specific, and there is no one answer as such, but some general tips would be much appreci...
I'm trying to use a Perl module from CPAN (AuthCookieDBI.pm to be specific) in a shared hosting environment.
I tried copying the .pm file to the directory I'm trying to use it with, and I have updated my .htaccess file as per the instructions on the AuthCookieDBI page, but my Apache log says:
Invalid command 'PerlModule', perhaps missp...
This may be a simple question for most Perl programmers, I have only used Perl for two weeks so far and am very unfamiliar with the Perl packages.
I have a simple XSD file as below:
<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element nam...
The hash method on a Ruby String returns a number based on the string's length and content:
>> "foo".hash
=> 876516207
What's the equivalent in Perl?
...
Hi,
I have downloaded the following file: rawdata_2001.text
and I have the following perl code:
open TEXTFILE, "rawdata_2001.text";
while (<TEXTFILE>) {
print;
}
This however only prints the last line in the file. Any ideas why? Any feedback would be greatly appreciated.
...
I have set up a local Perl web environment on my Windows machine. The application I'm working on is originally from a Linux server, and so the shebang for source .pl files look like so:
#!/usr/bin/perl
This causes the following error on my Windows dev machine:
(OS 2)The system cannot find the file specified.
Is it possible to chang...
I'm new to Perl, and I'm updating an old Perl website. Every .pl file seems to have this line at the top:
do "func.inc";
So I figured I could use this file to tag on a subroutine for global use.
func.inc
#!/usr/bin/perl
sub foobar
{
return "Hello world";
}
index.pl
#!/usr/bin/perl
do "func.inc";
print "Content-type: text/html...
I want to find the exact SQL statements that are generated by a Perl ORM package such as Class::DBI. I am not looking for SQL generated for simple inserts and deletes, but for row modifications that result from slightly complicated object manipulations (inserting rows in a table which is a child of a row in a parent table, for example)
...
Why does this code fail silently? How do I get it to show me exactly what the SQL error is?
$dbh=DBI->connect($db_name,$db_user,$db_pass);
I modified the code to look like this:
$dbh=DBI->connect($db_name,$db_user,$db_pass)
or die("could not connect to db: $db_name");
Which instead of allowing me to use $dbh unassigned, it will...
How do I treat the elements of @ARGV as UTF-8 in Perl?
Currently I'm using the following work-around ..
use Encode qw(decode encode);
my $foo = $ARGV[0];
$foo = decode("utf-8", $foo);
.. which works but is not very elegant.
I'm using Perl v5.8.8 which is being called from bash v3.2.25 with a LANG set to en_US.UTF-8.
...
Is there any way in Perl to generate file handles programmatically?
I want to open ten files simultaneously and write to them by using file handle which consists of (CONST NAME + NUMBER). For example:
print const_name4 "data.."; #Then print the datat to file #4
...
I have these two lines in an old Perl script. When I write the Python equivalent I get all sorts of errors like valueerror: invalid \x escape, and stuff about encoding.
$line =~ s/[^\x{8}-\x{7B}]/ /ig;
$line =~ s/(Û|²|°|±|É|¹|Í)/ /g;
What do I need to do to get them working in Python?
...
I am having trouble understanding / using name spaces with XML::LibXML package in Perl. I can access an element successfully but not an attribute. I have the following code which accesses an XML file (http://pastebin.com/f3fb9d1d0).
my $tree = $parser->parse_file($file); # parses the file contents into the new libXML object.
my $xpc =...