Updated According to comments:
I have outlog.txt file which contains multiple filenames, e.g: 2345_535_Dell&HP_3PAR_DEAL.txt, similarly there are many filename but not the actual folder where the files are located and so in code am appending filenames to folderpath to get actual file location. Now,I want to get disk usage of all the fil...
I have a program which is calling another program and processing the child's output, ie:
my $pid = open($handle, "$commandPath $options |");
Now I've tried a couple different ways to read from the handle without blocking with little or no success.
I found related questions:
perl-win32-how-to-do-a-non-blocking-read-of-a-filehandle-f...
I usually loop through lines in a file using the following code:
open my $fh, '<', $file or die "Could not open file $file for reading: $!\n";
while ( my $line = <$fh> ) {
...
}
However, in answering another question, Evan Carroll edited my answer, changing my while statement to:
while ( defined( my $line = <$fh> ) ) {
...
}
Hi...
Has anyone used the createHITType function in the Perl Amazon Mechanical Turk SDK to add Notification properties to their HIT?
I've managed to get it all working. I can grab the balance from both my sandbox account and the live system. I've successfully created new hits using the various techniques in the samples dir, but I need to enab...
For example, my docx file contains the following sentences:
This is a Perl example
This is a Python example
This is another Perl example
I want to apply bold style to all the occurrences of the word "Perl" like so:
This is a Perl example
This is a Python example
This is another Perl example
I've so far come up with the following scri...
Suppose I have a file with n words. As I read each word in the file, I will store it in hash (in Perl). When I go back and look up for the word in the hash, what is the time complexity of looking up a string(word) in a hash?
For example:
my %seen = ();
@arr=("one","two","three");
foreach $item (@arr){
if($seen{$item}) {//do someth...
Why will my script now work correctly?
I follow a YouTube video and worked for the guy.
I am running Perl on Windows using ActiveState ActivePerl 5.12.2.1202
Here is my tiny tiny code block.
print "What is your name?\n";
$name = <STDIN>;
if ($name eq "Jon") {
print "We have met before!\n";
} else {
print "We have not met before.\n";
...
I have a Perl script that prints multiple lines of output to screen. I need to capture those lines and either pipe them into a single piece of email ( /bin/mail ) or into a text file that I can send by /bin mail in another operation. Actually, I have already figured out the easy (dumb) way whereby I use a bash wrapper to do the mailing b...
I am learning Perl at my work and enjoying it. I usually do my work in Python but boss wants Perl.
Most of the concepts in Python and Perl match nicely: Python dictionary=Perl hash; Python tuple=Perl list; Python list=Perl array; etc.
Question: Is there a Perl version of the Python form of an Iterator / Generator?
An example: A Cla...
I was wondering if it's possible to actually print out the available ethernet cards that is present on a linux machine? I have so far read about "Grep" from the "ifconfig" command.
Do I have to use use "Net::IP" or "IO::Socket"? I am new to this programming language so can someone please give some advise on how to do this?
Sorry for c...
Summary
When I execute a very simple program using Perl's Benchmark utility. I get values that are not (appearing as) milliseconds or nanoseconds. The benchmark data returned is not useful to me because I do not know how to interpret it.
Example:
use Benchmark;
my $start = Benchmark->new;
print "foo!";
my $end = Benchmark->new;
my $...
I'm using Mail::Outlook to send messages, but when the content of the message is dynamic, for e.g. Time:$time\nEntry:$e, it prints this as it is and doesn't substitute the variables. What do I do for that?
...
The Perl script that contains a Unix command to grep the ethernet NICs cannot be executed within the script! I have tried "qx" , $var and "system" but it does not seem to work!
The codes:
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
print "\nYou are now in Showing Ethernet Cards!\n\n";
print "*********************...
I'm working with SGE (Sun Grid Engine) to submit jobs to a grid. I also use perlbrew to manage my installed Perl versions.
I wrote some short sh scripts that I use to run a perl script which requires a specific Perl version (5.12.2), which look something like this:
#!/bin/bash
#$-S /bin/bash
source /home/dave/.bash_profile
/home/dave/p...
$var = 'about/';
$var =~ s/^(.*)\/?$/index.php?action=$1/;
I want it to match and substitute the trailing slash. But it isn't, I'm getting this result:
index.php?action=about/
What am I doing wrong? I've tried wrapping it in parenthesis (\/)? and including the question mark in the parenthesis (\/?). Not including the preceding fo...
What does the below statement say exactly?
my @dirs = qw(fred|flintstone <barney&rubble> betty );
The complete story is:
my $tarfile = "something*wicked.tar";
my @dirs = qw(fred|flintstone <barney&rubble> betty );
system "tar", "cvf", $tarfile, @dirs;
This has been taken from Learning Perl, 4th Edition.
The result that the system ...
I would like to create a dir, but if it already exists I would like to remove it (along with all its content) first.
Should I explicitly add an if (-d ...) or is there a simpler mkdir that already does that?
...
I am using CGI.pm version 3.10 for file upload using Perl. I have a Perl script which uploads the file and one of my application keeps track of different revisions of the uploaded document with check-in check-out facility.
Re-creational steps:
I have done a checkout(download a file) using my application (which is web based uses apac...
The way a hash is structed can always vary, it can be a hash of a hash of an array or whatever.
And for every different struct of a hash there needs to be a different implementation of turning it into a two dimensional array.
Is there a general way of converting a hash into an array?
Such that i could say, for instance, first key become...
%TEST ;
...
for {
sub atest
}
sub atest {
...
push $TEST { TEST1 }[0] = "some value "
}
How push values into Hash of arrays and dont know anything about index?
How do I acheive this?
...