[25221] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 7466 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 30 14:11:05 2004

Date: Tue, 30 Nov 2004 11:10:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 30 Nov 2004     Volume: 10 Number: 7466

Today's topics:
    Re: looking for simple code to build a search engine <amead@comcast.net>
    Re: looking for simple code to build a search engine <jwillmore@fastmail.us>
    Re: looking for simple code to build a search engine <tadmc@augustmail.com>
    Re: looking for simple code to build a search engine <amead@comcast.net>
    Re: Minimize black screen <jimsimpson@cox.net>
    Re: MLDBM error <z3r0.00 @ gmail.com>
    Re: perl trim function (Anno Siegel)
    Re: perl trim function (Anno Siegel)
    Re: perl trim function <uri@stemsystems.com>
    Re: perl trim function <tassilo.von.parseval@rwth-aachen.de>
    Re: perl trim function <uri@stemsystems.com>
    Re: perl trim function <tassilo.von.parseval@rwth-aachen.de>
    Re: Question about implementing range operator with str bayxarea-usenet@yahoo.com
    Re: Question about implementing range operator with str <tadmc@augustmail.com>
    Re: Regarding Usage on Perl <tadmc@augustmail.com>
        SQLite - problem connecting to database (or doing a sel <lardattardisdoteddotacdotuk@mailinator.com>
    Re: SQLite - problem connecting to database (or doing a <amead@comcast.net>
    Re: SQLite - problem connecting to database (or doing a <lardattardisdoteddotacdotuk@mailinator.com>
    Re: SQLite - problem connecting to database (or doing a <jwillmore@fastmail.us>
    Re: SQLite - problem connecting to database (or doing a <nospam@nospam.com>
    Re: SQLite - problem connecting to database (or doing a <lardattardisdoteddotacdotuk@mailinator.com>
    Re: SQLite - problem connecting to database (or doing a <amead@comcast.net>
    Re: Storing a substitution (similar to qr()) <usenet@morrow.me.uk>
    Re: System command <varunjindal@yahoo.com>
    Re: System command <eon@hotmail.com>
    Re: System command <tony_curtis32@yahoo.com>
        Telnet - groupd id <nospam@spam.com>
    Re: Telnet - groupd id <jwillmore@fastmail.us>
    Re: Transiting from Perl: Learn Python or Ruby? <usenet@morrow.me.uk>
        Write at the beginning of a file <200410+news@pobox.com>
    Re: Write at the beginning of a file <jurgenex@hotmail.com>
    Re: Write at the beginning of a file <200410+news@pobox.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 30 Nov 2004 09:51:04 -0600
From: Alan Mead <amead@comcast.net>
Subject: Re: looking for simple code to build a search engine
Message-Id: <pan.2004.11.30.15.51.03.235998@comcast.net>

On Tue, 30 Nov 2004 09:47:37 +0000, Marcel wrote:

> looks something like "url= .... thumb= ... title= .... keywords= ...".
> The keywords-part (of course) must be scanned, and if a match is found,
> then the title, url and thumbnail must be returned to the search page.

You'll get your hand slapped if you ask CGI question here that really have
nothing to do with Perl.  Try comp.infosystems.www.authoring.cgi for those
sorts of questions but feel free to ask about PERL stuff here.

But here is some Perl advice:  You'll be re-inventing a fair bit of
wheel... not that you would be the first Perl hacker to do so....

But I wouldn't re-invent the database part.  Look into dbm or an SQL
database. dbm is simpler. It's like a hash on disk.  I would use two dbm
files. First, store your url+thumb+title in one with some sort of unique
key (it could be a sequential number).  Then store each keyword with the
unique key in a second dbm file.  You would have to code the search to
open the second file, find the unique keys of the matching keywords and
then open the first file to retrieve those records by the unique keys.

But this is clearly a tuple relationship where the unique key to your
pictures is the foreign key to the second table (or.. I reversed them).
I'm sure you would be better off using a good SQL engine which adds the
possibility of doing 'LIKE %keyword%' searches. Of course, you need to
learn some SQL. There are lots of good RDBMS for those level of use...
MySQL is very popular. You could also use SQLite or something similar if
you don't want to get into (or cannot) install something weighty.

Don't store your thumbnails in the database, just store the path to the
file.

-Alan


------------------------------

Date: Tue, 30 Nov 2004 12:15:01 -0500
From: James Willmore <jwillmore@fastmail.us>
Subject: Re: looking for simple code to build a search engine
Message-Id: <pan.2004.11.30.17.14.59.907440@fastmail.us>

On Tue, 30 Nov 2004 09:47:37 +0000, Marcel wrote:

> I have a hobby website with many, many pages with pictures on which I
> want to install a search engine. The ones I've had a look at don't
> exactly do what I want. So I want to make it myself. On the other hand,
> I'm completely new to Perl - it does work fine on my computer though. My
> idea is as follows:
> any search on my website looks into a file (search.txt) of which each
> line looks something like "url= .... thumb= ... title= .... keywords=
> ...". The keywords-part (of course) must be scanned, and if a match is
> found, then the title, url and thumbnail must be returned to the search
> page. The search.txt is fed by my pictures database. Is there something
> out there that I can use?

Try searching Freshmeat (http://freshmeat.net/).  There are scripts there
that will do exactly (or, at least, similar) to what you want to do.

Or, use Google :-)

HTH

Jim


------------------------------

Date: Tue, 30 Nov 2004 12:03:21 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: looking for simple code to build a search engine
Message-Id: <slrncqpdf9.48l.tadmc@magna.augustmail.com>

Alan Mead <amead@comcast.net> wrote:

> feel free to ask about PERL stuff here.


That would be "Perl stuff", not "PERL stuff".

The name of the language is not an acronym (the Perl FAQ says so).


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 30 Nov 2004 12:28:28 -0600
From: Alan Mead <amead@comcast.net>
Subject: Re: looking for simple code to build a search engine
Message-Id: <pan.2004.11.30.18.28.28.933376@comcast.net>

On Tue, 30 Nov 2004 12:03:21 -0600, Tad McClellan wrote:

> Alan Mead <amead@comcast.net> wrote:
> 
>> feel free to ask about PERL stuff here.
> 
> That would be "Perl stuff", not "PERL stuff".
> 
> The name of the language is not an acronym (the Perl FAQ says so).

That would be SHOUTING :)

-Alan


------------------------------

Date: Tue, 30 Nov 2004 09:06:25 -0500
From: "jim simpson" <jimsimpson@cox.net>
Subject: Re: Minimize black screen
Message-Id: <18%qd.587$Nj4.246@lakeread01>

Thanks to all who responded. Many good ideas.

Jim


"jim simpson" <jimsimpson@cox.net> wrote in message
news:sFHqd.4076$QR.3735@lakeread01...
> Is there anyway to minimize the black screen while a Perl script is
running
> an then return it to normal just before the script comcludes?
>
> Thanks,
>
> Jim
>
>




------------------------------

Date: Tue, 30 Nov 2004 23:59:54 +1100
From: Mark Ng <z3r0.00 @ gmail.com>
Subject: Re: MLDBM error
Message-Id: <pan.2004.11.30.12.59.53.922177@gmail.com>

On Mon, 29 Nov 2004 23:13:54 -0500, Bob Walton wrote:

> 
> Just a guess:  The problem is probably with the DB_File end of things -- 
> DMB-type files tend not to be portable across platforms/versions or 
> perhaps even nominally similar computers (depending on what compilation 
> options were used for each system).  You may need to go back to the same 
> platform/version where the file was written in order to read it, and 
> there generate an ASCII dump of the key/value pairs to bring to your 
> current system to regenerate the DB_File file.  

Yes, found a machine with Perl 5.6 and it worked perfectly.

> DBM-type files are not a 
> good choice for archiving data.

Yes, definitely.


mark



------------------------------

Date: 30 Nov 2004 11:52:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl trim function
Message-Id: <cohmta$31p$1@mamenchi.zrz.TU-Berlin.DE>

Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:

[...]

> 	sub trim {
> 
> 		my $str_ref = defined wantarray ? \"$_[0]" : \$_[0] ;
> 
> 		$$str_ref =~ s/^\s+// ;
> 		$$str_ref =~ s/\s+$// ;
> 
> 		return $$str_ref if defined wantarray ;
> 		return ;
> 	}
> 
> there could be a better way to get a ref to a copy of $_[0] but that
> should work ok.

That's the lack in Perl of an anonymous scalar ref constructor.

I don't see an attractive alternative to quoting (or $_[ 0] . '' and
equivalent).  One could say "... ? my $x = shift : shift;" instead,
but that's neither cleaner nor clearer.  Here's a ref-free
alternative:

    sub trim {
        for ( defined wantarray ? my $x = shift : shift ) {
            s/^\s+//;
            s/\s+$//;
            return $_ if defined wantarray;
        }
    }

Anno


------------------------------

Date: 30 Nov 2004 12:08:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl trim function
Message-Id: <cohnrb$3k4$1@mamenchi.zrz.TU-Berlin.DE>

Arndt Jonasson  <do-not-use@invalid.net> wrote in comp.lang.perl.misc:
> 
> Uri Guttman <uri@stemsystems.com> writes:
> > >>>>> "AJ" == Arndt Jonasson <do-not-use@invalid.net> writes:
> >   AJ> sub trim ($) {
> >   AJ>     if (! defined wantarray) {
> >   AJ> 	trim1 \$_[0];
> >   AJ> 	return;
> >   AJ>     }
> > 
> > eww, prototypes! steer clear of them in general.
> 
> Oh. I thought they were meant to be useful, for example catching incorrect
> calling usage. What are the arguments against them?

Tom Christansen has written the "classical" paper on prototypes and
their drawbacks.  Google for "tchrist prototypes".

Anno


------------------------------

Date: Tue, 30 Nov 2004 16:35:33 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: perl trim function
Message-Id: <x7zn0z47mz.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:
  AS> [...]

  >> my $str_ref = defined wantarray ? \"$_[0]" : \$_[0] ;

  >> there could be a better way to get a ref to a copy of $_[0] but that
  >> should work ok.

  AS> That's the lack in Perl of an anonymous scalar ref constructor.

yep.

  AS> I don't see an attractive alternative to quoting (or $_[ 0] . '' and
  AS> equivalent).  One could say "... ? my $x = shift : shift;" instead,
  AS> but that's neither cleaner nor clearer.  Here's a ref-free
  AS> alternative:

  AS>     sub trim {
  AS>         for ( defined wantarray ? my $x = shift : shift ) {
  AS>             s/^\s+//;
  AS>             s/\s+$//;
  AS>             return $_ if defined wantarray;
  AS>         }
  AS>     }

i like it but it took a while for my morning eyes to follow the aliasing
levels. i never realized that shift kept the same aliasing as $_[0] but
i rarely use shift on @_ or the aliasing like that. and we both have the
duplicate use of wantarray but i don't see any easy way around that.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Tue, 30 Nov 2004 17:52:15 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: perl trim function
Message-Id: <slrncqp99v.th.tassilo.von.parseval@localhost.localdomain>

Also sprach Uri Guttman:

>>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

>  AS> I don't see an attractive alternative to quoting (or $_[ 0] . '' and
>  AS> equivalent).  One could say "... ? my $x = shift : shift;" instead,
>  AS> but that's neither cleaner nor clearer.  Here's a ref-free
>  AS> alternative:
>
>  AS>     sub trim {
>  AS>         for ( defined wantarray ? my $x = shift : shift ) {
>  AS>             s/^\s+//;
>  AS>             s/\s+$//;
>  AS>             return $_ if defined wantarray;
>  AS>         }
>  AS>     }
>
> i like it but it took a while for my morning eyes to follow the aliasing
> levels. i never realized that shift kept the same aliasing as $_[0] but
> i rarely use shift on @_ or the aliasing like that. and we both have the
> duplicate use of wantarray but i don't see any easy way around that.

There is no need for the second wantarray check. It doesn't really harm
to return a value in void context. :-) As for the aliasing effect of
shift, I am not too much a fan of that either, so I'd write the whole
thing thusly:

    sub trim ($) {
	local *_ = defined wantarray ? \(my $dummy = shift) : \$_[0];
	s/^\s+//;
	s/\s+$//;
	return $_;
    }

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: Tue, 30 Nov 2004 17:49:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: perl trim function
Message-Id: <x7oehf447j.fsf@mail.sysarch.com>


  TvP> There is no need for the second wantarray check. It doesn't really harm
  TvP> to return a value in void context. :-) As for the aliasing effect of
  TvP> shift, I am not too much a fan of that either, so I'd write the whole
  TvP> thing thusly:

  TvP> sub trim ($) {
  TvP> 	 local *_ = defined wantarray ? \(my $dummy = shift) : \$_[0];
  TvP> 	 s/^\s+//;
  TvP> 	 s/\s+$//;
  TvP> 	 return $_;
  TvP> }

and now we can drop the prototype and allow trim to work on $_ if there
are no arguments:

    sub trim {
	local *_ = defined wantarray ? \(my $dummy = shift) : \$_[0] if @_ ;
	s/^\s+//;
	s/\s+$//;
	return $_;
    }

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Tue, 30 Nov 2004 19:57:15 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: perl trim function
Message-Id: <slrncqpgkb.18d.tassilo.von.parseval@localhost.localdomain>

Also sprach Uri Guttman:

>   TvP> sub trim ($) {
>   TvP> 	 local *_ = defined wantarray ? \(my $dummy = shift) : \$_[0];
>   TvP> 	 s/^\s+//;
>   TvP> 	 s/\s+$//;
>   TvP> 	 return $_;
>   TvP> }
>
> and now we can drop the prototype and allow trim to work on $_ if there
> are no arguments:
>
>     sub trim {
> 	local *_ = defined wantarray ? \(my $dummy = shift) : \$_[0] if @_ ;
> 	s/^\s+//;
> 	s/\s+$//;
> 	return $_;
>     }

Even better. Amazing how a bunch of people can occupy their minds for
several days to find the best five lines of Perl code for a given minor
problem. :-)

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: 30 Nov 2004 06:04:04 -0800
From: bayxarea-usenet@yahoo.com
Subject: Re: Question about implementing range operator with strings
Message-Id: <1101823444.871048.18760@z14g2000cwz.googlegroups.com>

Thanks for your reply.

After seeing that it worked for you - I looked further into the data as
it coming into the function I wrote.
As it turns out, the data included \r s instead of \n s as line
seperators - so I didn't have the lines as elements as I thought I did.

I changed my split to (@data_from_file) = split /\n|\r/,$data

and now it has the lines - and the range operator does work as you
suggested.

Thanks!


John



------------------------------

Date: Tue, 30 Nov 2004 12:04:51 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Question about implementing range operator with strings
Message-Id: <slrncqpdi3.48l.tadmc@magna.augustmail.com>

bayxarea-usenet@yahoo.com <bayxarea-usenet@yahoo.com> wrote:

> I changed my split to (@data_from_file) = split /\n|\r/,$data


   @data_from_file = split /[\n\r]/,$data


would be better.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 30 Nov 2004 07:52:57 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regarding Usage on Perl
Message-Id: <slrncqoupp.384.tadmc@magna.augustmail.com>

azbycx_47@yahoo.com <azbycx_47@yahoo.com> wrote:

> and so thought of posting a query to this mailing
> list.


This is not a mailing list (though there is an email->news gateway).

This is a Usenet newsgroup.

The difference can matter.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 30 Nov 2004 16:27:51 +0000
From: Alex Hunsley <lardattardisdoteddotacdotuk@mailinator.com>
Subject: SQLite - problem connecting to database (or doing a select)
Message-Id: <10qp7s3s51pif83@corp.supernews.com>

I've having a problem running a tiny snippet of test code that uses 
SQLite to connect to a local database (I'm running xampp on my local 
machine which includes mysql).

Firstly, just to demonstrate that I really do have a live database which 
is running:

$ mysql -h 127.0.0.1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16 to server version: 4.0.20a-debug-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use pmaster;
Database changed
mysql> show tables;
+---------------------+
| Tables_in_pmaster |
+---------------------+
| campaigns           |
| data                |
| logging             |
+---------------------+
3 rows in set (0.00 sec)

mysql>


Now, I've installed SQLite and am running this perl code:



----8<----

use DBI;

my $dbh = DBI->connect('dbi:SQLite:pmaster',
     '', '') || die("problem: ".DBI->errstr);


$results = $dbh->selectall_arrayref('SELECT * FROM data');

print "results=".$results."\n";

----8<----


when I run this, the output is as follows:

$ ./sqlTest.pl
DBD::SQLite::db selectall_arrayref failed: no such table: data(1) at 
dbdimp.c line 263 at ./sqlTest.pl line 24.
results=

No such table it says, yet clearly the database pmaster is there and 
does contain a table called data (see the mysql monitor stuff at the top).






------------------------------

Date: Tue, 30 Nov 2004 10:41:40 -0600
From: Alan Mead <amead@comcast.net>
Subject: Re: SQLite - problem connecting to database (or doing a select)
Message-Id: <pan.2004.11.30.16.41.40.778145@comcast.net>

On Tue, 30 Nov 2004 16:27:51 +0000, Alex Hunsley wrote:

> I've having a problem running a tiny snippet of test code that uses
> SQLite to connect to a local database (I'm running xampp on my local
> machine which includes mysql).

SQLite doesn't connect to other RDBMS... it's claim to fame is that it is
it's own RDBMS.  So the error you're getting says "There is no SQLite
database of that name" which is true because it's a *MySQL* database.

You need to pick one, MySQL or SQLite for your project. Both come with a
client and a DBD library for accessing them in Perl.

-Alan


------------------------------

Date: Tue, 30 Nov 2004 16:57:22 +0000
From: Alex Hunsley <lardattardisdoteddotacdotuk@mailinator.com>
Subject: Re: SQLite - problem connecting to database (or doing a select)
Message-Id: <10qp9jf4cftptf6@corp.supernews.com>

Alan Mead wrote:
> On Tue, 30 Nov 2004 16:27:51 +0000, Alex Hunsley wrote:
> 
> 
>>I've having a problem running a tiny snippet of test code that uses
>>SQLite to connect to a local database (I'm running xampp on my local
>>machine which includes mysql).
> 
> 
> SQLite doesn't connect to other RDBMS... it's claim to fame is that it is
> it's own RDBMS.  So the error you're getting says "There is no SQLite
> database of that name" which is true because it's a *MySQL* database.
> 
> You need to pick one, MySQL or SQLite for your project. Both come with a
> client and a DBD library for accessing them in Perl.

I've recently realised my folly :)
Basically, I just want to be able to access an sql database from perl. I 
thought it would be simple to get going :[
Been trying to get DBD::mysql going; latest is to download DBD::mysql 
manually and configure it that way, but problems with that too.
Unfortunately I don't have time to spend ages just getting perl to talk 
to an SQL server due to a looming deadline, so I may just have to ditch 
the perl idea and find something else I can get working quickly.
I don't suppose you know of a simple-to-get-working module that would 
fulfill my wildest SQL server connection dreams?

thanks
alex







------------------------------

Date: Tue, 30 Nov 2004 12:39:36 -0500
From: James Willmore <jwillmore@fastmail.us>
Subject: Re: SQLite - problem connecting to database (or doing a select)
Message-Id: <pan.2004.11.30.17.39.34.539266@fastmail.us>

On Tue, 30 Nov 2004 16:57:22 +0000, Alex Hunsley wrote:

> Alan Mead wrote:
>> On Tue, 30 Nov 2004 16:27:51 +0000, Alex Hunsley wrote:
>> 
>> 
>>>I've having a problem running a tiny snippet of test code that uses
>>>SQLite to connect to a local database (I'm running xampp on my local
>>>machine which includes mysql).
>> 
>> 
>> SQLite doesn't connect to other RDBMS... it's claim to fame is that it is
>> it's own RDBMS.  So the error you're getting says "There is no SQLite
>> database of that name" which is true because it's a *MySQL* database.
>> 
>> You need to pick one, MySQL or SQLite for your project. Both come with a
>> client and a DBD library for accessing them in Perl.
> 
> I've recently realised my folly :)
> Basically, I just want to be able to access an sql database from perl. I 
> thought it would be simple to get going :[
> Been trying to get DBD::mysql going; latest is to download DBD::mysql 
> manually and configure it that way, but problems with that too.
> Unfortunately I don't have time to spend ages just getting perl to talk 
> to an SQL server due to a looming deadline, so I may just have to ditch 
> the perl idea and find something else I can get working quickly.
> I don't suppose you know of a simple-to-get-working module that would 
> fulfill my wildest SQL server connection dreams?


A few suggestions ....

1) You *might* be able to use the DBD::Proxy module to connect. 
Basically, if you can install DBD::mysql on the machine that has MySQL
installed, you could run a proxy on that box and have the clients
(scripts) connect to the proxy.  I can't say I've ever done it, but I've
read about it :-)

2) Try another DBD module.  For example, you might be able to use the
DBD::JDBC module to connect to the MySQL database.  Now all you need to do
is use the appropriate Java driver for connection (far easier to install
:-) ).  Or DBD::ODBC.  *Most* RDBMS's support ODBC connections.  Simple if
you're on a Windows box, a little more effort of you use *nix box.

