[10608] in Perl-Users-Digest
Perl-Users Digest, Issue: 4200 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 11 18:07:55 1998
Date: Wed, 11 Nov 98 15:00:24 -0800
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 Nov 1998 Volume: 8 Number: 4200
Today's topics:
Re: 64-bit Perl? (Ilya Zakharevich)
Re: <<My Sort Problem>> <nospam@see.signature>
Re: attaching a jpeg (Martien Verbruggen)
Can't use "chomp" (Oliver Moffat)
Re: Can't use "chomp" (Serial # 0)
Re: Can't use "chomp" (Matt Knecht)
Exit UNIX from within a perl program <zzhang@Bayou.UH.EDU>
Re: Fun NYC job consulting/FT Perl/Tk/DBI/C++ jeans + T <bill@fccj.org>
Help! Authenticate password via Perl <matt@pcr7.pcr.com>
Re: Help! Authenticate password via Perl <bill@fccj.org>
Horizontal Bar??? apeng123@my-dejanews.com
Re: How do I sort this list by "port" number? <merlyn@stonehenge.com>
Re: hypermail files into text <bill@fccj.org>
Re: If -e different then If -d on a Directory, why? <stowians@ford.com>
looking for training in Houston, Texas (Paula Burch)
newbie to perl - need simple search perl script <ericw@recom.com>
Re: OOP or not? (for a Perl module) (Paul Winkler)
Re: percentages (Larry Rosler)
Re: percentages <merlyn@stonehenge.com>
Re: percentages <bill@fccj.org>
preventing core dumps from open3 invocation of executab <hamilton@deltanet.com>
Re: Regular expression questions <freter@freter.com>
Re: Regular expression questions <Allan@due.net>
Re: Regular expression questions (Matt Knecht)
Re: Regular expression questions <ckuskie@cadence.com>
Re: Regular expression questions <due@murray.fordham.edu>
Re: Sending a file to a printer (Odin J. Anderson)
Re: String Split Help <merlyn@stonehenge.com>
Re: value not entered (brian d foy)
Re: Value of <HANDLE> construct can be "0"... <ludlow@us.ibm.com>
Re: Value of <HANDLE> construct can be "0"... <ljz@asfast.com>
Re: XQL <sgordon@kenan.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Nov 1998 21:42:48 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: 64-bit Perl?
Message-Id: <72d0co$85v$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Zenin
<zenin@bawdycaste.org>],
who wrote in article <910776466.364784@thrush.omix.com>:
> If you need really big ints, Math::BigInt may be for you.
More probably Math::Pari from CPAN. Math::BigInt is almost completely
broken (in design and in implementation, if not in behaviour).
The only reason I wrote Math::BigInt was to test overloading :-(.
Well, it improved a tiny bit since then, but only a really *tiny* bit.
Ilya
------------------------------
Date: Wed, 11 Nov 1998 14:16:07 -0800
From: "J|rgen Exner" <nospam@see.signature>
Subject: Re: <<My Sort Problem>>
Message-Id: <72d28s$bi8@news.dns.microsoft.com>
Tom Christiansen wrote in message <72cnbi$jgk$1@csnews.cs.colorado.edu>...
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, dccobb@yahoo.com writes:
>:I appreciate you telling me that Perl does have a command for sorting.
>
>Well, *actually*.... Perl doesn't have `commands' any more than C++
>does -- shells do.
Well, to be nitpicking:
Perl is a procedural programming language (i.e. it does have variables and
states). Therefore Perl must have commands, otherwise you won't be able to
change the state or the content of a variable.
However "sort" is indeed a function, not a command.
jue
--
J|rgen Exner; microsoft.com, UID: jurgenex
Sorry for this anti-spam inconvenience
------------------------------
Date: Wed, 11 Nov 1998 22:29:20 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: attaching a jpeg
Message-Id: <4do22.52$MO.113308@nsw.nnrp.telstra.net>
In article <3649521C.41C6@strath.ac.uk>,
Gareth Ennis <gary.ennis@strath.ac.uk> writes:
>> NEVER pass email addresses to a shell.
>
> Surely if i validate $recip_email so that it cannot contain a " " or a
> "/" then nobody can cause any damage...???
Both " " and "/" are valid in an email address. And they are not even
the worst characters that you may pass to your shell. It's mainly
characters that separate commands that you should be worried about.
Things like '||', '&&', ';' and the like. And most of those are valid
in email addresses as well, so you can't simply toss them out.
Please, take the advise given, which comes from many years of
experience in this field, and which is well known to many programmers:
- Never pass email addresses to a shell.
- Never pass strings to a shell unless you know absolutely certain
that there's no problematic character in them.
In the case of sendmail, you just call it with the -t flag. In the
case of system and exec: try to avoid invoking a shell, it will only
call a shell if there is only one argument, and if that argument
contains shell metacharacters. So, use a list as argument to an exec
or system. Don't use shell metacharacters, unless you know what you
are doing. When you absolutely need shell parsing, make really really
sure that what you pass out doesn't do nasty things.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: Wed, 11 Nov 1998 16:00:17 -0500
From: xcom2@popserver.panix.com (Oliver Moffat)
Subject: Can't use "chomp"
Message-Id: <xcom2-1111981600170001@xcom2.dialup.access.net>
I've checked the FAQ's, carefully re-read Larry, Tom and Randal's Perl
books and I think I'm losing my mind.
When I try to use chomp any way:
chomp (@new);
...
chomp(@new);
...
chomp @new;
...
foreach $i (@new){ chomp($i);}
...
chomp $i;
I get this error message:
"chomp" may clash with future reserved word at ./chomper.pl line 17.
syntax error in file ./chomper.pl at line 17, next 2 tokens "chomp("
Execution of ./chomper.pl aborted due to compilation errors.
What am I doing wrong?
------------------------------
Date: Wed, 11 Nov 1998 21:34:00 GMT
From: Free-4-All@Cryogen.com (Serial # 0)
Subject: Re: Can't use "chomp"
Message-Id: <364b01fb.16743254@news.iaehv.nl>
On Wed, 11 Nov 1998 16:00:17 -0500, xcom2@popserver.panix.com (Oliver
Moffat) wrote:
>"chomp" may clash with future reserved word at ./chomper.pl line 17.
>syntax error in file ./chomper.pl at line 17, next 2 tokens "chomp("
>Execution of ./chomper.pl aborted due to compilation errors.
Yep, I get the same error message. A few weeks ago I was using the
same script without problems, but now I'm getting the same error
message.
Best Regards,
Rafely
------------------------------
Date: Wed, 11 Nov 1998 21:37:37 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Can't use "chomp"
Message-Id: <Bsn22.32475$%X2.2844310@news3.voicenet.com>
Serial # 0 <Free-4-All@Cryogen.com> wrote:
>On Wed, 11 Nov 1998 16:00:17 -0500, xcom2@popserver.panix.com (Oliver
>Moffat) wrote:
>
>>"chomp" may clash with future reserved word at ./chomper.pl line 17.
>>syntax error in file ./chomper.pl at line 17, next 2 tokens "chomp("
>>Execution of ./chomper.pl aborted due to compilation errors.
>
>Yep, I get the same error message. A few weeks ago I was using the
>same script without problems, but now I'm getting the same error
>message.
Check the version of Perl you're running. I'm unsure of the exact
history, but I believe chomp was added in Perl 5.
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Wed, 11 Nov 1998 15:22:40 -0600
From: Zhengdong Zhang <zzhang@Bayou.UH.EDU>
Subject: Exit UNIX from within a perl program
Message-Id: <Pine.OSF.3.95q.981111145124.5494A-100000@Bayou.UH.EDU>
Suppose I want to exit the Unix system after executing my perl program.
Can I include this step in my program? (system "exit" doesn't work.)
------------------------------
Date: Wed, 11 Nov 1998 16:00:22 -0500
From: Bill Jones <bill@fccj.org>
Subject: Re: Fun NYC job consulting/FT Perl/Tk/DBI/C++ jeans + Tshift
Message-Id: <3649FAE6.9994F1F6@fccj.org>
Brian Saltzman wrote:
>
> ... there seems to be few people
> who have unix experience and want to work with PC software.
Hmmm...
I have Unix experience and still work with PC software...
It's just that my 'PC software' is called RedHat Linux :]
(PS - What's a 'tshift' ? Is that like triple overtime ? :)
Cheers!
-Sneex- :]
________________________________________________________________________
Bill Jones | FCCJ Webmaster | x3089 | http://webmaster.fccj.org:81
__ _ RedHat 5.1 Manhatten
/ /(_)_ __ _ ___ __ http://www.apache.org
/ / | | '_ \| | | \ \/ / http://www.redhat.com
/ /__| | | | | |_| |> < http://www.perl.com
\____/_|_| |_|\__,_/_/\_\ http://www.gimp.org
------------------------------
Date: Wed, 11 Nov 1998 16:19:22 -0500
From: "Matt Heusser" <matt@pcr7.pcr.com>
Subject: Help! Authenticate password via Perl
Message-Id: <Ugn22.75$Xe1.1267@news14.ispnews.com>
Hello!
This is a question about validating passwords over
the web via CGI, but I think any FreeBSD systems
expert would be the most helpful. Here goes ...
Right now, I have a HTML page running on a FreeBSD
server. The HTML page accepts a username and password,
and then calls a perl (CGI) process. The perl process finds
the /etc/passwd file and parses it, searching for the username.
When it finds the username, it grabs the encrypted password.
It then takes the 'guess' password, and crypts it as follows -
$stringCipher = crypt($stringGuess, $stringTemp)
(Where $temp is the first two characters of the encrypted password)(*)
Then the following is executed: (psuedo code)
If stringCipher equals stringCryptedPassword
do_stuff
else
error_message
The code works fine under AIX, but bombs under FreeBSD.
(*) - The crypt-style is MD5, so I'm not sure If I should grab the first
two characters of the encrypted password, as they all start "$1$"
-- I got the idea from "Programming Perl" under "Crypt", pas 153. I've
searched through "Perl CGI Programming", "Learning Perl", "An intro
to Berkley Unix", "Unix Admin. Guide for System V", as well as
CGI FAQ, CGI-Security FAQ, and FreeBSD on-line docs. My conclusion
is that the problem is OS or crypt-library specific (since if works on AIX)
any ideas? if you could respond by e-mail (matt@pcr7.pcr.com) that
would be greatly appreciated.
thanks,
/*---------------------------------------------------------------------*/
Matthew R. Heusser, PCR Inc.
E-mail: <Matt@pcr7.pcr.com>
Phone: (616)-554-1036
/*---------------------------------------------------------------------*/
------------------------------
Date: Wed, 11 Nov 1998 16:57:59 -0500
From: Bill Jones <bill@fccj.org>
Subject: Re: Help! Authenticate password via Perl
Message-Id: <364A0867.53AAAF67@fccj.org>
Matt Heusser wrote:
>
> The code works fine under AIX, but bombs under FreeBSD.
> (*) - The crypt-style is MD5, so I'm not sure If I should grab the first
> two characters of the encrypted password, as they all start "$1$"
>
I believe the first two characters for the 'salt' are not
stored in the passwd/shadow file in FreeBSD. Otherwise
it would be easy for someone to crack those passwords as
you have done on AIX :]
Sorry,
-Sneex-
________________________________________________________________________
Bill Jones | FCCJ Webmaster | x3089 | http://webmaster.fccj.org:81
------------------------------------------------------------------------
__ _ RedHat 5.1 Manhatten
/ /(_)_ __ _ ___ __ http://www.apache.org
/ / | | '_ \| | | \ \/ / http://www.redhat.com
/ /__| | | | | |_| |> < http://www.perl.com
\____/_|_| |_|\__,_/_/\_\ http://www.gimp.org
------------------------------
Date: Wed, 11 Nov 1998 20:45:51 GMT
From: apeng123@my-dejanews.com
Subject: Horizontal Bar???
Message-Id: <72ct20$a37$1@nnrp1.dejanews.com>
I use GIFgraph module to create a copule of bar charts.
Right now, the data sets are getting bigger.
So, I would like to have horizontal bar chart instead vertical bar.
Can I do that with GIFGraph?
Or anyway I create rotate vertical bar to horizontal bar?
Thanks,
Alex
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 11 Nov 1998 21:10:39 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: How do I sort this list by "port" number?
Message-Id: <8c67cmx7ei.fsf@gadget.cscaper.com>
>>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
Larry> I think it works very poorly, because it is not '-w' clean, and all
Larry> programs should run with '-w' enabled at all times!
No. I disagree. -w is to keep beginners from making beginner
mistakes. It's not enabled by default so that experts can make only
expert mistakes. :)
There are many of my one-off programs that are not -w clean. Some are
not even "use strict" clean. Perl is a tool to get the job done. Some
parts of Perl prevent some kinds of debugging, and are therefore
redundant with some parts of my 29+ years of programming experience.
I don't need to put training wheels on my motorcycle, thank you.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 11 Nov 1998 16:32:22 -0500
From: Bill Jones <bill@fccj.org>
Subject: Re: hypermail files into text
Message-Id: <364A0266.D3915C56@fccj.org>
Warren Dodge wrote:
>
> Is there a package available that can take a hypermail'ed mail message
> and extract the text from all the HTML information.
>
> I assume any HTML to TEXT package would work for this.
No, there isn't just any HTML to Text package.
You may want to look up 'ParseHTML', I think,
written by 'Gisle Aas <aas@sn.no>'
See ftp://ftp.flirble.org/pub/languages/perl/CPAN/authors/id/GAAS/
>
> EMAIL replys would be best. Remove #_junk when replying.
EMAIL? What's that?
-Sneex- :]
________________________________________________________________________
Bill Jones | FCCJ Webmaster | x3089 | http://webmaster.fccj.org:81
------------------------------------------------------------------------
__ _ RedHat 5.1 Manhatten
/ /(_)_ __ _ ___ __ http://www.apache.org
/ / | | '_ \| | | \ \/ / http://www.redhat.com
/ /__| | | | | |_| |> < http://www.perl.com
\____/_|_| |_|\__,_/_/\_\ http://www.gimp.org
------------------------------
Date: Wed, 11 Nov 1998 16:34:55 -0500
From: Stan Towianski <stowians@ford.com>
Subject: Re: If -e different then If -d on a Directory, why?
Message-Id: <364A02FE.6A99@ford.com>
Well, it might be my mistake. I should have looked at
it more closely possibly but I was in a hurry.
Looking now, I don't know if I am looking at the exact
same directory, but I might be. It looks like the whole
path existed except for the last piece. And right now
anyway all the other entries in the directory are
directories, but the one I might have thought was wrong
is a file. Therefore the -d would say NO and the -e
would say YES correctly.
But then why I said: "...for a non-existent directory"
I don't know. Maybe it was just me, unless unix NON-rights
to a directory would make a difference?
Oh well I will probably not be able to figure it out now.
------------------------------
Date: 11 Nov 1998 20:43:39 GMT
From: pburch@bcm.tmc.edu (Paula Burch)
Subject: looking for training in Houston, Texas
Message-Id: <72cstr$1t5@ns2.bcm.tmc.edu>
Can anyone tell me of any perl training classes to be held in
Houston, Texas? I'm having trouble with carving out enough time
at work to learn on my own.
(Please do not send me information about training classes to be held in
other locations. Distribution of this post has been limited to Houston,
Texas; most newsreaders will not display it elsewhere.)
Thanks for any leads. Commercial contacts welcome - for classes to be
held in Houston.
--
Paula Burch
pburch@bcm.tmc.edu
http://mbcr.bcm.tmc.edu/pburch.html or http://www.flash.net/~pburch/
------------------------------
Date: Wed, 11 Nov 1998 16:41:29 -0500
From: "Eric Williams" <ericw@recom.com>
Subject: newbie to perl - need simple search perl script
Message-Id: <wMn22.8$eO3.347@newsfeed.slurp.net>
I am trying to create a simple perl script to search a comma delimited text
file and out put the line of info. that a particular field matches in html.
Any help or sample scripts w/ html input file would be greatly appreciated!!
eric.
ericw@recom.com
------------------------------
Date: Wed, 11 Nov 1998 21:18:46 GMT
From: zarmzarmNO@SPAMhotmail.com (Paul Winkler)
Subject: Re: OOP or not? (for a Perl module)
Message-Id: <3649e5a0.16241262@news.erols.com>
On Wed, 11 Nov 1998 10:14:55 -0600, "Keith G. Murphy"
<keithmur@mindspring.com> wrote:
>I'd use OOP, but also consider modifying the data structure to make it
>easier to do things without writing complex procedures or methods. I'm
>not sure at all that I understand how all your data structures fit
>together, but supposing (for the sake of argument) your composition is
>made up different verses, verses of beats, pfields are just named
>collections of beats:
Close, but pfields are not made up of notes; it's the other way
around. Beats (or more generally, "events") are made up of pfields.
A csound score is really just a text database: each line is an event,
each event is made up of whitespace-separated "pfields", which are
simply values to feed to the appropriate thingie.
So in this line:
i3 2 3.4 10 6200 3.14
p1(yes, counted from 1, not zero) is "i3", which means "the following
values are fed to instrument 3 as defined in the orchestra file."
p2 is "2", which means "this event occurs 2 beats into the output
soundfile."
p3 is "3.4", which means "this event is 3.4 beats long."
The meaning of all the remaining pfields is determined by the
definition of instrument 3. For example, p4 has the value 10, which
might refer to volume, or pitch, or stereo location, or a parameter
for some signal-processing algorithm, or anything else the instrument
designer can think of. In the orchestra file, this would simply be
given as p4, meaning "read this value from the fourth field of the
event that called this instrument."
I don't remember if there is a limit to the number of pfields an
instrument event can have... if there is, it is quite large.
There are other classes of events than "i" (instrument) events; "f1"
would define a function table which could be accessed by many
different instruments; "s" marks the end of a section and resets the
current relative time to 0; "r int" means the following section is
repeated "int" times; "t n" sets the tempo to "n" beats per minute;
and there's a few more. But "i" and "f" are the main ones. The problem
is that the s, r, and t sections are not very flexible: to name two
problems I've encountered, you can not have parallel streams of events
with different "t" tempos, and you can not have "s" sections that
overlap in time.
>Let's introduce the concept of a "Composition", so we'll have an object
>that refers to the whole, and a "Voice", made up of verses. These>concepts perhaps simplify by getting rid of stuff like "rewind".
Yes, "rewind" is probably a bad idea which could be avoided in various
ways ... but it IS necessary to be able to arbitrarily set the current
time whenever you feel like it. And I've considered the idea of
"voices" or "tracks", which might be useful in some ways...
>Doesn't it make more sense to play a composition, not a verse?
Yes and no. The script as a whole *is* the composition. That's sort of
like saying "Doesn't it make sense to print a document, rather than a
line?" It depends what you're doing. Anyway, this doesn't necessitate
an OOP approach: I could easily make my "play()" and related functions
write to a data structure which eventually gets output, rather than
directly to an output file.
But I suspect you're right: my plans for tempo control and variable
interpolation may mean that the whole output file needs some sorting
before it's ready to be written out. But then, this might be something
that gets done implicitly in the END code in the module. Or not.
>-------
>$comp = new Composition;
>$verse1 = new Verse("some-score-file.sco", [ 4 .. 10 ]);
>$verse2 = new Verse("other-file.sco", [ x .. y ]);
>push @{@{$comp->{'Voices'}}[0]->{'Verses'}} , $verse1;
>push @{@{$comp->{'Voices'}}[0]->{'Verses'}} , $verse1;
>push @{@{$comp->{'Voices'}}[1]->{'Verses'}} , $verse2;
>$comp->Play;
I have to say, this is a lot harder to write than the syntax I've been
working on, and I consider that a severe drawback to your approach. Is
there a way to clean that up some? Way, way too much punctuation
required.
Here's a slightly modified version of my original suggestion, with
comments removed:
pattern_from_file($Verse1, "some-score-file.sco", [ 4 .. 10 ]);
pattern_from_file($Verse2, "some-other-file.sco", [ 1 .. 4 ]);
track(1);
play($Verse1, 2);
track(2);
select_pat(Verse2);
play();
shuffle_pfield (pfield(5, beats(4 to 9), *= 2));
do_more_things();
do_even_more_things();
play();
All the OOP code I've seen suggested has a big disadvantage in
requiring you to constantly re-specify exactly which little bit of
data you're working on. In practice, one will frequently be working on
the same things repeatedly. For example, in my code above, note that
you can put an unlimited number of processing functions where it says
"do_more_things", and they'd all be working on the current copy of
Verse2, and you would NOT have to keep typing $Verse2 over and over.
Is there a way to do that in OOP? That would go a long way towards
resolving my concerns about an OOP approach.
A couple of asides about the code above: "track()" would work a little
like "select()" in that it would change the currently selected output
track. This would eliminate "rewind" at least in this example. (But I
still want a way to override my default output time... that's another
issue...)
I didn't explain that beats(4 to 9 ) doesn't do what you think. If I
wanted to use the list "4 5 6 7 8 9", I would just say "beats( 4 ..
9)" or even "[ 4 .. 9]" Instead, beats(4 to 9) returns a list of
lines for which p2 falls between 4 and 9. Remember that musicians
play between the beats!
(Actually, I'm not sure if this is really a good way to say it... I
need to check if "to" means something specific in the "english" module
already...)
>-------
>Now what about that pfield manipulation?
>-------
>pfield = new Pfield( @{$verse2->{'Beats'}}[4..9] );
>foreach (@{pfield->{'Beats'}}) {$_ *= 2};
> #I'll bet your shuffle_pfield was complicated...
Well, I haven't even written it yet, but probably, yes.
Sorry, I don't quite understand what you're suggesting. What's wrong
with having a complicated function in the module when it does
something a composer (me) will be doing over and over again? Your
version puts the complexity of a conceptually simple action --
shuffling a column of values for some list of lines --
right back into the composition, where it doesn't belong. Or were you
thinking this code would go in the module, and be accessed via a
simple method?
It bears repeating that my entire motivation for writing this module
is to make writing Csound scores faster and simpler for me.
>Hashes let you name the different parts of your structure to make the
>code clearer and the structure more extensible.
A good thing, but maybe beyond the scope of what I need right now. I
think my project is getting a bit out of hand: I want something useful
really soon!
> (A lot of folks would
>write some class methods instead of directly manipulating the structure
>contents, like I'm doing here, but the idea stays the same).
>If you're really careful with the data structure, you can get away from
>complicated methods or functions. (Does the term "data-driven" mean
>anything?)
The thing is, I don't want the data structure to be too inflexible,
and I'm worried that if I build the methods into the structure, I
would be forcing composers (i.e. me) to work only in the ways I've
provided for. I'm looking to hack compositions quickly in interesting
ways with clear, concise syntax. Elegance, consistency, and
re-usability are secondary concerns, and for those purposes, I will
turn traitor and suggest that Common Music (which is Lisp) already
does all that.
Still mulling it all over,
PW
==============================================================
Paul Winkler --- music & sound --- zarmzarm@hotmail.com
http://members.tripod.com/~slinkP/index.html
a member of
ARMS --- an ongoing pop music experiment
http://members.tripod.com/~slinkP/mini-arms.html
==============================================================
------------------------------
Date: Wed, 11 Nov 1998 13:02:04 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: percentages
Message-Id: <MPG.10b39b2886519b5a98986b@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <fYk22.91$5v3.805616@news.optonline.net> on Wed, 11 Nov 1998
18:46:35 GMT, News <dixonmat@pouch.com> says...
> I am not familiar with this -w tag you are reffering to
The '-w' flag turns warnings on, and should *always* be used on the
first line of a Perl program:
#!/usr/local/bin/perl -w
In this case, it would have pointed out five erroneous uses of array
slices (@in[0]) instead of scalar members ($in[0]).
> , but here is the monify section
>
<SNIP> about 25 lines of function.
>
> basically the monify routine sets the monitary value
So does this:
sub Monify { sprintf '%.2f', $_[0] }
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 11 Nov 1998 21:11:48 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: percentages
Message-Id: <8c1znax7cl.fsf@gadget.cscaper.com>
>>>>> "News" == News <dixonmat@pouch.com> writes:
News> $dollars = @in[0];
Ouch. This hurts my eyes. Ouch. Don't do this. Get the llama or
any other introductory text, and *learn* the difference between an
array slice and an array element.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 11 Nov 1998 16:19:43 -0500
From: Bill Jones <bill@fccj.org>
Subject: Re: percentages
Message-Id: <3649FF6F.A4538200@fccj.org>
Larry Rosler wrote:
>
> sub Monify { sprintf '%.2f', $_[0] }
>
Ouch!
Been there,
-Sneex- :]
________________________________________________________________________
Bill Jones | FCCJ Webmaster | x3089 | http://webmaster.fccj.org:81
------------------------------
Date: 11 Nov 1998 13:45:38 PST
From: Jerry Hamilton <hamilton@deltanet.com>
Subject: preventing core dumps from open3 invocation of executable
Message-Id: <Pine.SCO.3.96.981111133638.29352A-100000@delta1.deltanet.com>
I am working with a perl script that invokes an executable using
the open3 command. Under some circumstances, the executable cannot run
and currently generates a core dump. I would like to prevent the
creation of the core dump. Is there any way to do this within the
context of the open3 command? If not, what would be the suggested
replacement of the open3 with something functionally equivalent but
allowing the prevention of the dump?
Jerry Hamilton
The Boeing Company
Orange County CA
jerryh@ACM.ORG
------------------------------
Date: Wed, 11 Nov 1998 21:04:24 GMT
From: Craig Freter <freter@freter.com>
Subject: Re: Regular expression questions
Message-Id: <3649FAF8.22917B07@freter.com>
Dave,
Try this.
my $str = "abcdef";
# extract first 3 chars
$str =~ /(.{3})/;
my $extract = $1;
print "Substring = $extract\n";
> I have a string of characters from which I need to extract the first
> 23 characters. Everything form the 24 character to the end of
> the line must go.
>
> Could someone tell me what the regular expression for such an
> operation would be?
--
Craig Freter <freter@freter.com> <http://www.freter.com>
PGP fingerprint 61 A5 E2 51 F5 AC 9D 79 DD 15 56 90 F2 0A 97 25
Axis Data Management <http://www.admc.com>
------------------------------
Date: Wed, 11 Nov 1998 16:15:04 -0500
From: "AmD" <Allan@due.net>
Subject: Re: Regular expression questions
Message-Id: <72cup3$ftv$1@camel18.mindspring.com>
Dave Rathnow wrote in message <3649f426.94909612@news.cadvision.com>...
>
>I have a string of characters from which I need to extract the first
>23 characters. Everything form the 24 character to the end of
>the line must go.
>
>Could someone tell me what the regular expression for such an
>operation would be?
>
Depends on what you mean by character but one way might be:
$in = 'abcdefghijklmnopqrstufwxyz';
($keep) = $in =~ /(\w{23})/;
print $keep;
naw, too simple. How about:
$in = ' abcd efghij klmno pqrs tufwxyz';
$in =~ s/\W//g;
$keep = substr($in,0,23);
print $keep;
AmD
------------------------------
Date: Wed, 11 Nov 1998 21:33:57 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Regular expression questions
Message-Id: <9pn22.32474$%X2.2839432@news3.voicenet.com>
AmD <Allan@due.net> wrote:
>
>Dave Rathnow wrote in message <3649f426.94909612@news.cadvision.com>...
>>
>>I have a string of characters from which I need to extract the first
>>23 characters. Everything form the 24 character to the end of
>>the line must go.
>
>$in = 'abcdefghijklmnopqrstufwxyz';
>($keep) = $in =~ /(\w{23})/;
>print $keep;
That fails on strings less than 23 characters, and non-word characters.
This wont:
($keep) = $in =~ /(.{0,23})/;
If you don't use {0,23}, at least check and see if $keep is defined
before using it.
> naw, too simple. How about:
>
>$keep = substr($in,0,23);
This is more simple to me. YMMV.
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Wed, 11 Nov 1998 13:41:44 -0800
From: Colin Kuskie <ckuskie@cadence.com>
Subject: Re: Regular expression questions
Message-Id: <Pine.GSO.3.96.981111132824.5294L-100000@pdxue150.cadence.com>
On Wed, 11 Nov 1998, Dave Rathnow wrote:
> I have a string of characters from which I need to extract the first
> 23 characters. Everything form the 24 character to the end of
> the line must go.
>
> Could someone tell me what the regular expression for such an
> operation would be?
The obvious solution to this is to read the perl FAQ at
http://www.perl.com. The FAQ is also distributed with
every installation of perl and can usually be accessed
by typing:
perldoc perlfaq
on your command line.
Here's the scoop:
How can I access/change the first N letters of a string?
There are many ways. If you just want to grab a copy, use
substr:
$first_byte = substr($a, 0, 1);
If you want to modify part of a string, the simplest way is
often to use substr() as an lvalue:
substr($a, 0, 3) = "Tom";
Although those with a regexp kind of thought process will
likely prefer
$a =~ s/^.../Tom/;
HTH,
Colin
------------------------------
Date: 11 Nov 1998 22:54:39 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Regular expression questions
Message-Id: <72d4jf$osj$0@206.165.167.201>
Matt Knecht wrote in message <9pn22.32474$%
>>$in = 'abcdefghijklmnopqrstufwxyz';
>>($keep) = $in =~ /(\w{23})/;
>>print $keep;
>
>That fails on strings less than 23 characters, and non-word characters.
As intended, perhaps I was being a tad too literal. The post specifed "the
first 23 characters" nothing about some smaller number of chars. And I did
point out it that it depended on what he defined as a character. I suspect
he did not view a space as a character as you do, but that is speculation on
my part.
>($keep) = $in =~ /(.{0,23})/;
>
>If you don't use {0,23}, at least check and see if $keep is defined
>before using it.
Good advice, using {0,23} or no.
AmD
------------------------------
Date: Wed, 11 Nov 1998 22:03:42 GMT
From: Odin.Anderson@TDSTelecom.Com (Odin J. Anderson)
Subject: Re: Sending a file to a printer
Message-Id: <364c099c.2415232@news>
What about printing to network printers?
On Fri, 06 Nov 1998 11:17:55 GMT, collin@rogowski.de (Collin Rogowski)
wrote:
>you can use the command copy.
>e.g copy printer1.pl lpt1
>
>Collin Rogowski
>On 4 Nov 1998 22:10:57 GMT, m.adam@libr.canterbury.ac.nz wrote:
>
>>I feel that this is an embarassingly obvious question but I've searched all my
>>documentation and read all the FAQs I can find without getting an answer.
>>
>>I am writing perl scripts on Windows NT. I need to send a file to a printer:
>>\\NTServer\printer1. How do I do this?
>>
>>Margaret
------------------------------
Date: Wed, 11 Nov 1998 21:16:27 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: String Split Help
Message-Id: <8cvhkmvske.fsf@gadget.cscaper.com>
>>>>> "bigcheese" == bigcheese <bigcheese@my-dejanews.com> writes:
bigcheese> I have this split command...
bigcheese> @kana = split(/([aeiou ])/,"$ENV{'QUERY_STRING'}'}");
bigcheese> and it splits the a,e,i,o,u's and spaces on both sides
bigcheese> (ie: cow (w/space) splits to "c" "o" "w" and " ")
bigcheese> Is it possible to make it split "cow "(w/ space) to "co" and "w "?
By the time you're not throwing things away anymore, I find it much
better to use a list //g instead of a split.
@result = $ENV{WHAT} =~ /(.*?[aeiuo ])/g
I think you'll be much happier tweaking this to get it to work than to
keep fighting with split's even-odd result.
Remember... split has only two modes:
1) throw away things matching a regex
2) return a list with every other element matching a regex
where list //g has the third (often useful) mode:
3) return a list matching a regex (possibly skipping over other stuff)
They're very nice to use in a complementary fashion. Get good at both.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 11 Nov 1998 17:44:04 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: value not entered
Message-Id: <comdog-ya02408000R1111981744040001@news.panix.com>
In article <72csvt$ohq$1@sun4000.casema.net>, "Casema" <ours@casema.net> posted:
> print "<TEXTAREA NAME=\"text\" ROWS=\"12\" COLS=\"48\"
> VALUE=$dat[13]\n></TEXTAREA>\n";
>
> (neither if I put $dat[13] in between \" \"
>
> does not????
read the docs on TEXTAREA.
you might also like to use generalized quoting to save yourself
some back slashes:
print qq|<TEXTAREA NAME="text" ROWS=12 COLS=40>$dat[13]</TEXTAREA>|;
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 11 Nov 1998 15:06:49 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Value of <HANDLE> construct can be "0"...
Message-Id: <3649FC69.92933542@us.ibm.com>
Joakim Hove wrote:
> if (open(FILE , "filename) {
^^^
Quote?
> while ($line = <FILE>) {
> do-something
> }
> close(FILE);
> }
It's good that you're using -w. Don't stop just because of this
warning. You should probably stick to the standard method of checking
whether a file opened or not.
open FILE, "filename" or die "Error: $!";
while (defined ($line = <FILE>)) {
...
}
close FILE;
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: 11 Nov 1998 17:32:23 -500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Value of <HANDLE> construct can be "0"...
Message-Id: <ltpvatdfns.fsf@asfast.com>
James Ludlow <ludlow@us.ibm.com> writes:
> Joakim Hove wrote:
>
> > if (open(FILE , "filename) {
> ^^^
> Quote?
>
> > while ($line = <FILE>) {
> > do-something
> > }
> > close(FILE);
> > }
>
> It's good that you're using -w. Don't stop just because of this
> warning. You should probably stick to the standard method of checking
> whether a file opened or not.
>
> open FILE, "filename" or die "Error: $!";
> while (defined ($line = <FILE>)) {
> ...
> }
> close FILE;
... and here is the reason why:
Depending on the contents of your file and on other Perl configuration
variables, it's entirely possible for `<FILE>' to return a "0" if
that's the contents of one of the lines of your file. Since "0" gets
interpreted as `false' by Perl, this would cause your loop to
terminate as soon as this line is encountered in your file, instead of
the loop running until end-of-file.
What `<FILE>' would return at end-of-file is `undef', and so by using
`defined', you can explicitly test for this case.
--
Lloyd Zusman ljz@asfast.com
perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'
------------------------------
Date: Wed, 11 Nov 1998 16:36:08 -0500
From: Seth Gordon <sgordon@kenan.com>
Subject: Re: XQL
Message-Id: <364A0348.D083A878@kenan.com>
I looked at the page you cited, and I don't see what there is to worry
about.
The perl man page says: "Perl is a language optimized for scanning
arbitrary text files, extracting information from those text files, and
printing reports based on that information." XQL is a code for making
queries about the contents of an XML file, and nothing else. So one could
write a Perl module that processes XQL queries (not that I'm volunteering
to write one :-), but Perl can do many other things that XQL is not made
to handle.
Furthermore, X[MSQ]L are all being developed as open standards, not
proprietary Microsoft formats.
Gustaf Liljegren wrote:
> In the authors list it looks like XQL is a Micro$oft idea developed
> for W3C. Obviously M$ can't accept Perl to remain as The Programming
> Language of the web in the near future. The specification (see URL
> above) does not mention Perl. This means that it's too close to Perl
> or far away from it. I belive the former.
>
> Am I right that XQL is an alternative for Perl?
--
perl -le'$m="r 0rJaa.u0cksthe";$c=967150;s/$/substr$m,($i\
+=$c%2?4:1)%=16,1or$i-2?"no":"Perl h"/e while$c>>=1;print'
== seth gordon == sgordon@kenan.com == standard disclaimer ==
== documentation group, kenan systems corp., cambridge, ma ==
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 V8 Issue 4200
**************************************