Re: How to crypt more than 8 characters?

2002-10-24 Thread Robin Cragg
Hi Octavian , I'm afraid that's how crypt() (the UNIX function) is. Here's an extract from man crypt: By taking the lowest 7 bits of each of the first eight characters of the key, a 56-bit key is obtained. This 56-bit key is used to encrypt repeatedly a constant string

Re: regex ( i suck at them)

2002-10-24 Thread Robin Cragg
Hi, if all you want to do is remove the '[*]' why not do: s/^\[\*\]\s+//; R At 16:03 23/10/2002 -0800, Andres L. Figari wrote: Hello, I am having toruble getting my regex to work :^( The file I'm parsing for headlines looks like this [*] headline 1 [*] headline 2 etc ... here is my perl

Re: getting file on STDIN, howto process GLOB

2002-10-17 Thread Robin Cragg
Hi, You should think of a glob as an alias. $input = *STDIN; $file = $input; print $file; All that does is alias $input to STDIN, and then read the contents of $input into $file. The main use of this is redirecting your output without having to write loads of extra code R At 13:19

Re: Speeding up subs with RegEx's

2002-10-08 Thread Robin Cragg
Hi Kurt, You can save yourself the if statement. If the pattern is not found the s/// will not proceed. That will save process ting the line twice when you do match the pattern. Other than that, you are changing nl followed by a single letter to pX with X being a digit corresponding to that

Re: Regular expression

