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 OSX
dbd::sponge
DBD::Sponge(3) User Contributed Perl Documentation DBD::Sponge(3)NAME
DBD::Sponge - Create a DBI statement handle from Perl data
SYNOPSIS
my $sponge = DBI->connect("dbi:Sponge:","","",{ RaiseError => 1 });
my $sth = $sponge->prepare($statement, {
rows => $data,
NAME => $names,
%attr
}
);
DESCRIPTION
DBD::Sponge is useful for making a Perl data structure accessible through a standard DBI statement handle. This may be useful to DBD module
authors who need to transform data in this way.
METHODS
connect()
my $sponge = DBI->connect("dbi:Sponge:","","",{ RaiseError => 1 });
Here's a sample syntax for creating a database handle for the Sponge driver. No username and password are needed.
prepare()
my $sth = $sponge->prepare($statement, {
rows => $data,
NAME => $names,
%attr
}
);
o The $statement here is an arbitrary statement or name you want to provide as identity of your data. If you're using DBI::Profile it
will appear in the profile data.
Generally it's expected that you are preparing a statement handle as if a "select" statement happened.
o $data is a reference to the data you are providing, given as an array of arrays.
o $names is a reference an array of column names for the $data you are providing. The number and order should match the number and
ordering of the $data columns.
o %attr is a hash of other standard DBI attributes that you might pass to a prepare statement.
Currently only NAME, TYPE, and PRECISION are supported.
BUGS
Using this module to prepare INSERT-like statements is not currently documented.
AUTHOR AND COPYRIGHT
This module is Copyright (c) 2003 Tim Bunce
Documentation initially written by Mark Stosberg
The DBD::Sponge module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. In particular
permission is granted to Tim Bunce for distributing this as a part of the DBI.
SEE ALSO
DBI
perl v5.16.2 2011-09-14 DBD::Sponge(3)