I am required to pull out rows corresponding to column name. The rows being pulled out correspond to address in array @values. Following is my code:
use strict;
use DBI;
open (FH, "/user/address") or die $!;
my@values=<FH>;
close(FH);
my @names;
my $query = "Select name from table where address = ?";
my $sth = $dbh->prepare( $query ) ...
I would like to use this:
perl -pi -e 's/^(.*)$/\"$1\",/g' /path/to/your/file
for adding " at beginning of line and ", at end of each line in text file. The problem is that some lines are just empty lines and I don't want these to be altered. Any ideas how to modify above code or maybe do it completely differently?
...
I'm working on a large Perl application which gets bundled with PAR, along with a bunch of support files.
When the app is running within PAR, I can use PAR::read_file to get at these various files inside the archive. However, while I'm developing, I don't want to have to re-PAR the whole application every time I tweak some code.
Is the...
I have one file where the contents looks like:
pch
rch
channel
cap
nch
kappa
.
.
.
kary
ban
....
Now I want to read my file from nch to kary and copying those lines only in some other file. How can I do this in Perl?
...
I have a script that runs on a server and I want it now to send messages to my PC. I want to send TCP or UDP messages to some port.
What is the best way to do this (a tutorial will be great)?
And is there some client program that I can run on my PC that will listen to a local port for the messages?
...
This could seem like an obviously hopeless case, but is there a trick to create a cyclic graph of immutable objects in Perl? Something like this:
package Node;
use Moose;
has [qw/parent child/] => (is => 'ro', isa => 'Node');
package main;
my $a = Node->new;
my $b = Node->new(parent => $a);
Now if I wanted $a->child to point to $b, w...
Hello! Is there a tool that would watch file changes in a directory tree of a Perl application and re-run the test suite every time I save changes to some module? Something akin to masak’s tote.
...
I have a Win32 GUI proccess. Is there any way to control the GUI proccess input within another process (application built in Perl)? the user have a scanning system i want to identify when the keys dispatched by the scanning system check them if they are digits and then suffix them with \n character then send them to the GUI application?
...
In our classes we have a pattern where we create an attribute to represent a
calculated value. For obvious reasons we want to cache the calculated value
and then invalidate the cache when one of the underlying values change.
So we currently have this:
package FooBar;
use Moose;
has 'foo' => (
accessor => {
'foo' ...
I've been using Win32::FileNotify on Windows, and I was curious to know if there were something similar for Linux and OS X. I haven't been able to find such a module using Google. Does anyone here know of such a thing?
...
I'm curious if I can toggle between printing to STDOUT or STDERR based on some value or inline expression (without using an if statement).
print ($someFlag ? STDOUT : STDERR) "hello world!"
Obviously, that syntax doesn't work.
...
I'm aware of the match, prematch, and postmatch predefined variables. I'm wondering if there is something similar for the evaluated replacement part of the s/// operator.
This would be particularly useful in dynamic expressions so they don't have to be evaluated a 2nd time.
For example, I currently have %regexs which is a hash of vari...
When using the perl module LWP::Simple, is there a simple way to determine the speed and amount downloaded by a single getstore() invocation? This would be useful for observing the status of large file downloads.
Off the top of my head, one approach would be to:
store the current time (time0)
run getstore in a new process
poll the kn...
Possible Duplicate:
What is the best Perl module for sending email?
Hello
I need to send mail via my script , using some web mail service.
Not SSL one ,having problems with that thing here .
Is there some module that you can recommend ?
Some example will help also.
Thanks.
...
I am trying to install that module for mail sending .
And i am getting following errors :
Warning: Prerequisite 'IO::Socket::SSL => ' for 'CWEST/Net-SMTP-SSL-1.01.tar.gz'
failed when processing 'SULLR/IO-Socket-SSL-1.31.tar.gz' with 'make_test => NO'
. Continuing, but chances to succeed are limited.
cp lib/Net/SMTP/SSL.pm blib\lib\Net...
I have a simple contact form that I knocked up in a few minutes using NMS FormMail.pl. But the customer has requested that I have a second email address entry field, and validation that kicks them back if the two addresses are different. I could add the validation to FormMail.pl, but before I do, I thought I'd ask if there is a better ...
Here's my current thinking, but I dont know how to dispatch/execute it
my $key;
my @arraydata;
my %commandfunc{
"ab 1", \
foreach $k (keys %commandfunc){
if($something =~ /$k/){ #if $something match with a key string
$key= $k;
#some processing arraydata here;
}
}
#dispatching??
my $command = $commandfunc{$key}-...
I'm moving a website to Hostmonster and asked where the server log is located so I can automatically scan it for CGI errors. I was told, "We're sorry, but we do not have cgi errors go to any files that you have access to."
For organizational reasons I'm stuck with Hostmonster and this awful policy, so as a workaround I thought maybe I'd...
What is the best, in Perl, way to get the selected values of a multiple select form field?
<select name="mult" multiple="multiple">
<option value="1">Opt. 1</option>
<option value="2">Opt. 2</option> <!-- selected -->
<option value="3">Opt. 3</option>
<option value="4">Opt. 4</option> <!-- selected -->
<option value="5">...
I have a hash like so:
my %h = ( a => { one => 1,
two => 2
},
b => { three => 3,
four => 4
},
c => { five => 5,
six => 6
}
);
print join(',', @{$h{a}{qw/one two/}});
The error I get is:
Can't use an undefined value as a...