Hello! The following script works fine:
#!/usr/bin/env perl
use strict; use warnings;
use Data::Dumper;
use WWW::Mechanize;
my $loginData = "userName=username&password=password&deeplinkForward=%2Fselfcare%2Frestricted%2FprepareCoCo.do&x=84&y=7";
my $loginUrl = "https://www.login.login/login.do";
my $mech = WWW::Mechanize->new( show_pro...
What regex can I use to match any valid IP-address represented in dot-decimal notation?
...
How can I list all CPAN modules depending on a given module? For example, create a list of modules using Class::Workflow?
...
When I use catalyst.pl to auto-generate my application, the AUTHOR section of the POD includes only my name like this.
Kiffin Gish,,,
What are the missing fields and how can I use them? Is it possible to use another boilerplate for the PODs?
...
I want to read a table in oracle which contains database links for checking availabilty of each database link and return only the bad results for each database link and error message.
I want to fetch this lookup table into an array, and pass the entries of db_link to a select from dualQdb_link, test all the entries of lookup to test fo...
After many hair-pulling frustrations I've finally got one version of the PerlMagick module working with my ActivePerl 5.10.0 build 1005. Now I'm playing with it to do some very basic color substitution.
I already can substitute one color ,say, black, with another, say, blue, using the following code:
#!perl
use strict;
use warnings;
...
Hi foks,
my task is to convert JSON file into XML file in Perl. It is forbidden use automatic tools like XML2JSON, so I need to parse JSON in Perl variables and then, store it in XML file. Can you give me some examples how to use JSON:XS and XML:Simple to complete my task? Thanks a lot
...
I am trying to output a file in perl.
I open the file and output like this..
open(my $out, ">", "output.html") or die "Can't open output.txt: $!";
print $out "something!";
Which works perfect. If I change it to this
open(my $out, ">", "c:\somedirectory\output.html") or die "Can't open output.txt: $!";
print $out "something!";
It...
I'm trying to translate a Perl script to PHP and I'm having trouble with some Perl things. For instance, what does @_ -1 mean? And how do I write it in PHP?
The whole function is as follows:
sub variance {
my $sum = sum_squares (@_);
my $deg = @_ - 1;
return $sum/$deg;
}
...
Hi, I want to write a header and footer perl scrip that will return the headers and footers of my individual webpages. I was assuming I would do some sort of include of that file in the part of the html file I want it to appear. Is that the way I should go about this, if so how do I do that? If anyone has any other suggestions for bet...
The whole subroutine for the code in the title is:
sub histogram { # Counts of elements in an array
my %histogram = () ;
foreach my $value (@_) {$histogram{$value}++}
return (%histogram) ;
}
I'm trying to translate a Perl script to PHP and I'm having difficulties with it (I really don't know anything of Perl but I'm trying).
So...
I am using a perl script to read in a file, but I'm not sure what encoding the file is in. Basically, my file is a list of book titles, but each book has other info associated with it (author, publication date, etc). So each book title is within a discrete chunk of data for the book. So I iterate through the file line by line until I fin...
I have this code:
$coder = JSON::XS->new->utf8->pretty->allow_nonref;
%perl = $coder->decode ($json);
When I write print %perl variable it says HASH(0x9e04db0). How can I access data in this HASH?
...
How can I check what kind of exception caused the script or eval block to terminate?
I need to know the type of error, and where the exception occurred.
...
In PostgreSQL, there is a BLOB datatype called bytea. It's just an array of bytes.
bytea literals are output in the following way:
'\\037\\213\\010\\010\\005`Us\\000\\0001.fp3\'\\223\\222%'
See PostgreSQL docs for full definition of the format.
I'm trying to construct a Perl regular expression which will match any such string.
It sh...
In my code I have three classes as follows: Forum, Forum::Thread and Forum::Post
What I want to do is create a belongs_to-relationship from the Forum::Post class to the Forum class and vice versa with a has_many, preferably without creating a custom function for it. (This is admittedly more of an intellectual exercise than a technical l...
How do i get all of the lines of "$dblink is down" into one $l_msg string?
Ideally I would like to get the error returned by oracle on failure and I cannot see a way to solve this.
my $dblinks = $l_dbh->selectcol_arrayref("select dbname from db_link");
for my $dblink (@$dblinks) {
my $l_results = eval {
my ($l_erg) = $l_dbh->s...
I have been wondering if there's a nicer, but concise way for splitting a string into its characters
@characters = split //, $string
is not that hard to read, but somehow the use of a regular expression looks like overkill to me.
I have come up with this:
@characters = map { substr $string, $_, 1 } 0 .. length($string) - 1
but I f...
I have a Perl object that has defined use overload '""' => \&name;
and a name method.
In my unit tests I have mocked this object, including the name method, but code like
if (-d $object)
still gives me Use of uninitialized value in -d .... The mocked method is not being executed.
My mock code:
my $CMmock = Test::MockObject::Extend...
I've bumped into a strange problem. I wrote a little daemon in Perl which binds a port on a server.
On the same server there's a LAMP running and the client for my Perl daemon is a php file that opens a socket with the daemon, pushes some info and then closes the connection. In the Perl daemon I log each connection in a log file for lat...