I'm still trying to get a hang of Perl's OOP features. I'm confused about something, if I have a subroutine call like:
My::Package::sub_name($param1,$param2)
will this get "My::Package" sent as the first parameter? I'd tend to say no, but I'm not sure.
...
I have an array of references to anonymous hashes. From the reference to that array, $allDirArray, I want to access the value corresponding to the key 'dir'. Currently I am getting the error:
Can't use string ("HASH(0x100878050)") as a HASH ref while "strict refs"
in use at nameOfProgram.pl line 148.
My code:
my $tempDir = ${$allDi...
Hello,
I'm now thinking, is it possible to integrate Python, Perl and C/C++ and also doing a GUI application with this very nice mix of languages?
...
What is the equivalent to Crypt::CBC in Perl for Ruby?
Note: This problem similar to PHP/Perl at stackoverflow:655691.
Perl Version
use Crypt::CBC;
use MIME::Base64::Perl;
my $cipher = Crypt::CBC->new(
-key => "95A8EE8E89979B9EFDCBC6EB9797528D",
-keysize => 32,
-cipher => "Crypt::OpenSSL::AES"
);
$encypted = $ci...
I have an input file say, such as:
a=1 b=2 c=3 d=4
a=2 b=3
a=0 c=7
a=3 b=9 c=0 d=5
a=4 d=1
c=9
Assume that the order of column names (a,b, c and d) remains the same. How do I write a script/ command which will help me extract values specific to columns b and d? So my output should be:
b=2 d=4
b=3
b=9 d=5
d=1
I could write a "not-s...
$HoA{teletubbies} = [ "tinky winky", "dipsy", "laa-laa", "po" ];
How can I find the number of elements in this hash of arrayref(s)? It should return 4.
...
I would like to copy stdout and stderr of my Perl script to a file, while retaining it also onscreen, and preferrably using some trick inside the script itself. I.e. I want something similar to
./test.pl 2>&1 | tee foo.bar
but hidden inside the perl script implementation. For the moment I've just written a subroutine which prints all ...
I've been using Markdown recently.
One of my biggest problems with Markdown is that Markdown has no syntax for including files within a document (vs., say, the listings package for LaTeX).
I'd like to extend Markdown to support including whole and partial files as code snippets. For instance, it could look like this:
![:include src/fo...
Can you please name some large (maintained, with active communities) projects written using Perl? I'd like to be able to provide a list of mature, production-ready projects so that Perl can be seen as an alternative to other popular languages used today.
...
I'm interested in a parser that could take a malformed HTML page, and turn it into well formed HTML before performing some XPath queries on it. Do you know of any?
...
I'm having a killer time trying to create a JSON object to return to a jQuery request.
I'm trying to use the jQuery chained select module
and I'm trying to create the JSDN object using Perl's JSON module.
I have no idea what I'm doing wrong or how I can even debug it, about the best I can do is get a JS dialog box coming up with "A un...
Is it possible to dynamically specify a class in Perl and access a static method in that class? This does not work, but illustrates what I'd like to do:
use Test::Class1;
my $class = 'Test::Class1';
$class::static_method();
I know I can do this:
$class->static_method();
and ignore the class name passed to stat...
I want two special methods:
one that runs for all URLs
one that runs only for a specific path (/admin)
I thought the most general would be using begin, and the method for /admin would use auto. For example, in these two Catalyst controllers:
package MyApp::Controller::Root;
sub begin :Private {
my ($self, $c) = @_;
$c->log...
I have a Perl codebase, and there are a lot of redundant functions and they are spread across many files.
Is there a convenient way to identify those redundant functions in the codebase?
Is there any simple tool that can verify my codebase for this?
...
(Update to answer Jonathan Leffler's question below):
We're running Perl 5.8.7 and Oracle 11.1.0.7.0.
Due to the company's policy, developers have no arbitrary control in regard to software upgrade. Giving the proposal to the upper management takes months to be followed up (if approved) - I guess it's not a surprisingly odd situation f...
I have to write a Perl script to automatically copy data from remote server to my local system. The directory structure on remote systems is:
../log/D1/<date>.tar.gz
../log/D2/<date>.gz
../log/D3/<date>.tar.gz
../log/D4/<date>
and same on other server. I want to copy the data on local system in below format.
../log/S1/D1/<date>.tar.g...
I find that using labels inside Perl subroutines, to break from multiple loops, or to redo some parts with updated variables, very helpful. How is this coding style seen by the community? Is using labels inside subroutines frowned upon?
...
I'm trying to copy some files from one network share to another using File::Copy.
This is my code
#!C:/strawberry/perl/bin/perl.exe
use File::Copy;
print "Content-type: text/html\n\n";
print "<H1>Hello World</H1>\n";
copy("s:\\nl\\cover\\config.jsp", "s:\\temp\\config.jsp")
or die "File cannot be copied.";
print "this is no...
I wrote a little daemon in Perl that calls up FFMpeg to encode a video but the encoding stops after 5 or so seconds.
I use this piece of code to start it:
my $t = `echo '$ffmpeg_command' >>$self->{FFMPEG_OUTPUT}`;
my $log_data = `$ffmpeg_command 2>>$self->{FFMPEG_OUTPUT}`;
Any ideas?
If I start the FFMpeg command myself it works fin...
Suppose file1 looks like this:
bye bye
hello
thank you
And file2 looks like this:
chao
hola
gracias
The desired output is this:
bye bye chao
hello hola
thank you gracias
I myself have already come up with five different approaches to solve this problem. But I think there must be more ways, probably more concise and more elega...