3) Use the MySQL client application within Perl using 'system' or 'open'
or some other method used to execute commands within Perl.

4) For pre-made scripts and applications, visit Freshmeat
(http://freshmeat.net).  I'm sure you'll find something there :-)

Of course, you could just follow the directions given in the DBD::mysql
README to install the proper driver :-)  And contact the suthor of the
module if you're having that much trouble installing it :-)

HTH

Jim


------------------------------

Date: Tue, 30 Nov 2004 12:52:57 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: SQLite - problem connecting to database (or doing a select)
Message-Id: <1101837276.276477@nntp.acecape.com>

"Alex Hunsley" <lardattardisdoteddotacdotuk@mailinator.com> wrote in message
news:10qp9jf4cftptf6@corp.supernews.com...
> Basically, I just want to be able to access an sql database from perl. I
> thought it would be simple to get going :[


forgive my naiveness but i thought DBI comes standard with Perl and is
perfect for MySQL, and MySQL is free.....if you look at my past posts here
you will see i am band spanking new to Perl, had tons of problems,
etc....but the connecting and working with MySQL from Perl was practically a
breeze....so again, maybe i misread your question?





------------------------------

Date: Tue, 30 Nov 2004 17:59:41 +0000
From: Alex Hunsley <lardattardisdoteddotacdotuk@mailinator.com>
Subject: Re: SQLite - problem connecting to database (or doing a select)
Message-Id: <10qpd8ask3qkf9d@corp.supernews.com>

James Willmore wrote:
> On Tue, 30 Nov 2004 16:57:22 +0000, Alex Hunsley wrote:
> 
> 
>>Alan Mead wrote:
>>
>>>On Tue, 30 Nov 2004 16:27:51 +0000, Alex Hunsley wrote:
>>>
>>>
>>>
>>>>I've having a problem running a tiny snippet of test code that uses
>>>>SQLite to connect to a local database (I'm running xampp on my local
>>>>machine which includes mysql).
>>>
>>>
>>>SQLite doesn't connect to other RDBMS... it's claim to fame is that it is
>>>it's own RDBMS.  So the error you're getting says "There is no SQLite
>>>database of that name" which is true because it's a *MySQL* database.
>>>
>>>You need to pick one, MySQL or SQLite for your project. Both come with a
>>>client and a DBD library for accessing them in Perl.
>>
>>I've recently realised my folly :)
>>Basically, I just want to be able to access an sql database from perl. I 
>>thought it would be simple to get going :[
>>Been trying to get DBD::mysql going; latest is to download DBD::mysql 
>>manually and configure it that way, but problems with that too.
>>Unfortunately I don't have time to spend ages just getting perl to talk 
>>to an SQL server due to a looming deadline, so I may just have to ditch 
>>the perl idea and find something else I can get working quickly.
>>I don't suppose you know of a simple-to-get-working module that would 
>>fulfill my wildest SQL server connection dreams?
> 
> 
> 
> A few suggestions ....
> 
> 1) You *might* be able to use the DBD::Proxy module to connect. 
> Basically, if you can install DBD::mysql on the machine that has MySQL
> installed, you could run a proxy on that box and have the clients
> (scripts) connect to the proxy.  I can't say I've ever done it, but I've
> read about it :-)
> 
> 2) Try another DBD module.  For example, you might be able to use the
> DBD::JDBC module to connect to the MySQL database.  Now all you need to do
> is use the appropriate Java driver for connection (far easier to install
> :-) ).  Or DBD::ODBC.  *Most* RDBMS's support ODBC connections.  Simple if
> you're on a Windows box, a little more effort of you use *nix box.
> 
> 3) Use the MySQL client application within Perl using 'system' or 'open'
> or some other method used to execute commands within Perl.
> 
> 4) For pre-made scripts and applications, visit Freshmeat
> (http://freshmeat.net).  I'm sure you'll find something there :-)
> 
> Of course, you could just follow the directions given in the DBD::mysql
> README to install the proper driver :-)  And contact the suthor of the
> module if you're having that much trouble installing it :-)

