I'm working on a Perl script where the user adds a number of set variables at the beginning of the script, all prefixed with $XX, as seen below. The user-set variables, however, need to go through a short transformation function to clean them up.
Is there a way to run the sub on all the variables with the $XX prefix?
my $XXvar1 = "some...
Hello all
This is my first post and I am hoping someone can point me in the right direction. I have tried Google but am not coming up with anything; actually, there are hardly getting any hits so I assume this is going to be a pretty obscure error.
I am trying to run a perl application (squeezecenter-7.3.3) on Solaris 10 and get the ...
Hi,
I just installed Devel::PerlySense 0.0180.
I have put the following in my .emacs file:
; PerlySense
(load "~/perly-sense")
(global-unset-key "\C-p")
(global-set-key (kbd "\C-p \C-d") 'perly-sense-smart-docs-at-point)
(global-set-key (kbd "\C-p \C-g") 'perly-sense-smart-go-to-at-point)
But, now whenever I try to load a Pe...
Hi all,
I would like to extract values after I match the keyword "coor" multiple times in a string. My code doesn't do that at all. Can anyone help me to fix it please?
My code:
my $str = ;
if ($str =~ /$keyword/)
{
if ($' =~ /\[/) #'# everything after the matched string
{
$str=~ /\(coor\s(\d+)\s(\d+)\)\s\(coor\s(\d+)\s(\d+)\)...
I want to be able to place an array into an array. For example, I may have an array like this:
my @array1 = ("element 1","element 2","element 3");
Then I have another array
my $array_ref = ["this will", "go between", "element 1 and 2"];
I want to place $array_ref into the first so that the first array
looks like this:
("element 1"...
I have the following version being installed:
Apache::SmallProf - 0.09
Apache::Registry - 2.01
Devel::SmallProf - 2.02
And I try to add the following settings in my apache config file (/usr/local/apache_modperl/conf/httpd.conf):
<Perl>
require Apache::DB;
Apache::DB->init;
</Perl>
<Directory /home/website/www/cgi-m>
Set...
I have match regular expresion in Perl.
The match sentence that spreads over more than one line.
I realize that I must enter the match regular expresion in one line only, if I spread
to multiple lines it fails:
$array_11 =~ m{By Steve (.*), MarketWatch LONDON (.*) -- Shares of Anglo American rallied on Monday morning as (.*) bet that t...
I am looking at some old code in Perl, where the author has writtern
$| = 1 in the first line.
But the code does not have any print statements, it calls a C++ binary using the system command. Now I read that $| will force flush after every print. So does it affect the system command's output in any way or am I safe to remove that line....
I am using XML::Simple and I have the following XML structure in a variable $xmldata which I need to access through Perl code.
<root>
<a>sfghs</a>
<b>agaga</b>
<c>
<c1>sgsfs</c1>
<c2>sgsrsh</c2>
</c>
<d>
<d1>agaga</d1>
<d2>asgsg</d2>
</d>
</root>
I can access the value of a and b b...
I have a really big number in Perl. I use "bignum". How can I extract single digits out of this big number. For example if I have a number like this and what to get the 3rd digit from the end:
1029384710985234058763045203948520945862986209845729034856
-> 8
...
There are boolean values in the JSON data structure I am using. When call decode_json to convert it to a Perl data structure and feed to the XMLout function provided by XML::Simple, it throws an error because XMLout does not know how to deal with JSON::XS::Boolean values.
Is there a way to convert the JSON::XS::Boolean values in a data ...
In short: Is there an existing open-source Python interface for the Apache scoreboard IPC facility? I need to collect statistics from a running server WITHOUT using the "mod_status" HTTP interface, and I'd like to avoid Perl if possible.
Some background: As I understand it, the Apache web server uses a functionality called the "score...
I would like to write a script to login to a web application and then move to other parts
of the application:
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use Data::Dumper;
$ua = LWP::UserAgent->new(keep_alive=>1);
my $req = POST "http://example.com:5002/index.php",
[ user_name => 'username',
user_password => "passwor...
I'm trying to extract only certain elements of a string using regular expressions and I want to end up with only the captured groups.
For example, I'd like to run something like (is|a) on a string like "This is a test" and be able to return only "is is a". The only way I can partially do it now is if I find the entire beginning and end...
I am working with the following data:
__DATA__
Branch 1: 10..11
13 E 0.496 -> Q 0.724
18 S 0.507 -> R 0.513
19 N 0.485 -> S 0.681
Branch 2: 11..12
81 R 0.891 -> Q 0.639
88 Y 0.987 -> S 0.836
From the above data, I want to read numbers present before a character and then print them out. So for instance ...
Hi,
I created a Perl script and tested it on a couple of servers running Net::SNMP 5.3.1-19, but now I'm trying to run it on a different server and I'm getting the following error:
Can't load '/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/NetSNMP/default_store/default_store.so' for module NetSNMP::default_store: libnet...
I want to use Perl libraries from a PHP application. I have heard that it is possible.
I have considered the possibility of re-writing the libraries in PHP, but I do not think that is a good idea because it is difficult.
...
I know this kind of questions have been asked already many times before. The reason why I come here again is that I feel like I've missed something simple and fundamental.
Is it possible to make this kind of search-replace routine better. For example without opening same file twice. Also speed related advices are welcome.
Please notice...
Closing this question. Will drink red bull. Sleep. Code and come back with brand spanking new question with unit test cases.
UPDATE: The new file is here
Also the config file is here
I refactored the code again:
sub getColumns {
open my $input, '<', $ETLSplitter::configFile
or die "Error opening '$ETLSpliter::configFile':...
I need to find the full path to the Perl script I'm currently running, i.e.
for ~/dir/my.pl I would need it to be "/home/user/dir/my.pl". The $0 will give me "~/dir/my.pl".
for ./my.pl I would still need "/home/user/dir/my.pl"
etc. Thanks!
...