I'm a bit confused by conflicting advice between pre-5.10.0 documents and the more recent version module. Perl Best Practices makes it pretty clear that version strings ('v1.0.3') are bad and one is supposed to specify a version as follows:
use version; our $VERSION = qv('1.0.3');
but the version module says that we're back to using ...
I'm writing an HTML obfuscator, and I have a hash correlating user-friendly names (of ids and classes) to obfuscated names (like a,b,c,etc). I'm having trouble coming up with a regexp for accomplishing replacing something like
<div class="left tall">
with
<div class="a b">
If tags could only accept one class, the regexp would simpl...
I have a program in Perl that works with probabilities that can occasionally be very small. Because of rounding error, sometimes one of the probabilities comes out to be zero. I'd like to do a check for the following:
use constant TINY_FLOAT => 1e-200;
my $prob = calculate_prob();
if ( $prob == 0 ) {
$prob = TINY_FLOAT;
}
This wor...
I am storing information captured by regex into an array. But for some reason the first value is getting stored at 4 element of array. Any suggestion on whats going wrong and how to store the first value in the first element of array.
The following is the script:
#!/usr/bin/perl
use strict;
my @value;
my $find= qr/^\s+([0-9]+)\s+([A-Z...
I registered an application with Twitter. I use Net::Twitter::OAuth to manage the interaction with Twitter.
I managed to redirect the user to allow him to install the application in his Twitter account. The application is installed with read & write access. I have read access, but I didn't manage to send any tweet in his behalf: Twitter...
I really do not get how to run a Perl file. I have uploaded my .pl to the cgi-bin then chmod to 755. Then when i go to run the file i just get a 500 internal server error.
**/cgi-bin/helloworld.pl**
#!/usr/bin/perl
print 'hello world';
Any ideas as to what I am doing wrong?
...
I have 10 arrays, each consisting of similar type of values. I want to capture subset of these values (capture only the digits) from each array and then compare it with subset from other array. And also, I want to capture the number part of values from both arrays only when there is no dash in the value (i.e. 2EF = capture '2'but if 45F-...
I have the folowing XML file generated by my iLO HP server,
Do you have any examples of how can i parse it ? See the example XML file below.
I would like to extract fan speeds and temperatures from it.
<?xml version="1.0"?>
<GET_EMBEDDED_HEALTH_DATA>
<FANS>
<FAN>
<LABEL VALUE = "Fan 1"/>
<ZONE VALUE = "System"/>
<ST...
Hello friends,
How can I unpack a 4byte binary file, store like the following example,
to array or TEXT file ?
input file:
00000000 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 |................|
00000001 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 01 |................|
desired output file:
0,1,1,0,1,1,1,1
For now I'm u...
Hi,
I have the following Perl code:
STDOUT->autoflush(1);
foreach(...)
{
...
foreach(...)
{
print("Processing $folder");
$|=1;
process($folder);
}
...
}
but the print statement works only in the first iteration of the loop and does not print anything after that. Any idea why?
EDIT: I fou...
Hi I am using a perl script written by another person who is no longer in the company.
If I run the script as a stand alone, then the output are as expected. But when I call the script from another code repeatedly, the output is wrong except for the first time.
I suspect some variables are not initialised properly. When it is called st...
Hello friends,
How can I make a live time counter that ticks on the screen in parallel to part of a working program?
let's say I have the following little sub code which run an internal program for a couple of minutes:
system (`compile command`);
exec "simu -sh";
While waiting it to end, can I open a fork or something that output to...
I have a Perl routine that manages error checking. There are about 10 different checks and some are nested, based on prior success. These are typically not exceptional cases where I would need to croak/die. Also, once an error occurs, there's no point in running through the rest of the checks.
However, I can't seem to think of a neat w...
I am a complete Perl newb, but I am certain that learning Perl will be easier than figuring out how to parse XML in awk. I would like to parse the .sgm files from this dataset:
http://kdd.ics.uci.edu/databases/reuters21578/reuters21578.html
This is a collection of 20,000 Reuters articles from newswire from a decade ago, and is a stand...
Hi guys. I'm writing a tiny program that takes user input using Getops, and based on it, the program will either try to match a pattern against some text, or substitute text for what matched.
The problem I'm having is that I can't get the substitution portion to work. I'm looking at the qr// entry in the man pages: http://perldoc.perl....
I have a excel file. With many columns . I need to make multiple files using this
Eg: 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2. So these are the excel columns with each having many rows. I need one file which would contain 0 0 0 0 0 1 1 1 1 1 2 then second will contain only the second no 0 0 0 0 0 1 1 1 1 1 2....similarly the ot...
Hi guys,
I am extending a module and I want some tips on good practices. Specially namespace conflicts: what exactly are they and how to avoid them.
When extending, should I not access variables in the SUPER class and only alter its state through accessors or object methods? What to do in case there are no (or limited) accessors? Am I ...
I am writing a script using DBI to execute a select query to an Oracle db. I have successfully able to capture the data but I need help to change the output.
Below is the sample output.
Type
2
6
I want to display 2=>Good and 6=>Bad
Can anyone please suggest me the Perl code to map the output?
...
I currently have this in my Ant build script:
<exec dir="${basedir}" executable="perl">
<arg line="${basedir}/version.pl -major"/>
</exec>
However, when that runs, I get this error message:
[exec] Could not open -major
[exec] Result: 2
To me, that says that what I have is trying to run a file called -major, which doesn't ...
Why isn't this working?
eval "$response = $ua->request($r);"
print "$@";
gives:
syntax error at (eval 8) line 1, near "="
...