Hey.
I don't know anything about Perl but I urgently need to modify a Perl script. At some point it's downloading an about 500MB file from a server using system("lwp-download $HttpPath $Out");.
Is there any way I can find out if the downloading process went correctly, e.g. check whether downloaded file has the same size as the original...
open(LOG,"logfile.txt") or die "Unable to open $logfile:$!";
print "\n";
while(<$LOG>){
print if /\berror\b/i;
}
close(LOG);
...
I think the answer is yes but I just want to make sure. so if I have
sub something {
my $_;
my @array = ...;
while ( @array ) {
say;
}
}
is the my $_; actually effective at lexicalizing the parameter passed to the say?
In this particular case I'm using the DZP::UnusedVarsTests and it's complaining that I haven...
I have a couple of modules (DZP::Catalyst and DZP::OurPkgVersion) both of their purposes involve writing out files to the disk. I'm not sure how to test them, are there any good strategies for testing files written out to disk? any place I could go to read up on it?
...
Hi,
I am writing a Perl script and I need to execute Unix Ctrl-Z on the script.
How can I do it in Perl ?
thanks.
...
#!/usr/bin/perl
my $str = "abc def yyy ghi";
print substr($str, 0 , index($str,' '));
I want substr to print def yyy
print substr ($str, index ($str, ' '), rindex($str, ' ') does not work?
Any idea?
...
Hi Folks,
How can I assign processes to specific cores ?. I have a 16 core machine and need to assign processes to multiple cores rather then all/few of them running on same cores.
Can Parallel::ForkManager do this ?. or How do you do it with using standard perl distribution ?
Any pointers are appreciated.
Thanks
...
#!usr/bin/perl
$file_name = "file.txt";
open(FILE,$file_name);
while(<FILE>)
{
my $line = $_;
if($line =~ m/Svr\b/)
{
my $server_name;
$server_name = $1;
print $server_name;
}
}
file.txt:
ewrerfSvr//To be extracted
Rate=rpm
ID=123
RATE=45
ADDR=retriveBal
Grocer="-r -e ${MAIN_ROOT}/logs/stderr -o ${MAIN_ROOT}/logs/stdout -A --...
What's happening behind the scenes when I do a concatenation on a string?
my $short = 'short';
$short .= 'cake';
Is Perl effectively creating a new string, then assigning it the correct variable reference, or are Perl strings always mutable by nature?
The motivation for this question came from a discussion I had with a colleague, who...
I have a Perl script (standalone program) which contains some subs I'd like to reuse in other scripts. Due to limitations of the execution environment, I can't move the functions to a common .pm file.
Is it possible to differentiate whether the script was run as a standalone program or it was requireed/doed by another script?
The only ...
I have a Perl script and needed to call a method that's in a .NET assembly. I found this technique but it's quite involved for a one-off Perl script so I didn't use it. I ended up writing a trivial .NET console app as a wrapper for the call I need and have my Perl script communicate with the wrapper, using Console.In / Console.Out / IP...
I am using HTML::FormHandler. To use it one is supposed to subclass from it and then you can override some attributes such as field_name_space or attribute_name_space.
However, I now have lots of forms all extending HTML::FormHandler or its DBIC based variant HTML::FormHandler::Model::DBIC and therefore have these overidden attributes ...
I made the following script which searches for certain processes, displays uses pflags for each one, and stops when it finds one with the word "pause":
!cat find_pause
#!/usr/bin/perl -W
use warnings;
use strict;
if (open(WCF,
"ps -ef | grep '/transfile' | cut -c10-15 | xargs -n1 pflags 2>&1 |"
)) {
while (<WCF>) {
...
Given a hash in Perl (any hash), how can I extract the values from that hash, in the order which they were added and put them in an array?
Example:
my %given = ( foo => '10', bar => '20', baz => '15' );
I want to get the following result:
my @givenValues = (10, 20, 15);
...
I've been trying to run some sockets code in Rakudo Perl (freshly built from the repository at http://github.com/rakudo/rakudo) but the implementation of IO::Socket::INET appears to be incomplete.
The code I'm trying to run is here: http://github.com/carlins/irc-client/blob/master/lib/IRC/Client.pm
This is the error:
Method 'inpu...
This question is related to one I asked previously, see here.
As a way to implement segmented ajax responses, I created a code which does this:
The client first calls the script which initializes the process. On the server side, the startScript.cgi code starts generating data, and as it does this, it groups the responses into chunks, a...
is there anyway to compare two strings regardless of case size?
For Example
"steve" eq "STevE" <----- these would match
"SHOE" eq "shoe"
You get the picture
...
I am trying to have my perl script get an Xxml file from online and validate it according to an XSD file.
The code to do this is as follows:
my $url = shift @ARGV;
my $response = $ua->get($url) || die "Can't fetch file";
my $file = $response->content;
my $schema_file = "schema.xsd";
my $schema = XML::LibXML::Schema->new(location => $s...
I am new to perl, but I am trying to write a plug-in for nagios. I have a simple get request that fails, but if I try the same request with snmpwalk it works.
My code is:
#!/usr/bin/perl -w
use strict;
use Net::SNMP;
my $host = '10.10.10.203';
my $community = 'myComm';
my $session;
my $error;
my $response = undef;
($s...
Perl newbie here...I had help with this working perl script with some HASH code and I just need help understanding that code and if it could be written in a way that I would understand the use of HASHES more easily or visually??
In summary the script does a regex to filter on date and the rest of the regex will pull data related to tha...