[24053] in Perl-Users-Digest
Perl-Users Digest, Issue: 6250 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 12 14:05:51 2004
Date: Fri, 12 Mar 2004 11: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 Fri, 12 Mar 2004 Volume: 10 Number: 6250
Today's topics:
Re: [OT] Text editors (religious war awaits) (was Re: <todd@tdegruyl.com>
bit string parsing and mapping question (Paul)
Re: Deleting a folder recursively <bernie@fantasyfarm.com>
formmail problem (James)
Re: How to redirect headers in Perl? (Crazy Monkey)
Mixing WAV Files <me@here.com>
Passing variables / data between php - perl <replytogroup>
Re:ligious, Emacs v. vi <usenet@morrow.me.uk>
Regex to match simple line of XML (ac)
Re: Regex to match simple line of XML <tore@aursand.no>
Re: removing trailing spaces <ittyspam@yahoo.com>
Re: removing trailing spaces <raisin@delete-this-trash.mts.net>
Re: removing trailing spaces <noreply@gunnar.cc>
Re: removing trailing spaces <noreply@gunnar.cc>
Re: removing trailing spaces <david@tvis.co.uk>
Re: scheduling a perl script <remorse@partners.org>
Re: Text editor implemented in Perl <jkrugman@yahbitoo.com>
Re: Text editor implemented in Perl <jgibson@mail.arc.nasa.gov>
Re: Text editor implemented in Perl <xx087@freenet.carleton.ca>
Re: Text editor implemented in Perl <aaraines@pobox.com>
Re: Tricky Perl Bug (amusing/unamusing) <skuo@mtwhitney.nsc.com>
Re: using an assoc. array as a 'set' (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Mar 2004 16:30:02 GMT
From: Todd de Gruyl <todd@tdegruyl.com>
Subject: Re: [OT] Text editors (religious war awaits) (was Re: Text editor implemented in Perl)
Message-Id: <va49i1-vr7.ln1@espresso.tdegruyl.com>
Brad Baxter wrote:
> On Fri, 12 Mar 2004, J Krugman wrote:
>
>>What makes vim so much better than Emacs?
> Ever since IBM destroyed WordStar (for me) by relocating the Ctrl key,
> I've had an aversion to Ctrl key combinations--it's a carpal tunnel
> problem. At a key point, I bit the bullet and worked at wrapping my mind
> and fingers around vi. Now it's second nature, and having to edit text
> with anything else makes me feel quadriplegic.
>
Recently, I have been going through a bout of wrist-related RSI's, so I
had to move from Emacs to an editor that did not need me to contort my
hand so much.
That's how I ended up learning vi (specifically vim)
I would imagine that there are quite a few people out there who have
similar responses. On the other hand, it was *work* trying to learn the
rules, and I don't think it is necessary if you already know how to use
a *real* editor (i.e. not notepad).
--
Todd de Gruyl
todd@tdegruyl.com
http://www.tdegruyl.com
------------------------------
Date: 12 Mar 2004 10:21:44 -0800
From: Paul.Sue@telus.com (Paul)
Subject: bit string parsing and mapping question
Message-Id: <8757b529.0403121021.5f3efcc0@posting.google.com>
Hi,
Let's say a command outputs results like this:
code1 = 1
code2 = 0
code3 = 0
code4 = 0
code5 = 1
code6 = 0
code7 = 1
code8 = 0
(always 8 lines returned; values are 0 or 1)
I want a script to read this in and then map all the 1's to a
user-friendly code.
E.g.:
@desc = qw(lowMem badHandle badPasswd noSpace badArg invalidInput
badSyntax outOfRange);
So for the above command output, it would output something like:
Errors: lowMem badArg badSyntax
I can do it in a simplistic pedantic way, but I'd like to a more
elegant solution.
Thanks,
Paul
------------------------------
Date: Fri, 12 Mar 2004 12:38:01 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: Deleting a folder recursively
Message-Id: <u9t350l7nere9u4t6cmlqttt7osks8vhp2@library.airnews.net>
Regent <arthur0421@163.com> wrote:
} Shabam wrote:
}
} >>Why are you ignoring files beginning with a dot? If you have a directory
} >>with a dotfile in it, the dotfile won't be deleted and then you won't be
} >>able to rmdir the directory.
} > Could you provide sample code that would work better? I'm a newbie and I
} > actually got that snippet off someone else's code on the newsgroups.
} >
} I guess the relevant RegExp is /^\.\.$/
Wouldn't that be "/^\.\.?$/" ?
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: 12 Mar 2004 10:34:36 -0800
From: jamersoniiv@yahoo.co.uk (James)
Subject: formmail problem
Message-Id: <110564f1.0403121034.336eaf62@posting.google.com>
Hi all, I have a perl script I've been editing so that I can send some
form data. it's based on one I used before and I'm pretty sure it's ok
(had this problem before and it's been something to do with the isp,
but I just wanna check I'm not doing something daft).
sooooo, does all this lot look ok to you?
#!/bin/perl
# Define fairly-constants
# This should be set to the username or alias that runs your
# WWW server.
$recipient = 'james@autonomy-multimedia.com';
# This should be set to the URL of your home page, or wherever
# you wish users to return.
$homepage = 'http://www.autonomy-multimedia.com/';
# This should match the mail program on your system.
$mailprog = '/usr/lib/sendmail';
# Print out a content-type for HTTP/1.0 compatibility
print "Content-type: text/html\n\n";
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Stop people from using subshells to execute commands
# Not a big deal when using sendmail, but very important
# when using UCB mail (aka mailx).
# $value =~ s/~!/ ~!/g;
# Uncomment for debugging purposes
# print "Setting $name to $value<P>";
$FORM{$name} = $value;
}
# Now send mail to $recipient
open (MAIL, "|$mailprog $recipient") || die "Can't open $mailprog!\n";
print MAIL "Reply-to: $FORM{'username'} ($FORM{'realname'})\n";
print MAIL "Subject: A6 Results \n\n";
print MAIL "------------------------------------------------------------\n";
print MAIL "Name : $FORM{'name'}\n";
print MAIL "dealer : $FORM{'dealer'}\n";
print MAIL "role : $FORM('role'}\n";
print MAIL "date : \n\n$FORM{'date'}\n";
print MAIL "time : $FORM{'time'}\n";
print MAIL "score : $FORM{'score'}\n";
print MAIL "Responses : $FORM{'responses'}\n\n";
print MAIL "\n------------------------------------------------------------\n";
close (MAIL);
the format for the date, time, score and responses are:
date: 12/12/03
time: 12:12:00
score: 22.1
responses: 1,2,3,4,5,6
just in case you think those could be messing it up?
thanks for any help
James
------------------------------
Date: 12 Mar 2004 10:08:20 -0800
From: wlin98004@hotmail.com (Crazy Monkey)
Subject: Re: How to redirect headers in Perl?
Message-Id: <db81df92.0403121008.4d91310e@posting.google.com>
> I am afraid I do not exactly follow what you are trying to do.
>
> basic authentication works roughly like this
> a) client does a request to a page
> b) server replies with a header to prompt for
> authentication for its Realm
> c) client (browser) prompts user for this
> d) client resends request, with auth info
> e) if auth successful, page returned
> f) client takes note of this, and silently sends same
> auth info to all subsequent pages in session to same server
> when the server requests it (or, i believe, some clients may
> preemptively send auth info with all page requests to same server
> in session)
> ...
> x) when session closes (browser window closed, browser exits,...)
> the auth info is discarded by client
>
What you describe is correct except I have another server in the flow.
Here is what I needed.
a) client (user browser) hits an auto-login page (perl) on server 1.
b) The perl program on server 1 is going to request a secure page from
server 2.
c) Server 2 will reply with a Realm authentication header.
d) Perl program on server 1 will respond with the user information.
e) If the user information is correct, server 2 will send the page to
server 1.
f) Server 1 will simply forward the content of the page to client.
g) Client see the page on the secure server without login.
So far I was able to get the above to work. The issue is that, when
the client hit another secure page on server 2 without going through
server 1, the user is prompted for authentication information again.
This is expected, because the client never did authentication on
server 2. I was hoping there is a way that the authentication from
server will stick such that user don't have to login again to view
other secure pages on server 2 without login. At first, I thought I
can just pass the cookie from server 2 to client through server 1 and
make the client to send the cookie again. This will work for pages
that use SESSION to keep track of user authentication. It will not
work for Realm authentication.
I don't think what I want to do is possible, but you never know.
------------------------------
Date: Fri, 12 Mar 2004 11:21:35 -0500
From: "Frescard" <me@here.com>
Subject: Mixing WAV Files
Message-Id: <isl4c.49145$6y1.1673497@news20.bellglobal.com>
Is there a way (or module) that would allow me to overlay two or more WAV
files and create a new file out of the mix?
(If not in Perl, then perhaps someone knows of a way to do it in PHP or
ASP?)
------------------------------
Date: Fri, 12 Mar 2004 18:26:39 -0000
From: "dave" <replytogroup>
Subject: Passing variables / data between php - perl
Message-Id: <405200e0@212.67.96.135>
Hi,
I'm looking for code samples on passing variables between php pages to perl
scrips and from perl scripts to php pages.
Any suggestions for websites which show this.
Thanks,
------------------------------
Date: Fri, 12 Mar 2004 16:26:18 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re:ligious, Emacs v. vi
Message-Id: <c2soba$nco$1@wisteria.csv.warwick.ac.uk>
Quoth J Krugman <jkrugman@yahbitoo.com>:
> In <c2sasr$4u0$1@nets3.rz.RWTH-Aachen.DE> "Tassilo v. Parseval"
> <tassilo.parseval@rwth-aachen.de> writes:
>
> >People will probably be using one or the other, but not both. The one
> >you start with (and provided you stick with it for a couple of weeks)
> >will ultimately be your editor.
>
> I should have made it more explicit that my question was specifically
> addressed to those, like Ben and Rocco, who switched from Emacs to
> vi(m) (i.e. their using the latter is not simply because that's the
> one they started out with).
I am wary of answering this kind of question as such things are very
personal. However, the main reasons I swapped were:
1. I was using vim quite a lot anyway: for just editing a config file
emacs takes far too long to start up. Anyway, emacs feels 'too big' a
program to run as root :). As a result I would every so often perform
the wrong keystrokes on autopilot and get annoyed.
2. I have yet to learn enough elisp to even begin to modify any of the
syntax highlighting. Hell, I've yet to learn enough elisp to understand
my own .emacs file. Vim's language makes a lot more sense to me.
3. I never managed to get Mule working properly, for inserting funny
characters.
Things I miss from emacs are its intelligent indent mode, which is
rather cleverer than vim's (though the flip side of this is that vim
mucks up your indenting by mistake much less often); and the fact that
emacs won't let you delete something without copying it to the kill
ring. It is of course possible that both of these are due to my
unfamiliarity with vim... :)
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. ben@morrow.me.uk
------------------------------
Date: 12 Mar 2004 09:47:36 -0800
From: aclarke@austin.rr.com (ac)
Subject: Regex to match simple line of XML
Message-Id: <ec432b9c.0403120947.42a8d0ad@posting.google.com>
I am trying to get a regex to match a simple line of XML. Below is the
program:
use strict;
use Benchmark;
my $testline = '<someelement a="123" b="rrr sss ttt" c="14 or 15">';
my $xmlregex = qr/(?:^\s*<(\w+))|(?:\s+(\w)+=\"(.*?)\")|(?:>\s*$)/;
my @lines = ($testline) x 5000;
my @example = ();
sub useregex
{
my @items = ();
foreach my $line (@lines)
{
@items = ($line =~ m/$xmlregex/g);
unless (@items)
{
print "Malmformed XML in $line\n";
exit;
}
}
unless (@example)
{
@example = @items;
print "Line: $lines[0]\n\n";
print "First line items:\n";
print "\t", join("\n\t",@items), "\n";
}
}
sub usesplit
{
foreach my $line (@lines)
{
my @items = split(/\s+/,$line);
}
}
timethese (1000, {
'useregex' => \&useregex,
'usesplit' => \&usesplit,
});
I know that XML can be broken across lines, but this is just a special
case that I'm interested in. The partial output of the program is:
Benchmark: timing 1000 iterations of useregex, usesplit...
Line: <someelement a="123" b="rrr sss ttt" c="14 or 15">
First line items:
someelement
a
123
b
rrr sss ttt
c
14 or 15
Note the blank lines (null entries) that came from the match. How do I
change the regex to avoid generating these null entries? I'm actually
trying to find the quickest way to parse that line of XML.
Many Thanks,
Allan
------------------------------
Date: Fri, 12 Mar 2004 19:18:46 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Regex to match simple line of XML
Message-Id: <pan.2004.03.12.18.17.26.789699@aursand.no>
On Fri, 12 Mar 2004 09:47:36 -0800, ac wrote:
> I am trying to get a regex to match a simple line of XML.
Why? What's wrong with the many XML modules?
--
Tore Aursand <tore@aursand.no>
"A car is not the only thing that can be recalled by its maker." --
Unknown
------------------------------
Date: Fri, 12 Mar 2004 11:23:53 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: removing trailing spaces
Message-Id: <20040312112241.Y27834@dishwasher.cs.rpi.edu>
On Fri, 12 Mar 2004, zzapper wrote:
> To be punctillious, if the guy wants a trim function
>
> $_="xxxxxx ";
> s/\s+$//;
> s/^\s+//;
> print ;
Out of curiousity, why would you be breaking that into multiple regexps?
s/^\s+|\s+$/g;
Paul Lalli
------------------------------
Date: Fri, 12 Mar 2004 10:32:31 -0600
From: Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: removing trailing spaces
Message-Id: <MPG.1abba21d1cbebeb99897c1@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <82f47a3c.0403120645.2619cbb1@posting.google.com>,
oamd@yahoo.com says...
> I am guessing this is simple one, but am not really a Perl guru, so am
> hoping I can get help from someone out here.
>
> I am trying to remove trailing spaces from a string value.
>
> original value what am looking for
> 'xxxxxx ' ==> 'xxxxxx'
>
> I am going to store this value in the database, but I want to remove
> the spaces so I can find exert match when am searching for specific
> value.
>
>
> Ollie.
>
$string =~ s/\s+//; # remove trailing whitespace
------------------------------
Date: Fri, 12 Mar 2004 17:58:26 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: removing trailing spaces
Message-Id: <c2sqf7$21hish$1@ID-184292.news.uni-berlin.de>
Paul Lalli wrote:
> On Fri, 12 Mar 2004, zzapper wrote:
>> To be punctillious, if the guy wants a trim function
>>
>> $_="xxxxxx ";
>> s/\s+$//;
>> s/^\s+//;
>> print ;
>
> Out of curiousity, why would you be breaking that into multiple
> regexps?
>
> s/^\s+|\s+$/g;
Because the latter doesn't compile? ;-)
Another theory is that "zzapper" has read the FAQ and cares about speed.
perldoc -q beginning/end
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 12 Mar 2004 18:03:52 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: removing trailing spaces
Message-Id: <c2sqpd$205e6k$1@ID-184292.news.uni-berlin.de>
Web Surfer wrote:
>
> $string =~ s/\s+//; # remove trailing whitespace
How is that comment related to the code?
Please read the rest of this thread.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 12 Mar 2004 18:00:28 +0000
From: zzapper <david@tvis.co.uk>
Subject: Re: removing trailing spaces
Message-Id: <27u35012kt61els8qvpqb8aq63bh32ou4s@4ax.com>
On Fri, 12 Mar 2004 17:58:26 +0100, wrote:
>Paul Lalli wrote:
>> On Fri, 12 Mar 2004, zzapper wrote:
>>> To be punctillious, if the guy wants a trim function
>>>
>>> $_="xxxxxx ";
>>> s/\s+$//;
>>> s/^\s+//;
>>> print ;
>>
>> Out of curiousity, why would you be breaking that into multiple
>> regexps?
>>
>> s/^\s+|\s+$/g;
>
>
>Another theory is that "zzapper" has read the FAQ and cares about speed.
>
> perldoc -q beginning/end
Exactly. Also you can instinctively feel that 2 operations are in
this case more efficient!
BTW I like your "perldoc -q beginning/end"
zzapper (vim & cygwin & zsh)
--
vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
------------------------------
Date: Fri, 12 Mar 2004 13:53:47 -0500
From: Richard Morse <remorse@partners.org>
Subject: Re: scheduling a perl script
Message-Id: <remorse-4D50DF.13534712032004@plato.harvard.edu>
In article <dfd17ef4.0403052053.632e2e8e@posting.google.com>,
s99999999s2003@yahoo.com (mike) wrote:
> hi
>
> i wrote a script that is supposed to check a directory and see if
> there is a file named "test.txt" there and if there is , use ftp to
> transfer the file to another server and then remove the file from the
> directory.
> I had scheduled a job in windows to poll for this directory looking
> for "test.txt" every month on day 8, 9 and 10 and 11, because test.txt
> will arrive anytime during 8,9 and 10. On the 11th, my script will
> poll the directory and if there is still no test.txt, will alert the
> administrator.
>
> How can i implement in perl such that on the 11th, my script will not
> mistake that test.txt is not there while in fact, it has already been
> transfered to another server and removed after transfered?
> I thought of not removing test.txt after transfered but if the file
> arrived on the 8th, then on the 9th i would do another identical
> transfer.
One possibility: your OS may allow you to schedule commands from the
command line. (Look to the 'at' command.) So, have the OS initiate the
script on the 8th, passing a parameter of '0'. If the file exists, do
the transfer, then exit. If the file doesn't exist, and the parameter
is '3' (ie, this is the fourth run of the program), fire off a message
to the sysadmin. If the file doesn't exist, and the parameter is less
than three, use system (or qx) to schedule the program to run again in
24 hours, passing the parameter incremented by one. If the parameter is
greater than three, notify someone that a mistake was made in running
the program...
HTH,
Ricky
------------------------------
Date: Fri, 12 Mar 2004 16:08:46 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Re: Text editor implemented in Perl
Message-Id: <c2snae$q9$1@reader1.panix.com>
In <c2sasr$4u0$1@nets3.rz.RWTH-Aachen.DE> "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> writes:
>People will probably be using one or the other, but not both. The one
>you start with (and provided you stick with it for a couple of weeks)
>will ultimately be your editor.
I should have made it more explicit that my question was specifically
addressed to those, like Ben and Rocco, who switched from Emacs to
vi(m) (i.e. their using the latter is not simply because that's the
one they started out with).
jill
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
------------------------------
Date: Fri, 12 Mar 2004 09:03:27 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Text editor implemented in Perl
Message-Id: <120320040903276556%jgibson@mail.arc.nasa.gov>
In article <Pine.A41.4.58.0403121029090.14112@ginger.libs.uga.edu>,
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> On Fri, 12 Mar 2004, J Krugman wrote:
> >
> > What makes vim so much better than Emacs?
>
> This is a long-standing religious topic. On the one hand are Emacs users,
> and on the other, users of the One True Editor, vi.
>
> Please don't take me seriously. But you're not likely to EVER get a
> decisive answer to your question. You've discovered for yourself the vi
> doesn't "work" with your own mindset. I think that's a legitimate reason
> not to use it.
>
> Ever since IBM destroyed WordStar (for me) by relocating the Ctrl key,
> I've had an aversion to Ctrl key combinations--it's a carpal tunnel
> problem. At a key point, I bit the bullet and worked at wrapping my mind
> and fingers around vi. Now it's second nature, and having to edit text
> with anything else makes me feel quadriplegic.
>
> Regards,
>
> Brad
I, too, dislike all of emacs ctrl key combinations. But for me the
fatal flaw of emacs is the jump scroll. You move your cursor
line-by-line down to the bottom of the screen and the display jumps up
half a screen's worth. I find that very disorienting. vi, on the other
hand, scroll's the display up a single line, enabling me to more easily
scan through a file.
A little more on-topic question about vim:
When I enter a '#' to start a comment, vim puts it in column one,
thinking, I suppose, that I am starting a C preprocessor directive. How
do I get vim to leave the comment indented where it is? I tried reading
the vim help about defining actions for various modes, but it was too
complicated to understand easily and I ran out of time and patience to
slog through the description.
Thanks.
------------------------------
Date: 12 Mar 2004 18:28:10 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Text editor implemented in Perl
Message-Id: <slrnc5409q.k63.xx087@smeagol.ncf.ca>
Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
> When I enter a '#' to start a comment, vim puts it in column one,
> thinking, I suppose, that I am starting a C preprocessor directive. How
> do I get vim to leave the comment indented where it is? I tried reading
> the vim help about defining actions for various modes, but it was too
> complicated to understand easily and I ran out of time and patience to
> slog through the description.
Place, in your ~/.vimrc
" don't force perl comment to be entered into column 1
set cpoptions-=<
inoremap # X<BS>#
http://www.vim.org/tips/tip.php?tip_id=644
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Fri, 12 Mar 2004 12:25:08 -0600
From: "Andrew A. Raines" <aaraines@pobox.com>
Subject: Re: Text editor implemented in Perl
Message-Id: <w4y8q5x6rf.fsf@mid.packer.its.vanderbilt.edu>
Jim Gibson <jgibson@mail.arc.nasa.gov> writes:
> I, too, dislike all of emacs ctrl key combinations. But for me
> the fatal flaw of emacs is the jump scroll. You move your cursor
> line-by-line down to the bottom of the screen and the display
> jumps up half a screen's worth. I find that very disorienting.
I can understand the bothersome control-key dependency, but a minor
default setting fatal?
See <URL:http://www.emacswiki.org/cgi-bin/wiki.pl?BufferScrolling>.
--
aaraines@pobox.com (Andrew A. Raines)
------------------------------
Date: Fri, 12 Mar 2004 10:52:50 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Tricky Perl Bug (amusing/unamusing)
Message-Id: <Pine.GSO.4.21.0403121041340.16655-100000@mtwhitney.nsc.com>
On Fri, 12 Mar 2004, Thomas Kratz wrote:
> zzapper wrote:
> ...
> > $phone was always being assigned
> > SCALAR(0x18ef230) this drove me crazy until I FINALLY noticed the
> > STRAY DOLLAR on the previous line (not so easy to spot in 100's of
> > lines of code)
> >
> > presumably Perl saw this as a process number ie
> >
> > $$phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";
> >
> > perl -w did not indicate anything amiss
>
> But using strict would have:
> use strict;
> use warnings;
> my $phone = '1';
> my $phonelocal = '2';
> my $phonecentral = '3';
> $
> $phone=($phonelocal =~ /\d\d/) ? "$phonelocal":"$phonecentral";
>
> results in:
>
> Can't use string ("1") as a SCALAR ref while "strict refs" in use at - line 6.
>
> This is assuming you don't have a scalar ref in $phone. You don't I presume?
>
> Thomas
In the case you presented, yes -- strict issues a warning. But this
(below) is valid code under strict:
use strict;
use warnings;
my $phone;
$$phone = 1;
print $phone;
perl warns only if $phone contains an initialized value that's not a
scalar ref. An uninitialized (i.e., undef) value in $phone will not
cause a warning to be issued.
--
Hope this helps,
Steven
------------------------------
Date: 12 Mar 2004 19:02:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: using an assoc. array as a 'set'
Message-Id: <c2t1go$olu$1@mamenchi.zrz.TU-Berlin.DE>
Michele Dondi <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
> On 11 Mar 2004 09:33:18 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote:
>
> >Mathematics goes that way. Starting from sets, "ordered pairs" can
> >be defined. Then mappings, the mathematical counterparts of hashes,
>
> I'd say that I have a mathematically oriented personality: I like and
> it is natural for me to think in terms of mathematic concepts of
> programming language features and charachteristics...
>
> >are defined as certain sets of ordered pairs.
> [snip]
> >they aren't sets. Perhaps when quantum computing makes the
> >implementation of sets a snap and voids all efficiency considerations
> >we shall see the BOURBAKI computing language :)
>
> I understand that this is a joke, but taking it just a little bit
> seriously, I'd say that quantum computing has very few or nothing to
> do with this issue...
I was envisioning a system that works directly with the objects
mathematics works with: sets, relations, mappings, groups, what have you.
Oh, numbers too, I almost forgot those... Sets and their operations would
be the only primitives (in hardware). The mathematical literature is
full of recipes how to build (almost) any other structure from sets,
so no wheels have to be invented. The recipes, however, show utter
disconcern for efficiency.
"A set is a collection to a whole of definite, well-differentiated
objects of our input media or our storage." Implement that on anything
but a quantum computer :)
> I made it clear from the start that this was a particular, minor,
> concern of *mine*, and I think that Perl's hypothetical support of
> sets or similar structures as primitive objects of the language
> wouldn't be of any added utility but in a very limited way in just a
> very limited bunch of cases, that simply wouldn't be worth the trouble
> of adding such a support.
I haven't looked at Ruby yet, but it seems it has set operations
in the language core.
> >That said, Perl 6 will have pairs (but not sets) as a primitive, and
> >hashes will be based on pairs.
>
> I had already heard that... I'm both very curious about Perl 6 because
> of rumors gathered here and there and afraid about some changes
> because of the same rumors and especially the reputable opinions of
> extraordinaire PH's like Abigail, for example!
Abigail judges quickly and has strong opinions. I'm not worried about
design details, even major ones, in Perl 6. It's going to be the
distillate of many years programming experience with Perl, and that
makes it interesting enough for me.
My one concern is if the Perl community has the power, right down to
the sense of man-power, to run two major lines of development, or
three, if you count Parrot.
Anno
------------------------------
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 6250
***************************************