Scope

2006-10-01 Thread John Ackley
simple scope question when is a global not a global? or how to get a value from inside a while() to the outside? two tests-extracted from much large program to show my problem test 1 my $count; my $service; while( ($service) = $SERVICE->fetch

Re: Re unexpected result

2006-09-10 Thread John Ackley
it! Tom Phoenix wrote: On 9/10/06, John Ackley <[EMAIL PROTECTED]> wrote: Trying to split class C IPs into network and host parts. For educational or experimental reasons, I hope, since you're writing your own low-level code instead of using a module. this works but I expected the

Re unexpected result

2006-09-10 Thread John Ackley
Trying to split class C IPs into network and host parts. this works but I expected the host part in $2: print "<$bu>\n" if $debug; if( $bu =~ /^((\d+\.){3})(\d+)$/ ) { print "$1 $2 $3\n" if $debug; } output: <172.19.252.130> 172.19.252. 252. 130 where did my

Re: sssh bang problem

2006-08-24 Thread John Ackley
o need to store the image as it is created each time viewed but I have not figured out how I might create an image and spit it out without first creating a file. Maybe I should switch to javascript and let it draw the image in the user's browser! John Tom Phoenix wrote: On 8/24/06,

sssh bang problem

2006-08-24 Thread John Ackley
script runs as expected from command line - user root fails when launched by Apache - user nobody # perl -c plot.cgi Args must match #! line at plot.cgi line 1. where did I go astray? script is owned by root with suid set -rwsr-sr-x 1 root wheel 5415 Aug 24 11:42 plot.cgi -- To unsubscri

Re: backticks

2006-08-20 Thread John Ackley
e strict; my $oldimage = "/usr/local/billmax/html/images/day-0020a6-5a9bfc*"; my $files = unlink glob $oldimage; print "Files $files\n"; -------- fails John Ackley wrote: thanks to all who replied down to this # pe

Re: backticks

2006-08-20 Thread John Ackley
thanks to all who replied down to this # perl -e "print unlink glob '/usr/local/billmax/html/images/day-0020a6-5a9bfc*';" 1 but in script my $oldimage = "/usr/local/billmax/html/images/day-0020a6-5a9bfc*"; my $files = unlink glob $oldimage; fails -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: backticks

2006-08-19 Thread John Ackley
Thanks in line comments Tom Phoenix wrote: On 8/19/06, John Ackley <[EMAIL PROTECTED]> wrote: `/bin/rm -f \"$oldimage\"`; `/bin/rm /tmp/errormessage`; Why not simply use Perl's unlink function? apparently unlink will not deal with wild cards in $oldimage (neede

backticks

2006-08-19 Thread John Ackley
I have a program which should create a new image after deleting the old. Image names have $$ embeded to assure uniqueness (within a reasonable period of time). The following backticks don't work as expected. `/bin/rm -f \"$oldimage\"`; `/bin/rm /tmp/errormessage`; `/usr/local/bin/gnuplot $gpfil

Re: Pattern Matching

2006-07-23 Thread John Ackley
[EMAIL PROTECTED] wrote: Hi, I am a beginner in perl and am having a dickens of a time trying to identify this pattern in messages. [URL Here is what I have: if ($FORM{'message} =~ /\[URL/ig) { #do something; } Where $FORM('message') is a messaage that includes many l

Re: reg ex problem

2006-06-27 Thread John Ackley
Ryan Moszynski wrote: i have this string extracted from a text file i'm writing a program to process: test_freq = 1.0001; and i have to extract the "1.0001" i can't count on the whitspace being where it now is. I would like to change this line of perl $getTestFRQ =~ s/\D+//g; so that

Re: Handle date structured folders - CORRECTIO

2006-06-22 Thread John Ackley
argument 2 of DateCalc() should be "$days days ago" NOT "$days ago" sorry John Ackley wrote: Khairul Azmi wrote: Hi all, I have this problem. There is a script that stores log files into folders that follows structure of the following /MM/DD eg.. /var/log/proj

Re: Handle date structured folders

2006-06-22 Thread John Ackley
Khairul Azmi wrote: Hi all, I have this problem. There is a script that stores log files into folders that follows structure of the following /MM/DD eg.. /var/log/projects/2006/06/20/8231.tgz /var/log/project1/2006/06/21/1432.tgz /var/log/projects/2006/06/22/1756.tgz /var/log/projects/20

Re: How to convert these tablespace output report into a delimited file, csv or tilde

2006-06-21 Thread John Ackley
There is more than one way to do it! #! /usr/bin/perl -w use strict; my $DELIMITER = "\t"; my $state = 0; while(<>) { if($state) { next if /Detailed explanation:|Normal/; if(/Number of containers.*= (.*)$/) { print "$DELIMITER$1\n";

Re: What is the reason for different outputs for a cgi script run from a browser and run from the command line?

2006-06-20 Thread John Ackley
command line you see the instructions to build a display sent to the browser on browser you see how browser reacted to those instructions sfantar wrote: sfantar a écrit : Charles K. Clarkson a écrit : sfantar wrote: : In the apache's error log, here is what's written : : : : [error] HTML::Te

Re: map array to hash

2006-05-29 Thread John Ackley
Jenda Krynicky wrote: From: John Ackley <[EMAIL PROTECTED]> there is more than one way to do it is there an easier way to do this map: my $index = 0; while( my @a = $SQL->fetchrow_array) { my %a = map { $fieldnames[$index++] => $_ } @a; print "$_ => $a

map array to hash

2006-05-29 Thread John Ackley
there is more than one way to do it is there an easier way to do this map: my $index = 0; while( my @a = $SQL->fetchrow_array) { my %a = map { $fieldnames[$index++] => $_ } @a; print "$_ => $a{$_}\n" for (keys %a); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comma

Re: Mismatch Positions of Two Ambiguous Strings

2006-04-26 Thread John Ackley
Wijaya Edward wrote: Hi, I have two strings that I want to compute the number of mismatches between them. These two strings are of the "same" size. Let's call them 'source' string and 'target' string. Now, the problem is that the 'source' and 'target' string may come in ambiguous form, meaning th

Re: match file name at end of a http url

2006-04-25 Thread John Ackley
Ken Perl wrote: If I want to use regular expression to extract the charactors after the last '/' in the url, but below regexpr doesn't work, what I do wrong? $url = 'http://website.com/path/file_name.img'; if (/\/.*$/) { print $url."is matched \n"; } else { print "failed"; } -- perl -e

Re: Running Perl Code in Windows

2006-04-23 Thread John Ackley
Mazhar wrote: Hi Folks, i have written down a code in perl which is used as a file analyser. I need to run the same on Windows 2000. Should i need to install Active State Perl on the same. Is there any other alternative for running the same without installation of Active State Perl on t

Re: truncate

2006-04-23 Thread John Ackley
Smith, Derek wrote: I want to use truncate to delete a matched line out a named.conf file on my DNS box. Here is my code use strict; use warnings; my $file = qq(/usr/local/admin/perl/derek_perl/test); open (FH, "+< $file"); while ( ) { unless (/\Acheck\-names/) {

Re: Problems with simple regexps

2006-04-14 Thread John Ackley
Mattheus Henrique wrote: Hi, I'm learning Perl but I've found some difficulties: Why doesn't this: [code] #!/usr/bin/env perl use warnings; use strict; while(<>){ if(/[A-Z][^A-Z]+/){ print; } } [/code] Act like this: [code]#!/usr/bin/env perl use warnings; use strict; while(<

Re: hash and parsing help

2006-04-09 Thread John Ackley
to recurse through the values for $key1 (keys %hash) { for $key2 (keys %{$hash{$key1}}) { for $integer (keys %{$hash{$key1}{$key2}} ) { print "\$hash{$key1}{$key2}{$integer} = $hash{$key1}{$key2}{$integer}\n"; } } } -- To unsubscribe, e-mail: [EMAIL PROTE

Zombie Trouble Shooting

2006-04-06 Thread John Ackley
I have a perl script that becomes a zombie. It runs fine for days or weeks checking for new data every 60 seconds. But after a long period of time running on Red Hat 9, Fedora Core 4, and now Fedora Core 5 it remains in memory as an active process and maintains its network tcp/ip connections but

Re: only one of two hash keys

2006-04-05 Thread John Ackley
perl wrote: Is there a nice clean perl way to test to see if only one key of a hash has data? %some_hash = ( key1 => 1, key2 => 2 ); should fail the test %some_hash = ( key2 => 2 ); should pass the test %some_hash = ( key1 => 1 ); should pass the test Thank you print keys(%some_hash) == 1

Re: Determine total days of month

2006-04-04 Thread John Ackley
My favorite is Date::Manip by Sullivan Beck - check www.cpan.org which does just about anything your can think of associated with date and time in just about any language use Date::Manip; $days=&Date_DaysInMonth($m,$y); Mike Blezien wrote: Hello, I am trying to come up with a function,

Re: @hash{} versus $hash{}

2006-04-02 Thread John Ackley
Thanks Shawn - I think I got it now. The first @ in @[EMAIL PROTECTED] = split /\t/,$rec; flags list context for the split else a $ would flag a scalar context which is deprecated because of the implicit split to @_ that could clobber subroutine arguments. And (mis)use of $ rather than @ lead

@hash{} versus $hash{}

2006-04-02 Thread John Ackley
Inherited code (from Verisign): @[EMAIL PROTECTED] = split /\t/,$rec; which worked but really puzzled me. I assumed that it meant[EMAIL PROTECTED] = split /\t/,$rec; which worked also as I verified by testing both versions. However [EMAIL PROTECTED] = split /\t/,$rec; gives the warning quo