[27332] in Perl-Users-Digest
Perl-Users Digest, Issue: 9049 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 13 21:06:55 2006
Date: Mon, 13 Mar 2006 18:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 13 Mar 2006 Volume: 10 Number: 9049
Today's topics:
Re: A Problem With GD <abigail@abigail.nl>
Re: Creating Graphs Dynamically with Perl <no@spam>
Re: Creating Graphs Dynamically with Perl <rvtol+news@isolution.nl>
Re: Creating Graphs Dynamically with Perl <abigail@abigail.nl>
Re: Creating Graphs Dynamically with Perl <john@castleamber.com>
Re: Creating Graphs Dynamically with Perl <anfi@priv.onet.pl>
Re: Creating Graphs Dynamically with Perl <1usa@llenroc.ude.invalid>
Re: Creating Graphs Dynamically with Perl <abigail@abigail.nl>
Re: Creating Graphs Dynamically with Perl <rvtol+news@isolution.nl>
Re: Creating Graphs Dynamically with Perl <kraven@not-here.org>
Re: Creating Graphs Dynamically with Perl <abigail@abigail.nl>
Re: Creating Graphs Dynamically with Perl <kraven@not-here.org>
Re: export a variable from a module <tadmc@augustmail.com>
Re: export a variable from a module <rvtol+news@isolution.nl>
Re: for installing perl modules - is there a default C <sisyphus1@nomail.afraid.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Mar 2006 19:56:16 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: A Problem With GD
Message-Id: <slrne1bjiv.1v0.abigail@alexandra.abigail.nl>
Mark Manning (markem@airmail.net) wrote on MMMMDLXXVII September MCMXCIII
in <URL:news:121a80kk7n3g46b@corp.supernews.com>:
}}
}}
}} Uri Guttman wrote:
}}
}} >>>>>>"r" == robic0 <robic0> writes:
}} >
}} >
}} > r> On 11 Mar 2006 21:20:50 GMT, Abigail <abigail@abigail.nl> wrote:
}} > >> $var = [1, 0] -> [$var];
}} > r> meaningless..
}} >
}} > perfectly valid and working perl. not for production.
}}
}} Why not for production. Does it have side effects?
Well, it creates an array for each assignment. Not very efficient.
Here's a benchmark of various methods. Not that the speed is
very important, there's only a difference of 1.72 microseconds
between the slowest and fastest method in my measurements.
#!/usr/bin/perl
use strict;
use warnings;
no warnings 'syntax';
use List::Util qw {max sum};
my $times = 1_000_000;
my $runs = 5;
my $set = [1, 0];
my @set = (1, 0);
my @code = (
' $v = ($v + 1) % 2',
' $v = !$v',
' $v = 1 - $v',
'($v += 1) %= 2',
' $v = $v ? 0 : 1',
' $v = [1, 0] -> [$v]',
' $v = (1, 0) [$v]',
' $v = $$set [$v]',
' $v = $set [$v]',
);
my $l = max map {length} @code;
my $format = "%-${l}s: ";
$format .= join " " => ("%.2f") x $runs;
$format .= " %.2f\n";
my @data;
foreach my $code (@code) {
my @r;
my $CODE = <<" --";
my \$v = 0;
my (\$u0, \$s0, \$cu0, \$cs0) = times;
for (1 .. $times) {$code}
my (\$u1, \$s1, \$cu1, \$cs1) = times;
(\$u1 + \$s1 + \$cu1 + \$cs1) - (\$u0 + \$s0 + \$cu0 + \$cs0);
--
for (1 .. $runs) {
my $r = eval $CODE;
die $@ if $@;
push @r => $r;
}
push @data => [$code, @r, sum (@r) / $runs];
}
foreach my $data (sort {$$a [-1] <=> $$b [-1]} @data) {
printf $format => @$data;
}
__END__
$v = 1 - $v : 0.44 0.45 0.43 0.45 0.44 0.44
$v = $v ? 0 : 1 : 0.50 0.50 0.50 0.50 0.51 0.50
$v = $set [$v] : 0.54 0.54 0.55 0.54 0.54 0.54
$v = (1, 0) [$v] : 0.57 0.58 0.58 0.58 0.58 0.58
$v = !$v : 0.60 0.59 0.60 0.58 0.59 0.59
$v = $$set [$v] : 0.61 0.60 0.60 0.60 0.61 0.60
$v = ($v + 1) % 2 : 0.69 0.69 0.70 0.69 0.69 0.69
($v += 1) %= 2 : 0.70 0.69 0.69 0.70 0.70 0.70
$v = [1, 0] -> [$v]: 2.16 2.18 2.16 2.10 2.19 2.16
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
------------------------------
Date: Mon, 13 Mar 2006 13:32:15 -0600
From: "Hi" <no@spam>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <121bi686bstn5e5@corp.supernews.com>
My mistake. Thought everyone knew what MRTG was. Not sure why I thought
that. Anyway. I have some data and I want to use perl to make some nice
pretty graphs that look something like this.
http://www.linux.cz/stats/mrtg-rrd/eth0-day.png
I think I found what might be the solution.
http://search.cpan.org/~mverb/GDGraph-1.43/
Any other easy to use perl ways to make graphs like this out there?
Matt
>> How do I create graphs that look like MRTG dynamically with perl? Are
>> there any easy ways to do that?
>
> I had no idea what MRTG was, so I googled on it. The first hit said "MRTG
> is written in perl and works on Unix/Linux as well as Windows and even
> Netware systems". So my guess would be that to do something like MRTG in
> Perl, you would use MRTG. If you already tried that and encountered
> problems, then what were the problems?
------------------------------
Date: Mon, 13 Mar 2006 20:46:20 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <dv4lv5.1a4.1@news.isolution.nl>
Hi schreef:
Please don't top-post.
> [...] I want to use perl to
> make some nice pretty graphs that look something like this.
> http://www.linux.cz/stats/mrtg-rrd/eth0-day.png
> I think I found what might be the solution.
> http://search.cpan.org/~mverb/GDGraph-1.43/
> Any other easy to use perl ways to make graphs like this out there?
http://search.cpan.org/~mschilli/RRDTool-OO-0.13/
--
Affijn, Ruud
"Gewoon is een tijger."
echo 014C8A26C5DB87DBE85A93DBF |perl -pe 'tr/0-9A-F/JunkshoP cartel,/'
------------------------------
Date: 13 Mar 2006 20:00:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <slrne1bjrc.1v0.abigail@alexandra.abigail.nl>
Hi (no@spam) wrote on MMMMDLXXVII September MCMXCIII in
<URL:news:121b2r8hp8o2td9@corp.supernews.com>:
}} How do I create graphs that look like MRTG dynamically with perl? Are there
}} any easy ways to do that?
I'm quite charmed by gnuplot, and I use it exclusively to create graphs.
But it uses a pipe (Eeew!) to an external program (Eeew!) and doesn't
use a module (Eeew!). So most people consider me a heretic.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
------------------------------
Date: 13 Mar 2006 20:28:54 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <Xns9785934F0B610castleamber@130.133.1.4>
Abigail <abigail@abigail.nl> wrote:
> I'm quite charmed by gnuplot, and I use it exclusively to create
> graphs. But it uses a pipe (Eeew!) to an external program (Eeew!) and
> doesn't use a module (Eeew!). So most people consider me a heretic.
So I probably shouldn't write here that I use Ant to run a few Perl tasks,
one using pscp to upload some files :-P
--
John Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: Mon, 13 Mar 2006 21:34:57 +0100
From: Andrzej Adam Filip <anfi@priv.onet.pl>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <87slpmkrri.fsf@anfi.homeunix.net>
"Hi" <no@spam> writes:
> How do I create graphs that look like MRTG dynamically with perl?
> Are there any easy ways to do that?
Have you seen rrdtool?
It is mrtg successor. The program can accept commands via stdin
(one command per line) or you can use special perl module to do it.
--
[pl2en Andrew] Andrzej Adam Filip : anfi@priv.onet.pl : anfi@xl.wp.pl
http://anfi.homeunix.net/
------------------------------
Date: Mon, 13 Mar 2006 20:37:20 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <Xns97859F0819588asu1cornelledu@127.0.0.1>
"Hi" <no@spam> wrote in news:121bi686bstn5e5@corp.supernews.com:
> My mistake. Thought everyone knew what MRTG was.
That's OK, but it is a good idea to give a URL when you are talking
about a specific software package.
Another good idea is to trim your reply, and put your responses
interspersed with the relevant sections of previous posts. See the
posting guidelines for further suggestions on how to quote.
> Anyway. I have some data and I want to use perl to
> make some nice pretty graphs that look something like this.
>
> http://www.linux.cz/stats/mrtg-rrd/eth0-day.png
>
> I think I found what might be the solution.
>
> http://search.cpan.org/~mverb/GDGraph-1.43/
>
> Any other easy to use perl ways to make graphs like this out there?
I would recommend starting with GD::Graph.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 13 Mar 2006 20:37:25 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <slrne1bm05.1v0.abigail@alexandra.abigail.nl>
John Bokma (john@castleamber.com) wrote on MMMMDLXXVII September MCMXCIII
in <URL:news:Xns9785934F0B610castleamber@130.133.1.4>:
`` Abigail <abigail@abigail.nl> wrote:
``
``
`` > I'm quite charmed by gnuplot, and I use it exclusively to create
`` > graphs. But it uses a pipe (Eeew!) to an external program (Eeew!) and
`` > doesn't use a module (Eeew!). So most people consider me a heretic.
``
`` So I probably shouldn't write here that I use Ant to run a few Perl tasks,
`` one using pscp to upload some files :-P
``
I use 'make' to run all kinds of programs, including Perl programs.
I have replaced Perl programs by Makefiles (or Makefile targets)
more than once.
make rules.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Mon, 13 Mar 2006 21:41:48 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <dv4ovs.17g.1@news.isolution.nl>
Abigail schreef:
> Hi:
>> How do I create graphs that look like MRTG dynamically with perl?
>> Are there any easy ways to do that?
>
> I'm quite charmed by gnuplot, and I use it exclusively to create
> graphs.
> But it uses a pipe (Eeew!) to an external program (Eeew!) and doesn't
> use a module (Eeew!). So most people consider me a heretic.
MRTG-like gnuplots:
http://www.atd.ucar.edu/cgi-bin/weather.cgi
I still like PEAR_Image_Graph a lot:
http://pear.veggerby.dk/
http://pear.veggerby.dk/samples/
http://pear.php.net/package/Image_Graph/
--
Affijn, Ruud
"Gewoon is een tijger."
echo 014C8A26C5DB87DBE85A93DBF |perl -pe 'tr/0-9A-F/JunkshoP cartel,/'
------------------------------
Date: Mon, 13 Mar 2006 21:36:57 GMT
From: Kraven <kraven@not-here.org>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <ZBlRf.53739$H71.31403@newssvr13.news.prodigy.com>
Abigail wrote:
> Hi (no@spam) wrote on MMMMDLXXVII September MCMXCIII in
> <URL:news:121b2r8hp8o2td9@corp.supernews.com>:
> }} How do I create graphs that look like MRTG dynamically with perl? Are there
> }} any easy ways to do that?
>
>
> I'm quite charmed by gnuplot, and I use it exclusively to create graphs.
> But it uses a pipe (Eeew!) to an external program (Eeew!) and doesn't
> use a module (Eeew!). So most people consider me a heretic.
>
>
>
> Abigail
You mean a pipe like
#!/usr/bin/perl -w
use strict;
my $somefile = "/path/to/somefile";
my $pid = open Apipe, "| cat $somefile|less";
close(Apipe);
but surely not...
system("cat $somefile|less");
------------------------------
Date: 13 Mar 2006 21:53:17 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <slrne1bqec.1v0.abigail@alexandra.abigail.nl>
Kraven (kraven@not-here.org) wrote on MMMMDLXXVII September MCMXCIII in
<URL:news:ZBlRf.53739$H71.31403@newssvr13.news.prodigy.com>:
-: Abigail wrote:
-: > Hi (no@spam) wrote on MMMMDLXXVII September MCMXCIII in
-: > <URL:news:121b2r8hp8o2td9@corp.supernews.com>:
-: > }} How do I create graphs that look like MRTG dynamically with perl? Are there
-: > }} any easy ways to do that?
-: >
-: >
-: > I'm quite charmed by gnuplot, and I use it exclusively to create graphs.
-: > But it uses a pipe (Eeew!) to an external program (Eeew!) and doesn't
-: > use a module (Eeew!). So most people consider me a heretic.
-: >
-: >
-: >
-: > Abigail
-: You mean a pipe like
-:
-: #!/usr/bin/perl -w
-: use strict;
-: my $somefile = "/path/to/somefile";
-: my $pid = open Apipe, "| cat $somefile|less";
-: close(Apipe);
-:
-: but surely not...
-:
-: system("cat $somefile|less");
Those are different types of pipes?
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s};;;
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)}; # Perl 5.6.0 broke this...
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Mon, 13 Mar 2006 23:26:59 GMT
From: Kraven <kraven@not-here.org>
Subject: Re: Creating Graphs Dynamically with Perl
Message-Id: <7dnRf.53773$H71.44453@newssvr13.news.prodigy.com>
> -: You mean a pipe like
> -:
> -: #!/usr/bin/perl -w
> -: use strict;
> -: my $somefile = "/path/to/somefile";
> -: my $pid = open Apipe, "| cat $somefile|less";
> -: close(Apipe);
> -:
> -: but surely not...
> -:
> -: system("cat $somefile|less");
>
>
> Those are different types of pipes?
>
>
> Abigail
Yes, piping from inside PERL. It can get way more complicated with the
$pid version. Basically you can run other programs from within perl
with open, system, exec, `....`, or glob.
------------------------------
Date: Mon, 13 Mar 2006 18:11:49 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: export a variable from a module
Message-Id: <slrne1c2i5.an7.tadmc@magna.augustmail.com>
John Bokma <john@castleamber.com> wrote:
> Uri Guttman <uri@stemsystems.com> wrote:
>
>>>>>>> "JB" == John Bokma <john@castleamber.com> writes:
>>
>> JB> Uri Guttman <uri@stemsystems.com> wrote:
>> >> as you were told in another response perl has a constant pragma
>>
>> JB> Which just creates a subroutine in the current implementation.
> To me it's not the same as a constant in other programming languages, YMMV
To me Perl is not the same as other programming languages, YMMV.
(though I'd admit that Perl's constants are a bit crufty.)
> I only stated that a
> "constant" is a subroutine in the current implementation, nothing more,
> nothing less.
But we're all left wondering _why_ you thought it was worth stating.
Does their implementation render them not-applicable to the OP's
situation or something?
Or did you just want to get the cruftiness mentioned so others
can avoid thinking constants are like what they are familiar
with from other languages?
Some other reason?
To me, this exchange seems like someone posted:
$var = 1 + 3;
And got a followup like:
addition is performed using numbers in 1's complement form
What is the point of mentioning the implementation unless
the implementation makes a difference to the current discussion?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 14 Mar 2006 02:10:04 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: export a variable from a module
Message-Id: <dv58mk.gg.1@news.isolution.nl>
Tad McClellan schreef:
> John Bokma:
>> [Perl constants are implemented as inline subs]
>> To me it's not the same as a constant in other programming
>> languages, YMMV
>
> To me Perl is not the same as other programming languages, YMMV.
> (though I'd admit that Perl's constants are a bit crufty.)
Only a bit. For example:
$ perl -MO=Deparse -e 'use constant{one=>1}; $var=one'
use constant ({'one', 1});
$var = 1;
-e syntax OK
--
Affijn, Ruud
"Gewoon is een tijger."
echo 014C8A26C5DB87DBE85A93DBF |perl -pe 'tr/0-9A-F/JunkshoP cartel,/'
------------------------------
Date: Tue, 14 Mar 2006 12:22:14 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: for installing perl modules - is there a default C compiler on win X64
Message-Id: <44161b81$0$25196$afc38c87@news.optusnet.com.au>
"sm" <imfeaw5672@pacbell.net> wrote in message
news:rXPQf.38034$_S7.16680@newssvr14.news.prodigy.com...
> Here is "perl -V"
>
> --> perl -V
> Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
> Platform:
> osname=MSWin32, osvers=5.0, archname=MSWin32-x86-multi-thread
I've just received notification that build 816 has been released. The
release blurb informs me that ActiveState are now releasing a 64-bit version
of perl as well. I don't know if this is the first time they've done that
... maybe they've been doing it for a while and I hadn't noticed. Anyway ...
the op (and others) might be interested in trying it out.
Cheers,
Rob
------------------------------
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 9049
***************************************