I previously asked how to do this in Groovy. However, now I'm rewriting my app in Perl because of all the CPAN libraries.
If the page contained these links:
<a href="http://www.google.com">Google</a>
<a href="http://www.apple.com">Apple</a>
The output would be:
Google, http://www.google.com
Apple, http://www.ap...
Hi all,
Let's make this very easy. What I want:
@array = qw/one two one/;
my @duplicates = duplicate(@array);
print "@duplicates"; # This should now print 'one'.
Thanks =)
...
Hi everyone!
I have the following line:
"14:48 say;0ed673079715c343281355c2a1fde843;2;laka;hello ;)"
I parse this by using a simple regexp:
if($line =~ /(\d+:\d+)\ssay;(.*);(.*);(.*);(.*)/) {
my($ts, $hash, $pid, $handle, $quote) = ($1, $2, $3, $4, $5);
}
But the ; at the end messes things up and I don't know why. Shouldn't th...
How do I apply 'use base' in Perl to inherit subs from some base module?
I'm used to C++ inheritance mechanics, and all the sites I googled for this caused more confusion then help. I want to do something like the following:
#! /usr/bin/perl
#The base class to inherit from
use strict;
use warnings;
package 'TestBase';
#--------------...
Which XML validation tools can you recommend for both performance and accuracy, each of which is a critical issue on our system? We have the following requirements:
It is not not xmllint (see below)
Supports RelaxNG
Can easily integrate with Perl (this is optional, but it would be nice)
Why not xmllint? (This is background and you ...
I am trying to use an XML-RPC server on my Drupal (PHP) backend to make it easier for my Perl backend to talk to it. However, I've run into an issue and I'm not sure which parts, if any, are bugs. Essentially, some of the variables I need to pass to Drupal are strings that sometimes are strings full of numbers and the Drupal XML-RPC se...
I have a C program with an embedded Perl interpreter. I want to be able to precompile some Perl code from within the program. How do I do that?
Rationale (if anyone is interested) is to be able to compile it once, store the parse tree, and execute many times (as long as the compiled code does not change).
Thanks!
Madhu
PS: I am using ...
I'm tasked with replicating a production environment to create many test/sit environments.
One of the things I need to do is build up Perl, with all the modules which have been installed (including internal and external modules) over the years. I could just use CPAN.pm autobundle, but this will result in the test environment having much...
Here is some simple Perl to count the number of times a value occurs in an array. This runs without any warnings.
use warnings;
use strict;
my @data = qw(1 1 2 3 4 5 5 5 9);
my %histogram;
foreach (@data)
{
$histogram1{$_}++;
}
When the loop body is changed to
$histogram{$_} = $histogram{$_} + 1;
Perl warns "Use of uninitializ...
I have a text file which contains some data. I am trying to search for EA in ID column only and prints the whole row. But the code recognize all EA and prints all rows. What code I should add to satisfy the condition? Thanks Again:-)!
DATA:
Name Age ID
---------------------
KRISTE,22,EA2008
J**EA**N,21,ES4567
JAK,45,EA2008
The code...
I am making GUI (login window). When the password is correct, the login window must call other window. Is there a way in PerlTk to call another window rather than using subwindow?
use strict;
use Tk;
my $mw = MainWindow->new;
$mw->geometry("300x150");
$mw->configure(-background=>'gray',-foreground=>'red');
$mw->title("PLEASE LOGIN");
...
I have a local MINICPAN repository, but I want to remove a specific version of a module, and inject an older version.
This is the steps I've taken.
- create the MINICPAN, not filtering any modules
- use mcpani --add for the module in question
- use mcpani --inject
At this point, I can see in the MINICPAN that it has both the version ...
I have a simple web page that till now didn't need any login. It is programed with Perl CGIs.
I would like to know the steps to add session support in order to have the login information available.
I don't want very complicated methods, because the web page is very simple.
Also I want some recommendations for the technologies/libs tha...
I'm using Strawberry Perl which includes MinGW's GCC, I'm also making use of the GNU debugger GDB and Subversion. How can I have a single development environment that would suit this (other than just UltraEdit, the command shell and IE), and how can I further enhance its features?
...
Hi All,
I am having trouble with a very simple Perl process. I am basically querying an Oracle database and I want to load it into Excel. I have been able to use DBIx::Dump and it works. However, I need to be able to use a variety of Excel formatting tools. And I think Spreadsheet::WriteExcel is the best module that outputs to Excel ...
I'm optimizing some frequently run Perl code (once per day per file).
Do comments slow Perl scripts down? My experiments lean towards no:
use Benchmark;
timethese(20000000, {
'comments' => '$b=1;
# comment ... (100 times)
', 'nocomments' => '$b=1;'});
Gives pretty much identical values (apart from noise).
Benchmark: timing 1...
The Emacs cperl-mode seems to get confused less than perl-mode, but the Skittles effect makes the thing unusable for me. Does anyone have or know of an example of a .emacs block that causes cperl-mode to use the colorization from perl-mode, ideally in a form readable enough that I can go back and turn back on the default colors one elem...
This fails:
my @a = ("a", "b", "c", "d", "e");
my %h = map { "prefix-$_" => 1 } @a;
with this error:
Not enough arguments for map at foo.pl line 4, near "} @a"
but this works:
my @a = ("a", "b", "c", "d", "e");
my %h = map { "prefix-" . $_ => 1 } @a;
why?
...
Hi,
I asked a question earlier about which language to use for an AI prototype. The consensus seemed to be that if I want it to be fast, I need to use a language like Java or C++, but that Python / Perl / Ruby would be good for the interface bits.
So, this leads me on to another question. How easy is it to link these languages togethe...
Using DBIx::Class and I have a resultset which needs to be filtered by data which cannot be generated by SQL. What I need to do is something effectively equivalent to this hypothetical example:
my $resultset = $schema->resultset('Service')->search(\%search);
my $new_resultset = $resultset->filter( sub {
my $web_service = shift;...