[10594] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4186 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 10 03:07:16 1998

Date: Tue, 10 Nov 98 00:00:33 -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           Tue, 10 Nov 1998     Volume: 8 Number: 4186

Today's topics:
        [WOW!] Re: History Lesson... (Ilya Zakharevich)
    Re: Change in string (Ronald J Kimball)
        Displaying relationships between nodes (mapping network (David Formosa)
    Re: Displaying relationships between nodes (mapping net <rootbeer@teleport.com>
    Re: Displaying relationships between nodes (mapping net (David Formosa)
    Re: DOS to UNIX <rootbeer@teleport.com>
    Re: DOS to UNIX (Ethan H. Poole)
        Existence of a Perl Shell <shulman@caltech.edu>
    Re: Existence of a Perl Shell <rootbeer@teleport.com>
    Re: File upload/Netscape4.0.7> <rootbeer@teleport.com>
    Re: File upload/Netscape4.0.7> <ccarr@websocket.com>
    Re: Files and Hashes <rootbeer@teleport.com>
    Re: FTP/doing file testing on an array? <rootbeer@teleport.com>
    Re: Help with WinNT CGI-Perl <rootbeer@teleport.com>
        Help, I'm stuck again (this one may push the envelope) <rwilliamson@uno.gers.com>
    Re: Help, I'm stuck again (this one may push the envelo <rwilliamson@uno.gers.com>
    Re: History Lesson... (Bradley K. Farrell)
    Re: looking for a Perl script which... jbharvey@corp.home.net
    Re: Not to start a language war but.. (William Tanksley)
    Re: OOP or not? (for a Perl module) (Paul Winkler)
    Re: Parallel to Serial <rogersb@home.com>
    Re: Querying the OS. <rootbeer@teleport.com>
    Re: sysread() Question <uri@sysarch.com>
    Re: sysread() Question (Ilya Zakharevich)
    Re: sysread() Question (Ilya Zakharevich)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 10 Nov 1998 06:50:57 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: [WOW!] Re: History Lesson...
Message-Id: <728noh$cko$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Bradley K. Farrell
<bradley@iinet.net.au>],
who wrote in article <3647d842.178092841@news.m.iinet.net.au>:
> At perl.oreilly.com I found a link to an interesting article:
> http://www.salonmagazine.com/21st/feature/1998/10/cov_13feature.html

I'm *very* pleasantly surprised by this piece.  Right now it looks as
being a head (or two!) above *best* Perl-related papers I have seen.

Ilya

P.S.  Unfortunately, I cannot track the author on AltaVista, since the
      name is so common...


------------------------------

Date: Mon, 9 Nov 1998 21:40:09 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Change in string
Message-Id: <1di8w0h.18ei7y717aptsuN@bay1-265.quincy.ziplink.net>

Roderik Valcke <vhti-katho@unicall.be> wrote:

> How can I change  hex "0D 0A" to "0A" in a string
> with the command string$ =~ s/\n/...../g;

s/\x0D\x0A/\x0A/g;

s/\cM\cJ/\cJ/g;

s/\r\n/\n/g;

-- 
 _ / '  _      /         - 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: 10 Nov 1998 06:33:48 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Displaying relationships between nodes (mapping networks)
Message-Id: <slrn74fnic.cbn.dformosa@godzilla.zeta.org.au>

I have a problem that I keep running into and it keeps stumping me.
What is the best way to dispaly a system where you have
interconnecting nodes in some form of network.

Examplies would be a railway with tracks and stations, mapping
usenet paths, mapping pedestrian tunnels or freandship nets.

If there are not any modules to do this (and I haven't seen any) can
anyone suggest any algorythums that I could implement to do this task
in perl.

-- 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.



------------------------------

Date: Tue, 10 Nov 1998 06:48:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Displaying relationships between nodes (mapping networks)
Message-Id: <Pine.GSO.4.02A.9811092247450.2742-100000@user2.teleport.com>

On 10 Nov 1998, David Formosa wrote:

> What is the best way to dispaly a system where you have
> interconnecting nodes in some form of network.

Define "best". What's best for me may not be best for you, and there's no
point in any of us wasting our time until you can say just what you want.
 
You may need to choose among fastest, most memory efficient, easiest to
program, fewest lines of code, most robust, most portable, easiest to
debug, easiest to maintain, most like your other favorite programming
languages, or perhaps you mean some other criterion. (Of course, one
solution may fall into more than one of these categories.)

Cheers! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: 10 Nov 1998 06:59:26 GMT
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: Displaying relationships between nodes (mapping networks)
Message-Id: <slrn74fp2e.ebt.dformosa@godzilla.zeta.org.au>

In article
<Pine.GSO.4.02A.9811092247450.2742-100000@user2.teleport.com>, Tom
Phoenix wrote: 
>On 10 Nov 1998, David Formosa wrote:
>
>> What is the best way to dispaly a system where you have
>> interconnecting nodes in some form of network.
>
>Define "best". What's best for me may not be best for you, and there's no
>point in any of us wasting our time until you can say just what you want.

Ok,

What is the best way to dispaly a system where you have
interconnecting nodes in some form of network given readerbity is the
most importent concern, followed closly by lazyness and impatence.


-- 
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.



------------------------------

Date: Tue, 10 Nov 1998 04:12:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: DOS to UNIX
Message-Id: <Pine.GSO.4.02A.9811092011040.2742-100000@user2.teleport.com>

On Tue, 10 Nov 1998, Roderik Valcke wrote:

> I'm looking for a perl code to change in a $string the hexcode "0D 0A"
> to only "0A"; before exporting by the string to a file
> 
>          open (FILE,">$filename");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

>          print FILE "$string";

Those quote marks are merely misleading there.

>          close (FILE);       .

I think that you didn't mean to put that dot there, but I'm in a mood to
pick on every little detail. :-)

> I've tried $string =~ s/\x0d\x0a/\x0a/g;  but it always changes the
> "0A" to "0D 0A" once it's writen to the file;
> 
> If I use an extern DOS-to-UNIX utility on the file and save it's OK.
> (I'm working on WINDOWS)

Sounds like binmode. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 10 Nov 1998 05:35:46 GMT
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: DOS to UNIX
Message-Id: <SgQ12.758$%a6.824@news3.ispnews.com>

[Posted and Emailed]  In article <7281r3$9or$1@trex.antw.online.be>, 
Roderik.Valcke@unicall.be says...
>
>Hi
>
>I'm looking for a perl code to change in a $string the hexcode "0D 0A" to
>only "0A";
>before exporting by the string to a file
>
>         open (FILE,">$filename");
>         print FILE "$string";
>         close (FILE);       .
>
>
>I've tried   $string =~ s/\x0d\x0a/\x0a/g;  but it always changes the "0A"
>to "0D 0A" once it's writen to the file;
>
>If I use an extern  DOS-to-UNIX utility on the file and save it's OK. (I'm
>working on WINDOWS)
>
>But I want to export by the perl script so I don't have to change it.
>
>can someone help me

First: Check the status of open before you proceed - it's good practice.
       
       open (FILE, ">$filename") || die "Could not open $filename: $!";
       $string =~ s/\r|\r\n|\n/\n/g;
       print FILE $string;
       close (FILE);

That will probably have the desired affect.  I'm assuming you previously 
opened a file and read in $string somewhere....

Read up on Regular Expressions (regex) and substitution and familiarize 
yourself with what the function "$string =~ s/......" is performing in the 
above.  This is one of Perl's greatest features.

-- 
Ethan H. Poole              | Website Design and Hosting,
                            | CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day--
                            | http://www.interact2day.com/



------------------------------

Date: Mon, 09 Nov 1998 23:20:06 -0800
From: Michael Shulman <shulman@caltech.edu>
Subject: Existence of a Perl Shell
Message-Id: <3647E926.51AB0785@caltech.edu>

Does anyone know whether anyone has ever written a perl shell? By this I
mean a shell that will accept perl statements at the command line, as
well as executing other programs and manipulating files, and allowing
perl expressions in all commands. Another way to put it would be a shell
that uses perl instead of whatever scripting language other shells use.

________________________________________________________________________
|    \/|R|TR|LB|/\    | QOTD: "Let us have faith that right makes      |
|   Michael Shulman   |  might; and in that faith let us dare to do    |
| shulman@caltech.edu |  our duty as we understand it." -Abraham       |
|_____________________|__Lincoln_______________________________________|


------------------------------

Date: Tue, 10 Nov 1998 07:22:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Existence of a Perl Shell
Message-Id: <Pine.GSO.4.02A.9811092322030.2742-100000@user2.teleport.com>

On Mon, 9 Nov 1998, Michael Shulman wrote:

> Does anyone know whether anyone has ever written a perl shell? 

Have you seen what the FAQ has to say about this? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 10 Nov 1998 04:41:13 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: File upload/Netscape4.0.7>
Message-Id: <Pine.GSO.4.02A.9811092032470.2742-100000@user2.teleport.com>

On Mon, 9 Nov 1998, Clinton Carr wrote:

> I just noticed that the CGI.pm file upload feature does not work in
> Netscape 4.0.7 or Netscape 4.5. Any workarounds?

Well, if those browsers aren't following the protocol, install browsers
which do. If the module isn't following the protocol, install one which
does. If you're not sure about the protocol, the docs, FAQs, and
newsgroups about it would be a good place to start. 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Mon, 09 Nov 1998 23:55:44 -0600
From: Clinton Carr <ccarr@websocket.com>
Subject: Re: File upload/Netscape4.0.7>
Message-Id: <3647D560.805C1E53@websocket.com>

The problem appears to be related to cgi caching.  I added
'-expires=>'now' to my
scripts and all is fine again.

Clinton Carr wrote:

> I just noticed that the CGI.pm file upload feature does not work in
> Netscape 4.0.7 or Netscape 4.5.
> Any workarounds?
>
> Thanks



------------------------------

Date: Tue, 10 Nov 1998 04:56:08 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Files and Hashes
Message-Id: <Pine.GSO.4.02A.9811092043240.2742-100000@user2.teleport.com>

On Mon, 9 Nov 1998, Himani Naresh wrote:

> I'm looking for a way to compare files in perl without actually comparing
> them line by line.  Since I have to compare a file to about 200 others, I'm
> looking for some sort of hash function that will take any file and create a
> unique hash value.  

See whether the MD5 module on CPAN will do what you need.

> Does anyone know of such a hash function for files that will guarantee
> a unique hash for any file?

Sure, but you won't like it. Some of the hash keys can be kind of large,
and the function could be written somewhat more efficiently, but here
goes:

    sub always_unique_hash {
	return scalar $_[0] if @_ and $];	# Look busy... :-)
    }

Despite it's shortcomings, there's no function that guarantees a unique
hash value for every possible input yet returns smaller keys. I have an
elegant proof of this, but unfortunately there is insufficient space
between here and my .sig to include it in this posting. Oh, well!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 10 Nov 1998 04:24:38 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: FTP/doing file testing on an array?
Message-Id: <Pine.GSO.4.02A.9811092023480.2742-100000@user2.teleport.com>

On Tue, 10 Nov 1998, Arran Price wrote:

> @SCONTENTS=$ftp->dir;
> which gets me the contents of an ls -al type listing into the array.
> eg ----------   1 owner    group        45252636 Oct 19  0:39 MD799.001

> Now I need to grab the files that are newer than a day old.

> I thought about extracting the date fields and checking them but then
> I would need to figure out the days in the month etc..

Use one of the date-parsing modules, instead. There are several good ones
on CPAN. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 10 Nov 1998 04:29:29 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Help with WinNT CGI-Perl
Message-Id: <Pine.GSO.4.02A.9811092028490.2742-100000@user2.teleport.com>

On Tue, 10 Nov 1998 mila@stars.gsfc.nasa.gov wrote:

> When I try to run the same thing from an HTML form page (CGI with post
> command) it doesnt run the program.

It sounds as if the server isn't doing what you want. The docs, FAQs, and
newsgroups about servers may be of help to you. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Mon, 9 Nov 1998 20:28:24 -0800
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Help, I'm stuck again (this one may push the envelope)
Message-Id: <gfP12.180$DA6.31722@news.connectnet.com>

Hi!
I'm finding that sometimes its the simple things that hurt (well, simple to
most UNIX buffs), like how do you do the equivalent of:

#!/bin/sh
 ...
grep -i '^start_' arm_controls.h | awk -F\"  '{print $1 "," $2}'
 ...

I'm searching a file (arm_controls.h) for stuff like:
START_ARMFS="true"

and want to wind up with a hash containing:
START_ARMFS, true, .....

This is embarrassing!

Rusty





------------------------------

Date: Mon, 9 Nov 1998 21:49:00 -0800
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Re: Help, I'm stuck again (this one may push the envelope)
Message-Id: <RqQ12.186$DA6.31938@news.connectnet.com>

Hi Tom!

I myself feel I deserve that.  I don't have the Llama book and I will get
it.  However, I've read two other Perl books and have just started a
third -- so much stuff and I've learned how to do a lot.  But this is only
my 3rd script and somehow, when faced with this simple problem my brain
turns to clay.  I've been flipping through all my books -- I guess I open
the file, read all the records into an array, close the file and then loop
through it searching each array element for the pattern and once I find it,
extract the portions I need.  Is that it?  Somehow it seems simpler to use
back quotes and use the one line grep/awk statement, but then I'm back were
I started and that's not the reason I'm trying to learn Perl.  But thanks
anyway.

Rusty





------------------------------

Date: Tue, 10 Nov 1998 06:12:35 GMT
From: bradley@iinet.net.au (Bradley K. Farrell)
Subject: Re: History Lesson...
Message-Id: <3647d842.178092841@news.m.iinet.net.au>

