[9996] in Perl-Users-Digest
Perl-Users Digest, Issue: 3589 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 30 12:03:58 1998
Date: Sun, 30 Aug 98 09:00:26 -0700
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, 30 Aug 1998 Volume: 8 Number: 3589
Today's topics:
Re: \\ ...what's the point? (Tye McQueen)
Accessing remote computers throught RSH <jumpy@enter-net.com>
Re: Change NT IP Address Using Perl (Bill)
Re: COBOL and Perl <charles@hankel.mersinet.co.uk>
FREE PORN email@address.com
Re: How to extract first letter in string? <daniel@NOSPAMstridhammar.pp.se>
Re: How to extract first letter in string? <r28629@email.sps.mot.com>
Re: How to extract first letter in string? (Larry Rosler)
Re: Imagine... a non-greedy world! <mee@mine.com>
Re: Imagine... a non-greedy world! <tchrist@mox.perl.com>
Re: Imagine... a non-greedy world! (Michael Rubenstein)
Re: Imagine... a non-greedy world! <minich@globalnet.co.uk>
Re: Imagine... a non-greedy world! (Ronald J Kimball)
Re: Installed modules info? (Randy Kobes)
Re: parsing "mulitpart form-data" with cgi-lib.pl on JW <rootbeer@teleport.com>
PASSME (Michael Allen Gelman)
Re: PASSME (Jonathan Stowe)
Re: perl regex bug? (or feature?) <uri@sysarch.com>
Re: Posting images from a mSQL database (Larry Rosler)
Re: Problem with a package (Tye McQueen)
Re: Public Domain Module wanted (Jonathan Stowe)
Re: Random Numbers in Range? (M.J.T. Guy)
sorting <arm@home.net>
Re: SWF (Shockwave Flash) file format <uri@sysarch.com>
Re: SWF (Shockwave Flash) file format (Larry Rosler)
Re: tripped on chomp <uri@sysarch.com>
trouble writing 2 files in subroutines (Peter Bismuti)
Re: trouble writing 2 files in subroutines <uri@sysarch.com>
WANTED: 3rd level domain script (Michael Allen Gelman)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Aug 1998 02:08:32 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: \\ ...what's the point?
Message-Id: <6satpg$cel@fumnix.metronet.com>
Palisade Europe <admin@palisade-euorpe.com> writes:
) in single-quoted strings...
)
) print 'I am somewhat \obtuse';
)
) does the same as
)
) print 'I am somewhat \\obtuse';
)
) The only reason I could think of (cf. first print statement)
) \\ and \ being the same is that because defining that a single
) quote inside a single-quoted string is achieved by \' would
) require \\' if one wanted to end a single-quoted string in \
Yes, exactly.
) If that is true... why not not just a single exception to
) characters within a single-quoted string: '' (insert a
) single quote) instead of two exceptions: \' and \\
) (insert a single quote and insert a backslash)?
A much better solution. Unfortunately, it comes much too
late for it to be used in Perl. Perhaps it could be snuck
in as an option that is controlled by C<use>ing some module.
Or we could add something like C<qu{}> for unescaped quoting.
Or both; C<use> would decide whether ' acted like qu or q
until the end of the scope containing the C<use>.
At least "unrecognized escapes" inside q() leave the \ in
place while inside qq() the \ is dropped. That was a good
idea, IMHO.
To anticipate one argument, I do agree that using a doubled
delimiter to escape one is, in general, a worse idea than
using a separate escaping character (such as \). I saw that
after writing a few VMS *.COM scripts that had to resort to
C<OPTS="CC_FLAGS=""-Dname=""""fred"""""""> or using rcmd under
WinNT:
rcmd \\x "desktop ""cmd /k """"""""""""C:/Program files...
And this is particularly true when you only have one delimiter
to choose from.
The problem with Perl is that you only have one escaping character
to choose from so getting a \ into a string is never pretty in
Perl. You either have to double it or resort to "<<" (or rely on
there being a character after it that doesn't require escaping).
But there is no other character that requires such work. It isn't
a tragedy, but if you need a lot of \s, then it gets old fast.
Like most enhancement ideas, it is much easier to get it into Perl
if you provide a patch. Otherwise you have to get someone else
so excited about your idea that they'll write the patch.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Sun, 30 Aug 1998 10:21:57 -0400
From: Patrick Boucher <jumpy@enter-net.com>
Subject: Accessing remote computers throught RSH
Message-Id: <35E96005.F10E8036@enter-net.com>
I have to garner results of the 'ps -eaf' and 'who' commands on a remote
computer. I thought of using this with the usr/bin/rsh command. Is there a
way to use rsh to get this information, capture the result code of the rsh
execution AND the return of the executed command?
It would be like combining the system() function and the bacticks in some
weird way. Cuz if I do $rc = system('usr/bin/rsh', $computer, 'who') I'm
only going to get the result code and not the output of the who command...
But if I do $data = '/usr/bin/rsh $computer who' I'm not going to get the
result code from the rsh command...
Any ideas on how to do this or any help would be greatly appreciated!
--
__o Jumpy
_(\<._ Patrick Boucher
(_)/ (_) http://www.enter-net.com/~pboucher/
------------------------------
Date: Sun, 30 Aug 1998 08:42:22 GMT
From: wmcclatc@primenet.com (Bill)
Subject: Re: Change NT IP Address Using Perl
Message-Id: <363a0f5c.1167585439@nntpd.databasix.com>
For some reason on 19 Aug 1998 21:10:08 +0100,
chrisb@jesmond.demon.co.uk (Chris Benson) babbled:
>In article <01bdcac7$f31b57c0$636c8bd0@wkchiu>,
>wkchiu <wkchiu@yahoo.com> wrote:
>>Reboot is required in NT4.0 but not NT3.51
>>
>Actually NT4.0/workstation not required.
Someone should tell my copy this. Whenver I change the info I get a
message infoming that a reboot is needed for changes to come into
effect.
--
wmcclatc@primenet.com
wmcclatc@nyx.net
------------------------------
Date: Sun, 30 Aug 1998 15:35:56 +0100
From: Charles F Hankel <charles@hankel.mersinet.co.uk>
Subject: Re: COBOL and Perl
Message-Id: <35E9634C.D23702B@hankel.mersinet.co.uk>
David Coldrick wrote:
>
> Charles,
>
> I think you misunderstand what Perl is. I dismissed it as a pile of junk
> a couple of years ago after seeing those weird leading characters ($ for
> scalar, % for array, indeed!). <...snipped book recommendation...>
I'm not dismissing it as a pile of cack. What I do object to is that
someone feels a need to promote Perl in an attempt to get an advocacy
war going without understanding the environments that a lot of COBOL
people work in. As someone else said, they considered Selcopy to be a
language. So, if I have Selcopy available to me and it is suitable for
a particular task, then I am not about to holler for Perl. I don't see
Perl as another language but rather as another system tool and certainly
would resist the use of an interpretive language in preference to a
compiled one for final production purposes under most circumstances.
It should also be born in mind that the majority of COBOL programmers in
the world do not actually have a lot of say in what system tools they
use. They may be able to contribute meaningfully to the debate but
that's usually about it.
--
Charles F Hankel Wirral UK
------------------------------
Ready, Willing and (avail)Able
------------------------------
Date: 22 Aug 98 18:22:16 GMT
From: email@address.com
Subject: FREE PORN
Message-Id: <35df0c58.0@www.an.cc.mn.us>
Check out this great 100% free site it does not require a credit card, no long distance charges and no 800 numbers. It is pure hardcore with dozens of sections. Check it out now
<a href="http://www.bearcatonline.com/adult/index5.htm>Click Here For 100% Free Porn</a>
------------------------------
Date: Sun, 30 Aug 1998 11:51:53 +0200
From: Daniel Stridhammar <daniel@NOSPAMstridhammar.pp.se>
Subject: Re: How to extract first letter in string?
Message-Id: <35E920B8.D349A914@NOSPAMstridhammar.pp.se>
Of course. You're right! Sorry for my typo...
> > > Are there anyone, who can tell me how to extract the first letter in a
> > > string..
> >
> > Use:
> >
> > $firstLetter = substr($string, 1, 1);
> >
> > /Daniel
>
> If you haven't messed with $[ (have you?), I think it should be:
>
> $firstLetter = substr($string, 0, 1);
>
> More info on:
> perldoc -f substr
>
> -TK-
------------------------------
Date: Sat, 29 Aug 1998 08:13:45 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: How to extract first letter in string?
Message-Id: <35E7FE89.B3A45F81@email.sps.mot.com>
Mike Stok wrote:
> >> Are there anyone, who can tell me how to extract the first letter in a
> >> string..
> >
>
> Might something like
>
> ($firstLetter) = $string =~ /([^\W\d_])/;
>
> be better if the original poster really wanted the first letter, not the
> first character?
You mean first 'letter', as in /([a-zA-Z])/, right?
I have difficulty in translating /([^\W\d_])/ into English - perhaps
the problem is with my English lang. :)
-TK-
------------------------------
Date: Sun, 30 Aug 1998 07:11:21 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to extract first letter in string?
Message-Id: <MPG.1052fd648b254b80989816@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <35E7FE89.B3A45F81@email.sps.mot.com> on Sat, 29 Aug 1998
08:13:45 -0500, Tk Soh <r28629@email.sps.mot.com> says...
> Mike Stok wrote:
...
> > Might something like
> >
> > ($firstLetter) = $string =~ /([^\W\d_])/;
> >
> > be better if the original poster really wanted the first letter, not the
> > first character?
>
> You mean first 'letter', as in /([a-zA-Z])/, right?
> I have difficulty in translating /([^\W\d_])/ into English - perhaps
> the problem is with my English lang. :)
He meant first 'letter', as in /(whatever characters the current locale
defines as being included in [\w], less the decimal digits and
underscore)/. By default, that includes only the limited set of letters
[a-zA-Z] defined in the ASCII character set (where the A stands for
American, remember). But even in one-byte-land, there are *many* others
in specific locales. See `perldoc perllocale`.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 29 Aug 1998 22:25:43 -0700
From: Mee <mee@mine.com>
Subject: Re: Imagine... a non-greedy world!
Message-Id: <35E8E257.2449340@mine.com>
Michael,
Your explanation would make sense if '*?' was
considered as one quantifier by Perl, but they
sure look like two to me.
Perl seems to agree by merrily accepting '*'
alone as a quantifier.
Mee
------------------------------
Date: 29 Aug 1998 18:28:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Imagine... a non-greedy world!
Message-Id: <6s9h8j$979$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Mee <mee@mine.com> writes:
:So far so good:
:Everyone has noted a typo in the contrived example
:but noone has understood the question.
Or perhaps someone else has misunderstood the matter at hand--which,
as it turns out, has to do with the representation of the Kleene star
operator in regular languages, the relationship of the latter to formal
set theory, and the actual implementations of these matters in one's
day-to-day programming languages. Here are a few references that should
help you in your research of this fascinating topic:
http://watson2.cs.binghamton.edu/~lander/cs373/1997_cs373N3.html
http://www.cs.wesleyan.edu/courses/comp321/reglangs1.html
http://www.rxrc.xerox.com/research/mltt/fst/fssyntax.html#star
http://clwww.essex.ac.uk/LFG/FAQs
http://theory.lcs.mit.edu/~iandc/References/gorejksm1997:59.html
http://l3ux02.univ-lille3.fr/~tommasi/TATAHTML/node33.html
Once you have fully assimilated these documents, I'm sure you will
then have the answer to your question.
--tom
--
Chip Salzenberg sent me a complete patch to add System V IPC (msg, sem and
shm calls), so I added them. If that bothers you, you can always undefine
them in config.sh. :-) --Larry Wall in <9384@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Sun, 30 Aug 1998 09:59:29 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: Imagine... a non-greedy world!
Message-Id: <35ea2010.371159298@nntp.ix.netcom.com>
On Sun, 30 Aug 1998 01:21:28 -0700, Mee <mee@mine.com> wrote:
>Michael,
>
>>> WHAT THE HELL DIFFERENCE DOES IT MAKE? <<
>
>Absolutely none if you consider expressions such as /a*c/
>and /a.*[^fg;lfd]45\s86433[//]qw#/\W$54p3{9}9[59]45\s+?c/
>morally and aesthetically equal.
I don't understand. Why should I consider a regular expression and a
syntax error moraly and aesthetically equal? What does this have to
do with greed?
Your original message complained about greediness. One has a choice,
/a*c/ matches everything from the first a to the last that follows or
/a*?c/ which matches everything from the first a to the first c that
follows. I both cases the match fails if there is no c following the
first a.
--
Michael M Rubenstein
------------------------------
Date: Sun, 30 Aug 1998 12:01:25 +0100
From: "Martin" <minich@globalnet.co.uk>
Subject: Re: Imagine... a non-greedy world!
Message-Id: <6sbbde$nkt$1@heliodor.xara.net>
>>> WHAT THE HELL DIFFERENCE DOES IT MAKE? <<
>
>Absolutely none if you consider expressions such as /a*c/
>and /a.*[^fg;lfd]45\s86433[//]qw#/\W$54p3{9}9[59]45\s+?c/
>morally and aesthetically equal.
One isn't none greedy and the other greedy though! /a*c/
matchs aaaaaaaaaaaaaaaaaaac and ac and aaaaac etc.
If you only want it to match ac then you could use /a{1}c/
or for aac /a{2}c/ etc. both of which seem fairly self-explanatory.
Note however, * does NOT have the same meaning as in
globs. so /a*c/ is not a, anything, c. That is /a.*c/.
Martin
------------------------------
Date: Sun, 30 Aug 1998 10:22:56 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Imagine... a non-greedy world!
Message-Id: <1dekkh1.3y2kpq2soj28N@bay1-262.quincy.ziplink.net>
Mee <mee@mine.com> wrote:
> Regardless, the point is not in how many books someone
> has read.
When someone is arguing from a position of ignorance, as you are doing,
how many books someone has read on the relevant topic is very much to
the point.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 30 Aug 1998 02:49:39 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: Installed modules info?
Message-Id: <slrn6uhftd.2nc.randy@theory.uwinnipeg.ca>
On Fri, 28 Aug 1998 17:32:52 -0500,
Yevgeniy Belorusskiy <ybelor1@uic.edu> wrote:
>What is the proper way to get listing of all installed modules on a
>given system?
>I think I have seen it somewhere, but I can't find it again.
Hi,
One way is to use the CPAN module: invoke the CPAN shell via
perl -MCPAN -e shell
and then at the prompt type
autobundle
This will produce a file Snapshot_xxxx_xx_xx_xx.pm under, eg,
~/.cpan/Bundle, listing the installed modules with version numbers,
if available (the x's indicate the date the snapshot was taken).
--
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: Sat, 29 Aug 1998 21:29:12 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: parsing "mulitpart form-data" with cgi-lib.pl on JWS
Message-Id: <Pine.GSO.4.02A.9808291427570.15614-100000@user2.teleport.com>
On Sat, 29 Aug 1998 simple@nanospace.com wrote:
> This same Perl script which requires cgi-lib.pl v2.17 correctly parses an
> uploaded file through IIS on windows NT and through Apache on Linux and
> Solaris.
Okay, so it's not a Perl problem.
> It fails on Java Web Server on Windows NT.
Perhaps this is a problem with that webserver?
If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 30 Aug 1998 02:35:47 -0400
From: nospam@cheta.net (Michael Allen Gelman)
Subject: PASSME
Message-Id: <MPG.1052bccc353b4789896b1@news.cheta.net>
text
------------------------------
Date: Sun, 30 Aug 1998 13:07:01 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: PASSME
Message-Id: <35e94d69.2209248@news.btinternet.com>
On Sun, 30 Aug 1998 02:35:47 -0400, Michael Allen Gelman wrote :
>text
That may be valid Perl code. But you should have used the -w switch:
~> perl -we "text"
Unquoted string "text" may clash with future reserved word at -e line
1.
Useless use of a constant in void context at -e line 1.
~>
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 30 Aug 1998 03:03:15 -0400
From: Uri Guttman <uri@sysarch.com>
To: pete@theory2.phys.cwru.edu (Peter J. Kernan)
Subject: Re: perl regex bug? (or feature?)
Message-Id: <x7vhnb2bpo.fsf@sysarch.com>
>>>>> "PJK" == Peter J Kernan <pete@theory2.phys.cwru.edu> writes:
PJK> perl -ne 'print if /^[^aeiouA-Z][aeiou][^aeiou]$/' < /usr/dict/words
PJK> be #whoa there!
PJK> i expected somthing like egrep's behavior
PJK> egrep '^[^aeiouA-Z][aeiou][^aeiou]$' /usr/dict/words
PJK> perl -ne 'print if /^[^aeiouA-Z][aeiou][^aeiou\n]$/'
PJK> to get what i expected at the top w/perl and got w/egrep.
PJK> which surprised me and seems bizarre. If the /[^aeiou]$/
PJK> matches the new-line in the character class why does the
PJK> end-of-line anchor also match the newline? if it was
PJK> matching "be\n\n" this would seem more reasonable (yet
PJK> still absurd), but that can not happen with the -n switch.
PJK> should i re-read the owl book? the camel book? the perlre
PJK> manpage?
sounds like a different interpretation of $
here is what egrep says:
The caret ^ and the dollar sign $ are metacharacters that respectively
match the empty string at the beginning and end of a line.
perlre says
the "$" character [matches] at only the end (or before the newline at
the end)
so "be\n" would match in perl the first expression since \n was not in
the last char class and $ matched the end of the string. egrep seems to
define "line" and string as the same since it reads in lines only. but
the egrep's $ matches the \n so it really isn't a zero width match! or
maybe it does an implicit chomp on each line as it is read in. perl's $ is
a zero width or trailing \n match.
BTW use a -l option and perl will chomp the \n off and your problem goes
away. it also will print \n after each print for you.
hth,
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Sun, 30 Aug 1998 00:48:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Posting images from a mSQL database
Message-Id: <MPG.1052a3b65bf82478989814@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <simple-2908981713510001@tc1-dialin17.nanospace.com> on Sat,
29 Aug 1998 17:13:51 +0100, simple@nanospace.com <simple@nanospace.com>
says...
> open (IMAGE, "$imagefile");
Tom Phoenix has already commented on this line.
> print "Content-Type: image/jpeg\n\n";
>
> while (<IMAGE>) {
> print;
> }
>
> or
>
> while ($line = <IMAGE>) {
> print $line;
> }
Printing a binary file line by line doesn't make much sense. First, you
should say:
binmode IMAGE;
binmode STDOUT;
to inhibit possible munging of newline characters. Next, you should
either read and write the file as one block:
{ local $/; print <IMAGE> }
or, if you are concerned that the file is too big, one block at a time:
{ local $_ = ""; print while read IMAGE, $_, $BLOCKSIZE }
where $BLOCKSIZE is up to you to choose.
HTH,
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 30 Aug 1998 02:18:01 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: Problem with a package
Message-Id: <6saub9$e1u@fumnix.metronet.com>
Mark Lybrand <maryesme@localaccess.com> writes:
[...]
) package CGI::Multiple;
[...]
) use CGI;
) @ISA = qw/CGI/;
[...]
) sub hidden_multiple {
[...]
) --- begin script ---
[...]
) use CGI::Multiple;
) use CGI::Carp qw(fatalsToBrowser);
)
) $q = new CGI;
[...]
) $q->hidden_multiple($q->param);
[...]
) Undefined subroutine CGI::hidden_multiple
I think you want:
$q= new CGI::Multiple;
then $q could still invoke any methods from CGI.pm because a
CGI::Multiple object is also a CGI object due to inheritance,
C<@ISA = qw/CGI/>. And, of course, $q could invoke CGI::Multiple
methods such as hidden_multiple() because it would be a
CGI::Multiple object.
Your module does not make every CGI object know how to do
CGI::Multiple methods. Inheritance works the other direction.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Sun, 30 Aug 1998 13:06:59 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Public Domain Module wanted
Message-Id: <35e947e1.792952@news.btinternet.com>
On Sun, 30 Aug 98 02:31:31 GMT, Steve Silberberg wrote :
>You must get this all the time --
>
Err, pass ..
>Does anyone have a compiled perl script that will translate form data into
>something readable under Windows?
>
A) what is a "compiled perl script" ?
B) what is "form data" ?
C) How translate so "readable under windows" ?
I sense that this is a CGI question. You should be looking at the CGI
module which comes with recent Perl distributions and particularly its
excellent documentation. Of course if you neither know nor are
interested in learning Perl and simply want a plug'n'pray script then
this is not much use to you - but then again neither is asking here if
thats all you want.
There are a myriad of free CGI resources on the 'Net (albeit of varied
quality) - a quick search for "Perl CGI scripts" on your favourite
search engine should throw up a dauntingly large list.
Of course I may be miscalling you and you may be genuinely interested
in programming/learning Perl - in which case it would behove you to
check out the resources available at <URL:http://www.perl.com/>.
If you have some code that you have tried which doesnt work as you
expected and you have exhausted the Documentation & FAQ in the search
for resolution of your problem and you are sure that it is a problem
with Perl and not due to the environment that you are running your
program then feel free to post a small example of code that
demonstrates what is not working properly in order that people can
help you solve the problem.
>thanks.
>
'salright
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 30 Aug 1998 14:25:43 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Random Numbers in Range?
Message-Id: <6sbnd7$s30$1@pegasus.csx.cam.ac.uk>
In article <35E6C145.631F@min.net>, John Porter <jdporter@min.net> wrote:
>Matt Knecht wrote:
>>
>> $num = rand_range(97 => 122);
>
>I don't understand why people do this.
>It forces an unnecessary stringization of a number.
Eh? Why should it? It doesn't on any version of Perl I have installed.
Mike Guy
------------------------------
Date: Sat, 29 Aug 1998 17:36:44 GMT
From: Alan Melton <arm@home.net>
Subject: sorting
Message-Id: <35E83AE8.F7993A73@home.net>
Example of printout:
SKU Volume Cost DESC
=============================================================================
18 August 1998 1002 1 $ 28.25
Accounting:Conc.+Appl.-Std.Gde.1-14 5th 96 New
18 August 1998 1004 1 $ 84.45 Accounting:Concepts &
Application 1st New
18 August 1998 1005 1 $ 63.35 Accounting:Concepts &
Application 1st Used
19 August 1998 1002 1 $ 28.25
Accounting:Conc.+Appl.-Std.Gde.1-14 5th 96 New
19 August 1998 3139 1 $ 51.15 Business Math 4th 96
Used
Would like to sort report on $desc
and get subtotals after a break on each sort.
Last part of program to this point:
# Select the 'TOTAL' picture.
$FORMAT_NAME = "TOTAL";
# Write out the totals.
write;
# This format 'picture' is for the invioce.
format INVOICE_TOP =
SKU Volume Cost DESC
=============================================================================
.
format INVOICE =
@<<<< @<<<<<<<<<@<<<< @<<<<<< @### $@####.## @*
$dayy,$monthh,$yearr,$skunum,$voll,$costtot,$descc
.
format TOTAL =
=============================================================================
$@#####.## $@###.## $@#####.##
$@#####.##
#$totalPrice,$totalTax,$totalVoll,$totalCost
.
close IN;
}
1;
Alan Melton
------------------------------
Date: 30 Aug 1998 03:35:20 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: SWF (Shockwave Flash) file format
Message-Id: <x7soie3osn.fsf@sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>> sub larry { my $n_bits = ord(substr($data, 0, 1)) >> 3;
LR> I could do better here. I forgot that 'ord' works on the first
LR> character of its argument string, automatically, so the substr is
LR> a no-op.
LR> So let's see: I presented 5 lines of ungainly Perl code that runs
LR> faster than your ~40 well-formed lines (plus the module
LR> Bit::Vector). My code manipulates 'binary character strings';
LR> yours manipulates bits in words. But yours could be made faster
LR> using C and XS. Not surprising, because it reads like C code.
LR> One might well conclude that Perl-ish Perl (being tuned for
LR> string- slinging) does better on this kind of problem than C-ish
LR> Perl (which isn't tuned for bit-slinging).
LR> You may indeed have done me (and the perl community) a little
LR> favor. I appreciate the time you spent on this, and I do owe you,
LR> Uri! But I won't switch to using your code. :-)
i first thought that my idea would be faster since it didn't go to
strings and back. i was surprised that it was slower. as i said it could
be faster in perl and yes i wrote it C like since i wanted that type of
behavior. i could make a general version using your technique and see
what its speed is like. i then thought, bit vectors, someone had to have
done this and i searched cpan and found bit::vector. by this time i was
too involved to give up and i spent 2 hours learning that
module. heavily documented but tricky to learn at first. then i had to
master the bit inversion issues and i finally got it working. then the
benchmarks got to me.
anyhow, a c version of my code would be a nice module to get at short
fields, I/O registers (but perl doesn't to memory access well either),
etc.
the reason i had to go the 32 word route was that vec only works on
fields which are a power of 2 (boo). and substr as we know works only on
char strings. i even tried to vec out the bytes (no substr) but there
was no integer value, only a string value so i had to vec on top of the
substr. maybe unpack would be faster there (i just tried it, it is slower).
as larry (the other) said, "there has to be something awk is better at!"
s/awk/c/;
it was a fun challenge and 3 hours of wasted time. pay up!!
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Sun, 30 Aug 1998 06:34:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: SWF (Shockwave Flash) file format
Message-Id: <MPG.1052f4a7e7aa0d09989815@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <x7soie3osn.fsf@sysarch.com> on 30 Aug 1998 03:35:20 -0400,
Uri Guttman <uri@sysarch.com> says...
...
> i first thought that my idea would be faster since it didn't go to
> strings and back. i was surprised that it was slower. as i said it could
> be faster in perl and yes i wrote it C like since i wanted that type of
> behavior. i could make a general version using your technique and see
> what its speed is like. i then thought, bit vectors, someone had to have
> done this and i searched cpan and found bit::vector. by this time i was
> too involved to give up and i spent 2 hours learning that
> module. heavily documented but tricky to learn at first. then i had to
> master the bit inversion issues and i finally got it working. then the
> benchmarks got to me.
Maybe this is not surprising. In an interpreted execution, the main cost
is instruction dispatch, so the more instructions, the slower. The
relative speed of each primitive is secondary.
> anyhow, a c version of my code would be a nice module to get at short
> fields, I/O registers (but perl doesn't to memory access well either),
> etc.
>
> the reason i had to go the 32 word route was that vec only works on
> fields which are a power of 2 (boo).
Yes. When I realized that, I abandoned it for my solution.
> and substr as we know works only on char strings.
But relatively damned fast!
> i even tried to vec out the bytes (no substr) but there
> was no integer value, only a string value so i had to vec on top of the
> substr. maybe unpack would be faster there (i just tried it,
> it is slower).
>
> as larry (the other) said, "there has to be something awk is better at!"
> s/awk/c/;
No doubt. C's bit extraction and munging are excellent -- really
efficient access to the machine primitives.
> it was a fun challenge and 3 hours of wasted time. pay up!!
>
> uri
It was fun for me too (and I needed to solve the problem, so it was work
product too). But your effort also led me to some philosophical musing,
along these lines: Perl's primitives (like substr, pack, etc.) are tuned
toward string manipulation, while bit-level access is awkward and slow
(as you have shown). So maybe the idea of using binary character strings
to simulate bit vectors and operations (like & | ^, which work fine on
strings) isn't as grotesque as I thought when I posted the code.
This is what I meant by your having really made a contribution to the
Perl community with your code and benchmarks. I wonder will anyone else
weigh into the discussion. I certainly owe you the next beer.
Larry
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 30 Aug 1998 02:45:53 -0400
From: Uri Guttman <uri@sysarch.com>
To: bray1@pacbell.net
Subject: Re: tripped on chomp
Message-Id: <x7yas72cim.fsf@sysarch.com>
>>>>> "b" == bray1 <bray1@postoffice.pacbell.net> writes:
b> syntax error in file hello.pl at line 4, next 2 tokens "chomp ("
b> In its Perl FAQ, the host server says Perl 5 is located in
b> /usr/local/bin/perl. That's how the #! reads in my little script.
b> When I edit the script to chop ($name), it runs without errors. Is
b> chomp new to Perl 5? Could I be using 4 on the server, even though
b> I've followed the faq's instructions? I also get the same error
b> when I use the qw( ) operator in another script.
symptoms: chomp and qw() cause syntax errors
diagnosis: night of the living dead perl4
test: run perl -v
cure: chomp of the head of perl4
lesson: never trust an ISP's FAQ
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 30 Aug 1998 07:43:55 GMT
From: bismuti@dirac.scri.fsu.edu (Peter Bismuti)
Subject: trouble writing 2 files in subroutines
Message-Id: <6savrr$3ho$1@news.fsu.edu>
HI, I've noticed that if I open a file to write and then enter
into a subroutine, I can no longer write to this file.
Is this a bug?
Thanks!
_______________________________________________________________________
| Pete Bismuti |
| Supercomputer Computations Research Institute |
| Florida State University - Department of Mathematics |
| bismuti@scri.fsu.edu (904) 644-6263 |
|_____________________________________________________________________|
------------------------------
Date: 30 Aug 1998 04:21:23 -0400
From: Uri Guttman <uri@sysarch.com>
To: bismuti@dirac.scri.fsu.edu (Peter Bismuti)
Subject: Re: trouble writing 2 files in subroutines
Message-Id: <x7r9xy3mnw.fsf@sysarch.com>
>>>>> "PB" == Peter Bismuti <bismuti@dirac.scri.fsu.edu> writes:
PB> HI, I've noticed that if I open a file to write and then enter
PB> into a subroutine, I can no longer write to this file.
PB> Is this a bug?
it is a bug to not show example source. i am not karnak the magnificent
so i can't divine what the hell you are doing with your code.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Sun, 30 Aug 1998 03:03:16 -0400
From: nospam@cheta.net (Michael Allen Gelman)
Subject: WANTED: 3rd level domain script
Message-Id: <MPG.1052c33ccbe56df69896b2@news.cheta.net>
Could one of you PERL wizards give me a simple script to direct a 3rd
level domain to a sub-folder?
Domain name servers output an IP. I need to read 3rd level domains, then
direct them to various locations. This is done by ML.ORG and others, but
I don't know exactly how.
Input to the DNS would be 3RDLEVEL.CHETA.NET
The DNS would output an IP address
I might want to generate a redirect page to send it to a sub-folder of a
different domain, for example, WWW.OTHER.COM/3RDLEVEL
Please show me how. I'll find a way to return the favor!
Thanks,
Michael Allen Gelman
(replace NOSPAM with my last name)
------------------------------
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 3589
**************************************