Hi Jim
thanks for your helpful suggestions! Some good ideas there.
Today just isn't my day. I just thought "sod the cygwin perl - I'll just 
install active state perl and use ppm to install DBD-mysql and DBI, that 
will work".
How foolish I was! Bwwaa hahahahaahahaaaaa <gibber>

The fool I was, to think active state perl would work! When I run ppm2 
or ppm3 it throws a right wobbly and executes instruction at illegal 
address etc.
Oh dear.
I am about to throw an ugly exception at my computer.... like a boot.

thanks!
alex






------------------------------

Date: Tue, 30 Nov 2004 12:27:43 -0600
From: Alan Mead <amead@comcast.net>
Subject: Re: SQLite - problem connecting to database (or doing a select)
Message-Id: <pan.2004.11.30.18.27.42.27770@comcast.net>

On Tue, 30 Nov 2004 17:59:41 +0000, Alex Hunsley wrote:

> Today just isn't my day. I just thought "sod the cygwin perl - I'll just 
> install active state perl and use ppm to install DBD-mysql and DBI, that 
> will work".
> How foolish I was! Bwwaa hahahahaahahaaaaa <gibber>
> 
> The fool I was, to think active state perl would work! When I run ppm2 
> or ppm3 it throws a right wobbly and executes instruction at illegal 
> address etc.

