[13065] in Perl-Users-Digest
Perl-Users Digest, Issue: 475 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 12 02:17:16 1999
Date: Wed, 11 Aug 1999 23:10:17 -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, 11 Aug 1999 Volume: 9 Number: 475
Today's topics:
Re: New to Perl: File manipulation Question <knewman@mcs.com>
Re: obtaining local IP address in ActivePerl (Charles DeRykus)
Re: perl -splice - add an element/delete <rootbeer@redcat.com>
Re: printf problem - Left-Justifying Floats <USENET@questionexchange.com>
Re: reference to object method (Abigail)
Re: Reset .. ie clear out a hash array <USENET@questionexchange.com>
Re: s/// and interpolation <USENET@questionexchange.com>
Re: Scalar context? <USENET@questionexchange.com>
Re: search and match (Michel Dalle)
Re: Some help needed <USENET@questionexchange.com>
Re: Stripping quotes only from HTML tags <rootbeer@redcat.com>
Re: suggestions for CRAP <mmwright@ux12.cso.uiuc.edu>
Testing (Please disregard) (Chris)
Re: thanks for nothing everybody (Ronald J Kimball)
Upgrade issues joemoore@att.com
Why post trolls to comp.lang.perl.misc when we've got c (Greg Andrews)
Re: working with imagery <USENET@questionexchange.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 12 Aug 1999 00:40:44 -0500
From: Kevin Newman <knewman@mcs.com>
Subject: Re: New to Perl: File manipulation Question
Message-Id: <37B25E5B.A15FFFE8@mcs.com>
Thanks, Lauen. The -i parameter is what I was looking for.
kln
Lauren Smith wrote:
> Kevin Newman wrote in message <37B17E04.572475CD@mcs.com>...
> >I'm very new to PERL and have a few questions on how to create :
> >1) an edited temprary file of an original file that is being read in
>
> Open the original file. Open the temporary file. Read lines in from
> the original file, print lines out to the temporary file.
>
> >2) edit and save the original file in place
>
> If you want to edit and save the original file in place, why do you need
> a temporary file?
>
> >I am able to create the temporary file but I get the
> >error message:
> >Use of uninitialized value at "filename" line nn, <> chunk nn.
> >Where "filename" = the perl filename and nn = a number.
> >What does this mean? How do I correct it?
>
> You have an error on or before line nn.
>
> But seriously folks,
> perldiag "Use of uninitialized value"
>
> Lauren
------------------------------
Date: Thu, 12 Aug 1999 03:23:59 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: obtaining local IP address in ActivePerl
Message-Id: <FGC1Fz.HJ1@news.boeing.com>
In article <37B21234.2F89A61B@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> wrote:
>Charles DeRykus wrote:
>[snip]
>> You mean the following which works on NT doesn't work on Win32/95...
>>
>> perl -MSocket 'my $ip=gethostbyname("my_host");print inet_ntoa($ip),"\n"'
>
>Oh, I forgot to mention. This needs some tweaking to run
>on NT or 95/98, since those command processors insist on
>having the program in double quotes. cf. the FAQ, where
>TomC complains bitterly about the non-portability of
>one-liners.
True, I didn't show the NT one-liner... I was posting from a
real OS :)
--
Charles DeRykus
------------------------------
Date: Wed, 11 Aug 1999 21:22:04 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: perl -splice - add an element/delete
Message-Id: <Pine.GSO.4.10.9908112119340.7774-100000@user2.teleport.com>
On Thu, 12 Aug 1999 jatgirl@yahoo.com wrote:
> I read about splice and I'm still a little confused as to how to use
> it with the array I have .
You don't _have_ to use it just because you read about it. :-)
> I have an array whos elements contain hashes. I'm not being able to
> figure out the correct way to add or delete hash with in that array
I think you mean hashrefs; a hash can't be an element of an array. But to
delete an element that's a hashref, you use the same technique as if it's
not a hashref.
my @list = qw( fred barney dino betty wilma );
splice @list, 2, 1; # Remove element two
print "The list is: @list\n";
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 12 Aug 1999 5:27:2 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: printf problem - Left-Justifying Floats
Message-Id: <829qx@questionexchange.com>
> when attempting to left-justify float values.
> The following code:
> perl -e 'printf "|%-10.4f|\n",0;'
> results in:
> | 0.0000|
> While in Awk:
> echo "0" | awk '{printf("|%-10.4f|\n",$0);}'
> ksh:
> printf "|%-10.4f|\n" 0
> and C:
> #include <stdio.h>
> main()
> {
> printf("|%-10.4f|\n",0);
> }
> The result is:
> |0.0000 |
> Is this a known bug? Does anybody have a fix? We
> are using Perl version 5.004_01.
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
I do a "perl -e 'printf "|%-10.4f|\n",0;'", I get:
|0.0000 |
Which is the correct output.
By the way:
% perl -v
This is perl, version 5.005_03 built for i386-linux
My first suggestion would be to grab the latest release.
Hope this helps.
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2663&cus_id=USENET&qtn_id=2084
------------------------------
Date: 11 Aug 1999 23:23:45 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: reference to object method
Message-Id: <slrn7r4j1v.d88.abigail@alexandra.delanet.com>
David Christensen (dchristensen@california.com) wrote on MMCLXX September
MCMXCIII in <URL:news:37b09772@news5.newsfeeds.com>:
## Hello, World!
##
## I have started working with Perl objects, and am stuck:
##
## How do I create a reference to an object method?
Short answer: not really.
Techno answer: with a closure. (Which is explained in the manual).
#!/opt/perl/bin/perl -w
use strict;
sub Class::hello {
my $me = shift;
print "Hello, ", $me -> {name}, "\n";
print " and hello to you, ", join (", ", @_), ", too\n" if @_;
}
sub make_method_ref {
my ($obj, $refname) = @_;
sub {$obj -> $refname (@_)}
}
my $world = bless {name => "world"} => 'Class';
my $earth = bless {name => "earth"} => 'Class';
my $ref_w = make_method_ref ($world, "hello");
my $ref_e = make_method_ref ($earth, "hello");
$ref_w -> (); # Using -> ()
&$ref_e ('Gaia'); # Using &
__END__
Hello, world
Hello, earth
and hello to you, Gaia, too
## How do I dereference the reference?
With either of the methods above.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 12 Aug 1999 5:26:50 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: Reset .. ie clear out a hash array
Message-Id: <828qx@questionexchange.com>
> I have a hash variable structured something like ;
> $data{NUMBER_OF_RECORDS}
> $data{LIST_OF_RECORDS}
> $data{RECORD}{NAME}{<variable>}
> $data{RECORD}{NUMBER}{<variable>}
> $data{NUMBER_OF_FIELDS}
> $data{LIST_OF_FIELDS}
> $data{FIELD}{SEPARATOR}
> $data{FIELD}{NAME}{<variable>}
> ...
> ..
> and so on ..
> I want to set up this data in a cyclic loop and need to delete
> any
> previously set data.
> How can I reset %data to remove any data ? (both keys and
> values)
> without cycling through *all* the elements.
> --
> Cheers,
> /Nick Djurovich
> --
> Tel 01273 384 600
> E-Mail mailto:Nick.Djurovich@racalitsec.com
> ICQ 11810476
> WWW http://www.racalitsec.com
> Racal Security and Payments
> Sussex Innovation Centre
> Science Park Square
> Falmer
> Brighton
> BN1 9SB
> England
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2646&cus_id=USENET&qtn_id=2077
------------------------------
Date: 12 Aug 1999 5:26:22 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: s/// and interpolation
Message-Id: <826qx@questionexchange.com>
> user specify a search and replace expression, and
> then execute it. When I do something equivalent to:
> $search = '\d{3}-\d{2}-\d{4}' ;
> $replace = 'ID#$1$2$3' ;
> $record =~ s/$search/$replace/ ;
> The variables in the s/// get interpolated, but the
> variables in the interpolated string do not. Fine.
> How do I fix this? I.e., how do I force Perl to
> interpolate recursively one level down?
> Thanks,
> Chris
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Perl do not work the way you try (why ? who now :)
You need place all replace command on one string and than
execute replacement by "eval" command
For example
$search = '(\d{3})-(\d{2})-(\d{4})' ;
$replace = 'ID#$1$2$3' ;
$repStr = "s/".$search."/".$replace."/" ;
eval ($repStr);
I may make some mistakes, but principle is right. Hope this
helps you.
regards,
Olek
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2685&cus_id=USENET&qtn_id=2060
------------------------------
Date: 12 Aug 1999 5:27:31 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: Scalar context?
Message-Id: <831qx@questionexchange.com>
> with this statement? I've researched the FAQ's etc....but must
> be missing
> something.
> ---------------------------------------------------------------
> ---
> if ($input{'password'} eq $user{'password'}) {
> do this..
> } else {
> do this..
> }
> ---------------------------------------------------------------
> ---
> Where both values should equal "cat"? I don't know why it won't
> work. I've
> tried every combination that I can think of to get it, but it
> just refuses
> to believe that 'cat' is 'cat'.
> file is on www.calnet.com/login.html
> Thank you,
> George
> Here is the complete code if it helps:
> #! /usr/local/bin/perl
> use FileHandle;
> &ReadParse(*input);
> $dir=$input{'username'};
> $it=$dir.".dat";
> open(THISFILE, "jkuhnert.dat");
> # initial user data file reading
> while($line=<THISFILE>) {
> chomp($line);
> ($key, $value)=split('=', $line);
> $user{$key}=$value;
> }
> close(THISFILE);
> $password=$input{'password'};
> $pass=$user{'password'};
> if ($password eq $pass) {
> print"Content-type: text/html\n\n";
> print <<EOF;
> <HTML>
> <HEAD>
> <TITLE>Login Debug</TITLE>
> </HEAD>
> <BODY BGCOLOR="#FFFFFF"><center><br><h2>User
> Login</h2><hr><br><br>
> Login was successfull!!!!
> </center>
> </BODY>
> </HTML>
> EOF
> ;
> } else {
> print"Content-type: text/html\n\n";
> print <<EOF;
> <HTML>
> <HEAD>
> <TITLE>Login Debug</TITLE>
> </HEAD>
> <BODY BGCOLOR="#FFFFFF"><center><br><h2>User
> Login</h2><hr><br><br>
> Login was not successfull!!<br><br>
> The line is $value $it<br><br>File: $file
> <br><br><br>Password $hmm<br><br>Input Password: $hmm<br>
> Real Password: $real<Br><br>$real$hmm
> </center>
> </BODY>
> </HTML>
> EOF
> ;
> }
if ($hash{'key'} eq $hash2{'key'}) {}
as you've posted is indeed correct and *does* work, everytime.
Therefore if it's not returning true then $pass and $password
do not have the same value. Why not in your error message add
the following statement.
print "\n\n *$pass* *$password* \n\n";
view the source and see if you have the *exact* same string,
including newlines etc. It's hard to say without seeing the
datafiles and the input you gave it but one thing I did notice
was
$dir=$input{'username'};
$it=$dir.".dat";
open(THISFILE, "jkuhnert.dat");
Did you change $it to "jkuhnert.dat" and forget to change it
back?
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2687&cus_id=USENET&qtn_id=2106
------------------------------
Date: Tue, 10 Aug 1999 15:08:54 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: search and match
Message-Id: <7opffs$nei$1@news.mch.sbs.de>
In article <7op7r5$pvk$1@faatcrl.faa.gov>, "Christian Evans" <chris.evans@tc.faa.gov> wrote:
>I have a module in a perl script that allows users to search for a record
>with a field that matches a desired date. The dates are in the format with
>the first three letter of the month (i.e. Jan) followed by one OR two
>spaces, and the day of the month. How can I write the script to search for
>all possible records. I have tried many different possible choices and
>can't seem to get any of them to work.
>
>It seems as though when I search, my script will match all records with a
>field with a given month, but I can't seem to match the month and the date
>at the same time.
>
Why don't you show us some ID ... er ... I mean some example of your data,
how it's stored (file, database, ...), how you access it, and especially how
you try to match your records ? Give us at least one of your many trials...
That will be much clearer for everybody. Otherwise, we'll have to use
that ESP module again, and tell you to look at line 17 :-)
Michel.
------------------------------
Date: 12 Aug 1999 5:28:32 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: Some help needed
Message-Id: <835qx@questionexchange.com>
> I need counter for web pages. It must works without any other
> programms and
> providers.
> (CGI or Perl script).
> Pls. help me to find it.
> servber@mail.ru
www.worldwidemart.com/scripts/counter.shtml
There's also some 80 counters (both graphic and text based) at
http://cgi.resourceindex.com/Programs_and_Scripts/Perl/Access_C
ounters/
In general you'll find http://cgi.resourceindex.com/ is a good
starting place to look for CGI scripts.
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2684&cus_id=USENET&qtn_id=2117
------------------------------
Date: Wed, 11 Aug 1999 21:15:06 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Stripping quotes only from HTML tags
Message-Id: <Pine.GSO.4.10.9908112114050.7774-100000@user2.teleport.com>
On Wed, 11 Aug 1999, Warren Bell wrote:
> I have a messageboard script that I want to strip the quotes out of
> anything within HTML tags that is entered in the text area. If a
> quote is entered as text like: try the command "foo -a" it woulden't
> get stripped. But anything in between < and > gets the quotes stripped
> from it.
>
> Is there a way to do this with a simple substitution like:
>
> $message =~ s/?/?\g;
No, you can't parse HTML with merely a simple regular expression. Use
HTML::Parser from CPAN. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 12 Aug 1999 05:28:04 GMT
From: matthew michael wright <mmwright@ux12.cso.uiuc.edu>
Subject: Re: suggestions for CRAP
Message-Id: <7otm14$g7f$1@vixen.cso.uiuc.edu>
Abigail <abigail@delanet.com> wrote:
: And although IANAL, I can easily imagine that if Matt Wright gets ticked
: off, a bunch of lawyers will have a field day.
Nah, it takes a lot to tick me off. Even the oh-so-nice musings of purl
on topics related to my name and sites don't upset me.
I like the project's goal and think that it will be good for both users
of my stuf--errr... CRAP, and myself.
Matt
--
--------------------
Matt Wright (mmwright@students.uiuc.edu) http://www.mattwright.com/
------------------------------
Date: Thu, 12 Aug 1999 05:58:22 GMT
From: chrisl@tourneyland.com (Chris)
Subject: Testing (Please disregard)
Message-Id: <37b06624.5203709@news.swbell.net>
Please disregard this posting
(Sorry to do this, but my last 5 or 6 postings haven't made it to the
group, and I'm trying to fix the problem)
------------------------------
Date: Thu, 12 Aug 1999 01:49:04 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: thanks for nothing everybody
Message-Id: <1dwec4m.1bpxc0o1rnq9j9N@p189.tc19a.metro.ma.tiac.com>
Diane <tech1@magicnet.net> wrote:
> Gee thanks for your help NOT!!
>
> All I wanted was a brief interpretation of some of the lines of code that
> were NOT related to HTML, and all you people could come up with are
> critiques of the code. I did not want or need that. Its NOT a cgi class,
> just touches on it and I just wanted to explain some of the code, but
> apparantly none of you are capable of doing that. I must say this is my
> first time being treated so badly and getting such useless info from a
> newsgroup. Most groups are most helpful and willing to share knowledge..
> guess you folks are not. Sorry I wasted my time and hoped for some help
>
Yes, please go teach your students to use Perl code like this, so that
they too can come to this newsgroup, whine about how they need help
understanding poorly written Perl code, ask lots of FAQs, and get pissy
when they don't the free help they think they deserve because they're
too clueless to read the documentation. That's really what we want!
I would strongly recommend learning Perl before you teach it.
[I'm catching up on threads from the past week and a half. :) ]
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 12 Aug 1999 04:38:30 GMT
From: joemoore@att.com
Subject: Upgrade issues
Message-Id: <7otj46$djq$1@nnrp1.deja.com>
I'd love to have a book or Web resource to help me manage my Perl
installation in a large shop with dozens of Solaris hosts.
We have been using Perl5.003 for some time now and I would like to
upgrade. We have had issues with upgrades in the past. Every time we
need a new module, we build a new version of Perl but leave the old one
in place as the default version and as a result we now have multiple
versions of Perl lying around haphazardly on our various Solaris boxes.
What I would like to do is have one version of the latest Perl, backward
compatible with everything we are currently using and a strategy of
upgrading the Perl version regularly and adding/upgrading modules as
needed.
The problems I have encountered are:
1) The new Perl install breaks existing applications. I need a way to
undo anything I change.
2) If I install perl in a test area, then it all works, then I copy
everything to the working directory, it breaks.
3) I can't use the modules from the old installation with the new
installation. How can I make sure I get all the modules I already have
plus make sure they are backward compatible?
4) I need to install a version on one machine then move it to another
that has no make capability. Some of the modules, like GDBM, require C
libraries and include files to build, are they required on the other
machine?
Perl is nice in its openness in letting you choose which modules and
where to put everything, but I would like some reference to say, This is
the recommended way of doing things that won't ruin what you have and a
way out if you find out it does.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 11 Aug 1999 23:01:45 -0700
From: gerg@shell.ncal.verio.com (Greg Andrews)
Subject: Why post trolls to comp.lang.perl.misc when we've got comp.lang.python?!
Message-Id: <7oto09$p8q$1@shell1.ncal.verio.com>
Why indeed?
--
::::::::::::::::::: Greg Andrews gerg@wco.com :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
------------------------------
Date: 12 Aug 1999 5:25:2 GMT
From: QuestionExchange <USENET@questionexchange.com>
Subject: Re: working with imagery
Message-Id: <821qx@questionexchange.com>
> Does anyone have any info, links, etc. on using Perl for images
> (properties, cell values, etc.)?
> Thanks
> ..Tom
> --
> ---------------------------------------------------------------
> --------------------------
> Tom Kralidis Geo-Spatial
> Technologist
> Canada Centre for Remote Sensing Tel: (613) 947-
> 1828
> 588 Booth Street , Room 241 Fax: (613) 947-
> 1408
> Ottawa , Ontario K1A 0Y7
> http://www.ccrs.nrcan.gc.ca
> ---------------------------------------------------------------
> --------------------------
It covers libraries to manipulate images in many formats,
notably including GD, ImageMagick (Image::Magick), gimp,
postscript, and many others.
If you don't want to buy the book, or even if you do, you'd
probably also want to check out these web pages:
Gimp Scripting
http://www.gimp.org/scripts.html
Perl Imaging Libraries (which include docs)
http://www.perl.com/reference/query.cgi?graphics+index
That second URL, includes Image::Size which you can use to get
the width and height at runtime to put into html tags.
If you need to know more, please describe what you want to do
with perl and images.
--
This answer is courtesy of QuestionExchange.com
http://www.questionexchange.com/servlet1/showUsenetGuest?ans_id=2652&cus_id=USENET&qtn_id=2001
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 475
*************************************