At perl.oreilly.com I found a link to an interesting article:
http://www.salonmagazine.com/21st/feature/1998/10/cov_13feature.html


--
Bradley K. Farrell
bradley@iinet.net.au


------------------------------

Date: Tue, 10 Nov 1998 05:58:59 GMT
From: jbharvey@corp.home.net
Subject: Re: looking for a Perl script which...
Message-Id: <DCQ12.729$3o4.2642206@news.rdc1.sfba.home.com>


Hey, this might be of help:

http://stein.cshl.org/WWW/software/CGI/cgi_docs.html#upload_caveats

It's how to upload files via CGI.pm, I dunno if this is what you're looking
for.

j

Marquis de Carvdawg <carvdawg@patriot.net> wrote:

>> I am looking for a perl script which basically can help me upload a file (any)
>> to a server and then create a link to that file in a html page...
>>

> 1.  Keep a copy of the HTML page locally.2.  When you want to upload a new file,
> first make your
>      alterations/mods to the HTML page.
> 3.  Use Net::FTP or Win32::Internet to upload the two files.




--
Justin B. Harvey					@Home Network
@Work Software Engineer					425 Broadway
jbharvey@corp.home.net					Redwood City, CA 94063
Voice: (650) 569-5692					http://www.home.net


------------------------------

