I'm working on a project that involves parsing a large csv formatted file in Perl and am looking to make things more efficient.
My approach has been to split() the file by lines first, and then split() each line again by commas to get the fields. But this suboptimal since at least two passes on the data are required. (once to split by l...
Hi
I have no experience on perl.
I am trying to configure the W3C validator on my localhost (win32).
I have already followed all the instructions given by W3C @http://validator.w3.org/docs/install_win.html, but I am getting the following error:
Can't locate loadable object for module Encode::HanExtra in @INC (@INC contains: C:/xampp/...
In Perl, is it appropriate to use a string as a byte array containing 8-bit data? All the documentation I can find on this subject focuses on 7-bit strings.
For instance, if I read some data from a binary file into $data
my $data;
open FILE, "<", $filepath;
binmode FILE;
read FILE $data 1024;
and I want to get the first byte out, is...
I want to build perl apps with a gui that:
A: are windows compatible (no cygwin or the like)
B: utilize a nice GUI builder
C: is easily distributed (minimizing additional components that must be installed)
D: has good documentation and tutorials for building and using the GUI
E: is still be developed (has a future) and appears to be the...
Hi, I've got some data that I'm parsing in Perl, and will be adding more and more differently formatted data in the near future. What I would like to do is write an easy-to-use function, that I could pass a string and a regex to, and it would return anything in parentheses. It would work something like this (pseudocode):
sub parse {
...
Putting a precompiled regex inside two different hashes referenced in a list:
my @list = ();
my $regex = qr/ABC/;
push @list, { 'one' => $regex };
push @list, { 'two' => $regex };
use Data::Dumper;
print Dumper(\@list);
I'd expect:
$VAR1 = [
{
'one' => qr/(?-xism:ABC)/
},
{
'two' => qr/(?-xism:ABC...
I have finished my earlier multithreaded program that uses perl threads and it works on my system. The problem is that on some systems that it needs to run on, thread support is not compiled into perl and I cannot install additional packages. I therefore need to use something other than threads, and I am moving my code to using fork(). T...
I make a recv call on a TCP socket and it tured out to be that the recv call is a blocking one even though the socket itself has set to be in non-blocking mode. So my question is just as simple as: how to implement a non-blocking recv on a perl socket? thanks in advance.
...
I need to install two Perl modules on a web host. Let's call them A::B and X::Y. X::Y depends on A::B (needs A::B to run). Both of them use Module::Install. I have successfully installed A::B into a non-system location using
perl Makefile.PL PREFIX=/non/system/location
make; make test; make install
Now I want to install X::Y, so I try...
I am trying to install some Perl modules into a non-standard location, let's call it /non/standard/location. I used
perl Makefile.PL PREFIX=/non/standard/location
make;make install
to install them.
In the script which uses the module, it seems to be necessary to specify a long directory path including the version of Perl, like so:
...
Hi,
This code smells... how do I rewrite it better?
my $record;
eval {
while (
# undef $record here, so if getRecord() failed, nothing will be written
# in the reject file
do { undef $record; defined( $record = $dataFile->getRecord ) }
) {
$LT_DataFile->encode($record);
}
1;
};
if ( my...
Okay, so I'm using perl to read in a file that contains some general configuration data. This data is organized into headers based on what they mean. An example follows:
[vars]
# This is how we define a variable!
$var = 10;
$str = "Hello thar!";
# This section contains flags which can be used to modify module behavior
# All modules r...
I'm debugging some code and wondered if there is any practical difference between $1 and \1 in Perl regex substitutions
For example:
my $package_name = "Some::Package::ButNotThis";
$package_name =~ s{^(\w+::\w+)}{$1};
print $package_name; # Some::Package
This following line seems functionally equivalent:
$package_name =~ s{^(\w...
Let's say there are two modules that mutually use each other:
package a;
use b;
sub p {}
1;
package b;
use a;
1;
I think that it is systematically wrong to write code like the above, because the two modules will endlessly copy each other's code to themselves, but I can successfully run the following code, which makes me very surpris...
I am reading an .xls file using Spreadsheet::ParseExcel and was able to get data as is.
But,when reading an .xlsx file using Spreadsheet::XLSX, the read values are truncated.
E.g., 2.4578 in .xls and .xlsx file is read as 2.4578 and 2.45, respectively.
Please suggest why .xlsx file data is corrupted.
...
I have a raw email, (MIME multipart), and I want to display this on a website (e.g. in an iframe, with tabs for the HTML part and the plain text part, etc.). Are there any CPAN modules or Template::Toolkit plugins that I can use to help me achieve this?
At the moment, it's looking like I'll have to parse the message with Email::MIME, th...
I call my script:
$ ./script 'a!#*`*&
^$' "sdf sdf\"qw sdsdf" 1 -- 2 3
It gets arguments:
1: a!#*`*&
^$
2: sdf sdf"qw sdsdf
3: 1
4: --
5: 2
6: 3
If I need to call something with the same arguments locally, I do this:
someprogram "$@"
But how can I put all that array to a string (to store in file or in environment variable or pas...
I have a Moose class that i would like to store using Apache::Session::File.
However, Apache::Session::File by default will not store it and instead i get the error message:
(in cleanup) Can't store CODE items at blib\lib\Storable.pm (autosplit into blib\lib\auto\Storable\_freeze.al)...
This problem can be circumvented by setting
$...
sub DirectoryExists {
my $param = shift;
# Remove first element of the array
shift @{$param};
# Loop through each directory to see if it exists
foreach my $directory (@{$param}) {
unless (-e $directory && -d $directory) {
return 0;
}
}
# True
return 1;
}
Is there any...
Part 3 (Part 2 is here) (Part 1 is here)
Here is the perl Mod I'm using: Unicode::String
How I'm calling it:
print "Euro: ";
print unicode_encode("€")."\n";
print "Pound: ";
print unicode_encode("£")."\n";
would like it to return this format:
€ # Euro
£ # Pound
The function is below:
sub unicode_encode {
shift...