In one of the chapters in Mastering Perl, brian d foy shows this snippet from List::Util:
sub reduce(&@) {
my $code = shift;
no strict "refs";
return shift unless @_ > 1;
use vars qw($a $b);
my $caller = caller;
local(*{$caller . "::a"}) = \my $a;
local(*{$caller . "::b"}) = \my $b;
$a = shift;
foreac...
I am trying to call the web service from Perl with the SOAP:Lite module. The web service has a parameter of complex type that I fail to construct correctly. Here is the relevant portion of wsdl:schema
<complexType name="TagData">
<sequence>
<element name="order" type="xsd:int"/>
<element name="value" type="xsd:string"/>
</...
Hello, I am writing a CGI script that will process form data, and it should print the name of the input, along with its value, in a table. When I have one or more values with the same name, the name should span rows to accommodate all values that correspond to that name. For example, if I have a name "color" with its values at "red", "gr...
Is there a way in WWW::Mechanize or any Perl module to read on a file after accessing a website. For example, I clicked a button 'Receive', and a file (.txt) will appear containing a message. How will I be able to read the content? Answers are very much appreciated.. I've been working on this for days,, Also, I tried all the possibilitie...
In Perl, you can get a list of files that match a pattern:
my @list = <*.txt>;
print "@list";
Now, I'd like to pass the pattern as a variable (because it's passed into a function). But that doesn't work:
sub ProcessFiles {
my ($pattern) = @_;
my @list = <$pattern>;
print "@list";
}
readline() on unopened filehandle at ...
...
I'm writing a PHP library that has a Number class that uses the bcmath extension for arbitrary precision.
I have two questions:
How much slower is bcmath compared to using the built-in int and float types?
bcmath has an optional scale argument (that defaults to 3 digits). For an general purpose Number class that anyone could use, wha...
Hi, I have a longitudinal data set generated by a computer simulation that can be represented by the following tables ('var' are variables):
time subject var1 var2 var3
t1 subjectA ...
t2 subjectB ...
and
subject name
subjectA nameA
subjectB nameB
However, the file generated writes a data file in a format similar to the f...
Hello! What is the best way to get the cd-title and the cd-track-names from an audio CD?
I tried this module, but it didn't work.
#!/usr/bin/env perl
use warnings;
use strict;
use CDDB_get qw( get_cddb );
my %config;
$config{CDDB_HOST} = "freedb.freedb.org";
$config{CDDB_PORT} = 8880;
$config{CDDB_MODE} = "cddb";
$config{CD_DEVICE} = "...
Suppose there is a list that is input from the console using <STDIN>
@string = <STDIN>;
Now, I check for a pattern, say /manu/, in my program
foreach (@string)
{
if(/manu/)
{
print $_."\n";
}
}
The code is unable to look for the pattern /manu/.
However when I do the following, the code works perfectly fine:
...
I simply hate how CGI::Application's accessor for the CGI object is called query.
I would like my instance classes to be able to use an accessor named cgi to get the CGI object associated with the current instance of my CGI::Application subclass.
Here is a self-contained example of what I am doing:
package My::Hello;
sub hello {
...
I have the following subroutine in Perl to substitute "abc" for "xyz" in a string:
sub mySubst {
my ($str) = @_;
$str =~ s|abc|xyz|ig;
return $str;
}
It works, but seems way too verbose for Perl. How can I tighten it up?
...
I have a Role and several classes that mix-in the role. The Role class loads all of the implementing classes so that anything that imports Blah can use them without typing a lot of 'use' lines.
package Blah;
use Moose::Role;
use Blah::A;
use Blah::B;
(etc...)
requires '...';
requires 'foo';
around 'foo' => sub { ... }
A typical Blah...
I have a Perl command-line script that I want to convert to a rich. cross-platform desktop GUI application. What's the best method to do it. I want to the internal and the logic code in Perl but the GUI should be rich web application.
...
I want to start strictly doing Test-Driven-Development. However, I was wondering how much I should test methods generated by Moose and MooseX::FollowPBP. For example, I have the following class:
package Neu::Series;
use Moose;
use MooseX::FollowPBP;
use File::Find::Wanted;
has 'file_regex' => (
isa=>'RegexpRef',
is=>'rw',
...
I'm running a Perl script (both with 5.8.4) on two different machines (one Solaris 5.10, the other OpenSolaris 5.11). The output of the two scripts differs in the following way:
Solaris 5.10
$ perl myscript.pl
is' £ ä º <ä ¼ sa ... ³ ä º žÃ ... ¬ å ¸ ç ¬ ¬ ä º ¤ § œâ is œâ ¡ä ¸ ‡ å ... æœ ¬ æœ ¬ å ¸ È, ¡ä »½ çš" å ... ¬ ...
Running the md5 function from the ksh terminal does not matching the output from a simple Perl script.
In the terminal I run:
echo -n abc | md5
62fecf21103616856d72e6ffc9bcb06b
If I run it using Perl:
use Digest::MD5 qw(md5_hex);
foreach (@ARGV) {
print "Digest is ", md5_hex($_), "\n";
}
exit
I get
./perl_test.sh abc
Digest ...
I will listen on a port (simple server) when a request is passed parse the URL
and start a thread.
The thread will insert an element in a queue which is shared, and it is locked while inserting.
I am not able to get element when I call peek on queue.
use Thread qw(async);
use Thread::Queue;
my $DataQueue:shared = new Thread::Queue;...
I have this code:
use CGI;
use File::Basename;
use Image::Magick;
use Time::HiRes qw(gettimeofday);
my $query = new CGI;
my $upload_dir = "../images"; #location on our server
my $filename=$query->param("img");
my $timestamp = int (gettimeofday * 1000);
my ( $name, $path, $extension ) = fileparse ( $filena...
My project needs couple of things to be extracted from ClearCase data using the Perl script in a excel sheet,those are -
By giving two particular time line or two baseline.
all the activity associated within that baseline (column header "activity")
Owner's id (column header-Owner)
all the element associated within a particular activity...
Why is there no warning thrown for the redeclaration of $i in the following code?
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
for my $i (1..3) {
my $i = 'DUMMY';
print Dumper $i;
}
...