I have a folder called Client which contains many subfolders. I want to create a Perl script to look at each of those subfolders and check for a folder there. If it is there, I want to skip it and move on, if it is not there, I want to create it and do some processing.
How do I go about looping through all of the subfolders and chec...
This is a best practice question.
I've only seen the Perl spaceship operator (<=>) used in numeric sort routines. But it seems useful in other situations. I just can't think of a practical use.
Can anyone give me an example of when it could be used outside of a Perl sort?
...
Is it more preferrable, when assigning to a hash of just keys (where the values aren't really needed), to say:
$hash{$new_key} = "";
Or to say:
$hash{$new_key} = 1;
One necessitates that you check for a key with exists, the other allows you to say either:
if (exists $hash{$some_key})
or
if ($hash{$some_key})
I would think tha...
I'm having difficulty using MooseX::Declare properly when calling BUILDARGS.
I'm trying to create an object as an interface for a file. (Specifically, I want an interface to a binary file that lets me peek at the next few bytes in the file then chomp them off for further processing.)
I want to be able to create one of these objects li...
Hi,
I have a symbolic name java or jre or jre1.5 or jre1.6 or java1.5 or java1.6 that will point to the respective directory. Taking into account the first instance, it will look like:
java -> /usr/java/jdk1.5.x.x
My aim is as follows:
To check whether the symbolic exists or not
To get the value of the directory it is pointing
...
Why is the size of files capped at 4 GB when outputting to a
file using print? I would expect that with streaming output
it should be possible to generate files of arbitrary size.
Update: ijw and Chas. Owens were correct. I thought the F: drive was
NTFS formatted, but in fact it used the FAT32 filesystem. I
tried it on another drive a...
I am maintaining several Perl scripts that all have similar code blocks for different functions. Each time a code block is updated, I have to go through each script and manually make the change.
Is there a way to encapsulate the common functions into their own scripts and call them?
...
When executing a command on the command-line from Perl, is there a way to store that result as a variable in Perl?
my $command = "cat $input_file | uniq -d | wc -l";
my $result = system($command);
$result always turns out to be 0.
...
Is there any easy way to tell perl "now ignore everything that is printed"?
I have to call a procedure in an external Perl module, but the procedure prints a lot of unnecessary information (all through standard print).
I know select can be used to redirect it somehow, but I am not too wise from reading perldoc on it.
edit: I found th...
Is there a package in Perl that allows you to compute the height of probability distribution at each given point. For example this can be done in R this way:
> dnorm(0, mean=4,sd=10)
> 0.03682701
Namely the probability of point x=0 falls into a normal distribution, with mean=4 and sd=10, is 0.0368.
I looked at Statistics::Distribution...
In Perl, to run another Perl script from my script, or to run any system commands like mv, cp, pkgadd, pkgrm, pkginfo, rpm etc, we can use the following:
system()
exec()
`` (Backticks)
Are all the three the same, or are they different? Do all the three give the same result in every case? Are they used in different scenarios, like to ...
To ensure a script has at least version X of perl, you can do the following
require 5.6.8;
What is the best way of checking that a version is not too recent?
(i.e. version 5.8.x if fine, but 5.9 or 5.10 are not ok).
...
I have a script that needs to know what username it is run from.
When I run it from shell, I can easily use $ENV{"USER"}, which is provided by bash.
But apparently - then the same script is run from cron, also via bash - $ENV{"USER"} is not defined.
Of course, I can:
my $username = getpwuid( $< );
But it doesn't look nice - is ther...
I am writing a Perl script to do some mathematical operations on a hash. This hash contains the values as given in the sample below. I have written the code below. If I execute this code for an array value separately without using a foreach loop, the output is fine. But if I run this using a foreach loop on the array values, the sum for...
I want to make a singleton class which extends DBI. should I be doing something like this:
use base 'Class::Singleton';
our @ISA = ('DBI');
or this:
our @ISA = ('Class::Singleton', 'DBI');
or something else?
Not really sure what the difference between 'use base' and 'isa' is.
Thanks.
...
My department is currently settling on some general code best practices, which we would like to somewhat enforce, providing developers with Perl::Tidy and Perl::Critic configurations.
Now we are having problems with side comments. The side comment is this:
my $counter = 0; # Reset counter
We would prefer to not have side comments at...
So I'm trying to read in a config. file in Perl. The config file uses a trailing backslash to indicate a line continuation. For instance, the file might look like this:
=== somefile ===
foo=bar
x=this\
is\
a\
multiline statement.
I have code that reads in the file, and then processes the trailing backslash(es) to concatena...
I would like to call other Perl scripts in order to perform a contention test from with a main Perl script.
Something like this currently works:
system("perl 1.pl");
system("perl 2.pl");
exit;
However, I would like to kick these off as independent threads running at the same time.
I tried, based on my Google searches, doing somethin...
I'm trying to use the System.Diagnostics.Process class to run a Perl script from within an ASP.NET application. The Perl command runs fine when I type it into the command line, but when ASP.NET tries to run the same command it doesn't work.
I suspect it may have to do with input and output stream. The Perl script takes a long time t...
Though I've tried several ways, I'm unable to make WxPerl to work on Windows.
I tried with both ActivePerl and Strawberry Perl.
The error I get is:
Can't load 'C:/Perl/site/lib/auto/Wx/Wx.dll' for module Wx: load_file:Invalid access to memory location at C:/Perl/lib/DynaLoader.pm line 202.
...