[8868] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2485 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 3 19:06:46 1998

Date: Sun, 3 May 98 16:00:27 -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, 3 May 1998     Volume: 8 Number: 2485

Today's topics:
    Re: Calling another script... <admin@hatsoft.com>
        Client Server question. <jtownsen@computational.com>
    Re: Client Server question. (Jonathan Stowe)
    Re: DBI Oracle for HPUX 10 without Pro*C <Jacqui.Caren@ig.co.uk>
        endians <lj25+@andrew.cmu.edu>
    Re: Exporting vs. "direct" access <rootbeer@teleport.com>
    Re: Exporting vs. "direct" access (John Siracusa)
    Re: extracting a sub-string (Kevin Reid)
    Re: HELP Me PLEASE! <miki@bv.net>
    Re: help wanted (trivial) <horowitz@ulb.ac.be>
    Re: malformed header? <rjk@coos.dartmouth.edu>
    Re: malformed header? (Jonathan Stowe)
    Re: newbie, how to extract line n from a file <danboo@negia.net>
    Re: Passing type AV * ? <siddiqi-kaleem@cs.yale.edu>
        PErl Functions (Destini T. Butler)
    Re: PErl Functions <btate@primary.net>
    Re: PErl Functions <tchrist@mox.perl.com>
    Re: PErl Functions (Jonathan Stowe)
    Re: Perl script doesn't work (Jonathan Stowe)
        Please help me! <agjemmes@virtualis.com>
    Re: Problem evaluating scalars (Kevin Reid)
    Re: Serial port ... again (Andrew M. Langmead)
        Strange problem. <btate@primary.net>
        traverse a hash (Ask Bjoern Hansen)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 3 May 1998 12:20:30 -0700
From: "Henry Wolff" <admin@hatsoft.com>
Subject: Re: Calling another script...
Message-Id: <354cc37a.0@news.greatbasin.net>

I am assuming you use a perl script to generate the HTML
print "<!--exec:ads.cgi-->";
which is a server side include which will not work because the server never
parses it as an HTML file so never sees it as a SSI.

You need to use a shell or exec command.

Henry Wolff
Send Some Virtual Postcards - FREE
http://www.hatsoft.com/webcard/index.html

University Student wrote in message <354CA939.403A1B57@spam-sucks.com>...
>I use a complicated Perl Script for a BBS. I need to put a randomizzed
>ad graphix on each time someone views a message on the BBS. I know where
>to insert the script, but it doesn't work.
>
>print "<!--exec:ads.cgi-->";
>
>does not work. So I try to call the AD script :
>
>$something = ../../ads/ad.cgi;
>print " $something ";
>
>
>and all that is printed on the screen via the browser
>is some 5 digit number... Not the actuall add....
>I am so frustrated with this!
>
>
>Can anyone help?





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

Date: Sun, 03 May 1998 16:32:09 -0400
From: James Townsend <jtownsen@computational.com>
Subject: Client Server question.
Message-Id: <354CD449.261EB624@computational.com>

Hi,

I am using the example client server programs that come with
Activestate's Perl for Win 32.  What I need is a little help in getting
the server to send results back to the cleint.  Currently, the client
sends a message to the server which then processes the command.  Now, I
will like to see the results of the command on the client.  Help.


Server.

#tcp-server
($port) = @ARGV;
$port = 2345 unless $port;

$AF_INET = 2;
$SOCK_STREAM = 1;

$sockaddr = 'S n a4 x8';

($name, $aliases, $proto) = getprotobyname('tcp');
if ($port !~ /^\d+$/) {
    ($name, $aliases, $port) = getservbyport($port, 'tcp');
}

print "Port = $port\n";

$this = pack($sockaddr, $AF_INET, $port, "\0\0\0\0");

select(NS); $| = 1; select(stdout);

socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!";
bind(S,$this) || die "bind: $!";
listen(S,5) || die "connect: $!";

select(S); $| = 1; select(stdout);

print "Listening for connection....\n";

($addr = accept(NS,S)) || die $!;

