Re: Generating Graphs with Perl

2007-03-16 Thread Jeff Pang
> I am creating interesting (for me that is) applications at this site. > But I would like to be able to generate a Graph somehow. > Does anyone have any general idea how this might be possible? Hello, I once read part of the book "Graphics Programming with Perl" which is also suitable for you I t

Re: Files Operations in Pearl

2007-03-16 Thread Jeff Pang
>> @tmp = map { (split)[2] } grep { /localhost/ } ; > >This is a bad idea if the file you are reading from is at all large. Yes memory consuming of using map and grep is the fact. But AFAIK postgresql.conf is not big at all (just a few lines) b/c I'm pretty familiar with it. :) -- To unsubscr

Re: Files Operations in Pearl

2007-03-16 Thread Chas Owens
On 3/16/07, Jeff Pang <[EMAIL PROTECTED]> wrote: snip @tmp = map { (split)[2] } grep { /localhost/ } ; snip This is a bad idea if the file you are reading from is at all large. It is better to use a real loop rather than map or grep when reading from a file. The problem lies in the fact that

Re: Generating random numbers

2007-03-16 Thread Jeff Pang
Another way, my @c = (1,2,3); my @d = (1,2); print join '',$c[int rand @c],$d[int rand @d]; This could generate arbitrary random string other than the numbers of "1 2 3" or "1 2". ie,the original contents could be: my @c = qw(a,b,c); my @d = qw(4,5,6); > >Hello, I need to generate two random

Re: Generating random numbers

2007-03-16 Thread Chas Owens
On 3/16/07, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > my $num = int rand 3 + 1; That will return either 0, 1, 2 or 3. The addition has higher precedence. snip Yeah, I saw that after I posted. That is what I get for posting untested code. -- To unsubscribe, e-mail: [EMAIL PROTECTED] Fo

Re: Generating random numbers

2007-03-16 Thread Chas Owens
On 3/16/07, Chas Owens <[EMAIL PROTECTED]> wrote: snip If you need a better pseudo-random number than rand can provide and you are using Linux (or possibly other unix like operating systems) you can read from /dev/urandom snip I should have hit CPAN first. The Crypt::Random* module provides a

Re: Files Operations in Pearl

2007-03-16 Thread Jeff Pang
>In shell-script I get a variable with command line: > >AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" > | awk '{print $3}' | head -n1` > Hello, In Perl it can most likely be written as: open FILE,"$INPUTDB/postgresql.conf" or die $!; @tmp = map { (split)[2] } grep { /localhost/ } ; c

Re: Generating random numbers

2007-03-16 Thread John W. Krahn
Chas Owens wrote: > On 3/16/07, Grant <[EMAIL PROTECTED]> wrote: >> Hello, I need to generate two random numbers. One should be a 1, 2, >> or 3, and the other should be a 1 or 2. How can I do that? > > That depends on your needs. The rand function creates decent quality > pseudo-random numbers

Re: Generating random numbers

2007-03-16 Thread Chas Owens
On 3/16/07, Chas Owens <[EMAIL PROTECTED]> wrote: snip my $num = int rand 3 + 1; snip oops, that should be my $num = int rand(3) + 1; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Generating random numbers