Date: Tue, 10 Nov 1998 04:05:10 GMT
From: wtanksle@cx930311-b.ocnsd1.sdca.home.com (William Tanksley)
Subject: Re: Not to start a language war but..
Message-Id: <slrn74ferk.en6.wtanksle@cx930311-b.ocnsd1.sdca.home.com>

You know, we might need a .advocacy group.  Or maybe it's best that we don't
have one -- I wouldn't use it, and I'd be stuck knowing less about Perl
because I was revolted by it (past tense, guys, don't call me a liar again).

In article <3641DF6E.67E29EF2@min.net>, John Porter wrote:
>Garrett G. Hodgson wrote:

>> Tom Christiansen wrote:

>> > Or even the classic linked-list traversal:
>> >
>> >     for ($node = $head; $node; $node = $node->{LINK}) {
>> >         printf "I am %d.\n", $node->{VALUE};
>> >     }

>> i guess when i think data structures, i'm thinking more about higher
>> level constructs like those in the Gang of Four design patterns book.
>> something like the Visitor pattern, f'rinstance.

>That's all well and good, considering you didn't ask the question
>to which Tom C was responding.

Right.  That would have been me -- a newbie who's read too much of an
obsolete book.

>wtanksle@cx930311-b.ocnsd1.sdca.home.com (William Tanksley) wrote:
>> My point is that Perl is not very good at handling data because
>> it can't handle arbitrary structures very well.

>And by "arbitrary data structures" he apparently meant:

>> any data structure you want.  Classes, tuples, hashes, you name it.
>> Even functions...

Please accept my apology for an almost impossibly impenatrable post.  I used
words poorly, and I didn't have all the info about Perl, either.

The above list is a list of native types of Perl.  Of course Perl supports
its own native structures...  However, in the book I've got (or had, since
it's so far out of date), it lists incredibly ridiculous ways of passing
those native structures to functions, a feature I use constantly.  In that
version of Perl you evidently had to constantly work around language
deficiencies in order to do what I consider the most primitive things.  I
posted about it, and nobody seemed to have any alternative, although they
maintained that it was perfectly all right anyhow.

Okay.  Now, I've finally found some indication that Perl does have a
perfectly good parameter passing method in the newer versions; you declare
your subs with (%$@&) parameter type thingies.  Actually looks nice, once
you're used to it.

Take the good with the bad, add the positives (if, unless, etc) and subtract
the negatives ($ everywhere), and I believe that I'm now accepting Perl into
my community of programming languages.  No gain for Perl, I'm sure, but a
gain for me.  I still don't see myself ever programming in Perl where Python
is allowed, but some of that will fade.  I still think Python is the better
programming language, but Perl will see use as a scripting language --
whatever the negligable difference between the two may be :-).

