I have to create a loop, and with a regexp
populate any of the 4 variables
$address, $street, $town, $lot
The loop will be fed a string that may have info in it
like the lines below
'123 any street, mytown' or
'Lot 4 another road, thattown' or
'Lot 2 96 other road, her town' or
'this ave, this town' or
'yourtown'
since anything a...
Let's suppose I have a the following simplified example database consisting of three tables:
CREATE TABLE people (
person_id INTEGER PRIMARY KEY,
person_name VARCHAR(100)
);
CREATE TABLE events (
event_id INTEGER PRIMARY KEY,
event_name VARCHAR(100),
event_creator INTEGER
CONSTRAINT f...
It seems kind of a pain to have my Moose classes. Then to use DBIx::Class to get a result set..then to manually map my result set to the moose classes.
...
I have a Perl-based website that attempts to set a number of cookies on the users first visit and I just noticed that Safari has stopped setting all but the first cookie that is passed. On first visit two cookies should be set which are 'location' and 'referrer'. In IE and Firefox the cookies are being set correctly but Safari is only se...
Good Day,
I would like to use the HTML::Template module. However, it is not installed on the server I'm using to develop CGI scripts.
Is it possible to load a module at runtime: I found the Template.pm file on my local Perl installation and uploaded the file to the server I'm using.
#!/usr/bin/perl -w
use CGI qw(:standard :html4);
...
I'm very new to this Parallel::ForkManager module in Perl and it has a lot of credits, so I think it support what I need and I just haven't figured out yet.
What i need to do is in each child process, it writes some updates into a global hash map, according to the key value computed in each child process. However, when I proceed to cla...
I have 3 questions. I am making a C++ executable to launch a Perl program I made. I will compile it for Winows, Mac OSX and Linux. It's pretty much just: system("perl progam.pl");
When compiled with Mac OSX, the program starts in ~. How would I get it to start in the dir it was launched from, or is it just a problem with the compiler?
...
Can someone please explain why push behaves the way as shown below?
Basically I am trying to print values of an array populated by push as well unshift.
When I try to print array contents populated by push using array indexes, It always prints the element at the top of the array, whereas array populated by unshift prints contents of a...
Possible ways:
Using push:
my @list;
push @list, 'foo' if $foo;
push @list, 'bar' if $bar;
Using the conditional operator:
my @list = (
$foo ? 'foo' : (),
$bar ? 'bar' : (),
);
Using the x!! Boolean list squash operator:
my @list = (
('foo') x!! $foo,
('bar') x!! $bar,
);
Wh...
I have a file which has a line in it as:
/hosting/logs/U01-ecom-SIT01/CU01-DC05-IFIO_SIT01_NU01-nc3sz1ecmas11/waslogs/SystemOut_10.01.21_16.54.18.log`
I need a script which would read this line and remove the time stamp from it, that is:
10.01.21_16.54.18
The script should print the filename without the timestamp and holding the...
Is there a way to disabling a WRAPPER that was set in new(\%config), through either the template, or a temporary override with parse()? I want to have a single default WRAPPER (that I'll use for 99.9% of my templates), but exclude a few.
I'm doing this all through Catalyst::View::TT just like the example in the configuration synopsis, ...
Is there a function i can use in Perl to sanitize input before putting it into a MySQL db? I don't know regex very well so before I make my own function i was wondering if there was already one made.
...
I want to write a Net::Server chat server, probably using PreFork, with process tied to an active client. How do I "talk" between clients, with the proper filtering?
...
I have a small program:
#!/user/bin/perl
use strict;
system ("clear");
my($option, $path);
do
{
print "\tEnter the number of your chosen option:\n";
print "\n";
print "\tOption\t\tCommand\n";
print "\t======\t\t=======\n";
print "\t1\t\tDate\n";
print "\t2\t\tDirectory Listing\n";
print "\t3\t\tCalendar...
For example, given an empty file テスト.txt, how would I make a copy called テスト.txt.copy?
My first crack at it managed to access the file and create the new filename, but the copy generated テスト.txt.copy.
Here was my first crack at it:
#!/usr/bin/env perl
use strict;
use warnings;
use English '-no_match_vars';
use File::Basename;
...
Hey everyone,
I'm trying to use regex in Perl. What I was wonder was if it is possible to store all matches to the expression into an array? I know I can use the following: ($1,...,$n) = m/expr/g; but it seems as though that can only be used if you know the number of matches you are looking for. I have tried my @array = m/expr/g; but ...
Hi,
I would like to replace parent function (Somefunc) in child class, so when I call Main procedure it should fail.
Is it possible in Perl?
Code:
package Test;
use strict;
use warnings;
sub Main()
{
SomeFunc() or die "Somefunc returned 0";
}
sub SomeFunc()
{
return 1;
}
package Test2;
use strict;
use warnings;
our @ISA...
I have an array @test. What's the best way to check if each element of the array is the same string?
I know I can do it with a foreach loop but is there a better way to do this? I checked out the map function but I'm not sure if that's what I need.
...
I have a big paragraph which I need to split into lines such that each line must not have more than 100 characters and no words must be broken. How would I go about doing this? I guess with regular expressions is the best way but I'm not sure how.
...
I have a application executable, which runs with different parameters to produce different outputs. I want to give some parameters to this from the command line parameters of the script and others will be local to the script. Usage:
./dump-output.pl <version> <folder-name> <output-file>
my $version = $ARGV[0];
my $foldername = $ARGV[1...