I am reading data from a file like this
while (<$fh>)
{
@tmp = split; # <-- ?
push @AoA, [@tmp];
}
I have a couple of questions regarding this. What does the marked line do? Does it split the file by lines and store elements of each line into an array?? If so, is it possible to convert @tmp into a string or do a regex...
I have some POD that looks like
=head2 C<close() on unopened filehandle %s>
=over
=item C<Yer tryna close() %s what ain't been opened yet>
=back
The pod2html command turns it into
<h2><a name="close____on_unopened_filehandle__s"><a href="#item_close"><code>close () on unopened filehandle %s</code></a></a></h2>
<dl>
<dt><strong><a ...
I'm using mod_perl 2 with Apache 2.2.3 on Red Hat 5.2, and I'm trying to access the request headers, but the Apache2::RequestRec headers_in method (or rather, its return value) is not behaving the way I would expect.
Code fragment:
$logger->warn('version ' . $mod_perl::VERSION);
$logger->warn('r ' . $r);
my $headers = $r->headers_in;
$...
I want to fill in a web form with Perl. I am having trouble finding out the correct syntax to accomplish this. As in, how do I go to the URL, select the form, fill in the form, and then press enter to be sure it has been submitted? Any examples would be great. Thanks.
...
I have an existing Perl application which is deployed to multiple customer sites. Unfortunately, the code has been cloned multiple times to customise it for individual customers. So there are now several complete copies of the code which all have slight (or major) differences.
My task is to fix this mess by creating a single, generic co...
I have a list of possible values:
@a = qw(foo bar baz);
How do I check in a concise way that a value $val is present or absent in @a?
An obvious implementation is to loop over the list, but I am sure TMTOWTDI.
Thanks to all who answered! The three answers I would like to highlight are:
The accepted answer - the most "built-in" ...
Hi
I am writing a small program in Perl for my assignment and I am new to Perl.
Code that I have written provides me with exactly the same values I need, but I am getting this error while creating bar chart.
Invalid data set: 0 at line 67
Line 67 is marked with a comment in the code below.
The values stored in x-axis are:
40 44 48...
Hello,
How can I create an anonymous hash from an existing hash?
For arrays, I use:
@x = (1, 2, 3);
my $y = [@x];
but I can't find how to do the same for a hash:
my %x = ();
my $y = ???;
Thanks
...
Below is the code I'm using to run the query, parse the result set, and parse the rows (respectively)
$exec_ret = $DBS->SQLExecSQL($STMT);
while ($DBS->SQLFetch() == *PLibdata::RET_OK)
{
$rowfetch = $DBS->{Row}->GetCharValue($colname[$i]);
}
Can I grab the column/field name of a temp table using similar syntax? $colname[$i] is...
I'm having trouble finding it in the CPAN documentation -- is there a way to create a table (IF NOT EXISTS) from manually-entered Rose::DB::Object metadata?
I'm using SQLite as an engine, if it happens to matter. Thanks!
...
Having a lot of pain with the following Perl file parsing code [last reply on PM @http://www.perlmonks.org/index.pl?node_id=754947] below:
#!/usr/bin/perl -w
use strict;
use warnings;
#use diagnostics;
use Parse::RecDescent;
use Data::Dumper;
# Enable warnings within the Parse::RecDescent module.
$::RD_ERRORS = 1; # Make sure the pa...
Hello,
I have the following piece of code in my program:
$val = chr(someFunction());
if($val == " ")
{
#do something
}
elsif($val == 0)
{
#do something else
}
But whenever 0 is passed to $val, the if part executes instead of the elsif which I expect to get executed.
How can I fix this?
Thank You.
...
I need to write an XS module for Perl. It is my understanding that h2xs is pretty much deprecated today, what is the preferred method for starting an XS module today? I looked at Module::Starter, but it only handles pure Perl modules.
...
Solaris 10 doesn't seem to like me a lot.
I am trying to run a simple script to accept date and return epoch of that date:
#!/usr/bin/perl -w
use strict;
use Time::ParseDate;
my $date1 = "Mon Mar 27 05:54:08 CDT 2009";
#Convert to seconds since start of epoch
my $time1 = parsedate($date1);
print $time1;
Works perfectly fine on RHEL ...
Is it possible to send custom HTML messages to users when they first start a
session through a squid proxy server?
I want to be able to redirect a users first request to the "message of the
Day".... then the rest of their browsing requests for the remainder of the
session go without being redirected.....
Detailed Steps:
User o...
I recently wrote a new Perl script to kill processes based on either process name / user name and extended it using Classes so that I could reuse the process code in other programs. My current layout is -
/home/mutew/src/prod/pskill <-- Perl script
/home/mutew/src/prod/Process.pm <-- Package to handle process descriptions
I ad...
I am drawing a graph using GD::Graph module in Perl.
I can draw the graph fine but in the drawn image I want to add some text around the top of the drawn graph image. Basically just want to add some text to this drawn image. However, I don't see an option to do that.
Does someone know if this is doable?
...
I have a hash which contains a regular expression: the number of matches to be captured in it and variables and their position of match. For example:
my %hash = (
reg_ex => 'Variable1:\s+(.*?)\s+\n\s+Variable2:\s+(.*?)\s+\n',
count => 2,
Variable1 => 1,
Variable2 => 2,
);
I am going to use this regex in some other par...
I want to add my data stored in 2x2 dimension array in Excel using Perl. I know how to open and add simple data. This I can do using for loop. But how can I do it elegantly?
This is what I am trying to do
$sheet->Range("A1:B"."$size")->{Value} = @$data;
or @data;
...
I would like to expose all subs into my namespace without having to list them one at a time:
@EXPORT = qw( firstsub secondsub third sub etc );
Using fully qualified names would require bunch of change to existing code so I'd rather not do that.
Is there @EXPORT_ALL?
I think documentation says it's a bad idea, but I'd like to do it a...