I have a few bash scripts I run, but they can take several hours to finish, during which time they spew out download speeds, ETAs and similar information. I need to capture this information in perl, but I am running into a problem, I cannot read the output line by line(unless I'm missing something).
Any help working this out?
EDIT: to ...
I know that in a subroutine in Perl, it's a very good idea to preserve the "default variable" $_ with local before doing anything with it, in case the caller is using it, e.g.:
sub f() {
local $_; # Ensure $_ is restored on dynamic scope exit
while (<$somefile>) { # Clobbers $_, but that's OK -- it will be restored...
I have a .pl file and I want to execute that file in any system even though perl is not installed. How can i achieve it?
Can any one let me know with some good examples to do that?
...
Hi folks,
I'm planning to move from Class::DBI to Rose::DB::Object due to its nice structure and the jargon that RDBO is faster compares to CDBI and DBIC.
However on my machine (linux 2.6.9-89, perl 5.8.9) RDBO compiled time is much slower than CDBI:
$ time perl -MClass::DBI -e0
real 0m0.233s
user 0m0.208s
sys 0m0.024s
$ t...
I'm using Perl's PDF::API2 module to create a PDF document and I need to add an PNG image at a specific X,Y location on the page.
How do I do this?
...
Hi, I have a text file that's composed of fixed length records but all in one line with no line breaks in between. What's the best way to process it in Perl? Thanks!
...
I have an XML file
<PARENT >
<TAG string1="asdf" string2="asdf" >
</TAG >
</PARENT>
I want to extract the string2 value here.. and also I want to set it to a new value..
How to do that?
...
I have three hashes named %hash1, %hash2, %hash3. I need to reference each hash by variable and am not sure how to do it.
#!/usr/bin/perl
# Hashes %hash1, %hash2, %hash3 are populated with data.
@hashes = qw(hash1 hash2 hash3);
foreach $hash(@hashes){
foreach $key(keys $$hash){
.. Do something with the hash key and value...
How do I append hash a to hash b in Perl without using a loop?
...
I am looking for a way to generate a graph with multiple sets of data on the X-axis, each of which is divided into multiple sets of multiple sets. I basically want to take this graph and place similar graphs side by side with it. I am trying to graph the build a graph of the duration (Y-axis) of the same jobs (0-3) with different confi...
I have an application that waits for the user to press a key and then executes a long running method that periodically updates the GUI.
sub keypress{
my $self = shift;
my $event = shift;
if ($event->GetKeyCode() == WXK_F12){
$self->doStuff();
}else{
$event -> Skip(0);
}
}
I would like to have the application ignore...
I am having some problems with memory in Perl. When I fill up a big hash, I can not get the memory to be released back to the OS. When I do the same with a scalar and use undef, it will give the memory back to the OS.
Here is a test program I wrote.
#!/usr/bin/perl
###### Memory test
######
## Use Commands
use Number::Bytes::Human qw(...
Is there a simple way, using some common Unix scripting language (Perl/Python/Ruby) or command line utility, to convert an Excel Spreadsheet file to CSV? Specifically, this one:
http://www.econ.yale.edu/~shiller/data/ie_data.xls
And specifically the third sheet of that spreadsheet (the first two being charts).
...
I was just wondering what is best for performance when making a web service in Perl.
Is it best to have as short as possible .pl script and put as much code as possible in a module that is used by the .pl script, or doesn't it impact performance if i don't use a module at all?
I am using mod_perl on a CentOS Linux box with perl 5.8.8....
I have a huge SQL file that gets executed on the server. The dump is from my machine and in it there are a few settings relating to my machine. So basically, I want every occurance of "c://temp" to be replace by "//home//some//blah"
How can this be done from the command line?
...
Is there a simpler or better (=>easier to maintain) way to use Perl and Moose to instantiate classes based on incoming data?
The following code is a stripped down sample from a project I'm working on.
package FooBar;
use Moose;
has 'SUBCLASS' =>('isa'=>'Str',required=>'1',is=>'ro');
has 'MSG' =>('isa'=>'Str',required=>'1',is=>'ro');
s...
I need to write an ISAPI filter for IIS 6.0 to rewrite ugly URLs into SEO-friendly URLs. Because of the need for string parsing and regular expressions, I'd prefer to use Perl to do this. There is a module for IIS called (ingeniously) Perl for IIS, but I'd rather not use that because it's an ISAPI extension itself (running in a DLL), so ...
Hi
I have a C++ object that I am converting to Perl using Perl XS. This process works fine with Perl 5.8.5 and 5.8.7. But as soon as I try to use Perl 5.10.0, I run into a lot of compile errors. Most of them are along these lines:
undefined reference to 'PL_stack_max'
undefined reference to 'PL_stack_sp'
undefined reference to 'Perl_...
I want to do this in Perl:
>> "foo bar baz".scan /(\w+)/
=> [["foo"], ["bar"], ["baz"]]
Any suggestions?
...
I have this Perl snippet from a script that I am translating into Python. I have no idea what the "s!" operator is doing; some sort of regex substitution. Unfortunately searching Google or Stackoverflow for operators like that doesn't yield many helpful results.
$var =~ s!<foo>.+?</foo>!!;
$var =~ s!;!/!g;
What is each line doing? I...