Quoting from PerlMonks: The difference between my and local,
But in real life, they work virtually the same? Yes. Sort of. So when should you use them?
Use my when you can (it's faster than local) ...
I know the lexical vs dynamic scoping difference between my and local, as discussed in this SO thread, but I am not sure why my...
So I recently wanted to thread one of my Perl programs to increase its speed. Taking in a list of websites, I wanted to start a thread for each url and get the content of each website and then look for a company description on the page. Once one thread found a result, or all thread's didn't, I wanted to exit, write my result, and read ...
Hi, my question is the inverse of this one. In particular, I've dozens of existing modules written in Perl, some are object oriented and others just export a group of functions. Now since I have to write certain scripts in python but still would like to call those Perl modules, I'm wondering
1) if it is achievable, and
2) if so, what ...
I am trying to write a package in perl. I need one of the members to be a hash. However, when I reference and run the program, I cannot get it to work with the usual syntax. If I have:
sub new
{
my $class = shift;
my $self = {
textfile => shift,
placeholders => ()
};
bless $self, $class;
return $self;
}
Is there any way of mak...
I ran this test script:
use strict;
use warnings;
use Test::More tests => 3;
use Carp;
ok(1<2);
pass();
fail();
croak "example";
using the command line prove -MCarp=verbose -v foo.pl, and got the following errors:
Subroutine App::Prove::verbose redefined at /opt/ActivePerl-5.12/lib/App/Prove.pm line 407
App::Prove::_load_ext...
Say I make an object as follows:
$object22=new somepackage("stuff");
and later I want to run a subroutine like this:
$object22->somesubroutine();
I would like to capture the string "object22" in the subroutine "somesubroutine."
I tried:
$self=@_;
print $self;
but that just gave me somepackage=HASH(somehexnumber)
Please let me k...
In Perl, how do I use the next statement? In all sample programs I see the statement expressed like this: next LINEP
I do not understand what that label is doing. Can any one help me with an easily understandable example?
...
I recently had a friend tell me
"see perl was never designed to be fast"
Is that true?
The relevant piece of information I can find is this from Wikipedia:
The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal).
But it doesn't directly talk about speed. I ...
Why do all Perl 5 modules have to end with 1;?
...
how to lock all the streams under integration stream in clearcase in UCM
...
I want to add an attribute to every tag in my xml, which is incrementing using either awk, sed, perl or plain shell cmd
For Eg:
<tag1 key="123">
<tag2 abc="xf d"/>
<tag3 def="d2 32">
</tag3>
</tag1>
I am expecting the following output
<tag1 key="123" order="1">
<tag2 abc="xf d" order="2"/>
<tag3 def="d2 32" order="3">
...
CPAN has the Template::Declare package. A declarative way to create html templates in perl code without any html directly written.
I would love to use similar packages in python and ruby. Are there equivalent packages for those languages?
...
Hi, let's say you've got a Moose class that requires an attribute that does a Role:
package MyMooseClass;
use Moose;
has 'a' => ( does => 'MyRole' );
Now, I'd like to build an instance of MyMooseClass like this:
my $instance = MyMooseClass->new( { a => $a_non_moose_stuff } );
Where $a_non_moose_stuff is an instance of a non-moose ...
Hi,
I want to add a new widget to my script that will open a new window with text and will close automatically after 1sec.
how can I do it ?
...
I am completely new to perl and have just been learning it. I came across this script I need to run that has some network Tstat trace data. However, I get an error 'Cannot parse date.'
The code that generates this is here
foreach my $dir (@trace_dirs) {
undef @traces;
opendir(DIR, $dir) || die "Can't open dir: $dir \n";
@traces = gr...
Hi all,
I am trying to write a regex to solve the below C struct
for one of our requirement.
I am parsing the C structure file. In that I will have child and parent struct. The child will inherit parent struct members. I want the output, which consists of struct members and there length for further processing
INPUT:
#define Len1 10;...
This RFC mentions
Unlike many programming languages Perl does not currently implement true multiline comments. This, and the workarounds that are in common use can be problematic. This could be solved by adding a new syntax to allow for comments to span more than one line, like the variation on here-documentation cited below.
What ...
I'm trying to write the following perl subroutine. Given are an array a of length n, an index i in the array (0<=i<n an upstream window length u and a downstream window length d.
I want to iterate over the values in the upstream window and the downstream window to i. In the simplest case, this will iterating over the values in a[i-u..i...
Using Perl, I am trying to parse a bunch of XML files and trying to find any form of URL in the XML and print it. My regex does not seem to work and it is not returning any match. What am i missing?
sub findURL{
local($inputLine, $outText);
$inputLine = $_[1];
while (length($inputLine) > 0)
{
if ($inputLine =~ /^(((http|https|ftp):\/...
I would like to take input from a text file in Perl. Though lot of info are available over the net, it is still very confusing as to how to do this simple task of printing every line of text file. So how to do it? I am new to Perl, thus the confusion .
...