2007-03-16 Thread Chas Owens
On 3/16/07, Grant <[EMAIL PROTECTED]> wrote: Hello, I need to generate two random numbers. One should be a 1, 2, or 3, and the other should be a 1 or 2. How can I do that? - Grant That depends on your needs. The rand function creates decent quality pseudo-random numbers (it calls srand with

Re: Generating random numbers

2007-03-16 Thread John W. Krahn
Grant wrote: > Hello, Hello, > I need to generate two random numbers. One should be a 1, 2, > or 3, int( rand 3 ) + 1 > and the other should be a 1 or 2. int( rand 2 ) + 1 perldoc -f int perldoc -f rand John -- Perl isn't a toolbox, but a small machine shop where you can special-order

Generating random numbers

2007-03-16 Thread Grant
Hello, I need to generate two random numbers. One should be a 1, 2, or 3, and the other should be a 1 or 2. How can I do that? - Grant -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Module for pulling actual queries from search engine URLs?

2007-03-16 Thread Tom Phoenix
On 3/15/07, Grant <[EMAIL PROTECTED]> wrote: > > Does anyone know of a perl module for pulling the actual search > > queries from search engine URLs? Have you looked on CPAN yet? I found this, but there may be something better: http://search.cpan.org/~sden/URI-ParseSearchString-1.9/lib/UR

Re: Files Operations in Pearl

2007-03-16 Thread John W. Krahn
Rodrigo Faria Tavares wrote: > Hello, Hello, > In shell-script I get a variable with command line: > > AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" > | awk '{print $3}' | head -n1` UUOC: AUXIP=`grep "localhost" "$INPUTDB/postgresql.conf" | awk '{print $3}' | head -n1` AWK can do re

Files Operations in Pearl

2007-03-16 Thread Rodrigo Tavares
Hello, In shell-script I get a variable with command line: AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" | awk '{print $3}' | head -n1` In C++, I use the functions read, write and others for manipulation files. And Pearl ? After I open the file, i like to get a simple word and store

Re: Files Operations in Pearl

2007-03-16 Thread Chas Owens
On 3/16/07, Rodrigo Faria Tavares <[EMAIL PROTECTED]> wrote: snip After I open the file, i like to get a simple word and store in a scalar variable. Or write after line 10 for example. And others. snip In Perl file operations are generally handled by file handles. If you want to use the object

Re: How to revinent wget?

2007-03-16 Thread Jay Savage
On 3/16/07, Alan <[EMAIL PROTECTED]> wrote: I wrote: > (ftp), however, does not work which I'd guess is due to difference in > communication method. Doh! (Net::FTP struck me upside the head!). Don't reinvent the wheel. LWP comes with the lwp-download and lwp-request scripts. They're normally

Re: Module for pulling actual queries from search engine URLs?

2007-03-16 Thread Grant
> > > Does anyone know of a perl module for pulling the actual search > > > queries from search engine URLs? Have you looked on CPAN yet? I found this, but there may be something better: http://search.cpan.org/~sden/URI-ParseSearchString-1.9/lib/URI/ParseSearchString.pm Oh man that looks

Re: Files Operations in Pearl

2007-03-16 Thread Igor Sutton Lopes
Hi Rodrigo, On 2007/03/16, at 18:09, Rodrigo Faria Tavares wrote: Hello, In shell-script I get a variable with command line: AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" | awk '{print $3}' | head -n1` In C++, I use the functions read, write and others for manipulation files. And P

Re: Dealing with ar archives

2007-03-16 Thread Igor Sutton Lopes
On 2007/03/16, at 20:33, Ana Saiz García wrote: Thank you for your answer On 15/03/07, Chas Owens <[EMAIL PROTECTED]> wrote: On 3/15/07, Ana Saiz García <[EMAIL PROTECTED]> wrote: > Hello everybody > > I have to make a little program that deals with the contents of some > ar archives. Do yo

Files Operations in Pearl

2007-03-16 Thread Rodrigo Faria Tavares
Hello, In shell-script I get a variable with command line: AUXIP=`cat $INPUTDB/postgresql.conf | grep "localhost" | awk '{print $3}' | head -n1` In C++, I use the functions read, write and others for manipulation files. And Pearl ? After I open the file, i like to get a simple word and store

Re: Dealing with ar archives

2007-03-16 Thread Ana Saiz García
Thank you for your answer On 15/03/07, Chas Owens <[EMAIL PROTECTED]> wrote: On 3/15/07, Ana Saiz García <[EMAIL PROTECTED]> wrote: > Hello everybody > > I have to make a little program that deals with the contents of some > ar archives. Do you know any alternative way to do this without using >

Re: How to revinent wget?

2007-03-16 Thread Rob Dixon
Alan wrote: Hi. The orig post of this code did not come to my email -- but the post is on Google Groups. (I'm emailing). I got the code (as enclosed below) working when the url is http. But, ftp://slackware.mirrors.tds.net/pub/slackware/slackware-11.0-iso (ftp), however, does not work whi