Nov 27, 2006

Perl and sql connections

Imagine this scenario: you company is running a sql server which is only accesible from your LAN, you cannot use NAT, so you need to acces from you webserver you sql server and show some information.... Then this is the solution to your scenario, there are a few steps you would need to make before star coding:

1.- if you don't have freetds, then download and install freetds you can get it from http://www.freetds.org/
2.- then you would need to go to cpan (search.cpan.org) and downlaod and install perl sybase module, this url might help http://www.linuxjournal.com/article/5732
3.- Then you are ready to query any sql sever as long as you have all ports opened on you LAN to your sql server.

Question are welcomed.. so don't hesitate in contacting me..

Perl and Mysql

You might wonder how to make perl work something similar to php or even asp when querying DB, well here is a code that might help you.

Php as well as asp they allow you to call fields from a record set in the way $rs['field_name'] and perl some times seem to be verydifucult... then this might change your point of views. take a look a t this:

#!/usr/bin/perl

use CGI;
use DBI;
$dbname = "";
$host = "";

my $db = 'DBI:mysql:$dbname:$host';
my $username = 'user';
my $pass = 'password';

my $dbh = DBI->connect($db, $username, $pass);
my $sql = "SELECT * FROM categoria";

$sth = $dbh->prepare($sql);
$sth->execute() or die "Error";

my($count) = $sth->rows();
print "Records: $count\n";

my %row;
$sth->bind_columns( \( @row{ @{$sth->{NAME_lc} } } ));
while ($sth->fetch) {
foreach $key (keys (%row)){
print "\$$key - $row{$key} ** ";
}
print "\n";
}
$sth->finish;
$dbh->disconnect();
exit;



This will code will let you call record set field streight from the query.. supose you have a field name id then you can cal $row{'id'} within the foreach loop.

Hope this is usefull, comments are welcomed..

Perl old but usefull

I amazing how old programming languages as perl still exist and they have proven to be very usefull.

When I first started programming in perl, I thouhgt it was a tough language and that it was not usefull at all, now a days I have discovered that is extremely powerfull and easy to use (if you have programmes in c++ or c, or something similar) I have used it for server maintenance scripts and related tasks as well as web programming. On the long run I have discovered that perl tends to be a little slow and messy for websites so I have moved to PHP, I think asp is to dump for web, so I rather use php or somethign similar.

Its amazing how perl can do a lot of thing that with java would take a lot of time, lets say open a file, with perl you just execute the command:

open(file_handler,"filepath/filename") or print "error\n\n";

on the other hand asp, or java you need to create an instance then open, let't not mention reading a file.

As far as I have used perl, I can say perl is fantastic, and that it will stay for a while.. for more information about perl you can visit cpan.org, perlmonks.org and some other perl related links. in this blogss I will be posting a few codes from perl script I have made and explanning them.

comments are welcome.
Greeting.

Oct 13, 2006

Googletube? who could say that!


At the beginning of this year I got to know you tube and google video because a friend of mine showed me a few videos. Then, a few weeks ago watching CNN, I watched a report on youtube.com where they mentioned that youtube had grown so much and had become a very popular company.

In that news I could see the creators of youtube talk about the history and how had it all started, but now google has acquired them form 1.65 Billion US dollars! WOW!!! It seems that it is profitable to start little websites that can become popular expecting to sell them for a high price later. Form more information on youtube purchase by google you can read this article from TechCrunch: http://www.techcrunch.com/2006/10/09/google-has-acquired-youtube/

I have noticed that huge companies that exist now a days, started a few years behind with a little site or portal as google. When I first met google it was just a search engine.. Now I am using google web accelerator, google search bar, google adsense, google analytics, google pack, and I guess there's more to come from google.

Another case is youtube, who could say that a site that allows you to upload your videos for free to the web could make its price grow as high as 1.65 Billions?. There are some other sites coming up on the list, Hi5.com, seems to be very popular, the question now is: who will purchase hi5? Msn? Yahoo? Google? Going back in history, the first story similar to this one I heard about was hotmail, which was sold to microsoft for a huge amount.

I will try to sit for a while and try to come up with and and Idea that later I can sell for some amount (2.0 billions at least) . At least this seems to be the tendency now a days. Make your site popular and sell it to some huge company.