Re: Large numbers

2002-10-24 Thread Robin Cragg
Hi Kristi , perl is like most other languages. It counts in binary. The way signed )ie ones that can be positive or negative) are differentiated is the first bit. If the first bit is negative, the number is negative. If I use 3 bit numbers, I would count like this: 000 0 001 1 010

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 16

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 " 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? > > >a

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, @new

Re: Net::Telnet::Cisco telnet to PIX Firewall

2002-10-03 Thread Robin Cragg
A PIX only allows telnet to the "inside" interface and you have to be listed as a trusted host (telhet ]. Can you telnet i ok yourself from that machine? If that's all ok, I would guess it's a problem with Prompt. Net::Telnet uses a pattern match to determine if it's time to send data, so whe

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]] S

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 ($lin

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, e

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: $tablename{$table}{"con_

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 t

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: $1, $2, $3, ... as array

2002-09-30 Thread Robin Cragg
If it's complex, why not evaluate code() first, then pass what it returns into the regexp? R At 12:39 30/09/2002 +0200, Jenda Krynicky wrote: >From: Ramprasad A Padmanabhan <[EMAIL PROTECTED]> > > > while($string=~/regexp/g) { push @arr , $1 } > >I said that the code that needs access to the

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: 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 r

Re: can my code be shortened?

2002-09-24 Thread Robin Cragg
Hi, how about: while(@results = $dbh->dbnextrow){ print ""; foreach (@results) { print "$_<\n"; } print ""; } 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
don't 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- >F

Re: inputs to my script.

2002-09-23 Thread Robin Cragg
If you want multiple words to be treated as one argument, just enclose them in quotes... R At 15:26 23/09/2002 +0530, Javeed SAR wrote: >Hi all, > >I am giving 4 command line inputs to my script. >I want to give the 4 input($com) which has spaces in it input, eg: Hello how >do you do >How sho

RE: background process

2002-09-22 Thread Robin Cragg
# then burn 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 Trembla

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 @Zi

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 i

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 f

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, b

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 Change_Date,Person,Event,Hi