Paul Lalli hit the nail on the head when he suggested that you are
spinning your wheels posting to newsgroups rather than reading docs.  The
link that Paul gave you seemed to me to say "Thar Be Dragons" regarding AS
Perl and MySQL (did you read it... recompile Perl just to install DBD??!!).

I think you've gotten a lot of good ideas.  If you cannot make things go,
I suggest you find a MySQL forum and courteously whine about how hard
you've been trying to get Perl DBD working on Win32 and does anyone have
an easy answer... You might get lucky and find someone who's done all the
hard work and who can hand it to you as a compiled binary.

Now that it helps you at all, but for the record, I've gotten MySQL DBD
working on Red Hat Linux without much struggle.  I once hit a snag like
the missing header file and I was able to fix it by just installing the
devel package.  Not that this helps you.  Unless you have a Linux box
handy.

BTW, if you JUST want an SQL engine, you could try SQLite.

-Alan


------------------------------

Date: Sun, 28 Nov 2004 19:06:32 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Storing a substitution (similar to qr())
Message-Id: <o6kp72-ts4.ln1@osiris.mauzo.dyndns.org>


Quoth Brian McCauley <nobull@mail.com>:
> 
> The s///e operator can be seen as a function that takes two arguments, 
> the first being a regex and the second a block of code that is evaluated 
> to find the replacement.
> 
> The s/// operator without the /e modifier is the same but the block is 
> implicitly enclosed a qq() operation (but with a delimiter outside the 
> real character set).
> 
> So...
> 
>    s/xxx/yyy/e; # The most primative form
> 
>    s/xxx/yyy/;  # Same as s/xxx/qq(yyy)/
                                          ^e
