Repost from Perlmonks for a coworker:
I wrote a perl script to separate long lists of email separated by a semi colon. What I would like to do with the code is combine the split with the trimming of white space so I don't need two arrays. Is there away to trim while loading the first array. Output is a sorted list of names.
Thanks.
#!/...
The following snippet searches for the index of the first occurrence of a value in an array. However, when the parentheses around $index are removed, it does not function correctly. What am I doing wrong?
my ($index) = grep { $array[$_] eq $search_for } 0..$#array;
...
We need a cross platform solution for compressing files. Our server runs on Windows XP/Vista/7 and 3 Unix distros, SunOS, HPUX, and AIX. Our server creates files that needed to be zipped before being set back to the client. Our initial thought was to compress the files with jar, as most of the servers have java installed, but apparent...
How might this block of code in Date/Manip.pm from the Date::Manip module:
#*Get rid of a problem with old versions of perl
no strict "vars";
# This sorts from longest to shortest element
sub sortByLength {
return (length $b <=> length $a);
}
use strict "vars";
I get this warning:
Use of uninitialized value in length at /perl/lib...
I have an XML string like this:
<DATA>
<CHILD_DATA ATVAL="value1"/>
<CHILD_DATA />
</DATA>
The final output I want is:
<DATA>
<CHILD_DATA ATVAL="value1"/>
<CHILD_DATA ATVAL="value2"/>
</DATA>
My twig $t is at <DATA>. Now I want to add an attribute to the second <CHILD_DATA />. The attribute is ATVAL="value2". I tried th...
Duplicate: http://stackoverflow.com/questions/1259545/let-me-know-alternate-command-in-dos-for-following-sed-and-perl-commands-closed
the following commands have unique implementation in unix box.
Need to implement in informatica(etl tool).
If not any windows solution for the same
sed 's/^#//g' < kam_account_calls.txt > kam_account_...
Is it possible to create an attribute that can only be set in the constructor in Moose? I’d like to do something like this:
my $foo = new Foo(file => 'foo.txt');
my $bar = new Foo(string => $str);
$foo->file('baz.txt'); # dies
I know I can create an attribute that can not be set in constructor, but the complementary case seems to be m...
I am creating a Perl/TK GUI code that will call a seperate exe inside. The progress bar widget will be the only indication that execution is happening inside it but problem is, as you run the code, the progress bar freezes because it has to finish first the execution of the seperate exe and after it's done, activity on the progress can b...
The perlstyle pod states
No space before the semicolon
and I can see no reason for that. I know that in english there should not be any space before characters made of 2 parts ( like '?',';','!' ), but I don't see why this should be a rule when writing Perl code.
I confess I personally use spaces before semicolons. My reason is t...
I have a YAML document like this:
---
version: 1
rootdirectory:
- subdirectory:
- file1
- file2
- subdirectory2
that I am loading into a YAML::Tiny object like this:
$configuration = YAML::Tiny->read($configuration_file)
I see from invoking the script with the Perl debugger that what I end up with is a set of nested has...
I have a Perl script that processes a bunch of file names, and uses those file names inside backticks. But the file names contain spaces, apostrophes and other funky characters.
I want to be able to escape them properly (i.e. not using a random regex off the top of my head). Is there a CPAN module that correctly escapes strings for use ...
How do I fix this error?
foreach (values %{$args{car_models}}) {
push(@not_sorted_models, UnixDate($_->{'year'},"%o"));
}
Error:
Can't use string ("1249998666") as a HASH ref while "strict refs" in use at /.../BMW.pm line 222.
...
In the C#/.Net world, there are ORMs such as NHibernate or ActiveRecord that includes transparent caching: database updates are transparently replicated to the cache, objects are retrieved directly from the cache when available, etc (often with memcached).
It doesn't look like transparent caching is available in Perl with DBIx::Class. D...
I'm feel like I'm missing something pretty obvious here, but I can't seem to figure out what's going on. I have a perl script that I'm calling from C code. The script + arguments is something like this:
my_script "/some/file/path" "arg" "arg with spaces" "arg" "/some/other/file"
When I run it in Windows, Perl correctly identifies it...
Related/possible duplicate: http://stackoverflow.com/questions/1263943/why-do-i-get-uninitialized-value-warnings-when-i-use-datemanips-sortbylength
This block of code:
my @sorted_models = sort {
UnixDate($a->{'year'}, "%o") <=>
UnixDate($b->{'year'}, "%o")
} values %{$args{car_models}};
kept generating the following err...
What's the best technique for handling US Dollar calculations in Perl?
Especially: the following needs to work:
$balance = 10;
$payment = $balance / 3; # Each payment should be 3.33. How best to round amount?
$balance -= $payment * 3;
# assert: $balance == .01
...
I need to rejig some VERY old Windows code that uses Perl to talk to MQ. Specifically, I need to be able to install Perl's MQClient::MQSeries, MQSeries::QueueManager, MQSeries::Queue and MQSeries::Message modules.
When I fire up Strawberry Perl, go into CPAN and try to install them, I can see that there's several MQ client DLLs that ar...
I'm trying to create a regex to recognize English numerals, such as one, nineteen, twenty, one hundred and twenty two, et cetera, all the way to the millions. I want to reuse some parts of the regular expression, so the regex is being constructed by parts, like so:
// replace <TAG> with the content of the variable
ONE_DIGIT = (?:one|two...
Hi All,
I have a bunch of Perl scripts and Perl modules given to me by someone. I have a driver program that tests all these scripts and modules. I want to generate a call graph and see the flow.
Is there something available for Perl for doing this?
I'd like something like pycallgraph (for python). I am running all this in AIX.
Thank...
Hi everyone,
I am new to Perl. I need to define a data structure in Perl that looks like this:
city 1 -> street 1 - [ name , no of house , senior people ]
street 2 - [ name , no of house , senior people ]
city 2 -> street 1 - [ name , no of house , senior people ]
street 2 - [ name , no of house , senior p...