perl mysql 
my $dsn = 'dbi:mysql:dbname:localhost:3306';

# set the user and password
my $user = 'user';
my $pass = 'pass';

# now connect and get a database handle
my $dbh = DBI->connect($dsn, $user, $pass)
or die "Can’t connect to the DB: $DBI::errstr\n"

my $sth = $dbh->prepare('insert into subscribers(username, emailaddr)
values "jim", "jim@microsoft.com")');

Then you can execute it:

$sth->execute();

my $sth = $dbh->prepare("select username, email from subscribers");
$sth->execute;

while(@row = $sth->fetchrow_array()) {
print "$row[0]: $row[1]<br>";
}
As you can see, $sth->fetchrow_array returns an array of the results. If you like, you could write the loop like this to make it a bit more readable:

while(my($username, $email) = $sth->fetchrow_array()) {
print "$username: $email<br>";
}

[ add comment ]   |  permalink  |   ( 3 / 25 )
perl CGI 
use CGI;

my $q = CGI->new;

# Process an HTTP request
@values = $q->param('form_field');

$fh = $q->upload('file_field');

$riddle = $query->cookie('riddle_name');
%answers = $query->cookie('answers');

# Prepare various HTTP responses
print $q->header();
print $q->header('application/json');

$cookie1 = $q->cookie(-name=>'riddle_name', -value=>"The Sphynx's Question");
$cookie2 = $q->cookie(-name=>'answers', -value=>\%answers);
print $q->header(
-type => 'image/gif',
-expires => '+3d',
-cookie => [$cookie1,$cookie2]
);

print $q->redirect('http://somewhere.else/in/movie/land');

[ add comment ]   |  permalink  |   ( 3.1 / 34 )
Perl contenttype 
print "Content-type: text/html\n\n";

[ add comment ] ( 1 view )   |  permalink  |   ( 3 / 72 )
Apache Htaccess 
.htaccess

AuthUserFile /home/sandeep/install/ixquick/data/Admin_Passwords
AuthGroupFile /home/sandeep/install/ixquick/data/Admin_Passwords.Groups
AuthName "Ixquick Partners"
AuthType Basic
<Limit GET POST PUT>
require group ixadmins ixpartners belzabarteam
require user guest
</Limit>

Options +ExecCGI
AddHandler cgi-script cgi pl


[ add comment ] ( 1 view )   |  permalink  |   ( 3 / 71 )
Perl smiple wordwrap 
$data_hr->{URL} =~ s/.{1,80}/$& /sg; ## Perl simple "wordwrap"

[ add comment ] ( 1 view )   |  permalink  |   ( 3 / 65 )
iphone useragent 
Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3

[ add comment ] ( 1 view )   |  permalink  |   ( 2.9 / 39 )
STDERR Redirect 
The following redirects both stdout and stderr into a file named tmp

sh <filename> 1>tmp 2>&1

[ add comment ] ( 1 view )   |  permalink  |   ( 2.8 / 34 )
Slide Show more then one image in Java Script 


<html>
<title>:: Image Rotation ::</title>


<a href="" id="link1"><img src="" name="Rotating1" id="Rotating1" height="100" width="100"></a>
<a href="" id="link2"><img src="" name="Rotating2" id="Rotating2" height="100" width="100"></a>
<a href="" id="link3"><img src="" name="Rotating3" id="Rotating3" height="100" width="100"></a>

<script language="JavaScript">
var ImageArr1 = new Array('1.gif','2.gif','3.gif');
var ImageHolder1 = document.getElementById('Rotating1');
var urlHolder1 = document.getElementById('link1');
var url1=new Array('http://www.tigersportsmarketing.com/cms/index.php?option=com_expose&Itemid=3&topcoll=7&album=5&photo=1&playslideshow=yes','google2.com','google3.com');

var ImageArr2 = new Array('4.gif','5.jpg','6.jpg');
var ImageHolder2 = document.getElementById('Rotating2');
var urlHolder2 = document.getElementById('link2');
var url2=new Array('google4.com','google5.com','google6.com');

var ImageArr3 = new Array('7.jpg','8.jpg','9.jpg');
var ImageHolder3 = document.getElementById('Rotating3');
var urlHolder3 = document.getElementById('link3');
var url3=new Array('google7.com','google8.com','google9.com');

function RotateImages(whichHolder,Start)
{
var a = eval("ImageArr"+whichHolder);
var b = eval("ImageHolder"+whichHolder);
var ur=eval("urlHolder"+whichHolder);
var u=eval("url"+whichHolder);
if(Start>=a.length)
Start=0;
b.src = a[Start];
ur.href=u[Start];
window.setTimeout("RotateImages("+whichHolder+","+(Start+1)+")",3000);

}

RotateImages(1,0);
RotateImages(2,4);
RotateImages(3,7);

</script>
<body>



</body>
</html>


[ add comment ] ( 1 view )   |  permalink  |   ( 2.9 / 64 )
Change something in multiple files using Find 
find ./ -name 'index.cgi' -exec sed -i 's#$shortboardname = "";#$shortboardname = "";\n$meta_title= "ESL/TEFL Jobs";#' '{}' \;

[ add comment ] ( 1 view )   |  permalink  |   ( 3 / 50 )
Copy a folder from one folder to multiple folders 
perl -e 'opendir DR,".";@files = grep {/tesl/} readdir DR;foreach (@files) {next if ! -d $_; print $_,"\n";$x=qq{cp -rf ~/public_html/esl-tesol-jobs/captcha/ $_/};print $x,"\n";qx{$x};} closedir DR;'

[ add comment ] ( 1 view )   |  permalink  |   ( 3 / 52 )

<<First <Back | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Next> Last>>