> 
>    s/xxx/yyy/ee;# Same as s/xxx/eval(yyy)/
                                            ^e

(I know *you* know that, of course... :)

Nice explanation. I hadn't thought of it like that.

Ben

-- 
For far more marvellous is the truth than any artists of the past imagined!
Why do the poets of the present not speak of it? What men are poets who can
speak of Jupiter if he were like a man, but if he is an immense spinning
sphere of methane and ammonia must be silent? [Feynmann]     ben@morrow.me.uk


------------------------------

Date: 30 Nov 2004 03:18:49 -0800
From: "Varun Jindal" <varunjindal@yahoo.com>
Subject: Re: System command
Message-Id: <1101813529.671424.295560@z14g2000cwz.googlegroups.com>

I got it.
Thanks for your help and prompt responses.

-- Varun.



------------------------------

Date: Tue, 30 Nov 2004 14:00:41 GMT
From: "Leon" <eon@hotmail.com>
Subject: Re: System command
Message-Id: <d2%qd.65$FD1.63@newsfe6-win.ntli.net>


"Varun Jindal" <varunjindal@yahoo.com> wrote in message
news:1101810600.015345.187340@z14g2000cwz.googlegroups.com...
> hello,
>
> i am using a unix shell command within my perl script using system
> command.
>
> lets say, i want to know what is hte system time (it is just an
> example).
>
> so i use the system command, but i want to put the output of the
> command in a variable in the perl script.
> how do i do it.
>
> thanks in advance,
>
> --Varun.
>
@Result = `date`;




