What is the smartest way of searching through an array of strings for a matching string in Perl?
One caveat, I would like the search to be case-insensitive
so "aAa" would be in ("aaa","bbb")
Hi guys,
I am parsing command line options in Perl using Getopt::Long. I am forced to use prefix - (one dash) for short commands (-s) and -- (double dash) for long commands (ex. --input=file), but problem is, that there is one special option (-r=) so it is long option for its requirement for argument, but it has to have one dash (-) prefix not…
I'm sort of new to Perl and I'm wondering if there a prefered unit testing framework?
Google is showing me some nice results, but since I'm new to this, I don't know if there is a clear preference within the community.
I'm looking for an example of redirecting stdout to a file using Perl. I'm doing a fairly straightforward fork/exec tool, and I want to redirect the child's output to a file instead of the parents stdout.
Is there an equivilant of dup2() I should use? I can't seem to find it
could someone provide a good /nice solution in perl for comparing 2 arrays (a and b ) which check if every element on array a is founded on array b (and founded only once on array b) ?
I need to know if there is some way to replace any string as @ or * or ? or & without to put the "\" before it
Example
perl -pe 'next if /^#/; s/\@d\&/new_value/ if /param5/' test
in this example need to replace the @d& with new_value
but I need to put the "\" before @ or &
can be other way without to put the "\" because I…
I'm trying to a good Perl module to use for connecting to a Sybase database.
My Googling has led me to see sybperl as a possible choice, but it hasn't been updated since 2005.
In a perl script, I'm trying to accept input without blocking and without echoing the characters entered (The script is producing output and I want to have 'hotkeys' to alter its behaviour).
I got as far as using
use Term::ReadKey;
ReadMode( "cbreak", STDIN );
if($input = ReadKey($pause_time, STDIN)){
#process input
}
But once the user…
In Perl I would do something like this for taking different fields in a regexp, separating different fields by () and getting them using $
foreach $line (@lines)
{
$line =~ m/(.*?):([^-]*)-(.*)/;
$field_1 = $1
$field_2 = $2
$field_3 = $3
}
How could I do something like this in Python?
Hi,
I am trying extract number, from line has 'copies : 5' string.
this look behind expression not working.
echo "copies : 5" |perl -ne 'print $1 if /(\d+)(?
Thanks
I've installed apache2 on Ubuntu 11.04, and localhost is working. I created a simple printenv.pl script and put it in the following directory
$ mv printenv.pl /usr/lib/cgi-bin/
$ chmod +rx /usr/lib/cgi-bin/printenv.pl
However when I go to http://127.0.0.1/cgi-bin/printenv.pl, I get a 500 Internal Server Error
I checked the error log at…
We're using Catalyst to render lots of webforms in what will become a large application. I don't like the way all the form data is confusingly into a big hash in the Controller, before being passed to the template. It seems jumbled up and messy for the template. I'm sure there are real disadvantages that I haven't described properly... Are…
I've written an extension to RequestTracker for a client, but he says the performance isn't good enough. I'd like to do some profiling, but I'm not sure how to connect up a profiler (say NYTProf, for example)? I tried what the man page says and put PerlModule Devel::NYTProf::Apache in my apache config, but all I get in the results are…
I have a problem in sending and receiving data between php and perl socket:
-Problem:
+php can not send all byte data to perl socket
+Perl socket can not receiving all data from php .
Here code php:
function save(){
unset($_SESSION['info']);
unset($_SESSION['data']);
global $config,$ip;
$start=$_POST['config'];
$fp =…
I am new to the File::Slurp module, and on my first test with it, it was not giving the results I was expecting. It took me a while to figure it out, so now I am interested in why I was seeing this certain behavior.
My call to File::Slurp looked like this:
my @array = read_file( $file ) || die "Cannot read $file\n";
I…
hey guys i have config this miniwebserver, however i require the server to download a file in the local directory i am getting a problem can you please fix my issue thanks
!/usr/bin/perl
use strict;
use Socket;
use IO::Socket;
my $buffer;
my $file;
my $length;
my $output;
Simple web server in Perl
Serves out .html…
For more information see this Example
use strict; use warnings;
use CGI::Simple;
use DBI;
my $cgi = CGI::Simple->new;
my $dsn = sprintf(
'DBI:mysql:database=%s;host=%s',
'cdcol', 'localhost'
);
my $dbh = DBI->connect($dsn, root => '',
{ AutoCommit => 0, RaiseError => 0 }
);
my $status =…
I realize that I am attempting to go beyond the "supported" behavior of the manf's released drivers for Perl, after all they have only released it in package with x86 .so's.
However, since I cannot use their package with x64 Perl on a RHEL 5.4 x86_64 box, and maintaining a seperate install of x86 Perl just for this…
Hi everyone I am having some issues getting Bugzilla setup, I have the software on the server and am trying to get the pre-rec's setup. I am using RedHat 4.1.2-42.
I have all of the required perl modules save one:DBD::mysql
When I try:
sudo perl install-module.pl DBD::mysql
I get the following response(this is…
we're trying to get awstats up and running on our IIS6 server. awstats is running fine and generating output and all that jazz... no problem there.
When trying to change the selected month/year in the output page though, it is trying to run awstats.pl through IIS, and coming up with a 404 error. To debug I made…