2002-10-04 Thread Robin Cragg
Hi Javeed , the last element of the array is $attt[$#attt]. If you have one line per element, that should do it. R At 14:24 04/10/2002 +0530, Javeed SAR wrote: I have the following output in array @attt I want the last line in a variable $out. What should the regular expression be?

Re: Cookies and IP Addresses

2002-10-03 Thread Robin Cragg
Hi, not sure about the REMOTE_ADDR, I've never had any problems with it. To get an IP from a URI try this: use Socket; $referral_address = $ENV{'HTTP_REFERER'}; $referral_address =~ m#^.*http://([^/]+)/.*$#; $IP = inet_ntoa inet_aton $1; If you want the IP address in hex, just use

RE: Using map

2002-10-03 Thread Robin Cragg
Hi Eric, if you want a more pretty way, (if a touch slower) try: my @new_names = @old_names; foreach (@new_names) { s/\.(jpg|gif)/\.html;i ; } I personally don't like map as I came to PERL from C, but if you want to use it instead... my @new_names = @old_names; map s/\.(jpg|gif)/\.html/i,

RE: cookies

2002-10-02 Thread Robin Cragg
Hi Aman, I've had exactly the same problem. I strongly suspect it's an IE thing. I've not found a way round it other than looking at the HTTP_REFERER and removing cookies from pages that had not come from my site. R -Original Message- From: aman cgiperl [mailto:[EMAIL PROTECTED]]

Re: Anyone want to help modify a script?

2002-10-01 Thread Robin Cragg
Even simpler... opendir DIR, /logs/test; @dirs = readdir DIR; closedir DIR; foreach (@dirs) { if ( -d /$_) { # do your stuff # Notice that you need to preceed the $_ with the path you passed to opendir. } } R At 16:47 30/09/2002 -0500, eric

Re: Creating hash?

2002-10-01 Thread Robin Cragg
Hi Paul, Ihashes would need a little bit of work to work with this, as you will have multiple entries with the same key, eg you have three lines beginning 123. if you have all you lines in an array, you could do this: foreach $line (sort @arry) { die Invalid input: $line\n unless ($line

Re: Has Perl extra memory!?

2002-09-30 Thread Robin Cragg
Sounds like a mod_perl problem. If you are using Apache::Registry apache will compile your script once and just keep running it until the child process dies. This means that any global variables you pass to it will stay in scope. How is your script being called? R At 17:45 30/09/2002 +0200,

Re: dbmopen can't open /etc/aliases.db file

2002-09-30 Thread Robin Cragg
Hi Bruno, The reason you could not open it properly is that Sendmail changed the hashing algorithm it uses some time back. Have a look at man makemap to see how Sendmail does it. PERL can read the Sendmail hash tables if you save them in the right format R At 16:22 27/09/2002 -0300, Bruno

Re: State Variables

2002-09-30 Thread Robin Cragg
Here's a simple version... $a = 5; while ($a) { foreach (1..10) { if ($_ == $a) { $exit++; } } last if ($exit); } print \$a is $a\n; R At 20:20 27/09/2002 -0700, Michael Kelly wrote: On Fri, Sep 27, 2002 at 08:29:53PM -0500, Grant Hansen wrote:

Re: how to know weather perl script is already running?

2002-09-30 Thread Robin Cragg
There are two easy ways... If your file creates a lock file when it starts and removes it when it finishes, a chec to see if the file exists will tell you if the script is already running./ On linux / unix systems do a ps and looks for any occurrances of your script name. If there are more

Re: What Type Of Data Structure Is This?

2002-09-30 Thread Robin Cragg
Hi Ken, the reason you lose your data is simple. You have something of the form: $myscalar = A weird hested hash; you then try to add an entry by doing: $myscalar = Some other data; What you look at it like that, it's clear what is going wrong. What you want is:

RE: perldoc as root

2002-09-25 Thread Robin Cragg
on a linux / unix box: alias perldoc='perldoc -U' R -Original Message- From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]] Sent: 25 September 2002 11:01 To: [EMAIL PROTECTED] Subject: perldoc as root Cant I tweak perldoc so that it allows me to run as root Everytime I want to

Re: can my code be shortened?

2002-09-24 Thread Robin Cragg
Hi, how about: while(@results = $dbh-dbnextrow){ print TR; foreach (@results) { print TD$_/TD\n; } print /TR; } R At 08:19 24/09/2002 -0700, loan tran wrote: Hi, I codes in the while loop is too long. Can it be written in different way?

RE: inputs to my script.

2002-09-23 Thread Robin Cragg
want the input to be given in quotes (that is from command line). Script has to accept it without quotes. I want to make changes in script. my script is as follows: my ($str1, $str2,$lb1,$comment) = @ARGV; -Original Message- From: Robin Cragg [mailto:[EMAIL PROTECTED]mailto:[EMAIL

RE: background process

2002-09-22 Thread Robin Cragg
Hi Pual, I think this will do the trick... $MAXSIZE = 500 $size = 0; @Zip_Now = (); foreach (@Files_to_zip) { $size += (stat $_)[7]; if ($size $MAXSIZE) { exec tar -vr -T @Zip_Now -f $tar_file; # then burn this to CD

RE: background process

2002-09-22 Thread Robin Cragg
this to CD @Zip_Now = (); $a++; } push (@Zip_Now, $_; } exec tar -vr -T @Zip_Now -f $tar_file; -Original Message- From: Robin Cragg [mailto:[EMAIL PROTECTED]] Sent: 22 September 2002 12:17 To: 'Paul Tremblay'; [EMAIL PROTECTED] Subject: RE

Re: Removing duplicate entries from an array

2002-09-20 Thread Robin Cragg
How about.. if(/\[(\d+\.\d+\.\d+\.\d+)\].+reject=550/) { $IP{$1}++; } the your array of unique IPs is just keys %IP R At 14:14 20/09/2002 +0100, Griggs Rob wrote: Hi All, Whats the easiest way to remove duplicate entries from an array. Below is a script that removes ip

Re: Forking, Passing Parameters to forks

2002-09-19 Thread Robin Cragg
Hi, we use netsint now, but before that we had a massive PERL driven forked system. The basic flow of the program was: read in data from mySQL table into an array foreach $test (@tests) { if ($pid = fork) { # this is the parent process # we just wait

RE: PERL over multiple source files

2002-09-18 Thread Robin Cragg
Hi, if you're a C programmer, then you use make with decent sized projects, I assume? If so, keep all your little source scaps in files with a particular suffix and then use make... SUFFIX = .pl.bit TARGET = myprog.pl all: @cat *${SUFFIX} ${TARGET } That will work fine, but

Re: Can Someone Point Me in......

2002-09-10 Thread Robin Cragg
Hi Mark, given how small your data chunk is, you can do it any way you'd like. Here's a chunk that works .. (Query_Database() just returns an array where each element contains an array ref to all the elements of that column.) @History = Query_Database(SELECT