Right now, I am using something like
copy catfile($PATH1, "instructions.txt"), catfile($ENV{'DIRWORK'});
individually for each of the .txt files that I want to copy. This code is portable as it does not use any OS specific commands.
How can I copy all the text files from $PATH1 to DIRWORK, when I do not know the individual names of a...
I'd like to be able to call pod2usage in a method that encapsulates a lot of standardized command line argument handling, but I can't see how I'd be able to put that handling into a separate module and have the pod2usage output be the documentation from the calling file. Is this possible?
...
Not sure if its a duplicate. Given the relative path, how do i determine absolute path using a shell script?
Example:
relative path: /x/y/../../a/b/z/../c/d
absolute path: /a/b/c/d
...
I am working on patching the Zoidberg Perl shell to fix some errors that modern Perl versions throw when testing. Note, I am not the original author nor am I criticizing him. I came upon an interesting problem that I would like a little history on.
The code below takes an array of inputs and for each strips off and ending sigil. Then i...
I have two existing scripts that work fine as individuals.
The main script is Perl. I wish to execute the PHP script from a sub in the Perl script.
Usually, the PHP script is just run via direct url e.g. http://me.com/phpscript.php?foo=bar
I would like to just call the PHP script from the Perl and pass the foo var so, I don't need to ...
For my work, I sometimes have to deal with logfiles from a binary protocol (the logfiles contain hexdumps of the messages). I want to write a Perl script that can interpret the binary data for me and print the contents in a more friendly format.
I have a (machine readable) description of the protocol messages in a proprietary format and...
As far as I know it is required to run CPAN with sudo on Mac
sudo perl -MCPAN -e shell
to install new modules. Theoretically, a module can be removed by deleting it from the Perl folders.
My question is: Where are Perl modules put when installed from CPAN with 'sudo' and without 'sudo'? I installed BioPerl both ways and it seemed to ...
I am running a script that runs 24/7. It just loops through over and over, very simple:
while ($daemon) {
sleep 60;
chomp(my $currentDate = `date +%c`);
print LOG "-- Running trigger: $currentDate --\n";
system("$triggerCmd >> $daemonLog");
print LOG "-- Completed trigger test. --\n\n";
}
It works fine. ...
I have 3 dimensional hash and a 2 dimensional hash, and I want to merge the 2 dimensional hash with one of the inner hashes of the 3 dimensional hash, something like this, which is similar to what I do to merge a pair of 2d hashes:
my %3dhash;
my %2dhash;
my $key = "some string";
%3dhash{$key} = ($3dhash{$key}, %2dhash);
But when I tr...
I'm working with a few Perl packages, we'll call them Some::Parser and Some::Data. A Some::Parser object has methods to return objects of type Some::Data. I have written a class that extends the Some::Data class, let's call it My::Data. Objects of class My::Data are really just objects of class Some::Data, but with additional methods tha...
I was trying to join elements of a Perl array.
@array=('a','b','c','d','e');
$string=join(']',@array);
will give me
$string="a]b]c]d]e";
Is there anyway I can quickly get
$string="[a][b][c][d][e]";
?
...
I want to have a perl subroutine that creates and returns an ordered hash via the Tie::IxHash module. It looks something like this:
sub make_ordered_hash {
my @hash_contents = munge_input(@_); # I get a list of alternating keys and values
tie(my %myhash, Tie::IxHash, @hash_contents);
return %myhash;
}
Now, if I do my %orde...
Dear All,
Update3: If you like this posting please don't upvote me but upvote the genius answer by DVK below.
I have the following subroutines:
use warnings;
#Input
my @pairs = (
"fred bill",
"hello bye",
"hello fred",
"foo bar",
"fred foo");
#calling the subroutine
my @ccomp = connected_component(@pairs);
use...
Ok, this is a very interesting question and there may not be any easy way to do this but figured I would throw this out there before deciding that modifying Perl is my underlying answer.
So I've got a C application that calls Perl scripts in an embedded fashion. This all works fine and dandy and it's pretty awesome that I can pass info...
Hi,
I inherited an environment that has a "compiled" perl script on Unix. Is it possible to de-compile, reverse engineer (whatever the term is) it, and obtain the source code from the compiled object code ?
Might not be possible, but thought I'd ask rather than assume.
Thanks,
-Kevin.
...
In perldoc perlvar, I read this:
Note that currently "ARGV" only has
its magical effect within the "<>"
operator; elsewhere it is just a plain
filehandle corresponding to the last
file opened by "<>". In particular,
passing "*ARGV" as a parameter to a
function that expects a filehandle may
not cause your function to
a...
Would an anchor like "^" or "\A" at the beginning of this regex make any sense - any difference?
$string =~/(.*)([a-z])$/
...
I want to parse the text from a pdf file in perl without converting the pdf into any other format . Is it possible ?
...
Why I get this error?
use strict;
use warnings;
my $str = <<str;
88087 23/11/2010
35192 25/07/2010
B3J 5X9 17/08/2011
C8U 5L6 16/08/2011
F4Q 3B4 17/10/2010
D3X 9P4 11/05/2010
O7L 6Z8 28/02/2010
W8L 9P2 05/09/2010
str
print $str;
my @arr = split/\n/,$str;
foreach (@arr) {
my @tmp = split/\t/;
print "$tmp[...
I am trying to learn pure functional programming language like Haskell as I am from Perl background and read that Perl can also implement functional programming techniques. So few qusetions came in mind:
Whether it is worth doing it in Perl 5? Does Perl 6 will make a difference?
Can anybody suggest some code/examples implementing functi...