print "accept ok\n";

($af,$port,$inetaddr) = unpack($sockaddr,$addr);
@inetaddr = unpack('C4',$inetaddr);
print "$af $port @inetaddr\n";

while (<NS>) {
    print;

}
close(NS);


Client:

#tcp-client
( $them, $port ) = @ARGV;

$port = 2345 unless $port;
$them = 'localhost' unless $them;

$AF_INET = 2;
$SOCK_STREAM = 1;

$SIG{'INT'} = 'dokill';
sub dokill {
    kill 9,$child if $child;
}

$sockaddr = 'S n a4 x8';

#chop($hostname = `hostname`);

($name,$aliases,$proto) = getprotobyname('tcp');
($name,$aliases,$port) = getservbyname($port,'tcp')
    unless $port =~ /^\d+$/;;
($name,$aliases,$type,$len,$thisaddr) =
 gethostbyname($hostname);
($name,$aliases,$type,$len,$thataddr) = gethostbyname($them);

$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);

if (socket(S, $AF_INET, $SOCK_STREAM, $proto)) {
    print "socket ok\n";
}
else {
    die $!;
}

if (bind(S, $this)) {
    print "bind ok\n";
}
else {
    die $!;
}

if (connect(S,$that)) {
    print "connect ok\n";
}
else {
    die $!;
}

select(S); $| = 1; select(STDOUT);

while( <STDIN> ) {
    print S;
}


Thanks,

Jim Townsend



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

Date: Sun, 03 May 1998 22:58:01 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Client Server question.
Message-Id: <354cecf2.8589830@news.btinternet.com>

On Sun, 03 May 1998 16:32:09 -0400, James Townsend wrote :

>Hi,
>
>I am using the example client server programs that come with
>Activestate's Perl for Win 32.  What I need is a little help in getting
>the server to send results back to the cleint.  Currently, the client
>sends a message to the server which then processes the command.  Now, I
>will like to see the results of the command on the client.  Help.
>

<snip examples>

You might look at the small HTTP server example that was posted by
brian d foy last week in a thread with a subject line:

HTTP Request Headers

You will notice that this uses the Socket module which comes with
Perl.  There is also a module IO::Socket module which provides a level
of abstraction to the socket functions.

A client will basically do similar things: it will typically send its
request on the open socket and then read back all the data that is
sent from the server then close the connection and do whatever it
wants with the data.

For a production strength server on Windows you may have to overcome
the problem of not having fork.  A unix based server will typically
fork a new process after the accept to process the request so it can
go straight back and accept more connections.  You cant do that with
windows (Unless you compile your own perl with CygWin32, but enough of
that or Jonathan Feinberg will get his voodoo doll of me out again.).
How to overcome this is left as an exercise.

For most of the common network applications you will probably find a
module on CPAN that implements it : HTTP,SMTP,NNTP etc etc so in
reality you might actually avoid writing sockets code unless of course
you find yourself working with a novel protocol (then you make a new
module and post it to CPAN so the next guy doesnt have to reinvent the
wheel  ;-})

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sun, 3 May 1998 19:27:23 GMT
From: Jacqui Caren <Jacqui.Caren@ig.co.uk>
Subject: Re: DBI Oracle for HPUX 10 without Pro*C
Message-Id: <EsEBDo.MrK@ig.co.uk>

In article <6gjeva$55b$1@nnrp1.dejanews.com>,  <Danny_Aldham@bctel.com> wrote:
>I would like to use the DBI::Oracle module to access some Oracle
>data via perl cgi scripts. But, I do not have the Pro*C library
>required to build the module. Does anyone have a binary distribution
>I could borrow?

Dont event think about it - unless you are both using exactly the same
arch, OSVER patchlevel and installations of oracle, including oracle
OFA paths etc, then you will hit problems such as the

   "I can't create tables anymore!"

The documentation is being/has been updated to reflect the fact that
DBD::Oracle DOES NOT rely upon Pro*C but OCI, which seems to move
about quite a bit under different perl releases etc. If you don't
have PRo*C then follow the guidelines about how to find your OCI
libs and install DBD::Oracle - this does not work for all
versions/platforms of Oracle though.

