[12841] in Perl-Users-Digest
Perl-Users Digest, Issue: 251 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 25 13:07:21 1999
Date: Sun, 25 Jul 1999 10:05:07 -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 Sun, 25 Jul 1999 Volume: 9 Number: 251
Today's topics:
Re: Amateur (Jimtaylor5)
Re: Best Perl book? <tchrist@mox.perl.com>
Re: Best Perl book? <unigni@zaynar.demon.co.uk>
Re: Extracting plain text from email (Tad McClellan)
Re: Extracting plain text from email (Tad McClellan)
Re: flock - does it wait for people to finish reading? <dan@tuatha.sidhe.org>
index.cgi script help (Anno Siegel)
Is this the proper if else syntax <steven_crazyman@worldnet.att.net>
Re: Is this the proper if else syntax (Ronald J Kimball)
Re: Is this the proper if else syntax <steven_crazyman@worldnet.att.net>
Re: Is this the proper if else syntax (Larry Rosler)
Re: its 1.30am <snip> - eval - morning - I can see clea (Anno Siegel)
Re: John F. Kennedy, Jr (I R A Darth Aggie)
need to understand do { block } (Michael Wang)
Re: output to screen and log file simultaneously? (Michael Wang)
random (Tony Greenwood)
Re: random (Anno Siegel)
Re: random <mike@crusaders.no>
Re: random (Tony Greenwood)
Re: Realsysytem and perl (I R A Darth Aggie)
Re: Replacing and Stripping HTML (Tad McClellan)
Re: special problem (Larry Rosler)
struct, |= and print (Marc Haber)
What's the deal with Lookout Express? <cmcurtin@interhack.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Jul 1999 15:07:40 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Re: Amateur
Message-Id: <19990725110740.28104.00001708@ng-fh1.aol.com>
>If you only care about the first two lines of the file, I'd use something
>like the following after the open.
>
>$wordline = <CONFI>;
>$locks = <CONFI>;
>close(CONFI);
So Simple. Thanks
------------------------------
Date: 25 Jul 1999 06:19:29 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Best Perl book?
Message-Id: <379b00d1@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Unigni <unigni@zaynar.demon.co.uk> writes:
:>iii) A listing of perl books with ratings is available at the perl home
:> page: http://www.perl.com/pub/language/critiques/index.html
:Wouldn't that site be a little bit biased towards O'Reilly books, since
:they actually own the web site? :-)
They don't own it. I do.
Nobody has sent me reviews, nor copies of books to review,
for quite some time, however.
--tom
--
*bp++ = i; /* now go back to screaming loop */
--Larry Wall, from perl/sv.c in the v5.0 perl distribution
------------------------------
Date: Sun, 25 Jul 1999 17:11:58 +0100
From: Unigni <unigni@zaynar.demon.co.uk>
Subject: Re: Best Perl book?
Message-Id: <uRBFeEAOdzm3EwAb@zaynar.demon.co.uk>
In article <379b00d1@cs.colorado.edu>, Tom Christiansen
<tchrist@mox.perl.com> writes
>In comp.lang.perl.misc,
> Unigni <unigni@zaynar.demon.co.uk> writes:
>:>iii) A listing of perl books with ratings is available at the perl home
>:> page: http://www.perl.com/pub/language/critiques/index.html
>:Wouldn't that site be a little bit biased towards O'Reilly books, since
>:they actually own the web site? :-)
>
>They don't own it. I do.
>
>Nobody has sent me reviews, nor copies of books to review,
>for quite some time, however.
>
>--tom
Sorry... I guess I was wrong :-) Most other people seem to think that
the O'Reilly ones are best anyway, so that's probably what I'll get...
--
Philip Taylor
philip @ zaynar . demon . co . uk
http://www.ultrastore.com -- "The Shopping Experience of Tomorrow - NOW!"
(an example of what can be done with *loads* of JavaScript and cookies!)
------------------------------
Date: Sun, 25 Jul 1999 05:24:34 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Extracting plain text from email
Message-Id: <i4len7.1pf.ln@magna.metronet.com>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote:
: Oh, and please place your replies *after* the sufficiently tailored
: text you quote. This is good usenet custom, and it is for a reason.
: [Sheesh, I'm getting tired of adding this to every other followup.
: clpm is worse than many newsgroups in this respect.]
Many posters here skip Usenet kindergarten, then get all
huffy when told to stand in line. :-(
-------------------------------------------------------------------
In article <1995Nov9.193745.13694@netlabs.com>, lwall@netlabs.com (Larry
Wall) wrote: ...
<Larry> [snip] I view a programming language as a place to be
<Larry> explored, like Disneyland. You don't need to have a lot of preparation
<Larry> to explore a theme park. You do have to go along with the crowd
<Larry> control measures, though. In a sense, each ride has its own
<Larry> prerequisites--if you cut in line, you risk getting tossed out of the
<Larry> park.
<Larry>
<Larry> What we have here in this newsgroup is a failure in crowd control.
<Larry> Reading the FAQ is like staying in line--it's something you should
<Larry> learn in kindergarten. Usenet needs a better kindergarten.
-------------------------------------------------------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Jul 1999 05:22:07 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Extracting plain text from email
Message-Id: <vvken7.1pf.ln@magna.metronet.com>
Roger (rexcell@btinternet.com) wrote:
: > Oh, and please place your replies *after* the sufficiently tailored
: > text you quote. This is good usenet custom, and it is for a reason.
: I am sorry u mean like this
: I am also new to news groups mabey a good way to get help as long as i dont
: upset every one.
Read news.announce.newusers if you are a new user of news
and want so see tha announcements so that you look like you
know what you are doing.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Jul 1999 13:33:09 GMT
From: <dan@tuatha.sidhe.org>
Subject: Re: flock - does it wait for people to finish reading?
Message-Id: <pmEm3.19122$y92.10823@news.rdc1.ct.home.com>
James Thurley <jamesthurley@hotmail.com> wrote:
> This may seem a stupid question, but when you lock a file with flock(), does
> it wait for people to finish reading from the file before it locks it (if
> the people reading it haven't locked it)?
flock in general only blocks or is blocked by other flocks. Plain file opens
and closes don't affect and aren't affected by flock in any way. (Whether this
is a good thing or not is left to the reader who cares to argue it with
Tom...)
So the answer to your question is "No".
Dan
------------------------------
Date: 25 Jul 1999 12:28:32 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: index.cgi script help
Message-Id: <7nevtg$5oh$1@lublin.zrz.tu-berlin.de>
Mike <mike@customautotrim.com> wrote in comp.lang.perl.misc:
>Abigail,
>
>Your so smart that your stupid. Kind of like drinking yourself straight (I'm sure
[snip rest of complaint]
Welcome to usenet.
You posted a question which, while marginally on topic, was utterly
silly. Basically you asked: I have this script, and it contains
line X. I want this line to be Y. What can I do? Some people
replied, many decided not to. Abigail said, among other things:
>> And what is your problem? How to type it in? If you did it once in
>> the newsgroup, why not in the program?
Coming from her, that means it has a good chance to work. If you
had lurked a bit before posting, you'd know that. She also made fun
of you, which you made pretty hard not to do, given your posting.
You don't get to decide who responds to you and in which way they
chose to be helpful.
Welcome to usenet.
Anno
------------------------------
Date: Sun, 25 Jul 1999 09:19:10 -0500
From: "Steve Wagner" <steven_crazyman@worldnet.att.net>
Subject: Is this the proper if else syntax
Message-Id: <7nf6md$i42$1@bgtnsc01.worldnet.att.net>
I am just starting off in perl. My question is are the if else statments in
the proper places with the proper syntax? Any suggestions would be
appreciated.
BTW I did get this to run succesfully on my server but dont know if it will
cause problems when I add on to it. THANK YOU.
#!/usr/bin/perl
print "Content-type:text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
$mailprog = '/usr/sbin/sendmail';
$recipient = 'crazyman@cgi101.com';
if ($FORM{'name'} eq "" or $FORM{'email'} eq "" or $FORM{'age'} eq "") {
&dienice("Please fill out the fields for your name, age, and email.");
}
else {open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
print MAIL "To: $recipient\n";
print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
print MAIL "Subject: Thank You for Registering\n\n";
foreach $key (keys(%FORM)) {
print MAIL "$key = $FORM{$key}\n";
}
foreach $key (sort(keys %ENV)) {
print MAIL "$key = $ENV{$key}\n";
}
}
close(MAIL);
print <<EndHTML;
<h2>Thank You</h2>
Thank you for writing. Your mail has been delivered.<p>
Return to our <a href="index.html">home page</a>.
</body></html>
EndHTML
;
sub dienice {
($errmsg) = @_;
print "<h2>Error</h2>\n";
print "$errmsg<p>\n";
print "</body></html>\n";
exit;
}
Sorry if you didnt need the whole code but I wasnt sure.
------------------------------
Date: Sun, 25 Jul 1999 10:56:02 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Is this the proper if else syntax
Message-Id: <1dvhv6h.a8dfnzoj951cN@p86.tc19a.metro.ma.tiac.com>
Steve Wagner <steven_crazyman@worldnet.att.net> wrote:
> I am just starting off in perl. My question is are the if else statments in
> the proper places with the proper syntax? Any suggestions would be
> appreciated.
Your if-else syntax looks fine, and you check the result of open() just as
you should. One thing you missed is that your code should be indented
properly.
For example:
if ($FORM{'name'} eq "" or $FORM{'email'} eq "" or $FORM{'age'} eq "") {
&dienice("Please fill out the fields for your name, age, and email.");
}
else {
open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
print MAIL "To: $recipient\n";
print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
print MAIL "Subject: Thank You for Registering\n\n";
foreach $key (keys(%FORM)) {
print MAIL "$key = $FORM{$key}\n";
}
foreach $key (sort(keys %ENV)) {
print MAIL "$key = $ENV{$key}\n";
}
}
Notice how the statements in the else block are all indented from the left
margin, and the statements in the foreach blocks are indented twice as much.
This makes the code easier to read.
Another thing that you should consider is using the CGI module, rather than
trying to do all the form processing and data munging yourself.
You're off to a good start!
--
_ / ' _ / - 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: Sun, 25 Jul 1999 10:42:16 -0500
From: "Steve Wagner" <steven_crazyman@worldnet.att.net>
Subject: Re: Is this the proper if else syntax
Message-Id: <7nfbi7$7pa$1@bgtnsc01.worldnet.att.net>
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote in message
news:1dvhv6h.a8dfnzoj951cN@p86.tc19a.metro.ma.tiac.com...
> Your if-else syntax looks fine, and you check the result of open() just as
> you should. One thing you missed is that your code should be indented
> properly. (Thank You that does make it easier!)
> Another thing that you should consider is using the CGI module, rather
than
> trying to do all the form processing and data munging yourself.( ? Never
heard of it. What is it and where do I find it?)
> You're off to a good start!
(Thank You Again)
------------------------------
Date: Sun, 25 Jul 1999 09:09:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Is this the proper if else syntax
Message-Id: <MPG.1204d6a9dffac1b0989d46@nntp.hpl.hp.com>
In article <1dvhv6h.a8dfnzoj951cN@p86.tc19a.metro.ma.tiac.com> on Sun,
25 Jul 1999 10:56:02 -0400, Ronald J Kimball
<rjk@linguist.dartmouth.edu> says...
...
> if ($FORM{'name'} eq "" or $FORM{'email'} eq "" or $FORM{'age'} eq "") {
> &dienice("Please fill out the fields for your name, age, and email.");
> }
> else {
Just a small improvement: As dienice() dies nicely, the 'else' clause
could be omitted and the consequent code could simply be left-aligned.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Jul 1999 13:25:29 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: its 1.30am <snip> - eval - morning - I can see clearly now ...
Message-Id: <7nf389$5s5$1@lublin.zrz.tu-berlin.de>
Eric Smith <eric@fruitcom.com> wrote in comp.lang.perl.misc:
[snip brian d foy]
>Ok, I have this script that looks in my flat text telephone list (it a
>largish list). Now it used to take only three args and the script needed
>to match those three args in the same line, so ..
>bri Fo mong
>as args, would match an entry
>Perl Mongers, Brian Foy
>
>Now I wanted to be able to use unlimited number of args for this script so
>thats what I failed to do last night, being the first time I had the
>courage to use eval. Well this morning it works :).
>Albeit a little slowly, anyone know how to make it faster .. see code
>below.
I think so, though I haven't benchmarked. I believe you have two
efficiency problems: For one, you recompile all those regexen for
each line. You might try to add the /o option to compile them only
once, since the strings you match don't change during each run of
the script. I'm almost sure this works even across evals, though
I didn't check.
The other point is eval itself. It compiles the perl code in $command,
again once for each line. But you don't really need eval, you can check
for print-worthiness in a loop which can be curtailed to a single step
for most lines. This is how I'd do it (using DATA instead of an external
file, you know the drill):
#!/usr/bin/perl -w
use strict;
print "@ARGV \n";
while (<DATA>) {
my $printit = @ARGV; # don't print if no @ARGV given
foreach my $pattern ( @ARGV ) {
$printit &&= m/$pattern/io;
last unless $printit;
}
print if $printit;
}
print "\n";
__END__
Brian Foy
Eric Smith - Accidental Hacker
------------------------------
Date: 25 Jul 1999 14:33:50 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: John F. Kennedy, Jr
Message-Id: <slrn7pm86k.osq.fl_aggie@thepentagon.com>
On Sat, 24 Jul 1999 16:13:03 -0700, Larry Rosler <lr@hpl.hp.com>, in
<MPG.1203e85327c98fd9989d3b@nntp.hpl.hp.com> wrote:
+ There is no particularly polite way to tell you to shove it.
I think in this case it would be appropriate to tell him to "go
fly an airplane".
James
------------------------------
Date: 25 Jul 1999 16:26:19 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: need to understand do { block }
Message-Id: <7nfdrb$3i9$1@news.ml.com>
Perl experts,
what will be output by the following Perl script?
print(
do { foreach (1, 2) {
(1..5);
}
}
)
Here is my analysis:
(1) It will print what do { } returns
(2) what do returns is the last expression evaluated in the do block
[Camel book page 158]
(3) foreach (1, 2) { } is a statement, not an expression
which has no return value
(4) (1..5) is an expression and returns itself
(5) Expression (1..5) is evaluated twice per foreach {}
(6) Last expression evaluated is (1..5) in do {} block
(7) do {} should (1..5)
(8) print should output (1..5)
But in fact the above Perl script output nothing (no errors either).
So I would like to know what steps in above analysis are not true? Thanks.
--
Michael Wang
http://www.mindspring.com/~mwang
------------------------------
Date: 25 Jul 1999 15:52:54 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: Re: output to screen and log file simultaneously?
Message-Id: <7nfbsm$35s$1@news.ml.com>
>I use print,warn, and die to output message to
>screen in my program. I wish to save these message (including that
>generated by warn and die)
>to a log file at the same time. Is there any way to do so
>by not changing the structure of program. Don't suggest me to
>use a subroutine that print to stdout, and print to file, then call
>subroutine to output message.
I see anything wrong with subroutine, which is the best approach
that I can find. Without a subroutine, you need to repeat what should
be in subroutine each time you use it.
foreach my $fh (@fh) {
print($fh @m);
}
or you can use tee, which is more platform dependent, and at the cost
of a fork.
As for warn and die, I do not know how to control where it goes.
If you really need to do that, I would suggest
warn -> print
die -> print + exit(-1)
or someone has better ideas.
I also do not know where the Perl internal error/diagnostics [use diagnostics]
go and how to log them. It does not go to STDOUT/STDERR, I think it
goes to the tty, but then how to, say, to a logfile and stdout?
sub printout {
my $i=shift();
my @m=@_;
my @fh;
if ( $i == 1 ) { @fh=(*STDOUT); }
elsif ( $i == 2 ) { @fh=(*STDERR); }
elsif ( $i == 3 ) { @fh=(*STDOUT, *LOG) }
elsif ( $i == 4 ) { @fh=(*STDERR, *LOG) }
else {
printout(4, "you must specify an option 1-4.\n"); # yes recursion
}
foreach my $fh (@fh) {
print($fh @m);
}
}
--
Michael Wang
http://www.mindspring.com/~mwang
------------------------------
Date: Sun, 25 Jul 1999 12:16:13 GMT
From: tony@webscripts.org (Tony Greenwood)
Subject: random
Message-Id: <37acff1b.11867048@news.freeserve.co.uk>
I am generating a random number between 2 and 7
What I would like to do is fix it so 4,5 and 6 appear more often.
I can think of one way and thats to put the numbers 2-7 into an array
50 cells long and put more 4,5 and 6 in than the others and random the
50. This should work as theers more chance of getting those numbers if
they appear in the array more.. common sense? :)
However it does seem a long way around the problem. is there a better
way ?
--
Tony Greenwood
PORTFOLIO www.webscripts.org
------------------------------
Date: 25 Jul 1999 13:39:37 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: random
Message-Id: <7nf42p$5ud$1@lublin.zrz.tu-berlin.de>
Tony Greenwood <tony@webscripts.org> wrote in comp.lang.perl.misc:
>
>
>I am generating a random number between 2 and 7
>
>What I would like to do is fix it so 4,5 and 6 appear more often.
>
>I can think of one way and thats to put the numbers 2-7 into an array
>50 cells long and put more 4,5 and 6 in than the others and random the
>50. This should work as theers more chance of getting those numbers if
>they appear in the array more.. common sense? :)
>
>However it does seem a long way around the problem. is there a better
>way ?
I depends on the exact distribution you want. Your method is the
recommended one if you want to approximate an arbitrary distribution.
(Used by professional statisticians all over the world! And you
re-invented it.) In special cases you can generate two or more
random numbers and use their sum (or difference, or other linear
combination). Some combinations that give the same result occur
more than others. For example 2 + int rand( 6) + int rand( 6)
emulates the throwing of two dice, with a maximum around seven.
I'd stick with your method, it's fine.
Anno
------------------------------
Date: Sun, 25 Jul 1999 15:41:49 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: random
Message-Id: <nvEm3.137$tW1.621@news1.online.no>
Tony Greenwood <tony@webscripts.org> wrote in message
news:37acff1b.11867048@news.freeserve.co.uk...
> I am generating a random number between 2 and 7
> What I would like to do is fix it so 4,5 and 6 appear more often.
How about getting another random number if the result is 2, 3 or 7. If it's
still 2, 3 or 7 you can keep it?
--
Trond Michelsen
------------------------------
Date: Sun, 25 Jul 1999 16:04:03 GMT
From: tony@webscripts.org (Tony Greenwood)
Subject: Re: random
Message-Id: <37a534fc.6058996@news.freeserve.co.uk>
Hey! anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
>>I can think of one way and thats to put the numbers 2-7 into an array
>I depends on the exact distribution you want. Your method is the
>recommended one if you want to approximate an arbitrary distribution.
>I'd stick with your method, it's fine.
It works so I will not try to fix it then.. I just see a large answer
and look for a smaller one (old habit)
Thanks.
--
Tony Greenwood
PORTFOLIO www.webscripts.org
------------------------------
Date: 25 Jul 1999 14:36:20 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Realsysytem and perl
Message-Id: <slrn7pm8bb.osq.fl_aggie@thepentagon.com>
On Sat, 24 Jul 1999 22:45:10 -0400, Joe Frey <jfrey@bon.net>, in
<379A7A34.AEA258C2@bon.net> wrote:
+ Guys and Gals, I'm running a realserver on an NT machine. Hence, I want
+ to use perl on the NT machine to poll a directory for a file's creation
+ date down to the second. If the creation date has changed, I want to run
+ an application with this file. Is this possible? TIA. Joe Frey.
Possibly. You may want to read up on opendir(),readdir(),closedir(),
stat() and system() (or moral equivalent).
James
------------------------------
Date: Sun, 25 Jul 1999 06:57:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Replacing and Stripping HTML
Message-Id: <jiqen7.1pf.ln@magna.metronet.com>
inlandpac@my-deja.com wrote:
: Here is what I am trying to do:
: 1. Open a file (which I know how to do)
: 2. Replace every occurance of </FONT> in that file with |
perldoc perlop
see: =item s/PATTERN/REPLACEMENT/egimosx
: 3. Strip remaining HTML from the file
perldoc -q HTML
: 4. Replace contents of file with new results.
Perl FAQ,part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
perldoc -f rename
: Can anyone please help?
You can, and should, help yourself before asking others to do it.
If you try and can't find it, _then_ post a question, but
you should try first.
: Everything I try does not work.
You are not trying to use the most valuable resource available
to you, namely the documentation about perl that comes with perl.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Jul 1999 07:09:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: special problem
Message-Id: <MPG.1204ba7e850b6dc989d45@nntp.hpl.hp.com>
In article <379AC631.DD380C4A@ufl.edu> on Sun, 25 Jul 1999 04:09:22 -
0400, Jeremy James <perly@ufl.edu> says...
> Frank de Bot wrote:
> > I want to do something weird ( I think ).
> > I have a string which is called array:
> >
> > $string = "array";
> >
> > Now I want to create an array with that variable.
> >
> > @array = ""; # To put something in it is for later
> >
> > if I have a string whit the value "mp3" I want to create a array @mp3
> >
> > Is this possible?
>
> I believe what you are looking for is a symbolic reference:
You are right. That's what he is looking for. But that's not what he
should use, for reasons eloquently explained by Tom Christiansen in his
response posted many hours before yours.
<SNIP> of symbolic-reference glop
> read the 'references' chapter of Programming Perl
Only if interested in building data structures dynamically, or using
objects, or a few other legitimate purposes. This is not such a
purpose.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 25 Jul 1999 15:36:31 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: struct, |= and print
Message-Id: <7nfau0$5qd$1@news.rz.uni-karlsruhe.de>
Hi!
Look at this:
|mh@torres[32/532]:/mnt/main6/home/mh/projects/misc$ cat struct
|#!/usr/bin/perl -w
|
|use strict;
|use Class::Struct;
|
|struct Mystruct =>
|{
| flags => '$'
|};
|
|my $s = Mystruct->new();
|
|# $s->flags=4; # WRONG!
|print "$s->flags\n";
|
|$s->flags(4);
|print "$s->flags\n";
|printf ("%s\n",$s->flags);
|
|# $s->flags |= 8; # WRONG!
|
|$s->flags($s->flags|8); # (1)
|printf ("%s\n",$s->flags);
|mh@torres[33/533]:/mnt/main6/home/mh/projects/misc$ ./struct
|Mystruct=HASH(0x80c1be8)->flags
|Mystruct=HASH(0x80c1be8)->flags
|4
|12
|mh@torres[34/534]:/mnt/main6/home/mh/projects/misc$
The two statements maked WRONG! are trying to directly access struct
members with assignment operators like |=. This doesn't work ("can't
modify subroutine entry"). Do I really have to use the more clumsy
expression (1)?
How can I simply print struct members?
Any hints will be appreciated.
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: 25 Jul 1999 09:32:41 -0400
From: Matt Curtin <cmcurtin@interhack.net>
Subject: What's the deal with Lookout Express?
Message-Id: <xlxaesk26ti.fsf@gold.cis.ohio-state.edu>
That is one hosed newsreader.
I simply cannot believe that someone would respond to a message,
manually stuffing a "[name] wrote in message" at the top, not giving
any indication of quoting, etc., and then putting the response between
the referenced post's text and its signature line.
At the very least, if the newsreader had any indication of standard
practice, it would require the user to go through great pains in order
to post such a horribly mangled article.
--
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/
------- Start of forwarded message -------
From: "Chocolate Moose" <relzing@redeemer.on.ca>
Newsgroups: comp.lang.perl.misc
Subject: Re: Geekspeak Programming Contest
Date: Sun, 25 Jul 1999 02:03:32 -0400
Organization: UUNET Canada News Transport
Message-ID: <7ne9f8$el$1@goblin.uunet.ca>
References: <37976d3d@cs.colorado.edu> <3798AFC7.620DCF8F@netdoor.com> <MPG.12027f85b13cf854989d2a@nntp.hpl.hp.com> <xlxu2qunhfz.fsf@gold.cis.ohio-state.edu>
X-Newsreader: Microsoft Outlook Express 4.72.3612.1700
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700
Matt Curtin wrote in message ...
>>>>> On Fri, 23 Jul 1999 14:33:29 -0700, lr@hpl.hp.com (Larry Rosler) said:
>> Jan 1, 2001 = Jan 1, 2000
Larry> I don't get that.
I believe it is a reference to the millennium, which The Masses seem
to think begins with 2000 despite the fact that it won't begin until
2000 has come to an end.
This is something I don't get. Isn't this analogous to saying that our life
doesn't begin until we are one? Or is it meant to imply(or implied by the
fact), that when, if AD or ACE was a living being, it was one at its birth.
Anyways, a new millenium begins, and a new millenium begins for every
infinitessimal ammount of time that passes. The only _real_ significance of
the "new millenium" is in the "millenium bug" and it's repurcussions if
there really are going to be any. (Two cents from someone who just visited
comp.lang.perl.misc for the first time today and more than likely has echoed
sentiments of previous posts). Moose out.
--
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/
------- End of forwarded message -------
------------------------------
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 251
*************************************