[23346] in Perl-Users-Digest
Perl-Users Digest, Issue: 5565 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 26 06:05:42 2003
Date: Fri, 26 Sep 2003 03: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 Fri, 26 Sep 2003 Volume: 10 Number: 5565
Today's topics:
Re: accessing Hash of Arrays <krahnj@acm.org>
Re: Another CRON question <abigail@abigail.nl>
Re: Another CRON question <krahnj@acm.org>
choose from duplicate hash keys <phddas@yahoo.com>
Re: choose from duplicate hash keys <mpapec@yahoo.com>
Re: choose from duplicate hash keys <phddas@yahoo.com>
Re: choose from duplicate hash keys <phddas@yahoo.com>
Re: Compiling perl with GCC <marcus@automint.co.uk>
Re: Compiling perl with GCC <kalinabears@iinet.net.au>
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Evals, quotes and backslashes problem <newsonly@pmburtonNOT-THIS.claraORTHIS.co.uk>
Re: favicon.ico and perl <ian@WINDOZEdigiserv.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 26 Sep 2003 09:46:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: accessing Hash of Arrays
Message-Id: <3F740AE1.59063CF@acm.org>
JohnWalter wrote:
>
> thanks for all the comments.
> my code as below, I can do $lineno++ to apply a code to only the first
> line inorder to put the column headings in an array on it's own. but
> maybe some of you know how to avoid this 'maybe expensive' process.
If you are reading from a filehandle in a while loop then perl provides
the $. variable which contains the current line number.
> while (<DATA>) {
> @column_header = split(/s+/); <- this is not correct, only needed at the
> first line.
> my ($key, @values) = split;
> $table{$key} = \@values;
> }
while ( <DATA> ) {
if ( $. == 1 ) {
@column_header = split;
}
else {
my ( $key, @values ) = split;
$table{ $key } = \@values;
}
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: 26 Sep 2003 08:16:58 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Another CRON question
Message-Id: <slrnbn7tfp.53d.abigail@alexandra.abigail.nl>
Sean O'Dwyer (notspam@spamfree.dud) wrote on MMMDCLXXVIII September
MCMXCIII in <URL:news:notspam-AA02F6.23050825092003@news-server.nyc.rr.com>:
.. Can I pass a variable to a Perl script via cron? It seems not from the
.. following error message...
..
.. /bin/sh: line 1: /cgi-bin/script2.cgi?action=call_a_routine: No such
.. file or directory
..
.. In my crontab I have...
..
..
.. MAILTO="my@emailaddress.net"
.. HOME="/cgi-bin/"
.. */5 * * * * /cgi-bin/script1.cgi
.. */3 * * * * /cgi-bin/script2.cgi?action=call_a_routine
..
.. ...is this just daft?
Yes. URL are *NOT* file names. The second line asks cron to start the
program '/cgi-bin/script2.cgi?action=call_a_routine' every 3 hours. I
doubt there is such a program. Frankly, I would be surprised if there's
a directory /cgi-bin.
CGI programs run in a specific environment. An environment that
naturaly isn't set up by cron.
Now, since none of this has anything to do with Perl, I stop here.
Abigail
--
perl -Mstrict='}); print "Just another Perl Hacker"; ({' -le1
------------------------------
Date: Fri, 26 Sep 2003 08:57:49 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Another CRON question
Message-Id: <3F73FF6D.4849C22D@acm.org>
Gregory Toomey wrote:
>
> It was a dark and stormy night, and Sean O'Dwyer managed to scribble:
> >
> > MAILTO="my@emailaddress.net"
> > HOME="/cgi-bin/"
> > */5 * * * * /cgi-bin/script1.cgi
> > */3 * * * * /cgi-bin/script2.cgi?action=call_a_routine
>
> Yes. You probably need
>
> HOME="/fully/qualified/path/cgi-bin/"
>
> Also, I'm not sure why use use */5 and */3.
*/5 means to run every five minutes, */3 every three minutes.
man 5 crontab
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 26 Sep 2003 18:01:25 +1000
From: JohnWalter <phddas@yahoo.com>
Subject: choose from duplicate hash keys
Message-Id: <3F73F255.9000709@yahoo.com>
Hello
in a data file with rows and columns, I need to see which lines are
repeated and get to choose which one of those repeated lines to keep and
delete the rest with their rows from the file.
the first column is a uniqe data so it can be considerd a key.
can some one give me a hint
I am thinking this way
open DATA, $file or die $!;
while (<DATA>) {
my ($key, @value) = split;
$table{$key}++;
}
then I am not thinkg right.. what is the value for each key? how can
this be done. print a list of duplicate and get to choose which to keep
and delete the rest.
thanks alot
------------------------------
Date: Fri, 26 Sep 2003 10:26:52 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: choose from duplicate hash keys
Message-Id: <rpt7nvcml5qvvuh9165760cvk0ls8m3fa1@4ax.com>
On Fri, 26 Sep 2003 18:01:25 +1000, JohnWalter <phddas@yahoo.com>
wrote:
>delete the rest with their rows from the file.
>the first column is a uniqe data so it can be considerd a key.
>
>can some one give me a hint
>
>I am thinking this way
>
>open DATA, $file or die $!;
>while (<DATA>) {
> my ($key, @value) = split;
> $table{$key}++;
>}
>then I am not thinkg right.. what is the value for each key? how can
>this be done. print a list of duplicate and get to choose which to keep
>and delete the rest.
Post some lines from your $file and show what you want as final
result.
------------------------------
Date: Fri, 26 Sep 2003 19:27:25 +1000
From: JohnWalter <phddas@yahoo.com>
Subject: Re: choose from duplicate hash keys
Message-Id: <3F74067D.8020609@yahoo.com>
JohnWalter wrote:
> Hello
>
>
> in a data file with rows and columns, I need to see which lines are
> repeated and get to choose which one of those repeated lines to keep and
> delete the rest with their rows from the file.
> the first column is a uniqe data so it can be considerd a key.
>
> can some one give me a hint
>
> I am thinking this way
>
> open DATA, $file or die $!;
> while (<DATA>) {
> my ($key, @value) = split;
> $table{$key}++;
> }
> then I am not thinkg right.. what is the value for each key? how can
> this be done. print a list of duplicate and get to choose which to keep
> and delete the rest.
>
> thanks alot
>
>
>
>
>
>
steps:
#loop into the file and build a hash with duplicate keys
open DATA, $from_file or die $!;
my %duple;
while (<DATA>) {
my ($key, @value) = split;
$duple{$key}++;
}
#loop into the file and build ARRAY of arrays of those duplicate lines.
for my $k ( keys %duple ) {
if ($duple{$k} > 1) {
while (<DATA>) {
if ($k = shift ( split )) {
my @duple_line = build ARRAY of arrays here.. heeeelp :)
}
#foreach ARRAY print arrays with numbers to choose which to keep.
this is over my head. but I love the challenge
------------------------------
Date: Fri, 26 Sep 2003 19:58:42 +1000
From: JohnWalter <phddas@yahoo.com>
Subject: Re: choose from duplicate hash keys
Message-Id: <3F740DD2.9020700@yahoo.com>
JohnWalter wrote:
> JohnWalter wrote:
>
>> Hello
>>
>>
>> in a data file with rows and columns, I need to see which lines are
>> repeated and get to choose which one of those repeated lines to keep
>> and delete the rest with their rows from the file.
>> the first column is a uniqe data so it can be considerd a key.
>>
>> can some one give me a hint
>>
>> I am thinking this way
>>
>> open DATA, $file or die $!;
>> while (<DATA>) {
>> my ($key, @value) = split;
>> $table{$key}++;
>> }
>> then I am not thinkg right.. what is the value for each key? how can
>> this be done. print a list of duplicate and get to choose which to
>> keep and delete the rest.
>>
>> thanks alot
>>
>>
>>
>>
>>
>>
>
> steps:
> #loop into the file and build a hash with duplicate keys
> open DATA, $from_file or die $!;
> my %duple;
> while (<DATA>) {
> my ($key, @value) = split;
> $duple{$key}++;
> }
>
> #loop into the file and build ARRAY of arrays of those duplicate lines.
> for my $k ( keys %duple ) {
> if ($duple{$k} > 1) {
> while (<DATA>) {
> if ($k = shift ( split )) {
> my @duple_line = build ARRAY of arrays here.. heeeelp :)
> }
>
>
> #foreach ARRAY print arrays with numbers to choose which to keep.
>
> this is over my head. but I love the challenge
>
open DATA, $from_file or die $!;
my %duple;
while (<DATA>) {
my ($key, @value) = split;
$duple{$key}++;
}
my @duple_line;
my $lineno = 0;
for my $k ( keys %duple ) {
if ($duple{$k} > 1) {
while (<DATA>) { #this line does not look like it will open
another instant of the same file.
my @line = split;
if ($k = shift @line ) {
$duple_line[$lineno] = [ split ];
$lineno++;
}
}
}
}
I am not even sure if this is the correct approch.
------------------------------
Date: Fri, 26 Sep 2003 08:23:14 +0100
From: Marcus <marcus@automint.co.uk>
Subject: Re: Compiling perl with GCC
Message-Id: <MPG.19ddf9a4b20a58f798968b@192.168.1.50>
In article <bkv4po$5td$1@ichaos.ichaos-int>, Juha.Laiho@iki.fi says...
> Marcus <marcus@automint.co.uk> said:
> >OK tried changing the -03 in the makefile to -02 and it looked better
>
> Note, the optimization option is -O2, not -02.
>
> >Thank you, but any more ideas?
>
> Check if there's any later gcc RPM for your distribution. Though what
> you have seems pretty recent already.
>
> Note that you can't safely mix&match RPMs from different distributions,
> so even through you might be succesful in installing an RPM meant
> for some other distribution, there's no guarantee it'll work properly.
>
Yes it was -O2 not -02 I used, sorry for the typo. Using the trial and
error method -O1 seemed to work, which is slightly bizarre given that
later reading revealed that there isn't an -O1 option!!!!
Anyway make test went through to the end. At which point I was told that
I'd failed just one of the tests. I was advised to set LD_LIBRARY_PATH
to include the build directory and then run ./perl harness.
I did this and was hit with this report:-
----------------------------------------------------------------------
Failed test ../lib/Net/t/hostname.t Total 2 Fail 1 Failed 50.00%
List of Failed 1
41 tests and 410 tests skipped.
Failed 1 out of 712 test scripts, 99.86% okay. 1/68623 subtests failed,
100.00% Okay.
----------------------------------------------------------------------
I found a newsgroup featuring somebody who had exactly this test failed
at 50% and they said that they fixed it by setting the reverse DNS up.
Thing is I don't even have forward DNS set up. I have a file /etc/hosts
which provides hostname to address mapping for the TCP/IP subsystem and
says it can be used on small systems instead of a "named" name server.
Do I need to set my machine up as a name server? If so which is the
simplest way to do it or do I need to go the whole hog and install bind
or some such?
I would be loath to go to the lengths of compiling and installing yet
another indepth piece of software. A fortnight ago I'd never seen a
linux prompt and decided I needed to set a box up as a proxy and mail
server. Every time I try to install something though, there seems to be
five things that it depends on that need installing first. All of which
seem to my novice eyes to be tricky. Hence my aversion to tackling bind
at this point.
So what is the simplest way to set up the reverse DNS?
Regards,
Marcus Thornton.
------------------------------
Date: Fri, 26 Sep 2003 18:43:19 +1000
From: Sisyphus <kalinabears@iinet.net.au>
Subject: Re: Compiling perl with GCC
Message-Id: <3f73fcda$0$23595$5a62ac22@freenews.iinet.net.au>
Marcus wrote:
> I was unable to compile some perl modules, because after running #perl
> Makefile.PL running #make was trying to call up /usr/bin/cc rather than
> gcc.
>
This happens presumably because 'perl -V:cc' reports 'cc' - which means
that cc is the appropriate compiler to use with this build of perl.
I gather you don't have cc installed - but it should be available from
the OS installation discs.
At least it's on my (Mandrake) linux pc and I certainly didn't purchase
it or download it over the web.
Afaik, neither cc nor gcc is part of the standard install - when I
installed gcc from the installation disks, cc mysteriously appeared also.
All I'm getting at is that it might be simpler for you to install cc and
stay with the existing perl installation *if* there's no other problems
with it.
The perl that came with my Linux is missing the CORE/ files - so I
installed another perl (running as a user, but I needed to run 'make
install' as root). Now I have 2 - the one that came with the OS (and
gets found by the OS or whenever I run as root), and the one I installed
(and gets found when I run as a user).
Sounds like you're trying to replace the original. Running as a user, I
had no problem in getting perl to build with both cc and gcc. I'm new to
Linux, and don't know which is the most appropriate course of action to
take. Just thought I'd throw this is in to give you something else to
think about (which I'm sure you need :-), and to see if someone has some
comments and advice that might lead to *my* edification, too.
Cheers,
Rob
------------------------------
Date: 26 Sep 2003 08:46:42 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1064565877@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs/XEmacs
o Unix:
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
o Unix Windows port (for Unix die-hards):
install http://www.cygwin.com/ which includes native Emacs 21.x.
XEmacs port is bundled in XEmacs setup.exe available from
XEmacs site.
o Pure Native Windows port
http://www.gnu.org/software/emacs/windows/ntemacs.html
ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe
o More Emacs resources at
http://tiny-tools.sourceforge.net/ => Emacs resource page
Emacs Perl Modules
Cperl -- Perl programming mode
ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
http://www.perl.com/CPAN-local/misc/emacs/cperl-mode/
<ilya@math.ohio-state.edu> Ilya Zakharevich
CPerl is major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
standard in newest Emacs.
TinyPerl -- Perl related utilities
http://tiny-tools.sourceforge.net/
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Grep through all Perl manpages (.pod)
o Follow POD references e.g. [perlre] to next pod with RETURN
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o Update `$VERSION' variable with YYYY.MMDD on save.
o Load source code into Emacs, like Devel::DProf.pm
o Prepare script (version numbering) and Upload it to PAUSE
o Generate autoload STUBS (Devel::SelfStubber) for you
Perl Module (.pm)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in Tiny Tools Kit]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
how to set up dattabases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to to do the search, You can adjust
recursive grep options, set search case sensitivity, add user grep
options etc.
You can find latest `igrep.el' module at
<http://groups.google.com/groups?group=gnu.emacs.sources> The
maintainer is Jefin Rodgers <kevinr@ihs.com>.
TinyCompile -- To Browse grep results in Emacs *compile* buffer
TinyCompile is a minor mode for *compile* buffer from where
you can collapse unwanted lines or shorten file URLs:
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Fri, 26 Sep 2003 09:10:01 +0100
From: Paul Burton <newsonly@pmburtonNOT-THIS.claraORTHIS.co.uk>
Subject: Evals, quotes and backslashes problem
Message-Id: <3F73F459.4060309@pmburtonNOT-THIS.claraORTHIS.co.uk>
I've got some code similar to this:
$a='$b="a_string"';
eval($a);
print $b;
For the above, this simply prints out "a_string".
Of course, I actually want something a little more interesting than
a_string. The output I actually want is the following string:
\$a_var
I thought I could achieve this by:
$a='$b="\\\$a_var"';
but this only produces the output:
\
I've managed to hack around this problem by generating my own special
string wherever I want a "\$" in the output, and using a string
substitution to put in the backslash:
$a='$b="\!\$a_var"'
eval($a);
$b =~ s/\!\$/\\\$/g;
which does the trick.
Is there a way of doing this without the substitution cludge, with some
clever combination of quotes and backslashes? I've tried a few things,
but nothing seems to work!
Cheers
Paul.
------------------------------
Date: Fri, 26 Sep 2003 07:18:35 GMT
From: "Ian.H" <ian@WINDOZEdigiserv.net>
Subject: Re: favicon.ico and perl
Message-Id: <pan.2003.09.26.07.19.30.225390@hybris.digiserv.net>
On Fri, 26 Sep 2003 09:19:58 +0200, Arjen wrote:
> I thouht that especially with
> IE it should work...
IE is _the_ worst browser for anything rational.. it's a horrible piece of
software to work with, as it tends to render what it assumes should be
right (which very often isn't) rather than how you actually coded things.
Regards,
Ian
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
------------------------------
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.
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 5565
***************************************