[24248] in Perl-Users-Digest
Perl-Users Digest, Issue: 6439 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 21 09:05:45 2004
Date: Wed, 21 Apr 2004 06:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 21 Apr 2004 Volume: 10 Number: 6439
Today's topics:
Re: "cloning" perl / CPAN install <Joe.Smith@inwap.com>
Re: activeperl + -T option <Joe.Smith@inwap.com>
Re: alternative to "cwd()" <Joe.Smith@inwap.com>
Re: Bundle::Apache compilation errors <matternc@comcast.net>
Re: cgi.pm <clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
Re: Create MD5 of files in directories and subdirectori (nicogroen)
Re: Curses::UI <keithABUSE@araneid.com>
Re: Encrypting files (SlimClity)
Re: Encrypting files (SlimClity)
Re: Encrypting files <zentara@highstream.net>
Re: Free source guestbook - unfinished <Joe.Smith@inwap.com>
grepping lines above and below a pattern found (mike)
Re: grepping lines above and below a pattern found <noreply@gunnar.cc>
Re: grepping lines above and below a pattern found <ittyspam@yahoo.com>
Re: grepping lines above and below a pattern found <matrix_calling@yahoo.dot.com>
Re: incorrect value for HOSTNAME executed as cron job <Joe.Smith@inwap.com>
Re: incorrect value for HOSTNAME executed as cron job (Julian)
Re: incorrect value for HOSTNAME executed as cron job <uri@stemsystems.com>
Re: Need help with table (Anno Siegel)
Re: pattern matching (LiHui)
Re: Popup labels in Tk::Canvas? <jack_challen@ocsl.co.uk>
Re: Popup labels in Tk::Canvas? <josef.moellers@fujitsu-siemens.com>
regular expressions for postgres syntax <jan.biel@tu-clausthal.de>
Re: regular expressions for postgres syntax <jack_challen@ocsl.co.uk>
Re: regular expressions for postgres syntax <jack_challen@ocsl.co.uk>
Re: regular expressions for postgres syntax <nospam@bigpond.com>
Re: Request for program test on different operating syt <Joe.Smith@inwap.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Apr 2004 07:33:46 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: "cloning" perl / CPAN install
Message-Id: <utphc.28585$hw5.47672@attbi_s53>
Walter Roberson wrote:
> In article <8ZGdnbKwNf6wDBjdRVn-gw@adelphia.com>,
> Sherm Pendley <spamtrap@dot-app.org> wrote:
> :Walter Roberson wrote:
> :> I'd perfer not to have to dig through cpan source
>
> :Did you also prefer not to have to dig through the "help" command?
>
> It so happens that I'd scrolled through the entire cpan source already
> once today, just a short time before, in order to answer another
> poster's question about where exactly perl -MCPAN -e shell was
> documented. I saw at that time that the cpan source was long and involved,
I try to make it a habit of using perldoc on the module before looking
at the source code. You'll often find important stuff on the first
page that way.
If you had done
perldoc CPAN
before going to
less /usr/lib/perl5/5.8.3/CPAN.pm
you could have saved a lot of wear and tear on your brain.
-Joe
------------------------------
Date: Wed, 21 Apr 2004 08:55:54 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: activeperl + -T option
Message-Id: <uGqhc.179775$K91.448477@attbi_s02>
Robin wrote:
> "Clyde Ingram"
> ... [over 100 lines deleted]
> Yeah, optiperl still isn't working with this, but it's cool, it's still
> running. Check out new scripts at www.infusedlight.net
Don't quote the entire article just to add two lines of commentary.
-Joe
------------------------------
Date: Wed, 21 Apr 2004 07:59:35 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: alternative to "cwd()"
Message-Id: <HRphc.28743$hw5.47978@attbi_s53>
Walter Roberson wrote:
> In article <LqFgc.164938$K91.421565@attbi_s02>,
> Joe Smith <Joe.Smith@inwap.com> wrote:
> :Have you tried this:
> : BEGIN {
> : $ENV{PERL5LIB} = "/primary/perl/lib";
> : push @INC,"/primary/perl/lib/subdir";
> : }
> : use Cwd;
>
> Any particular reason you used double-quotes instead of single-quotes?
1) Commodore Amiga. From the CLI, file names with embedded blanks needed
double quotes.
2) I don't buy into the religious argument of single quotes being better
than double quotes for constants. I understand the counter arguments,
I just don't find them convincing.
3) Old habit I don't think is worth the effort to break.
-Joe
------------------------------
Date: Wed, 21 Apr 2004 08:50:39 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Bundle::Apache compilation errors
Message-Id: <bIidnWcuwZ-98xvdRVn_iw@comcast.com>
gunzip wrote:
> Sherm Pendley wrote:
>
>> gunzip wrote:
>>
>>
>>>Looking closer at the output, this seemed relevant
>>
>>
>> It's very relevant. It is, in fact, the answer to your question. Have you
>> tried doing what the warning message says to do? What happened?
>>
>> sherm--
>>
>
> It seemed relevant to me at first until I looked at
>
> /private/var/root/.cpan/build/Apache-Test-1.10/t/
>
> ... and discovered it's permissions to be:
>
> drwxr-xr-x 9 nobody nobody 306 20 Apr 21:35 t
>
> Garry
That's nice. Is /private readable by nobody? Is /private/var?
Is /private/var/root? And so on? If you had bothered to read the error
message you got, you would have found out that they need to be. That's why
the suggested courses of action given in the error message don't inlcude
just checking your permissions, since reworking the permissions of the
entire directory path is probably not a good idea.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Wed, 21 Apr 2004 09:39:50 +0100
From: "Clyde Ingram" <clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
Subject: Re: cgi.pm
Message-Id: <Vpqhc.37$Zr5.33@newsfe1-gui.server.ntli.net>
Robin,
"Robin" <robin @ infusedlight.net> wrote in message
news:c655kv$s58$1@reader2.nmix.net...
> What are the easter eggs in cgi.pm... ? I must ask.
Er . . . An eggcellent question. I must answer.
The eggs have all been sold off, but looking at ":html2", I should
'comment', or 'cite', that it gives you the 'option' to 'Select' from a fine
'menu', for 'input' to your 'body';
":html3" offers a 'big' (or 'small') 'table' to 'sup' at, in 'style' -- I
recommend the 'applet';
":form" provides a 'hidden' 'radio_goup' to serenade you at your banquet;
to finish off, ":cgi" suggests a 'cookie', or 'raw_cookie', if your prefer.
Regards,
Clyde
------------------------------
Date: 21 Apr 2004 00:47:03 -0700
From: nicogroen@planet.nl (nicogroen)
Subject: Re: Create MD5 of files in directories and subdirectories
Message-Id: <b9343f9a.0404202347.2e0e5caa@posting.google.com>
Thanks for your replies. My problem in Windows is solved by updating
the ActivePerl version (from 5.6.1 to 5.8.3).
------------------------------
Date: Wed, 21 Apr 2004 21:35:26 +1000
From: Keith Davies <keithABUSE@araneid.com>
Subject: Re: Curses::UI
Message-Id: <87fzaxpnr5.fsf@arthur.zarquon>
> Keith Davies <keithABUSE@araneid.com> wrote in comp.lang.perl.misc:
>>
>> I'm not sure what I'm doing wrong:
>>
>> #!/usr/bin/perl -w
>> use strict ;
>> use Curses::UI;
>>
>> my $cui = new Curses::UI;
>> my %w;
>>
>> $w{1} = $cui->add(
>> 'w1', 'Window',
>> -border => 1,
>> -y => 1,
>> -padbottom => 3,
>> );
>> my %notes = ('lblNotes', 'Label',
>> -text => 'Notes: ',
>> -x => 1,
>> );
>> $w{1}->add(%notes);
>> $cui->mainloop();
>>
>> This results in the following error:
>>
>> Fatal program error:
>> ------------------------------------------------------------------------
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
>
> Using a hash for the parameters is wrong. ->add() expects the parameters
> "id" and "class" in the first two positions, but the hash may deliver them
> later. It will then interpret some other parameter as a class (for
> instance "Notes: "), which results in the error you see.
>
> Replace "%notes" with "@notes" in both places.
>
> Anno
Thanks. Does the job perfectly.
Keith
------------------------------
Date: 21 Apr 2004 01:06:29 -0700
From: slimclity@hotmail.com (SlimClity)
Subject: Re: Encrypting files
Message-Id: <3c209c5f.0404210006.776e2528@posting.google.com>
Joe Smith <Joe.Smith@inwap.com> wrote in message news:<I6ahc.174889$K91.441245@attbi_s02>...
> SlimClity wrote:
>
> > sub get16 {
> > my $data = shift;
> > return "\0" x ( 16 - length($data)%16) . $data;
> > }
>
> What happens if $data is 1024 bytes long?
> length($data) = 1024;
> length($data)%16 = 0;
> 16 - length($data)%16 = 16;
> return "\0" x 16 . $data; # Add corruption to every block read.
>
> The nulls belong at the end, not the beginning, and there should
> be 0 nulls, not 16, for full blocks.
Good point!
I've modified the get16:
sub get16 {
my $data = shift;
if (length($data)%16==0) {
$return = $data;
}
else {
$return = $data . "\0" x ( 16 - length($data) % 16 );
}
return $return;
}
------------------------------
Date: 21 Apr 2004 01:25:13 -0700
From: slimclity@hotmail.com (SlimClity)
Subject: Re: Encrypting files
Message-Id: <3c209c5f.0404210025.44b22291@posting.google.com>
slimclity@hotmail.com (SlimClity) wrote in message news:<3c209c5f.0404200134.78418af7@posting.google.com>...
> I think this has something to do with the get16, when decrypting I
> think I must remove those "\0" which were added (how??).... Or is it
> something else??
Thanks for the help, I used the script from zentara and add the
modifiction from Joe. The script works now, but I only have one small
problem:
The script is part of a larger automated process. To make sure that
the encrypting and decrypting goes well we want to create an MD5
checksum before and after the encryption. This works if the original
file is in parts of 16. But when the file don't exists in parts of 16
then "0" are add to make the encryption work.
Now the MD5 chekcum is different...
Is there a way to solve is problem? Is it possible to remove the extra
"0" at the decrypting script? (How? regexp on the (binary) file??)
------------------------------
Date: Wed, 21 Apr 2004 07:50:16 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Encrypting files
Message-Id: <opnc80hj044i3ogonm8l8cphv8qurm83q0@4ax.com>
On 21 Apr 2004 01:25:13 -0700, slimclity@hotmail.com (SlimClity) wrote:
>slimclity@hotmail.com (SlimClity) wrote in message news:<3c209c5f.0404200134.78418af7@posting.google.com>...
>> I think this has something to do with the get16, when decrypting I
>> think I must remove those "\0" which were added (how??).... Or is it
>> something else??
>
>Thanks for the help, I used the script from zentara and add the
>modifiction from Joe. The script works now, but I only have one small
>problem:
>
>The script is part of a larger automated process. To make sure that
>the encrypting and decrypting goes well we want to create an MD5
>checksum before and after the encryption. This works if the original
>file is in parts of 16. But when the file don't exists in parts of 16
>then "0" are add to make the encryption work.
>
>Now the MD5 chekcum is different...
>
>Is there a way to solve is problem? Is it possible to remove the extra
>"0" at the decrypting script? (How? regexp on the (binary) file??)
Just capture the $decoded to a string before printing it out, and strip
the trailing \0's.
####decrypt##############################
#!/usr/bin/perl
use Crypt::Rijndael;
$cipher = new Crypt::Rijndael "1234567890123456",
Crypt::Rijndael::MODE_CBC;
my $file = shift or warn "No input file $!\n";
$srcfile = $file;
$destfile = "$file.out";
#my ($srcfile, $destfile) = @_;
my $buffer;
open INF, $srcfile
or die "\nCan't open $srcfile for reading: $!\n";
open OUTF, ">$destfile"
or die "\nCan't open $destfile for writing: $!\n";
binmode INF;
binmode OUTF;
#slurp file in
read( INF, $buffer, -s INF );
close INF;
my $decode = $cipher->decrypt($buffer);
$decode =~ s/\0+$//;
print OUTF $decode;
close OUTF
or die "Can't close $destfile: $!\n";
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Wed, 21 Apr 2004 09:20:38 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Free source guestbook - unfinished
Message-Id: <F1rhc.170867$gA5.1990078@attbi_s03>
Robin wrote:
> sub getdate { open (DATE, "date +%D|") ...
A bit inefficient using an external program like that.
I use either
return scalar localtime;
or something like this:
sub get_now {
my ($sec,$min,$hour,$day,$month,$year) = localtime;
sprintf "%4d/%02d/%02d %02d:%02d:%02d",
$year+1900, $month+1, $day, $hour, $min, $sec;
}
The advantage of the result from get_now() is that it sorts properly
into chronological (or reverse chronological) order.
-Joe
------------------------------
Date: 21 Apr 2004 02:48:13 -0700
From: s99999999s2003@yahoo.com (mike)
Subject: grepping lines above and below a pattern found
Message-Id: <dfd17ef4.0404210148.5450fc51@posting.google.com>
hi
say i have this in a text file
"Use this form to
post your messages.
Remember that
it can be viewed by
millions of people worldwide.
For questions about posting,
check our FAQ"
what is the most commonly used way to print ,say , 2 lines above and 2
lines below a certain pattern found such that my output is
"post your messages.
Remember that
it can be viewed by
millions of people worldwide.
For questions about posting, "
for the matched pattern "viewed" .
thanks...
------------------------------
Date: Wed, 21 Apr 2004 12:14:08 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: grepping lines above and below a pattern found
Message-Id: <c65hqq$88rvl$1@ID-184292.news.uni-berlin.de>
mike wrote:
> say i have this in a text file
>
> "Use this form to
> post your messages.
> Remember that
> it can be viewed by
> millions of people worldwide.
> For questions about posting,
> check our FAQ"
>
> what is the most commonly used way to print ,say , 2 lines above
> and 2 lines below a certain pattern found
Don't know which way is most common. If the file isn't too big, an
easy approach is to slurp all the lines into an array. Otherwise you
can read the file line by line in a while loop, and keep the two
latest lines saved temporarily.
Which ways have you considered?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 21 Apr 2004 07:35:38 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: grepping lines above and below a pattern found
Message-Id: <20040421072554.L15178@dishwasher.cs.rpi.edu>
On Wed, 21 Apr 2004, mike wrote:
> hi
>
> say i have this in a text file
>
> "Use this form to
> post your messages.
> Remember that
> it can be viewed by
> millions of people worldwide.
> For questions about posting,
> check our FAQ"
>
> what is the most commonly used way to print ,say , 2 lines above and 2
> lines below a certain pattern found such that my output is
>
> "post your messages.
> Remember that
> it can be viewed by
> millions of people worldwide.
> For questions about posting, "
>
> for the matched pattern "viewed" .
>
> thanks...
Assuming the file is not so huge that putting it all in memory at once
will hurt you....
#!/usr/bin/perl
use strict;
use warnings;
{
local $/;
open FILE, 'file.txt' or die "Cannot open file: $!";
my $contents = <FILE>;
my $word = 'viewed';
my @matches = $contents =~ /((?:.*\n){2}.*\b$word\b.*\n(?:.*\n){2})/g;
foreach (@matches){
print "$_\n";
}
}
Paul Lalli
------------------------------
Date: Wed, 21 Apr 2004 18:31:45 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: grepping lines above and below a pattern found
Message-Id: <Gnuhc.11$2E2.43@news.oracle.com>
mike wrote:
> hi
>
> say i have this in a text file
>
> "Use this form to
> post your messages.
> Remember that
> it can be viewed by
> millions of people worldwide.
> For questions about posting,
> check our FAQ"
>
> what is the most commonly used way to print ,say , 2 lines above and 2
> lines below a certain pattern found such that my output is
>
> "post your messages.
> Remember that
> it can be viewed by
> millions of people worldwide.
> For questions about posting, "
>
> for the matched pattern "viewed" .
>
> thanks...
Is this allowed ?
system "grep -A2 -B2 $pattern $file";
Thanks
Abhinav
------------------------------
Date: Wed, 21 Apr 2004 09:32:38 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: incorrect value for HOSTNAME executed as cron job
Message-Id: <Wcrhc.179941$K91.447316@attbi_s02>
Robin wrote:
>>When I executed the script manually from the shell it obtain correct
>>value for hostname (harpo for this case). But when I put the script in
>>the cron the perl obtain incorrect value, it gets localhost.
>
> probably something with your crontabs.... or check the paths.
> -Robin
No, it is not Julian's crontab. It the way the cron daemon
handles _everybody's_ crontab files.
rh9# grep -i hostname /etc/bash* /etc/csh*
/etc/bashrc: PROMPT_COMMAND='echo -ne
"\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
/etc/bashrc: PROMPT_COMMAND='echo -ne
"\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
/etc/csh.cshrc: set prompt=\[`id -nu`@`hostname -s`\]\$\
/etc/csh.login:setenv HOSTNAME `/bin/hostname`
Those files are executed by /bin/login but not by /usr/sbin/crond.
Therefore it is up to the person who created the crontab entry to
ensure that the appropriate 'rc' files have been processed in a cron job.
-Joe
------------------------------
Date: 21 Apr 2004 03:51:04 -0700
From: jrodri@HotPop.com (Julian)
Subject: Re: incorrect value for HOSTNAME executed as cron job
Message-Id: <fd6c6323.0404210251.4cf40231@posting.google.com>
"Robin" <robin @ infusedlight.net> wrote in message news:<c64j7j$m0m$3@reader2.nmix.net>...
> "Julian" <jrodri@HotPop.com> wrote in message
> news:fd6c6323.0404201006.a2fce49@posting.google.com...
> > Hi.
> >
> > I have a problem with a script in perl that obtain value of HOSTNAME
> > environment variable.
> >
> > !/usr/bin/perl
> >
> > # Autoflush
> > $|=1;
> >
> > do("/home/sixsl/scripts/constantes.pl");
> >
> > $lock_dir="/var/dbsync";
> >
> > $host_actual=$ENV{HOSTNAME};
> >
> > ...
> >
> > When I executed the script manually from the shell it obtain correct
> > value for hostname (harpo for this case). But when I put the script in
> > the cron the perl obtain incorrect value, it gets localhost. Cron job
> > is executed with the same user that I executed the script from the
> > shell.
> >
> > The cron daemon is vixie cron. The perl version is 5.8.0. The Linux
> > box is RedHat 9.0.
> >
> > Julian.
> probably something with your crontabs.... or check the paths.
> -Robin
I edited crontab file and added HOSTNAME setting and now works. Thanks
for the help to all.
Julian
------------------------------
Date: Wed, 21 Apr 2004 12:51:12 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: incorrect value for HOSTNAME executed as cron job
Message-Id: <x765bto5og.fsf@mail.sysarch.com>
>>>>> "J" == Julian <jrodri@HotPop.com> writes:
J> "Robin" <robin @ infusedlight.net> wrote in message news:<c64j7j$m0m$3@reader2.nmix.net>...
>> probably something with your crontabs.... or check the paths.
>> -Robin
J> I edited crontab file and added HOSTNAME setting and now works. Thanks
J> for the help to all.
boy did you pick the wrong poster to listen to. you solution will work
but not be portable. wait until you need to deploy this to more
machines.
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: 21 Apr 2004 12:27:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need help with table
Message-Id: <c65pbg$cqd$1@mamenchi.zrz.TU-Berlin.DE>
Orion93 <orion93@club-internet.fr> wrote in comp.lang.perl.misc:
> Hi!
>
> I use File::Find and actually my script edit all files in a treefiles but
> don't exclude the files with extension define in extension.def.
>
> The line "elsif ($tabext{$ficext} != undef) {}" doesn't work, I am not able
That's not the way to test for undefined values. Use defined():
elsif ( defined $tabext{$ficext} ) { ...
Anno
------------------------------
Date: 21 Apr 2004 01:48:15 -0700
From: tanlh_listing@hotmail.com (LiHui)
Subject: Re: pattern matching
Message-Id: <500605f9.0404210048.99aced1@posting.google.com>
Thanks Brad & John. Got it now.
LiHui
------------------------------
Date: Wed, 21 Apr 2004 11:17:47 +0100
From: Jack Challen <jack_challen@ocsl.co.uk>
Subject: Re: Popup labels in Tk::Canvas?
Message-Id: <NTrhc.2$Tf.205@psinet-eu-nl>
Josef Möllers wrote:
> I've hacked up a small script which takes lines of numbers (sar output)
> and draws a histogram of the values found in one of the columns (I used
> it to check for anomalies in the sar output).
> I'd like to add some popup labels to the bars displayed, i.e. if I move
> the mouse cursor over one of the bars, a small window should appear
> telling me the value of the bar.
> Any suggestion how this might be done?
Use a Tk::Balloon widget.
FWIW, I'd change the average line so that it's a running average
(calculated again for each sample).
Code included below. I've hacked it about a bit, and I think there might
be an off-by-one error between the bars' values and the values in the
balloons. The essence of the code is there though.
--------
#! /usr/bin/perl -w
use strict;
use Getopt::Std;
use Tk;
use Tk::Balloon;
my %opts;
getopts('c:s:', \%opts);
my $column = $opts{'c'} || 0;
my $separator = $opts{'s'} || '\s+';
my @data = ();
my $max = undef;
my $min = undef;
while (<STDIN>) {
print;
next if /^\s*#/;
chomp;
my @values = split /$separator/;
my $v = $values[$column];
next unless (defined($v) && $v =~ m/^\d+(\.\d*)?$/);
push @data, $v;
$max = $v if (!defined($max) || $v > $max);
$min = $v if (!defined($min) || $v < $min);
}
my $range = $max - $min;
$range = 1 unless $range;
my $sum = 0;
my @original_values = @data;
foreach (@data) {
$_ = (($_ - $min) * 100) / $range;
$sum += $_;
}
my $nsamples = scalar @data;
my $linewidth = int(1000 / $nsamples);
my $top = new MainWindow;
my $c = $top->Canvas(-width => $nsamples * $linewidth,
-height => 100,
-state => 'normal');
$c->pack(-side => 'top');
my $balloon = $c->Balloon;
my %messages;
for (my $i = 0; $i < $nsamples; $i++) {
$c->createLine($i*$linewidth, 100, $i*$linewidth, 100-$data[$i],
-width => $linewidth, -fill => 'black', -tag => $i);
$messages{$i} = $original_values[$i];
}
$balloon->attach($c, -balloonposition => 'mouse', -msg => \%messages);
my $avg = $sum / $nsamples;
$c->createLine(0, 100-$avg, $nsamples*$linewidth-1, 100-$avg, -fill => 'red');
MainLoop;
------------------------------
Date: Wed, 21 Apr 2004 12:50:10 +0200
From: =?ISO-8859-1?Q?Josef_M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Popup labels in Tk::Canvas?
Message-Id: <c65jes$8i0$1@nntp.fujitsu-siemens.com>
Jack Challen wrote:
> Josef M=F6llers wrote:
>=20
>> I've hacked up a small script which takes lines of numbers (sar=20
>> output) and draws a histogram of the values found in one of the=20
>> columns (I used it to check for anomalies in the sar output).
>> I'd like to add some popup labels to the bars displayed, i.e. if I=20
>> move the mouse cursor over one of the bars, a small window should=20
>> appear telling me the value of the bar.
>> Any suggestion how this might be done?
>=20
>=20
> Use a Tk::Balloon widget.
>=20
> FWIW, I'd change the average line so that it's a running average=20
> (calculated again for each sample).
>=20
> Code included below. I've hacked it about a bit, and I think there migh=
t=20
> be an off-by-one error between the bars' values and the values in the=20
> balloons. The essence of the code is there though.
Thanks, exactly what I was after.
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Wed, 21 Apr 2004 12:47:19 +0200
From: "Jan Biel" <jan.biel@tu-clausthal.de>
Subject: regular expressions for postgres syntax
Message-Id: <c65jff$133a$1@ariadne.rz.tu-clausthal.de>
Hi there!
I'm looking for a regular expression or a set of expressions able to cut
Postgres (or any SQL) code into its syntactical parts.
For example if the code was
CREATE TABLE table_a (
attrib_a varchar(8) NOT NULL,
attrib_b varchar(10)
);
I need to extract the components like this:
CREATE TABLE
table_a
---
attib_a
varchar(8)
NOT NULL
---
attrib_b
varchar(10)
---
This is only a simplified example, since SQL code can be much more complex.
I was hoping there are given regular expressions so I wouldn't have to do
all the work by myself (which I'm not sure I'm able to).
Postgres would be awesome, but any SQL version would do since I could
translate the expressions rather easily, I guess.
Thanks in advance on any help towards the matter
Janbiel
------------------------------
Date: Wed, 21 Apr 2004 12:15:14 +0100
From: Jack Challen <jack_challen@ocsl.co.uk>
Subject: Re: regular expressions for postgres syntax
Message-Id: <0Kshc.3$Tf.285@psinet-eu-nl>
Jan Biel wrote:
> I'm looking for a regular expression or a set of expressions able to cut
> Postgres (or any SQL) code into its syntactical parts.
You really *don't* want to try a regex approach. SQL's an entire language,
I doubt a regular expression would be possible, and it certainly wouldn't
be readable.
You want a parser.
In fact, you want SQL::Parser.
http://search.cpan.org/search?query=sql%3A%3Aparser&mode=module
jack
------------------------------
Date: Wed, 21 Apr 2004 12:18:04 +0100
From: Jack Challen <jack_challen@ocsl.co.uk>
Subject: Re: regular expressions for postgres syntax
Message-Id: <nMshc.4$Tf.292@psinet-eu-nl>
Jan Biel wrote:
> I'm looking for a regular expression or a set of expressions able to cut
> Postgres (or any SQL) code into its syntactical parts.
Whoops. Previous post missed out obvious module to try...
You really *don't* want to try a regex approach. SQL's an entire language,
I doubt a regular expression would be possible, and it certainly wouldn't
be readable.
You want a parser.
In fact, you want SQL::Parser, or SQL::Translator::Parser::PostgreSQL
http://search.cpan.org/search?query=sql%3A%3Aparser&mode=module
http://search.cpan.org/~kclark/SQL-Translator-0.05/lib/SQL/Translator/Parser/PostgreSQL.pm
-or-
http://tinyurl.com/yruzd
jack
------------------------------
Date: Wed, 21 Apr 2004 21:56:48 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: regular expressions for postgres syntax
Message-Id: <1130149.GzZTxOMpSK@GMT-hosting-and-pickle-farming>
Jan Biel wrote:
> Hi there!
>
> I'm looking for a regular expression or a set of expressions able to cut
> Postgres (or any SQL) code into its syntactical parts.
You want a parser, not a regular expression. If you dont know the difference
then you are out of your depth.
gtoomey
------------------------------
Date: Wed, 21 Apr 2004 08:46:04 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Request for program test on different operating sytsems
Message-Id: <gxqhc.170742$gA5.1989516@attbi_s03>
edgrsprj wrote:
> open batfile, '> '.$directoryname.'Perltest.bat';
> print batfile 'c:\windows\start.exe '.$directoryname.'Perltest.txt';
> # print batfile 'c:\windows\start.exe '.$directoryname.'Perltest.txt';
> close batfile;
What about
system "editor ${directoryname}Perltest.txt";
or
system "notepad ${directoryname}Perltest.txt";
Of course that has the disadvantage of completely ignoring the registry
setting that associates *.txt with the user's favorite plaintext editor.
-Joe
------------------------------
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 6439
***************************************