>As for "higher level constructs", like Patterns, Perl is more than
>adequate (if not entirely ideal) as an implementation language.

My post was mostly insulting, since it implied a lack of support for the
languages' own primitives.  I believed that the lack of support would make
implementation of much more sophisticated things that much harder.

So now that that's out of the way...  What else prevents Perl from being
ideal?  Educate a newbie.  Feel free to reply to the Perl NG at this
point; I think my reply here contains the last reference to Python for this
thread.

>John Porter

-Billy


------------------------------

Date: Tue, 10 Nov 1998 07:30:51 GMT
From: zarmzarmNO@SPAMhotmail.com (Paul Winkler)
Subject: Re: OOP or not? (for a Perl module)
Message-Id: <3647e266.7834573@news.erols.com>

Thanks for the reply, Zenin...

On 09 Nov 1998 12:09:11 GMT, Zenin <zenin@bawdycaste.org> wrote:
>	"pretty easy" and "add a graphical front-end" don't normally
>	belong in the same sentance. :-)

Well, I'll fall off that bridge when I come to it (like, never?).

>: As I said, the big question is whether to take an OOP approach or not.
>: Reasons Why OOP:
>: --might make usage syntax easier? We're dealing with a pretty unwieldy
>: data structure (see below).
>: --might make extension of the module easier?
>
>	Both, as well as other indirect features.

Example?