------------------------------

Date: Tue, 30 Nov 2004 08:09:43 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: System command
Message-Id: <87r7mbfmxk.fsf@limey.hpcc.uh.edu>

>> On 30 Nov 2004 03:18:49 -0800,
>> "Varun Jindal" <varunjindal@yahoo.com> said:

> I got it.  Thanks for your help and prompt responses.

OK.  Now you realize that if you want the system time, you'd
just say:

    my $now = time;

For a formatted person-friendly "now", use strftime() from the
POSIX module:

    use POSIX qw(strftime);
    my $now = strftime('%Y-%d-%m %H:%M:%S', localtime);

No need here to bother a shell with anything.


------------------------------

Date: Tue, 30 Nov 2004 17:05:35 +0100
From: bunnytail <nospam@spam.com>
Subject: Telnet - groupd id
Message-Id: <41ac9a50$1@news.cadence.com>

Greeting,

I am trying to use Net::Telnet module, however I was stoped by
some strange thing with this tool. In this script, I want to
telnet to a machine(abc), change directory to somewhere and change
current gid to another one using newgrp. But it seems that newgrp is
forbidden to be use in this protocol while in normal shell interaction I 
was able to do what I want to do.

any help?
cheers,
h.s


===============================


#!/usr/local/bin/perl -w

