[13396] in Perl-Users-Digest
Perl-Users Digest, Issue: 806 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 15 14:17:33 1999
Date: Wed, 15 Sep 1999 11:10:26 -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, 15 Sep 1999 Volume: 9 Number: 806
Today's topics:
Perl build fails under Linux RH 6.0 (Peter Choynowski)
Re: Perl build fails under Linux RH 6.0 (Kragen Sitaker)
Please help a newbie! sg95m476@dunx1.ocs.drexel.edu
Re: Please help a newbie! (Kragen Sitaker)
Re: Please help a newbie! <makkulka@cisco.com>
Re: PLEASE HELP! - Symbolic References (Tramm Hudson)
Re: PLEASE HELP! - Symbolic References <aqumsieh@matrox.com>
Re: Procedure result inheritance (Kragen Sitaker)
Re: Question with moving string to array <aqumsieh@matrox.com>
Sendmail: Address family not supported by protocol fami <rhamersma@intermodulair.nl>
Re: trimming spaces from a string (Larry Rosler)
Re: trimming spaces from a string (Gabor)
Re: Use of uninitialized value at... (Kragen Sitaker)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Sep 1999 16:09:56 GMT
From: pkc@scs.carleton.ca (Peter Choynowski)
Subject: Perl build fails under Linux RH 6.0
Message-Id: <7rogck$g45$1@bertrand.ccs.carleton.ca>
Perl 5.005_02 and _03 fails on test 12 in lib/anydbm. I suspect that
this problem was talked about before, forgive me if that is the case.
From what I can see ( and I find this very strange :) the following
$h{''} = 'bar'; # <-- does not work but
$ha{''} = 'bar'; # <-- this works - how strange
I have tried 5.005_02 on an older Linux system, and it works just
fine so the problem I suspect is somewhere in the newer RH versions.
[root]# ldd /usr/bin/perl
libnsl.so.1 => /lib/libnsl.so.1 (0x4000a000)
libdb.so.3 => /lib/libdb.so.3 (0x40022000)
libgdbm.so.2 => /usr/lib/libgdbm.so.2 (0x40060000)
libdl.so.2 => /lib/libdl.so.2 (0x40066000)
libm.so.6 => /lib/libm.so.6 (0x40069000)
libc.so.6 => /lib/libc.so.6 (0x40088000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x40182000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
Any info or pointers very much welcomed.
TIA,
Peter
------------------------------
Date: Wed, 15 Sep 1999 17:50:24 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Perl build fails under Linux RH 6.0
Message-Id: <A%QD3.13090$N77.949434@typ11.nn.bcandid.com>
In article <7rogck$g45$1@bertrand.ccs.carleton.ca>,
Peter Choynowski <pkc@scs.carleton.ca> wrote:
>Perl 5.005_02 and _03 fails on test 12 in lib/anydbm. I suspect that
>this problem was talked about before, forgive me if that is the case.
Yes, something is broken in Red Hat Linux 6.something. (00?) I don't
think anybody has posted a correct analysis and solution during the
week or two I've been here, but it's one of the most-commonly-asked
questions.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 15 Sep 1999 17:19:05 GMT
From: sg95m476@dunx1.ocs.drexel.edu
Subject: Please help a newbie!
Message-Id: <7rokdr$ndp$1@nnrp1.deja.com>
Please help a perl newbie:
I have a text file. For every line of the file in character positions
181-186 there are date values in the format MMDDYY. What I would like
to do is modify this to a MM/DD/YY format, inserting slashes between MM,
DD, and YY for every line of the file - thus expanding the character
position range of this date format for every line from character
positions 181-188.
Can anyone help me with this?
Thanks!
Chuck
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 15 Sep 1999 18:01:59 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Please help a newbie!
Message-Id: <raRD3.13131$N77.950903@typ11.nn.bcandid.com>
In article <7rokdr$ndp$1@nnrp1.deja.com>,
<sg95m476@dunx1.ocs.drexel.edu> wrote:
>I have a text file. For every line of the file in character positions
>181-186 there are date values in the format MMDDYY. What I would like
>to do is modify this to a MM/DD/YY format, inserting slashes between MM,
>DD, and YY for every line of the file - thus expanding the character
>position range of this date format for every line from character
>positions 181-188.
Which part of this are you having trouble with? Figuring out you
should use s///, constructing the regex, constructing the replacement,
or extracting the substring?
You should probably have picked a more descriptive subject line.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 15 Sep 1999 10:55:43 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Please help a newbie!
Message-Id: <37DFDD9E.8B8B7E7E@cisco.com>
[ sg95m476@dunx1.ocs.drexel.edu wrote:
> I have a text file. For every line of the file in character positions
> 181-186 there are date values in the format MMDDYY. What I would like
> to do is modify this to a MM/DD/YY format, inserting slashes between MM,
> DD, and YY for every line of the file - thus expanding the character
> position range of this date format for every line from character
> positions 181-188.
use substr() to do this.
Here is the relevant part from the perldoc
You can use the C<substr()> function
as an lvalue, in which case EXPR must be an lvalue. If you assign
something shorter than LEN, the string will shrink, and if you assign
something longer than LEN, the string will grow to accommodate it. To
keep the string the same length you may need to pad or chop your value
using C<sprintf()>.
And don't you think you should expand to mm/dd/YYYY to take
care of Y2K issues !!
---
------------------------------
Date: 15 Sep 1999 10:20:51 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: PLEASE HELP! - Symbolic References
Message-Id: <7roh13$ll4@llama.swcp.com>
Keywords: troll troll troll
[posted and cc'd to the two cited authors]
<makau@multimania.com> wrote and mis wrapped:
> "Zach Thompson" <cublai@earthlink.net> babbled:
> > The first line of the error message says it all. Remove the "my" in
> > front of ${$key}. Symbolic refs access the symbol table and lexical
> > variables are not stored there.
>
> I have already tried this so many times.... Removing the 'my' doesn't
> solve the problem. The first error message disappears by the others
> remain!
You should have been alerted by Zach's improper quoting style
and realized that his answer would be wrong without even having to
read it.
Zach gets some points for the partial answer. Yes, symbolic
references access the symbol table and lexical variables are not stored
there, but he missed the whole point of the exercise -- to make
the code work with use strict. Almost always sym refs are a
bad idea and you can do a much better job with a hash table
rather than scribbling on the %main:: hash.
He then loses all of them for including the entire message
below his (wrong) response. Sorry, play again?
> Without the 'strict' subs, it works just fine. But the problem is I do
> NOT want to remove it (since some warnings are not displayed otherwise)!
Yes, turning on strict disallows symbolic references. This is a good
thing. And you are correct to want to keep the strict pragma tuned
on -- it does prevent bugs from creeping in due to mistyped variable
names and other common problems.
> And YES, I want to get $$key and not a hash. I have my reason.
> Is there a work-around, or can't Perl handle this when 'use strict' is
> mentionned?
Do you mind sharing your reason? Perhaps if you are auto-creating
methods or other such magic then you need to turn off strict. In
any event, pragmas are lexically scoped, so you can do this:
#!/usr/bin/perl -w
use strict;
# Strict is on here
{
no strict 'refs';
${"foo"} = 'bar';
}
#Strict is back on here
__END__
As usual, this is all covered in the FAQ. Check out the perlref
pod page for more details. Especially the section on "symbolic
references". And just a few lines later it even shows you how to
turn off strict refs to create a method function.
Good luck, and don't forget to ignore those wacky replies that
use incorrect formating, quoting and almost always give incorrect
answers.
Tramm
--
o hudson@swcp.com tbhudso@cs.sandia.gov O___|
/|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.284.24.32 \ \/\_\
0 U \_ |
------------------------------
Date: Wed, 15 Sep 1999 11:27:39 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: PLEASE HELP! - Symbolic References
Message-Id: <x3yzoyodwk5.fsf@tigre.matrox.com>
makau@multimania.com writes:
> ---------------------------------
> #!/usr/local/bin/perl -w
>
> use strict;
>
> my $key;
> my %hash = (
> hello => 'world',
> perl => 'rOckz',
> );
> foreach $key (keys %hash) {
> my ${$key} = $hash{$key};
> };
>
> print "The $hello $perl !";
> ---------------------------------
>
> but the Perl interpreter prints out :
>
> ---------------------------------
> Can't declare scalar deref in my at ./a.pl line 11, near "} ="
> Global symbol "$hello" requires explicit package name at ./a.pl line 14.
> Global symbol "$perl" requires explicit package name at ./a.pl line 14.
> Execution of ./a.pl aborted due to compilation errors.
> ---------------------------------
Of course. This is due to the nature of lexical variables. It is all
explained in perlref. Here is a relevant snippet:
Only package variables are visible to symbolic references.
Lexical variables (declared with my()) aren't in a symbol
table, and thus are invisible to this mechanism.
> Without the 'strict' subs, it works just fine.
Are you sure?
It shouldn't and it doesn't for me.
% perl -v
This is perl, version 5.004_04 built for sun4-solaris
What is your Perl version?
> But the problem is I do NOT want to remove it (since some warnings are
> not displayed otherwise)!
Good choice.
> And YES, I want to get $$key and not a hash.
> I have my reason.
Which is?!
Symbolic references are too confusing (IMHO) to work with. Using a
hash is the suggested way of doing things. I don't see any good
reasons for not using a hash.
> Is there a work-around, or can't Perl handle this when 'use strict' is
> mentionned?
You can always turn off the strict pragma for a certain part of your
program:
use strict;
...
{
no strict;
# here the strict pragma is ineffective
...
}
HTH,
--Ala
------------------------------
Date: Wed, 15 Sep 1999 17:41:39 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Procedure result inheritance
Message-Id: <nTQD3.13039$N77.948641@typ11.nn.bcandid.com>
In article <37DF5239.A2C20FDE@inx.de>,
Daniel Krajzewicz <krajzewicz@inx.de> wrote:
>Let's say I#m constructing a set of modules - I can just animate you to
>do this.
Please don't animate me. I'm animated enough as it is :)
>I wish to have a simple error-handler which works in the following way :
>Each modules only expor the variable "result" and "error". When an error
>occures,
>the variable "error" holds the word "true" and result the
>error-description.
>On no error "error" contains "false" and "result" the result of the
>procedure.
>So far about the technics, now two questions :
>1. Is this nonsence ?? Is there a better way for an error-handler ?
It depends on what you want out of the error handler. "return undef"
and "die" are two popular ways of returning errors in Perl, and "croak"
-- from the Carp module -- is popular for telling your caller that they
called you incorrectly. "return" is a popular way of returning the
result of a procedure.
I can't think of a situation in which what you describe would be
better, but maybe you have one :)
>2. Is there a possibility to map both variables onto the same calling
>variables, that means when an error occures in a submodule,
>automatically the same variables in the caller will be set ??
Sounds like you want "die" or "croak".
I'm not sure what "calling variables" are. But you can export
variables into every module that uses them so that every module ends up
having '$result' and '$error' point to the same variable (or not point
to anything).
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 15 Sep 1999 12:31:52 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Question with moving string to array
Message-Id: <x3yyae8dtl3.fsf@tigre.matrox.com>
Hal Flynn <hflynn@gibralter.net> writes:
> After I get rid of the information I don't need through substitution,
> how do I split up what's left of the string into another array? Here's
You use split().
> what I'm doing in respect to editing:
>
> $count = 0;
>
> while ($list[$count] ne "") {
> $list[$count] =~ s/^[\W]+[\w]+[\W]+//;
> $count++;
> }
A better (less ambiguous) way of doing the above would be:
for my $line (@list) {
$line =~ s/^\W+\w+\W+//;
}
> From this point in the code, I'm trying to take what's in @list and
> break each string into another array of values. Can anybody point me in
> the right direction to find the answer or perhaps some sample code to
> work from?
I am not sure how you want to split your strings. But you should be
using the split() function. Check it out.
HTH,
--Ala
------------------------------
Date: Wed, 15 Sep 1999 11:19:02 +0200
From: "Ron Hamersma" <rhamersma@intermodulair.nl>
To: comp.lang.perl.misc
Subject: Sendmail: Address family not supported by protocol family
Message-Id: <INTR40436D716@intermodulair.nl>
Hi, I am new to Perl,
am using Perl sendmail program,
which uses SMTP
now when the program is called I get the following error message:
Could not connect to server (Address family not supported by protocol
family).
which is strange, can anybody shed some light on this curious message?
Thanks in advance,
Ron Hamersma.
PS. here's some output from the program:
looking at the returned parameters you can see that I do have a connection:
begin van sendmail.pl
Parameters:
--------------------------------
subject = Informatieaanvraag website
from = anonymous@
to = xxxx@intermodulair.nl
cc =
bcc =
body = /usr/local/WWW/www.intermodulair.nl/templates/info_email_send.html
files =
encoding=
--------------------------------
WEB_SERVER = www.intermodulair.nl
SMTP_SERVER = smtp.xs4all.nl
--------------------------------
WEB_SERVER = www.intermodulair.nl
SMTP_SERVER = smtp.xs4all.nl
local variables:
to = xxxx@intermodulair.nl
cc =
bcc =
attach_files =
encoding =
MIME_FILES =
protocol = 6
$server_socket_address = Âm3
$server_address = Âm3
$local_address = ÂmÈ>
Content-type: text/html
------------------------------
Date: Wed, 15 Sep 1999 09:11:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: trimming spaces from a string
Message-Id: <MPG.12496513fa1bf7d2989f6a@nntp.hpl.hp.com>
In article <slrn7tvfm6.gtr.gabor@vnode.vmunix.com> on 15 Sep 1999
11:44:06 -0400, Gabor <gabor@vmunix.com> says...
> In comp.lang.perl.misc, Larry Rosler <lr@hpl.hp.com> wrote :
> # In article <slrn7tv56a.g1t.gabor@vnode.vmunix.com> on 15 Sep 1999
> # 08:44:59 -0400, Gabor <gabor@vmunix.com> says...
> # > In comp.lang.perl.misc, Dolly & Will Cardwell <wellhaven@worldnet.att.net> wrote :
> # > # #Given:
> # > #
> # > # $s=' aa bcdef ';
> # > # $t='aa bcdef';
> # >
> # > if($s =~ /^\s*$t\s*$/ || $t =~ /^\s*$s\s*$/) {
> # > print "match\n";
> # > }
> #
> # This is wrong in several ways. It fails if $s and $t each have leading
> # or trailing white-space, or if either of them includes a regex
> # metacharacter. Think twice before substituting a variable into a regex
> # without surrounding it with \Q and \E.
>
> I wasn't trying to give a fool-proof solution but a start. ;)
Even with that knowledge, my PSI::ESP module failed to detect any
tentativeness in your response. Maybe posting conjectures before
thousands of readers, without identifying them as such and without
testing them at all, is a poor idea.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Sep 1999 13:06:27 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: trimming spaces from a string
Message-Id: <slrn7tvkgj.hdt.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Larry Rosler <lr@hpl.hp.com> wrote :
# In article <slrn7tvfm6.gtr.gabor@vnode.vmunix.com> on 15 Sep 1999
# 11:44:06 -0400, Gabor <gabor@vmunix.com> says...
# > In comp.lang.perl.misc, Larry Rosler <lr@hpl.hp.com> wrote :
# > # In article <slrn7tv56a.g1t.gabor@vnode.vmunix.com> on 15 Sep 1999
# > # 08:44:59 -0400, Gabor <gabor@vmunix.com> says...
# > # > In comp.lang.perl.misc, Dolly & Will Cardwell <wellhaven@worldnet.att.net> wrote :
# > # > # #Given:
# > # > #
# > # > # $s=' aa bcdef ';
# > # > # $t='aa bcdef';
# > # >
# > # > if($s =~ /^\s*$t\s*$/ || $t =~ /^\s*$s\s*$/) {
# > # > print "match\n";
# > # > }
# > #
# > # This is wrong in several ways. It fails if $s and $t each have leading
# > # or trailing white-space, or if either of them includes a regex
# > # metacharacter. Think twice before substituting a variable into a regex
# > # without surrounding it with \Q and \E.
# >
# > I wasn't trying to give a fool-proof solution but a start. ;)
#
# Even with that knowledge, my PSI::ESP module failed to detect any
# tentativeness in your response. Maybe posting conjectures before
# thousands of readers, without identifying them as such and without
# testing them at all, is a poor idea.
Well, I would never trust anyone's code posted here. Even the so
called 'gurus' have posted crap here before, or code that didn't quite
work. Covering all possible scenarios was left to the person asking
the question. I offered something can serve as a start. If he, or
you, don't like it, you can offer something better. ;)
------------------------------
Date: Wed, 15 Sep 1999 17:26:14 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Use of uninitialized value at...
Message-Id: <WEQD3.12985$N77.947392@typ11.nn.bcandid.com>
In article <7ro0m4$4r1c$1@pike.uhc.com>, Peter Icaza <picaza@chsi.com> wrote:
>hi,
>i reading a file into a string and then extract the different sections using
>the following code. however i cant seem to rid myself of the error msg "Use
>of uninitialized value at... " at the first attempt to match once all
>sections are parsed and split has nothing to put in to $Section. the two
>commented if stmts are some attempts at correcting the situation which dont
>work. i ask two things 1) how can i correct the code to get rid of the
>error msg and 2) why dont the "defined" and/or "ne" work properly while the
>print stmt works ok?
It looks like you're interpolating $Section into a string before
checking to see if it's defined. If you say
if (defined $Section) {
print "gooble $Stars varble $Section\n";
# . . .
}
you should be OK.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
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 806
*************************************