>: Reasons Why NOT OOP:
>: --I don't really understand OOP.
>
>	For what you want to do I don't think it would be too hard
>	to get upto speed easily.

Good to know.

>: --I think I know how to do what I want in traditional programming.
>
>	Which should make moving it to OO that much easier. :-)
>
>: --Don't have to worry about mucking around outside of established
>: class methods.
>
>	Er, huh?

Sorry, my terminology is rather confused. I mean that, from what I've
read, it's considered a no-no to alter the data in an object other
than by the methods provided by the object. Whereas I don't want to
limit or force the techniques used in each script (or "composition" as
the case may be). 

>: The main issue is whether or not an OOP approach would make the system
>: easier to use?
>
>	Maybe, maybe not.
>
>: Remember, the scripts we're writing with this Perl
>: module are compositions, not applications!
>
>	Never say never.  I could easily picture a GUI CMusic composer
>	being built from a good set of libraries, even ones that spit
>	out Perl code to be later run as a composition.

Hmmm... I see your point. Still, I want to keep the focus on making it
very, very fast and intuitive to write music -- er, code -- using this
module.

>: Probably at this point it would be helpful if I gave an example of
>: what I want to be able to do.
>	>snip<
>	You might want to check out the Data::Dumper and/or Storable
>	modules to make saving/reading such structures very easy.

Thanks, will do.

>	Moving to OO wouldn't mean much more then moving some of this
>	around:
>
>	my $verse1 = CMusic->new ("some-score-file.sco", [ 4 .. 10 ]);
>	my $verse2 = CMusic->new ("some-other-score-file.sco", [ 0 .. 20 ]);
>
>	$verse1->play (2);
>	$verse1->rewind();
>	$verse2->play (2);
>
>	$verse2->shuffle_pfield ($verse2->pfield(5, beats(4 to 9),  *= 2));
>	$verse2->play();

Ah. That clarifies things a lot. (Maybe my problem with the OO
examples I've seen was that they didn't have a direct comparison to
something I already understood...)

And it forces me to clarify something else: this looks like it would
alter the data stored in the object permanently. Occasionally, this is
explicitly desirable; but most of the time, I'd want to be working on
a temporary copy of the stored pattern before playing it. 

So in traditional programming style, I'd have a function load_pattern(
some_pattern_name )  that loads the named pattern into a L.o.L., let's
call it @current. The data in @current would be accessible like
$current[$line][$pfield], and this is the data that  most of my
functions would work on by default. In the cases where we DO want to
store the current L.o.L. into a named pattern, all it would take would
be a function store_current( some_pattern_name ) to do that... So
load_pattern(), save_current(), pattern_from_file() would usually be
the only things that would directly access the H.o.L.o.L data, but
there'd be nothing to prevent a user from directly reading or writing
any particular $HoLoL{$pattern_name}[$line][$pfield] any time they
felt like it.

So, how might I go about that? Maybe something like:

$verse1 -> load;
$current - > $pfield(5, beats(4 to 9),  *= 2));
$current - > play;

The only bummer about that is I can't see how to avoid having to type
"$current" a thousand times in one composition ... it would be nice to
be able to assume $current unless otherwise specified...