p.s.
	this is probably not the best place to talk "DBI" - try the
dbi-users list - see http://www.hermetica.com/technologia/DBI/

This URL may have changed recently and I don't have the new name.

Jacqui
-- 
Email: Jacqui.Caren@ig.co.uk  http://www.ig.co.uk/
Fax  : +44 1483 419 419       http://www.perlclinic.com/
Phone: +44 1483 424 424       http://www.perl.co.uk/
Paul Ingram Group Ltd,140A High Street,Godalming GU7 1AB United Kingdom



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

Date: Sun,  3 May 1998 18:21:33 -0400
From: Lee W Jones <lj25+@andrew.cmu.edu>
Subject: endians
Message-Id: <gpHCrhi00YUp0ecG40@andrew.cmu.edu>


Hi!

I'm working with large binary data files across different system
architectures (SUN -> INTEL) where the endian order is not the same. 
Perl has a builtin template structure for unpacking endian specific
integers, but I can't find any documentation on pulling out endian
specific floats, doubles, etc.  Is there an easy way of doing this or is
it going to be a matter of writing the routines in C and calling them
externally?

Am I just missing something obvious?

Any advice appreciated!
thanks
lee 


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

Date: Sun, 03 May 1998 19:19:18 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: John Siracusa <macintsh@cs.bu.edu>
Subject: Re: Exporting vs. "direct" access
Message-Id: <Pine.GSO.3.96.980503120159.21603Q-100000@user2.teleport.com>

On 3 May 1998, John Siracusa wrote:

> 	use constant CONST => "hello";
> 	...
> 
> 	s/@{[CONST]}/foo/o;
> 
> Is the "o" necessary?  

No, but it doesn't hurt anything.

> Am I to assume that Perl understands this and that it'll replace
> @{[CONST]} with a hard value at compile time? 

Here's a way to find out: Let's redefine the constant's sub.

    use constant CONST => "fred";
    for my $count (1..2) {
	print "$count: CONST is now ", &CONST, ".\n";

	$_ = "I saw fred and barney.";
	s/@{[CONST]}/wilma/;	# Replace CONST with wilma
	print "$count: $_\n";

	eval q{ sub CONST () { 'barney' } };	# Redefine it
    }

When you run this normally, you'll see that the explicit call to CONST
shows you the (redefined) sub, while the substitution is using the
original (compiled-in) value. If you run it under the debugger, though,
you'll get a surprise - optimization is turned off, so the sub is actually
called each time!

In normal usage, a scalar constant will be recognized as such by Perl.
Hope this helps! 

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



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

Date: 3 May 1998 21:48:29 GMT
From: macintsh@cs.bu.edu (John Siracusa)
Subject: Re: Exporting vs. "direct" access
Message-Id: <6iiond$fuc$1@news1.bu.edu>

Tom Phoenix (rootbeer@teleport.com) wrote:
: When you run this normally, you'll see that the explicit call to CONST
: shows you the (redefined) sub, while the substitution is using the
: original (compiled-in) value. If you run it under the debugger, though,
: you'll get a surprise - optimization is turned off, so the sub is actually
: called each time!

Gah!  Is that a bug or a "feature"?  Thanks for all the help!

-----------------+----------------------------------------
  John Siracusa  | If you only have a hammer, you tend to
 macintsh@bu.edu | see every problem as a nail. -- Maslow


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

Date: Sun, 3 May 1998 18:00:27 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: extracting a sub-string
Message-Id: <1d8eq96.v1h3a41xnjeekN@slip-32-100-246-138.ny.us.ibm.net>

Paul Farber <farber@f-tech.net> wrote:

> Hello all, 
> 
> Perl is good, regular (m/// s/// tr///) epressions are killing me.
> 
> How the heck do you pull a string from sentence???
> 
> The info I need is between < and >, split won't work as the placement
> of the  < > will vary, so I need an expression to rip out this string
> and put it into a scalar.

$_ = "This <is the> example";

# method 1
/<(.*)>/;
$result = $1;

# method 2 
($result) = /<(.*)>/;

# method 3
$result = (/<(.*)>/)[0];

> Should I put the sentence into @sentence and POP off each word?  

No.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Sun, 03 May 1998 18:39:41 -0400
From: Aaron Faby <miki@bv.net>
Subject: Re: HELP Me PLEASE!
Message-Id: <354CF22D.95F19C3F@bv.net>

Umm... IE is the problem, get Netscape.

Aaron

Alex wrote:

> Hello,
>          I have a problem, I cannot chat in Java chats because I cannot type
> in the fields. I use Windows 98 1702 beta with IE. Help me, please. What is
> wrong?
>
> Sincerly,
>
> Alex.





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

Date: Sun, 03 May 1998 17:15:16 -0600
From: Joel Horowitz <horowitz@ulb.ac.be>
To: fantha@berlin1.netsurf.de
Subject: Re: help wanted (trivial)
Message-Id: <6iiq9l$o6v$1@nnrp1.dejanews.com>


> print "Bitte geben Sie eine Farbe ein :";
> $farbe = <STDIN>;
>
> # print $farbe;
> #
> # This only was a test, to see if $farbe contains data
> # It does !
>
> print $COLORS{$farbe};

In addition to the other answer which explain you why there is an error, I
advise you to use something like

	sub debugprint { $var=shift;
			 print "The value of $var is <${$var}>\n"; }

so you would type

	$v="Hello\n";
	&debugprint(v);

and get:

The value of v is <Hello
>

Which immediately shows that there's a newline in your Hello...

	This can sometimes save a lot of trouble...

	Joel Horowitz

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Sun, 03 May 1998 14:57:01 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
To: star@sonic.net
Subject: Re: malformed header?
Message-Id: <354CBDFF.A0B105E7@coos.dartmouth.edu>

[posted and mailed]

~arthur wrote:
> 
> Anyone know why I get the ole' malformed header message when i try and
> get the following program on the net.

Could it be related to the fact that the program doesn't compile?  Duh!

As you are obviously aware, since you noticed several compilation errors, including:

> # syntax error, near "my"
> File 'StarMax HD:Desktop Folder:Mac_Perl:extra folder:ice_cream_stand';
> Line 13

>From the perldiag documentation:

     syntax error
         (F) Probably means you had a syntax error.  Common reasons include:

             A keyword is misspelled.
             A semicolon is missing.
             A comma is missing.
             An opening or closing parenthesis is missing.
             An opening or closing brace is missing.
             A closing quote is missing.

I'll give you a hint; your syntax error is caused by one of those reasons.

-- 
 _ / '  _      /         - 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: Sat, 02 May 1998 08:48:08 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: malformed header?
Message-Id: <354ad812.26002703@news.btinternet.com>

On Sun, 03 May 1998 10:54:24 -0800, ~arthur wrote :

>Hi,
>Anyone know why I get the ole' malformed header message when i try and
>get the following program on the net. the problem is O"Reilly's llama
>book, Learning Perl page 190-----

The problem is unlikely to be the book. There are books out there with
bad examples in but I doubt that this is one of them. What I think you
have here is the ole "Too many typos error" possibly combined with a
misunderstanding of the use of if..else construct in the second use of
else towards the end.  Those error messages give a fairly clear
pointer as to where the problems lie however the line number given is
for the point where Perl realizes there is a problem and not the line
on which the actual mistake occurred.

/J\ 
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sun, 03 May 1998 14:49:26 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: newbie, how to extract line n from a file
Message-Id: <354CBC36.36A41EFD@negia.net>

Gregory J. Sandell wrote:
> 
> Hi, perl newbie here.  Can someone tell me how I would grab a line from
> a file and assign it to a variable?  For example if I had a file FOO
> consisting of the lines
> 
>         Hey there
>         What's up?
>         Let's go
> 
> I want to be able to say
>         $myline=getline(2);
> 
> And have $myline == "What's up?"

what are your current troubles? it's difficult to diagnose your
problem without seeing your attempts (i.e., code), or at least
an explanation of where you're getting tangled.

here are two ways to do it:

1. read the whole file into a list, and grab the index which
is one less than the line number you want. this could be bad with
large files.

2. iterate through the file line by line, checking the current line
number with the special varaible '$.'. once it hits the desired line
number, assign that line to your variable and break out of the loop.

cheers,

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: Sun, 03 May 1998 15:05:26 -0400
From: Kaleem Siddiqi <siddiqi-kaleem@cs.yale.edu>
Subject: Re: Passing type AV * ?
Message-Id: <354CBFF6.41C67EA6@cs.yale.edu>

> I believe the complaint means the array ref Perl
> puts on the stack doesn't look like an AV * to
> the XSUB at all - just a mere scalar. You'll have
> to pry the array nature out of the scalar.
> 
> Clear as mud ?
> 
> Try something like this:
> 
> SetArrayValue(arrayRef, width, height, val)
>     SV  *arrayRef
>     int width
>     int height
>     SV  *val
> 
>     CODE:
>     {
>        AV *array;
>        int xx,yy;
> 
>        array = (AV *) SvRV(arrayRef)
>        for (...) {
>            for(...) {
>                av_store(array, xx + yy * width, SvREFCNT_inc(val));
>            }
>        }
>      }
> 

Thanks for the tip! Can you tell me why its necessary
to increment the reference count to val, i.e., SvREFCNT_inc(val) ?

-Kaleem Siddiqi


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

Date: 3 May 1998 20:46:02 GMT
From: tabutler@newstand.syr.edu (Destini T. Butler)
Subject: PErl Functions
Message-Id: <6iil2a$g37@newstand.syr.edu>
Keywords: "DIE"

what does the Perl built in function "die" do?  and what is the snytax and
synopsis for this function





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

Date: Sun, 3 May 1998 15:48:09 -0500
From: "Bob Tate" <btate@primary.net>
Subject: Re: PErl Functions
Message-Id: <354cd833.0@news.primary.net>


Destini T. Butler wrote in message <6iil2a$g37@newstand.syr.edu>...

>what does the Perl built in function "die" do?  and what is the snytax and
>synopsis for this function

Destini,

========
 Syntax
========

die(string) or die(@list)

=========
  USAGE
=========

The die function sends the contents of "string" or "@list" to STDERR and
ceases the execution of the program.  Die is commonly used to verify that
actions, such as opening a file or directory, are completed correctly.  If
the file is unable to be opened, for example, then the string or list will
be printed on the user's screen.

Hope it helps.

Bob Tate




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

Date: 3 May 1998 22:05:20 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: PErl Functions
Message-Id: <6iipn0$j8q$1@csnews.cs.colorado.edu>
Keywords: "DIE"

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, doitboo@innocent.com writes:
:what does the Perl built in function "die" do?  and what is the snytax and
:synopsis for this function

USENET is not here to read you bedtime manpages.  See perlfunc.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    str->str_pok |= SP_FBM;                     /* deep magic */
    s = (unsigned char*)(str->str_ptr);         /* deeper magic */
        --Larry Wall in util.c from the perl source code


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

Date: Sun, 03 May 1998 22:57:59 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: PErl Functions
Message-Id: <354ce845.7420257@news.btinternet.com>

On 3 May 1998 20:46:02 GMT, Destini T. Butler wrote :

>what does the Perl built in function "die" do?  and what is the snytax and
>synopsis for this function
>
The most excellent and comprehensive documentation should be available
with every Perl distribution.  Assuming you have access to a command
prompt on the system on which perl is installed you can type:

perldoc -f die

A table of contents of all available documentation on your system can
be had with:

perldoc perltoc

You might find the documents with names beginning "perlfaq"  useful -
these are the FAQ (Frequently Asked Questions) about Perl and the
answers thereof

The documentation is also available in a variety of formats to suit
the majority of tastes.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sat, 02 May 1998 08:48:10 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl script doesn't work
Message-Id: <354adc38.27035183@news.btinternet.com>

On Sat, 02 May 1998 07:59:45 GMT, Jonathan Stowe wrote :
>
>Well I took a cursory grant at your code.

Apologies to the confused : that should be "a cursory glance" of
course.  Obviously spent too long in the Kings Head earlier.

/J\ 
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 3 May 1998 22:13:17 GMT
From: "Asbjorn Gjemmestad" <agjemmes@virtualis.com>
Subject: Please help me!
Message-Id: <01bd76e0$b1484fa0$1aad4382@asbj-rng>

I am in desperate need for someone to help me debug a perl script.
The work shouldn't take more than half an hour, and you will get
compensation for your work if requred.

Please email me ASAP!!!

Asbjorn (agjemmes@online.no)


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

Date: Sun, 3 May 1998 18:00:24 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Problem evaluating scalars
Message-Id: <1d8dexp.5j0k9z1ysyxwuN@slip-32-100-246-138.ny.us.ibm.net>

Mihails Nikitins <nikitins@infoservriga.lv> wrote:

> Hello PERL experts,
> 
> I have a stupid problem evaluating strings being read from a text file.
> 
> I'd like to substitute scalar names with its values for some pattern text
> file looking like:
> Some preformatted text $some $good $values
> 
> Imagine a simple text file containing one string:
> $name is cool
> 
> Here are 4 lines of code:
> *********************
> $name = "PERL";
> open( IN, "text.txt" );
> $string = <IN>;
> print $string;
> *********************
> The program prints out
> $name is cool
> instead of the desired
> PERL is cool
> 
> How can I force PERL to substitute $name with its value in a very simple
> manner? Function eval tries to evaluate 'is' and 'cool'. It works
> correctly only if $name is the only word in the string.

print eval qq{
  "$string";
};

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Sun, 3 May 1998 21:03:21 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Serial port ... again
Message-Id: <EsEFtL.LI9@world.std.com>

mcai3ph2@ist4.co.umist.ac.uk (Pablo Hortal) writes:

>I'm after some code to read data comming from the serial port (Windows 95 
>system), I already know how to write to it.