$host = "abc";
$prompt = "_funkyPrompt_";
$match = "/" . $prompt . "\$/";

use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>5,
                             Prompt => '/abc/',
                             Errmode=>'return');

print "start\n";
$telnet->open($host);
print "connected\n";
$telnet->login("me","mo");

print "ACL done\n";

$telnet->prompt($match);
$telnet->cmd("set prompt = '$prompt'");
print "setprompt done\n";
@output = $telnet->cmd("ll;pwd");
print @output;

@output = $telnet->cmd("newgrp a_group;pwd");
print @output;
print $telnet->errmsg;
print "\n";



	


------------------------------

Date: Tue, 30 Nov 2004 12:25:20 -0500
From: James Willmore <jwillmore@fastmail.us>
Subject: Re: Telnet - groupd id
Message-Id: <pan.2004.11.30.17.25.18.889048@fastmail.us>

On Tue, 30 Nov 2004 17:05:35 +0100, bunnytail wrote:

> I am trying to use Net::Telnet module, however I was stoped by
> some strange thing with this tool. In this script, I want to
> telnet to a machine(abc), change directory to somewhere and change
> current gid to another one using newgrp. But it seems that newgrp is
> forbidden to be use in this protocol while in normal shell interaction I 
> was able to do what I want to do.
< ... >