>: Are there some existing Perl modules that might be useful? (I
>: haven't found any yet...)
>
>	I think I remember some MIDI stuff once upon a time.  Check
>	CPAN for "MIDI" and "sound": www.cpan.org

I have looked around CPAN, and you're right, I forgot there was a MIDI
module. Maybe I should take another look at that... it might have some
useful concepts or even code...

PW
==============================================================
Paul Winkler  ---   music & sound   ---   zarmzarm@hotmail.com
              http://members.tripod.com/~slinkP/
                       a  member  of
           ARMS --- an ongoing pop music experiment
       http://members.tripod.com/~slinkP/mini-arms.html
==============================================================


------------------------------

Date: Tue, 10 Nov 1998 05:56:36 GMT
From: Brad Rogers <rogersb@home.com>
Subject: Re: Parallel to Serial
Message-Id: <355C2643.D4A53174@home.com>

can you describe the parallel to serial converter? could it be that the serial
port side is attempting to establish a link and keeps sending out that char?  What
cable is used, and what signaling is going on?   cts rts dtr dsr   null modem,
link, etc

eric.wai@bcs.org.uk wrote:

> Hi,
>
> I am trying to hook up the Parallel Port on a PC with the Serial Port on a SUN
> running Solaris 2.5.1.  When the PC sends a file to the printer/parallel port,
> it will be captured by the SUN.
>
> Signal from the Parallel Port will go thru a Parallel-to-Serial converter and
> convert to serial signal before it is fed into the ttya of the SUN box.  For
> example, if I do "echo hello world > lpt1".  The text will get convert to
> serial signal and pump into the Serial port of the Solaris machine.
>
> Since it is the first step of my project, I have written a simple Perl program
> on the SUN and try to capture the signal.
>
> #!/usr/local/bin/perl5 -w
> open(COM_PORT, "< /dev/ttya") || die "cannot read from /dev/ttya\n";
> while (! (eof COM_PORT)) {
>     $char = getc COM_PORT;
>     print "(",ord $char,")(",$char,")\n";
> }
> close COM_PORT;
> exit;
>
> As expected, "hello world" is captured by my program.  However, the PC keeps
> sending the newline character (ascii 10) to the SUN.  If I keep the set
> up/program running, my SUN will end up crashed with error message
> "output_echo_char: out of blocks" appears on the console.
>
> Can anyone tell me why the PC keeps sending out the newline character after
> "hello world", and how could I stop it.
>
> Thanks in advance.
>
> Eric.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



------------------------------

Date: Tue, 10 Nov 1998 04:22:42 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Querying the OS.
Message-Id: <Pine.GSO.4.02A.9811092015230.2742-100000@user2.teleport.com>

On Tue, 10 Nov 1998 mlentz@my-dejanews.com wrote:

> Ho do I query the OS from perl?  

Maybe your system provides a system call that you're looking for.

> I'm trying to get the number of open files I can have at one time.

Bear in mind that there may be reasons you can't open so many as your
system may seem to otherwise permit. For example, perl itself needs to be
able to open some files from time to time.

> I believe this is in sys/param.h, but is there a way to check this
> file within perl?  Can I just use $FileCache::maxopen?

As the docs for the FileCache module point out, sometimes the sys/param.h
lies. But if you want to read the sys/param.h file for yourself, that's
fine; see how the FileCache module does it. Or, (ask your program's users
to) use h2ph on sys/param.h, perhaps. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: 10 Nov 1998 00:48:19 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: sysread() Question
Message-Id: <x7pvawayjg.fsf@sysarch.com>

>>>>> "TP" == Tom Phoenix <rootbeer@teleport.com> writes:

  TP> On 9 Nov 1998, Uri Guttman wrote:
  BD> My ultimate goal is to determine if the contents of this buffer 
  BD> is all zeros.
  >> 
  >> this should work:
  >> 
  >> $buffer =~ /^\x00*$/

  TP> This should work somewhat more reliably:

  TP>     my $naught_but_nulls = ($buffer =~ /^\0*(?!\n)$/);

  TP> The first could be mistaken if the last byte in the buffer happens to be
  TP> the newline character. Hope this helps!

just because TIMTOWTDI i found a few other methods. the benchmark
results are a little confusing.

$buf = "\x00" x 100 ;

$len = length( $buf ) ;

$buf = "\x00" x 100 ;

$len = length( $buf ) ;

$zero_buf = "\0" x $len ;

timethese (1 << 13, {
		eq => sub { $buf eq $zero_buf }, 
		regex => sub { $buf =~ /^\0*(?!\n)$/ },
		regex2 => sub { $buf =~ /[^\0]/ },
		tr => sub { ( $buf =~ tr/\0// ) == length( $buf ) }, 
		tr2 => sub { ( $buf =~ tr/\0//c ) }, 
	}
) ;

this is length = 100

Benchmark: timing 8192 iterations of eq, regex, regex2, tr, tr2...
        eq:  2 wallclock secs ( 0.81 usr +  0.00 sys =  0.81 CPU)
     regex:  2 wallclock secs ( 1.63 usr +  0.00 sys =  1.63 CPU)
    regex2:  2 wallclock secs ( 1.28 usr +  0.00 sys =  1.28 CPU)
        tr:  2 wallclock secs ( 1.60 usr +  0.00 sys =  1.60 CPU)
       tr2:  0 wallclock secs ( 1.32 usr +  0.00 sys =  1.32 CPU)

this is length = 1000

Benchmark: timing 8192 iterations of eq, regex, regex2, tr, tr2...
        eq:  1 wallclock secs ( 2.04 usr +  0.00 sys =  2.04 CPU)
     regex:  4 wallclock secs ( 3.27 usr +  0.00 sys =  3.27 CPU)
    regex2:  5 wallclock secs ( 4.35 usr +  0.00 sys =  4.35 CPU)
        tr:  2 wallclock secs ( 3.44 usr +  0.00 sys =  3.44 CPU)
       tr2:  3 wallclock secs ( 4.17 usr +  0.00 sys =  4.17 CPU)

this is length = 10000

Benchmark: timing 8192 iterations of eq, regex, regex2, tr, tr2...
        eq: 15 wallclock secs (13.55 usr +  0.00 sys = 13.55 CPU)
     regex: 21 wallclock secs (19.67 usr +  0.00 sys = 19.67 CPU)
    regex2: 37 wallclock secs (34.90 usr +  0.00 sys = 34.90 CPU)
        tr: 23 wallclock secs (21.74 usr +  0.00 sys = 21.74 CPU)
       tr2: 36 wallclock secs (33.25 usr +  0.00 sys = 33.25 CPU)

so depending on the length of the buffer various methods are faster. the
tr and tr2 methods are faster than regex until the string get so 10k in
length. so what does the regex do that speeds it up for longer strings?
is it that study type algorithm of preindexing all the first locations
of chars?

why does regex always beat regex2 which would seem simpler?

why does regex2 beat all 100 and lose at 10k? why does tr2 beat tr at
100 but lose badly at 10k?

these and other fascinating benchmark questions may be answered by some
other investigative hackers. so stay tuned, same perl time, same perl
channel!

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: 10 Nov 1998 06:27:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: sysread() Question
Message-Id: <728mcr$bsf$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Phoenix 
<rootbeer@teleport.com>],
who wrote in article <Pine.GSO.4.02A.9811091818320.2742-100000@user2.teleport.com>:
> This should work somewhat more reliably:
> 
>     my $naught_but_nulls = ($buffer =~ /^\0*(?!\n)$/);

And do not forget that in 5.005 this is just /^\0*\z/.

Ilya


------------------------------

Date: 10 Nov 1998 06:32:53 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: sysread() Question
Message-Id: <728mml$c2i$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Uri Guttman 
<uri@sysarch.com>],
who wrote in article <x7pvawayjg.fsf@sysarch.com>:
> 		regex => sub { $buf =~ /^\0*(?!\n)$/ },
> 		regex2 => sub { $buf =~ /[^\0]/ },

> why does regex always beat regex2 which would seem simpler?

Supposedly slurp-all-\0 is optimized better than
skipper-to-the-first-[^\0].  After all, \0 is a const-char, while
[^\0] is a particular case of a (possibly) complicated pattern, so the
code to match against them is different.

(Note that this note is the after-the-fight-ends thought.  regex
vs. regex2 would be pretty hard to resolve by just exercising your
brain, without actual benchmarks.)

Ilya


------------------------------

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 4186
**************************************

home help back first fref pref prev next nref lref last post