EDIT: I have created a ticket for this which has data on an alternative to this way of doing things.
I have updated the code in an attempt to use MY_CXT's callback as gcxt was not storing across threads. However this segfaults at ENTER.
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifndef aTHX_
#define aTHX_
#endif
#ifdef...
Just a couple of quick questions. If I'm writing CGI programs to create web pages via HTML::Template, then do I have to write separate tmpl files for each distinctive screen (the control logic to be in the Perl code)?
Also, (and in a similar area) is it OK to put url links to the other screen CGI programs within the tmpl files? For exa...
I am need to push all the matched groups into an array.
#!/usr/bin/perl
use strict;
open (FILE, "/home/user/name") || die $!;
my @lines = <FILE>;
close (FILE);
open (FH, ">>/home/user/new") || die $!;
foreach $_(@lines){
if ($_ =~ /AB_(.+)_(.+)_(.+)_(.+)_(.+)_(.+)_(.+)_W.+txt/){
print FH "$1 $2 $3 $4 $5 $6 $7\n"; #nee...
# I have a hash
my %my_hash;
# I have an array
@my_array = ["aa" , "bbb"];
# I store the array in my hash
$my_hash{"Kunjan"} = @my_array;
# But I can't print my array's element
print $my_hash{"Kunjan"}[0];
I am new to Perl. Please help me.
...
Compiling (or executing) a perl program with unmatched array braces ("[ ]") or scope brackets ("{ }") causes the "missing right curly or square bracket" syntax error. Perl often reports the source as your last code line ("at EOF"), which could be far removed from the actual missing piece.
Example perl error message:
Missing right curly...
Does somebody have a working example of using WWW::Curl::Multi?
...
I am working so some stuffs where I need to get some information using kstat -p. So I am thinking to create a hash variable with all output of kstat -p.
Sample output from kstat -p
cpu_stat:0:cpu_stat0:user 18804249
To access values
@{$kstat->{cpu_stat}{0}{cpu_stat0}}{qw(user)};
I have also looked at CPAN for any available m...
Until now, the project I work in used ASCII only in the source code. Due to several upcoming changes in I18N area and also because we need some Unicode strings in our tests, we are thinking about biting the bullet and move the source code to UTF-8, while using the utf8 pragma (use utf8;)
Since the code is in ASCII now, I don't expect to...
I need to insert values from a hash into a database. Following is the code template I have to insert values in table1 column key and value:
use DBI;
use strict;
%hash; #assuming it already contains desired values
my $dbh = DBI->connect(
"dbi:Sybase:server=$Srv;database=$Db",
"$user", "$passwd"
) or die sprintf 'could not c...
I need to extract the text (characters and numbers) from a multiline string. Everything I have tried does not strip out the line feeds/carriage returns.
Here is the string in question:
"\r\n 50145395\r\n "
In HEX it is: 0D 0A 20 20 20 20 20 20 20 20 35 30 31 34 35 33 39 35 0D 0A 20 20 20 20
I have tried the following:
$s...
I'm trying to access a protected file. Server is using digest authentication - which I can see from the printed out response.
Here is the sample code:
use LWP;
use strict;
my $url = 'http://somesite.com/aa/bb/cc.html';
my $username = 'scott';
my $password = 'tiger';
my $browser = LWP::UserAgent->new('Mozilla');
$browser->credentials("...
I seem to be having some issues trying to install the signatures module
from CPAN using Strawberry Perl 5.10.1 on Windows XP.
I get some "undefined reference" errors during linking.
I'm guessing that there is something wrong with my B::Hooks::Parser module,
but reinstalling that one didn't fix my problem.
Here's the output:
cpan shel...
I want to extract all the links from a page. I am using HTML:LinkExtor. How do I extract all the links that point to HTML content pages only?
I also cannot extract these kinds of links:
javascript:openpopup('http://www.admissions.college.harvard.edu/financial_aid/index.html'),
EDIT: HTML Pages - text/html. I am not indexing pictures ...
I saw some code that called methods on scalars (numbers), something like:
print 42->is_odd
What do you have to overload so that you can achieve this sort of "functionality" in your code?
...
Maybe it's dumbest question in the world, but I seriously have problems with it and could use help. I am trying to run perl script on linux. It's a simple text editing script, nothing fancy. I googled for it and I found that I had to chmod +x it and then just run myscript.pl in the console. Since it's supposed to modify a text file I did...
Are there good GUI builder for Perl GUI libraries, especially for WxPerl?
...
Hi I want to search something in the file which looks similar to this :
Start Cycle
report 1
report 2
report 3
report 4
End Cycle
.... goes on and on..
I want to search for "Start Cycle" and then pull out report 1 and report 3 from it.. My regex looks something like this
(Start Cycle .*\n)(.*\n)(.*\n)(.*\n)
The above regex selec...
sh-3.2# perl -v
This is perl, v5.8.9 built for darwin-2level
...
sh-3.2# perl 2348.pl
Can't locate HTTP/Cookies.pm in @INC (@INC contains: /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level /opt/local/lib/perl5/site_perl/5.8.9 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.9/darwin-2level /opt/local/lib/perl5/ven...
In Perl it is possible to do something like this (I hope the syntax is right...):
$string =~ m/lalala(I want this part)lalala/;
$whatIWant = $1;
I want to do the same in Python and get the text inside the parenthesis in a string like $1.
...
So I need to match an ipv6 address which may or may not have a mask. Unfortunately I can't just use a library to parse the string.
The mask bit is easy enough, in this case:
(?:\/\d{1,3})?$/
The hard part is the different formats of an ipv6 address. It needs to match ::beef, beef::, beef::beef, etc.
An update: I'm almost there..
/^...