Someone posted a message stating that they were working on a
Win32::Serial module. Information is at
<URL:http://members.aol.com/Bbirthisel>

-- 
Andrew Langmead


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

Date: Sun, 3 May 1998 15:43:50 -0500
From: "Bob Tate" <btate@primary.net>
Subject: Strange problem.
Message-Id: <354cd733.0@news.primary.net>

This is a multi-part message in MIME format.

------=_NextPart_000_0096_01BD76AA.4507D120
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Here is a strange problem that I am seeing.  It is so strange that I =
know there must be a simple answer.

< Begin code block>

#################
# Set Variables #
#################
$filedate =3D "";
$filesafe =3D 0;
$newdir =3D 0;

###################################
# Open the Flight Training Record #
###################################

open(FILE,"FTR.TXT");
while(<FILE>)
{
   $database_row =3D $_;

   if (substr($database_row,0,10) eq "1REPORT NO")
   {
      # Read the first line and hold it until we know whos=20
      # record to put it with.

      $filesave =3D 0;  # reset the save indicator to off
      $filedate =3D substr($database_row,83,5); =20
      $holdline =3D substr($database_row,1,131);
      if ($newdir =3D=3D 0)
      {
         mkdir($filedate,777); # Make the director to store the info in
         $newdir =3D 1;
      }

   }

   if (substr($database_row,0,22) eq "0***EXCEPTION*** REGNO")
   {
      # get the PRN of the pilot we are looking at.
      $filesave =3D 1;  # set the file save indicator to on.  We now =
know who it is.
      $prn =3D substr($database_row,22,7);  =20
      $workline =3D substr($database_row,1,131);
      open(PRN,">>$filedate/$prn.dat");
      print PRN "$holdline\n";
      print PRN "$workline\n";
      close(PRN);
   }

   if ($filesave =3D=3D 1)
   {
      # start to save the info in the file.

      $workline =3D substr($database_row,1,131);
      open(PRN,">>$filedate/$prn.dat");
      print PRN "$workline\n";
      close(PRN);
      chmod (0777,"$filedate/$prn.dat");
   }
}
close(FILE);