Have you tried to do whatever it is you want to do from the command line
(meaning, you used telnet to access the box in question (abc) ?)  If you
have and it worked (which I doubt), then you might want to turn on logging
in the script ( ex. $telnet->dump_log('my_telnet_dump.log'); ).  Then you
can see exactly what's going on.

If you can not telnet to the box in question (abc) and execute the
commands you want to execute, then you will not be able to use a script
:-)  It's a permissions issue and you will need to fix the permissions
before you can run the script :-)

HTH

Jim


------------------------------

Date: Sun, 28 Nov 2004 19:14:47 +0000
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Transiting from Perl: Learn Python or Ruby?
Message-Id: <7mkp72-ts4.ln1@osiris.mauzo.dyndns.org>


Quoth Michele Dondi <bik.mido@tiscalinet.it>:
>
> Well, that's your *very* humble opinion. As far as you're concerned
> just choose the language you'll find most suitable for your needs and
> we will continue to be friends as before.

Fair (of course) :)

> However in the experience of most of us I think that your claims will
> sound plainly and definitely false. In other words I'm sure what that
> you think to be shortcomings of [Pp]erl for most of us plainly do not
> exist, period.

Here, though, I must disagree. I believe it is commonly accepted that
for serious OO stuff perl5 is not really good enough. Hence the emphasis
on it in perl6.

> So, in a certain sense, indeed you can avoid an unneccessary and
> futile debate about which language is the best, but you can't avoid a
> comment about the fact that Perl is perfectly suited for tasks well
> beyond quick hacks and short scripts.

This is also true (of course), but that is not what the OP was saying.

Ben

-- 
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
     -Assyrian stone tablet, c.2800 BC                         ben@morrow.me.uk


------------------------------

Date: Tue, 30 Nov 2004 16:25:48 +0100
From: "Alain Star" <200410+news@pobox.com>
Subject: Write at the beginning of a file
Message-Id: <41ac9167$0$14144$636a15ce@news.free.fr>

Hello!

Can anyone tell me how to write a block of text at the beginning of a file
instead of appending it as in the following example? Thanks. AS

my $fh = new FileHandle;
$fh->open(">> $fileName");
print $fh "$body";
print $fh "\n\n";
$fh->close;




------------------------------

Date: Tue, 30 Nov 2004 15:35:32 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Write at the beginning of a file
Message-Id: <8r0rd.3790$wr6.3541@trnddc04>

Alain Star wrote:
> Can anyone tell me how to write a block of text at the beginning of a
> file instead of appending it as in the following example? Thanks. AS

Your Question is Asked Frequently: perldoc -q "append to the beginning of a 
file"

jue 




------------------------------

Date: Tue, 30 Nov 2004 16:39:31 +0100
From: "Alain Star" <200410+news@pobox.com>
Subject: Re: Write at the beginning of a file
Message-Id: <41ac949d$0$23576$636a15ce@news.free.fr>

Jürgen Exner wrote:
:: Alain Star wrote:
::: Can anyone tell me how to write a block of text at the beginning of
::: a file instead of appending it as in the following example? Thanks.
::: AS
::
:: Your Question is Asked Frequently: perldoc -q "append to the
:: beginning of a file"


Mea Culpa.

Thanks.

AS




------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7466
***************************************


home help back first fref pref prev next nref lref last post