I'm writing a script to automate some post-install tasks on RHEL4 servers.
I need the following code to insert an 'A' in the middle of a string, then replace the string in a file. I know I can use sed to do this, but I'd like to use perl's in place edit so I don't have to write to a temp file,... (1 Reply)
Hi ,
Can anybody explain how this perl one liner works..
It is to test whether the number is prime or not
perl -le 'print "PRIME" if (1 x shift) !~ /^(11+)\1+$/' 19
Thanks in advance
Shihab (2 Replies)
Thanks for giving your time and effort to answer questions and helping newbies like me understand awk.
I have a huge file, millions of lines, so perl takes quite a bit of time, I'd like to convert these perl one liners to awk.
Basically I'd like all lines with ISA sandwiched between... (9 Replies)
can someone help me translate the following command, from:
/usr/bin/awk "/^$TOFDAYM $TOFDAYD /,0" $LOGFILE
to something like
perl -e .....
basically, i want to use perl to do awk functions within a shell script. i want to do the above awk, using perl.
any suggestions? (9 Replies)
hello,
I want to replace awk with a perl one liner in unix.
i use in awk REGEX and FS ( field separator) because
awk syntaxes in different unix os versions have not the same behaviour.
Awk, Nawk and GNU Awk Cheat Sheet - good coders code, great reuse
i have a file named "file" and want... (5 Replies)
Not quite a unix question but problem in a perl command. Taking a chance if someone knows about the error
cat 1
a b c d
perl -p -e 's/a/b/g' 1
b b c d
What is the problem here??
perl -p -i -e 's/a/b/g' 1
Can't remove 1: Text file busy, skipping file. (2 Replies)
Hi all,
I need a Perl one liner which prints a newline into a .txt file, only where the line starts with "/mediawiki-1.19.0/". It should add the newline to the line before.
My problem is, when I try to realize this (with my little knowledge :rolleyes: ) i come to the point where the // are... (4 Replies)
Greetings fellow scripters.
I find myself editing multiple files, sometimes with the same bits of information. My bash script, a changelog, and a plist file (OS X). Once I realized this, I thought why not script part of this process (and so it begins). In any case, I've solved several of the... (1 Reply)
Hi
I have an inherited perl script that extracts the first three octets of an IP Address using a combination of split() against a dot and then builds it all back together again, its a whole block of code to do this
I wondered if anyone had a one liner in their arsenal to extract the first... (7 Replies)
Discussion started by: hcclnoodles
7 Replies
LEARN ABOUT DEBIAN
cgi::session::driver::dbi
CGI::Session::Driver::DBI(3pm) User Contributed Perl Documentation CGI::Session::Driver::DBI(3pm)NAME
CGI::Session::Driver::DBI - Base class for native DBI-related CGI::Session drivers
SYNOPSIS
require CGI::Session::Driver::DBI;
@ISA = qw( CGI::Session::Driver::DBI );
DESCRIPTION
In most cases you can create a new DBI-driven CGI::Session driver by simply creating an empty driver file that inherits from
CGI::Session::Driver::DBI. That's exactly what sqlite does. The only reason why this class doesn't suit for a valid driver is its name
isn't in lowercase. I'm serious!
NOTES
CGI::Session::Driver::DBI defines init() method, which makes DBI handle available for drivers in Handle - object attribute regardless of
what "\%dsn_args" were used in creating session object. Should your driver require non-standard initialization you have to re-define init()
method in your .pm file, but make sure to set 'Handle' - object attribute to database handle (returned by DBI->connect(...)) if you wish to
inherit any of the methods from CGI::Session::Driver::DBI.
STORAGE
Before you can use any DBI-based session drivers you need to make sure compatible database table is created for CGI::Session to work with.
Following command will produce minimal requirements in most SQL databases:
CREATE TABLE sessions (
id CHAR(32) NOT NULL PRIMARY KEY,
a_session TEXT NOT NULL
);
Your session table can define additional columns, but the above two are required. Name of the session table is expected to be sessions by
default. You may use a different name if you wish. To do this you have to pass TableName as part of your " \%dsn_args ":
$s = CGI::Session->new('driver:sqlite', undef, {TableName=>'my_sessions'});
$s = CGI::Session->new('driver:mysql', undef,
{
TableName=>'my_sessions',
DataSource=>'dbi:mysql:shopping_cart'.
});
To use different column names, change the 'create table' statement, and then simply do this:
$s = CGI::Session->new('driver:pg', undef,
{
TableName=>'session',
IdColName=>'my_id',
DataColName=>'my_data',
DataSource=>'dbi:pg:dbname=project',
});
or
$s = CGI::Session->new('driver:pg', undef,
{
TableName=>'session',
IdColName=>'my_id',
DataColName=>'my_data',
Handle=>$dbh,
});
DRIVER ARGUMENTS
Following driver arguments are supported:
DataSource
First argument to be passed to DBI->connect(). If the driver makes the database connection itself, it will also explicitly disconnect
from the database when the driver object is DESTROYed.
User
User privileged to connect to the database defined in "DataSource".
Password
Password of the User privileged to connect to the database defined in "DataSource"
Handle
An existing DBI database handle object. The handle can be created on demand by providing a code reference as a argument, such as
"<sub{DBI-"connect}>>. This way, the database connection is only created if it actually needed. This can be useful when combined with
a framework plugin like CGI::Application::Plugin::Session, which creates a CGI::Session object on demand as well.
"Handle" will override all the above arguments, if any present.
TableName
Name of the table session data will be stored in.
LICENSING
For support and licensing information see CGI::Session
perl v5.12.4 2011-07-08 CGI::Session::Driver::DBI(3pm)