<End code block>

This code, as it is now, appears to work fine.  It will create the =
directory and then create all 2000+ files in that directory.   When I =
examine the directory after the program runs I get what appears to be a =
valid directory, however, when I try to view one of the files I am told =
that it is an "invalid file or directory".

Any one got any ideas?

Bob Tate

"It is the simple problems that are the hardest to resolve -- R. E. =
Tate"


------=_NextPart_000_0096_01BD76AA.4507D120
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>Here is a strange problem that I am=20
seeing.&nbsp; It is so strange that I know there must be a simple=20
answer.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&lt; Begin code =
block&gt;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>#################<BR># Set Variables =

#<BR>#################<BR>$filedate =3D &quot;&quot;;<BR>$filesafe =3D =
0;<BR>$newdir=20
=3D 0;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 =
size=3D2>###################################<BR># Open=20
the Flight Training Record =
#<BR>###################################</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000=20
size=3D2>open(FILE,&quot;FTR.TXT&quot;);<BR>while(&lt;FILE&gt;)<BR>{<BR>&=
nbsp;&nbsp;=20
$database_row =3D $_;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; if =
(substr($database_row,0,10) eq=20
&quot;1REPORT NO&quot;)<BR>&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #=20
Read the first line and hold it until we know whos=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # record to put it with.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$filesave =3D=20
0;&nbsp; # reset the save indicator to =
off<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$filedate =3D substr($database_row,83,5);&nbsp; =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$holdline =3D =
substr($database_row,1,131);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if=20
($newdir =3D=3D 0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
mkdir($filedate,777); #=20
Make the director to store the info=20
in<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $newdir =3D=20
1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; if =
(substr($database_row,0,22) eq=20
&quot;0***EXCEPTION*** REGNO&quot;)<BR>&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # get the PRN of the pilot we are =
looking=20
at.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $filesave =3D 1;&nbsp; # set the =
file save=20
indicator to on.&nbsp; We now know who it =
is.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$prn =3D substr($database_row,22,7);&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $workline =3D=20
substr($database_row,1,131);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
open(PRN,&quot;&gt;&gt;$filedate/$prn.dat&quot;);<BR>&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
print PRN &quot;$holdline\n&quot;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
print PRN=20
&quot;$workline\n&quot;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
close(PRN);<BR>&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp; if ($filesave =3D=3D =
1)<BR>&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # start to save the info in the=20
file.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$workline =3D=20
substr($database_row,1,131);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
open(PRN,&quot;&gt;&gt;$filedate/$prn.dat&quot;);<BR>&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
print PRN &quot;$workline\n&quot;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
close(PRN);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chmod=20
(0777,&quot;$filedate/$prn.dat&quot;);<BR>&nbsp;&nbsp;=20
}<BR>}<BR>close(FILE);</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&lt;End code block&gt;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>This code, as it is now, appears to =
work=20
fine.&nbsp; It will create the directory and then create all 2000+ files =
in that=20
directory.&nbsp;&nbsp; When I examine the directory after the program =
runs I get=20
what appears to be a valid directory, however, when I try to view one of =
the=20
files I am told that it is an &quot;invalid file or=20
directory&quot;.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Any one got any ideas?</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Bob Tate</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>&quot;It is the simple problems that =
are the=20
hardest to resolve -- R. E. Tate&quot;<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_0096_01BD76AA.4507D120--



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

Date: Sun, 03 May 1998 21:59:21 +0200
From: ask@cs.nospam.netcetera.dk (Ask Bjoern Hansen)
Subject: traverse a hash
Message-Id: <ask-0305982159210001@balder.netcetera.dk>

In article <Pine.GSO.3.96.980427153340.18175A-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:

> foreach is not the best way to
> traverse a hash - using each within a while loop is generally better.

Why is that?  (if it's not a faq)



ask


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2485
**************************************

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