[10436] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4029 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 21 06:03:19 1998

Date: Wed, 21 Oct 98 03:00:22 -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           Wed, 21 Oct 1998     Volume: 8 Number: 4029

Today's topics:
        -Help Please-: Efficiency of substr vs. join for string chunkstar@my-dejanews.com
    Re: Assigning to $! <erhmiru@erh.ericsson.se>
    Re: Boston.pm will be Quiz Kings [was] Randal's Big Day (Larry Rosler)
    Re: Help: string variable $patTar in s/$patSrc/$patTar (Tad McClellan)
        LDAP (Tng Teng Boon David)
    Re: LWP documentation (Koos Pol)
    Re: New Module: File::Finder -- OO version of File::Fin (Ilya Zakharevich)
    Re: PERL ADO ODBC (Thomas)
        Probs w/ redirection and capture of STDERR/STDOUT <silversurf@seanet.com>
    Re: Probs w/ redirection and capture of STDERR/STDOUT (Tad McClellan)
    Re: Question... (Jerzy Orzeszek)
    Re: Randal's Big Day in Big D dave@mag-sol.com
        read main::DATA multiple <palm@gfz-potsdam.de>
        round a value dwiesel@my-dejanews.com
        round a value dwiesel@my-dejanews.com
    Re: Scotch drinkers Unite! [was] Re: Raleigh.pm (Raleig <showie@uoguelph.ca>
    Re: Scotch drinkers Unite! [was] Re: Raleigh.pm (Raleig <eashton@bbnplanet.com>
    Re: Scotch drinkers Unite! [was] Re: Raleigh.pm (Raleig (Larry Rosler)
    Re: serial port IO? module? (Alexander Trump)
    Re: serial port IO? module? (Joonas Timo Taavetti Kekoni)
    Re: serial port IO? module? <erhmiru@erh.ericsson.se>
    Re: serial port IO? module? <griessl@ihs.ac.at>
    Re: Socket Listner (Craig Berry)
        Testing a date <jjover@andorra.ad>
        undef $1 ??? dwiesel@my-dejanews.com
    Re: what is strlen() in perl? <erhmiru@erh.ericsson.se>
    Re: What isn't Perl good for? (Larry Rosler)
    Re: What isn't Perl good for? <swedel@spiff.tymnet.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 21 Oct 1998 05:09:33 GMT
From: chunkstar@my-dejanews.com
Subject: -Help Please-: Efficiency of substr vs. join for string manipulation ?
Message-Id: <70jqad$ja1$1@nnrp1.dejanews.com>

Hello.

  I have perused the newsgroups and FAQ's, but have not found an explicit
answer to my current dilemma.  I am trying to create a new string from a
combination of literal strings, interpolated strings and substrings in a
run-time efficient manner.  I will sacrifice memory for speed, but dual
efficiency would be nice :-).  I must retain the original string, so I don't
think I can do a direct replacement/insert job using something like substr(
$mystring, n, 0 ) = $replacement.  In C/C++ I would use something like
&mystring[offset] to get my "temporary" substring without extra allocation
and tag it on the end of a new string using strcat or memcpy.  In Perl, it
seems that the only way to do this is using a temporary ( resulting in an
extra allocation that may be potentially slow with large strings ).

     To illustrate what I am trying to do, here is my Perl snippet:

sub stringmanipulator {
   my $originalstring = shift;
   my $interpolate = shift;

   my $datapos = index( $originalstring, "KEYWORD" );
   if ( $datapos == -1 ) {
      die 'Didn't find KEYWORD';
   }
   $datapos += 7;   # find the text after the keyword ( assumes longer string)

   my $tempstring = substr( $originalstring, $datapos );
   my $newstring =  join( "", "EXTRA STUFF$interpolate", $tempstring );

   return $newstring;   # return new string - $tempstring discarded
}

     If I understand correctly, the $tempstring creation using substr will
create a new string of size @originalstring - ($datapos + 7 ).  The $newstring
creation with join also creates a new string with $tempstring 's data preceded
by "EXTRA STUFF$interpolate".  The $tempstring could take a bit of space and
time to create if it is large, right ?

     Is it more run-time ( cycles ) and/or space efficient to replace the
end of the above sub with:

   my $tempstring = substr( $originalstring, $datapos );
   substr( $tempstring,0,0 ) = "EXTRA STUFF$interpolate";
   return $tempstring;

?? Or will it even work as intended ?


Any advice or better solution would be greatly appreciated,

     James ( a Perl newbie ).

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 21 Oct 1998 10:27:49 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: Assigning to $!
Message-Id: <laww5u1fqy.fsf@erh.ericsson.se>

John Porter <jdporter@min.net> writes:
> Michal Rutka wrote:
> > Or how about:
> >   do 'bar.pl';
> > and test $@ instead?
> 
> Because that doesn't capture whatever bar.pl writes to stdout and
> stderr, which is what the guy said he needed to capture.

The guy does not need to capture stdout. All he wants is to capture
an error message if the called script terminates abnormaly. I assume
'die' here. Of course it would not capture all writes to stderr, but
he is not asking for this.

Here is an original question:

:I want to call one perl script from another and capture any error
:messages if the called script terminates abnormally. Is there any way of
:using $! as I would with a system call ? The docs seem to say that you
:can assign to $! but my simple tests fail ... can someone offer some
:enlightment ??

Regards,

Michal


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

Date: Tue, 20 Oct 1998 21:46:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Boston.pm will be Quiz Kings [was] Randal's Big Day in Big D
Message-Id: <MPG.109706fdb107273b9898d2@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <362D5367.CC99659C@bbnplanet.com> on Wed, 21 Oct 1998 
03:33:02 GMT, Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> 
says...
 ...
> The French are pigs. My grandfather and my own father are sick over the
> 'chunnel'. Puhleez. The whole entire continent was in one way or another
> owned by brits. :)
> /me knows the flame bait in that statement.
> 
> > Z.  [Yo Rocky!  Wha'cha do with my cheesesteak?]
> 
> Yo! guy! I ate it! OK?! mmmm...I had a cheesesteak fer lunch. :)

You are now involved in three (3) threads without a shred of Perl 
content.  Isn't it time to give the rest of us a break?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 20 Oct 1998 23:14:29 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help: string variable $patTar in s/$patSrc/$patTar
Message-Id: <53nj07.uta.ln@flash.net>

windog98@my-dejanews.com wrote:

: I want to swap blank spaces and minus sign:
: My first approach (which works) is this:

: $a = "-     1000";
: $a =~ s/-( +)([0-9])/\1-\2/;
                       ^^ ^^
                       ^^ ^^

   You should be using -w to enable warnings on every Perl script.

   Yep. On every one.

   Really!

   Then you should modify your program so that no warnings are generated ;-)


: print("$a\n");
: #the output is:
: #     -1000

: However, I want to use a string variable for
: the target pattern.
      ^^^^^^^^^^^^^^

   If I'm following what you want, then you have a non-trivial
   terminology problem there.

   "pattern" make perlers think "regular expression".

   You don't want to use a variable in a regular expression.

   You want to use a variable in the replacement part of an s/// operation.

   Anyway...


: My second approach is the following:

: $a = "-     1000";
: $b = "\\1-\\2";

   If you use single quotes you won't need so many back slashes...


: print("$b\n");
: $a =~ s/-( +)([0-9])/$b/;  # use a string variable $b
: print($a);
: #the output is:
: #\1-\2000

: Why is it not working? 


   Because you only get one round of variable interpolation.

   And that is used up resolving the $b, so what's left is taken literally.


: Any kind soul to fix this?


   Flattery will get you everywhere  ;-)


------------------
#!/usr/bin/perl -w

$a = "-     1000";
$b = '"$1-$2"';
$a =~ s/-( +)([0-9])/$b/ee;
print "$a\n";
------------------


: I want to keep using the variable $b. Is it possible
: to do this?


   Empirical evidence suggests that it is indeed possible  ;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 21 Oct 1998 09:05:29 GMT
From: davidtng@merlion.singnet.com.sg (Tng Teng Boon David)
Subject: LDAP
Message-Id: <70k84p$u0v$1@mawar.singnet.com.sg>

Hi,

   I recently installed the Net-LDAPapi-1.42 package using the
   Netscape LDAP Development kit on an OSF1 (Digital) machine.

   I had to use the cc directive -taso to link the shared library.

   Everything is fine until I try to execute my application with
   (use Net:LDAPapi).  It complains with "Cannot load TASO library
   with NON-TASO executable" or something like that.

   Does anyone have a clue to this?  I do not have such a problem
   with Solaris machines.

   Any pointers would be great.  Thanks!

   Please email me direct as I may miss the response.

  
Regards,
David



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

Date: 21 Oct 1998 06:20:19 GMT
From: koos_pol@nl.compuware.com.NO_JUNK_MAIL (Koos Pol)
Subject: Re: LWP documentation
Message-Id: <70juf3$b8n@news.nl.compuware.com>


On Tue, 20 Oct 1998 16:49:50 -0500, I R A Aggie <fl_aggie@thepentagon.com>
wrote:
| In article <slrn72podi.qt.root@ernie.sesamstraat>,
| kp@multiweb.nl.NO_JUNK_MAIL wrote:
| 
| + Am I correct that URI::Escape is not mentioned anywhere in the LWP
| + docs?
| 
| As far as I can tell, no.
| 
| + I never knew I could 'man URI::Escape'...
| 
| Or just:
| 
| % perldoc URI::Escape
| 
|      NAME
|           URI::Escape - Escape and unescape unsafe characters
| 
| James

That's the other way around, bro'. How do you know it exists if it
isn't mentioned in LWP?

-- 
Koos Pol
----------------------------------------------------------------------
S.C. Pol - Systems Administrator - Compuware Europe B.V. - Amsterdam
T:+31 20 3116122   F:+31 20 3116200   E:koos_pol@nl.compuware.com

Check my email address when you hit "Reply".


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

Date: 21 Oct 1998 07:05:06 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: New Module: File::Finder -- OO version of File::Find
Message-Id: <70k132$k63$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Russ Allbery 
<rra@stanford.edu>],
who wrote in article <ylzpaqd1ux.fsf@windlord.stanford.edu>:
> You're dealing with a sparsely-populated directory structure, which
> admittedly *is* the common case, so your approach will probably be faster
> in most circumstances.  However, you will find that if you have multiple
> levels along a given path that contain >1,000 directory entries (which is
> often the case when doing things on a Usenet news spool), the algorithm
> that File::Find uses now will be faster.

You forgot to mention "on primitive file systems (as normal with
Unix)".  Though I remember that HPFS (one which is not HPFS386) has
problems with big directories too (around 100000 entries).  HPFS386
(allegedly) will not give a damn.

But this has not much to do with Perl...

Ilya


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

Date: 20 Oct 1998 22:05:13 -0700
From: nouser@nohost.nodomain (Thomas)
Subject: Re: PERL ADO ODBC
Message-Id: <tz8u30yjyie.fsf@aimnet.com>

In article <r47X1.235$4k4.73091@198.235.216.4> jhardy@cins.com (John Hardy) writes:

   Well I have looked everywhere over the past week or so and have not
   found anything worthwhile concerning PERL and ADO. Whenever you
   mention PERL accessing MSSQL you immediatley get pointed to DBI and
   DBD, Or worse ASP!  The reason why I prefer to find something
   related to PERL and ADO only is because I have heard it is becoming
   a very popular way to access SQL through PERL and is faster then
   DBI, also more portable.

I don't know whether ADO is right for your needs or not, but I have
trouble seeing how ADO could be "more portable" than DBI or ODBC.
ODBC is a standard that is supported by just about every relational
database in existence (ODBC is really a Microsoft name for an XOpen
standard).  DBI is supported by Perl on many platforms.  ADO is
basically Microsoft-only technology and closely linked to OLE and
other Microsoft-proprietary and platform specific code.

Thomas.


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

Date: Tue, 20 Oct 1998 20:57:46 -0700
From: "Colin Stefani" <silversurf@seanet.com>
Subject: Probs w/ redirection and capture of STDERR/STDOUT
Message-Id: <70jme2$4nl@q.seanet.com>

I have been working on a script that improves upon tar and is tailored for
my groups particular situation and needs. I have written a script that feed
tar a path(s) inputted by the user. I then want to capture the output of
tar's verbose generated output in file as a log of what has been tar'd.
Pretty straight forward.

My problem is this, tar ouputs to STDERR and I have had no problem capturing
STDERR and redirecting it in to a file (as you can see from my enclosed
sample). But I when this is done, all error messaging goes to the file
(since it's being fed STDERR) and the user then cannot monitor the output of
tar on their console, which is really needed in our case. I have thought of
trying to do a 'tail -f $logfile' and reading that in to the script and
spitting it back out to STDOUT, but that's horribly inefficiant. I am more
after a split of STDERR, which I don't totally redirect it's output but "T"
it or divide it, much like a unix "tee" command. Or possibly redirecting
STDERR to the file AND to STDOUT. I have tried several things with no luck,
any ideas?

here's a snippet my main 'tar' calls and where I am doing the redirect so
you can get a feeling for what I am doing. Any help is greatly appreciated!

Thank You,
colin stefani
cstefani@pinnaclestudios.com

################################################
<SNIP>

# open (OUTLOG, "> /usr/people/tapeop/logs/$outname");
#
# foreach $path_name(@paths) {
#        if ($path_name eq undef) {next;}
#        else {
#                print "\n";
#                print "Archiving $path_name to DLT $tar_drive\...\n";
#                print "\n";
#                open STDERR, ">>&OUTLOG";
#                print OUTLOG "Date: $DATE\t Done By: $USER\n","Shot:
$path_name\n";
#                open TAR, "| tar -cvf $tar_drive $path_name" || die "An
error has occurred - backup failed";
#                print OUTLOG "\n";
#        }
#        if ($num_of_shots > 1) {
#                print "$path_name back-up successful, moving on to next
shot...\n";
#        } else {
#                print "$path_name back-up successful\n";
#        }
#        $num_of_shots--;
# }


<SNIP>
#########################################################




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

Date: Tue, 20 Oct 1998 23:28:01 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Probs w/ redirection and capture of STDERR/STDOUT
Message-Id: <hsnj07.30b.ln@flash.net>

Colin Stefani (silversurf@seanet.com) wrote:

: My problem is this, tar ouputs to STDERR and I have had no problem capturing
: STDERR and redirecting it in to a file (as you can see from my enclosed
: sample). But I when this is done, all error messaging goes to the file
: (since it's being fed STDERR) and the user then cannot monitor the output of
: tar on their console, which is really needed in our case. I have thought of
: trying to do a 'tail -f $logfile' and reading that in to the script and
: spitting it back out to STDOUT, but that's horribly inefficiant. I am more
: after a split of STDERR, which I don't totally redirect it's output but "T"
: it or divide it, much like a unix "tee" command. Or possibly redirecting
                                     ^^^
: STDERR to the file AND to STDOUT. I have tried several things with no luck,
: any ideas?


   One idea would be to search for 'tee' in the Perl FAQs   ;-)


Perl FAQ, part 5:

----------------------------
=head2 How do I print to more than one file at once?

If you only have to do this once, you can do this:

    for $fh (FH1, FH2, FH3) { print $fh "whatever\n" }

To connect up to one filehandle to several output filehandles, it's
easiest to use the tee(1) program if you have it, and let it take care
of the multiplexing:

    open (FH, "| tee file1 file2 file3");

Otherwise you'll have to write your own multiplexing print function --
or your own tee program -- or use Tom Christiansen's, at
http://www.perl.com/CPAN/authors/id/TOMC/scripts/tct.gz, which is
written in Perl.

In theory a IO::Tee class could be written, but to date we haven't
seen such.
----------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 21 Oct 1998 08:38:13 GMT
From: jurek@univcomp.waw.pl (Jerzy Orzeszek)
Subject: Re: Question...
Message-Id: <362d9ce6.6238195@news.icm.edu.pl>

I know how to parse <STDIN> twice
But I need to run
find / -size +$fnum -size -$snum -exec ls -l {} \; from perl script.

Thanks
Jerzy


>hehe, I think he need help getting input from STDIN
>
>Try this:
>
>$input = <STDIN>;
>
>This will read a line of input from the console.
>
>And instead of using the exec function, just use the backtics. 
>
>`find / - size -fi...`;



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

Date: Wed, 21 Oct 1998 09:08:33 GMT
From: dave@mag-sol.com
Subject: Re: Randal's Big Day in Big D
Message-Id: <70k8ag$4q9$1@nnrp1.dejanews.com>

In article <70ikt3$7p217@mercury.adc.com>,
  bhilton@tsg.adc.com (Brand Hilton) wrote:

> Anyway, as many of you already know, Randal came to Dallas on October
> 3rd to give his Just Another Convicted Perl Hacker talk.  If you're a
> Perl Mongers leader, you REALLY need to take Randal up on his offer to
> give this talk.  The talk itself is very informative and entertaining,
> and Randal is tons-o-fun to hang around with.

Last I heard, the subject of the talk precluded Randal from visiting us in
London. We're looking forward to hearing the Just Another Cleared Perl Hacker
talk tho'.

Dave...

--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Oct 1998 11:20:37 +0200
From: "Hartmut Palm" <palm@gfz-potsdam.de>
Subject: read main::DATA multiple
Message-Id: <70k90o$i7i$1@zrt7a.gfz-potsdam.de>

How to read main::DATA multiple. I can't reopen/rewind __DATA__. With "tell"
and "seek" there is a difference of 20 bytes first time.

Thanx for any help
--
Hartmut




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

Date: Wed, 21 Oct 1998 08:43:30 GMT
From: dwiesel@my-dejanews.com
Subject: round a value
Message-Id: <70k6ri$347$1@nnrp1.dejanews.com>

hi,

I would like to know how to round a value so that if it is

2.499 it will become 2.5

and if it is

2.999 it will become 3

Thank you

// Daniel

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Oct 1998 08:51:54 GMT
From: dwiesel@my-dejanews.com
Subject: round a value
Message-Id: <70k7ba$3p9$1@nnrp1.dejanews.com>

hi,

I would like to know how to round a value so that if it is

2.499 it will become 2.5

and if it is

2.999 it will become 3

(I want the value to become a new value with 0.5 between (sorry for my bad
english)

Thank you

// Daniel

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 21 Oct 1998 03:50:05 GMT
From: Steve Howie <showie@uoguelph.ca>
Subject: Re: Scotch drinkers Unite! [was] Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <70jlld$j9m$1@testinfo.uoguelph.ca>

Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:
: Steve Howie wrote:
:> quality blended scotches have higher proportions of signle malts in them
:> than the swill like Johnny Walker Red.

: Anything JW is SWILL even the Blue Label! Gack. Donut make me pour a
: good highland single malt down yer throat. :) Blends need not apply.
: *ptooi* I am a total snob when it comes to scotch. 

:> God this is getting me thirsty. I could do with some Highland Park right
:> now ... yummee :)

: Ack. Get you some of The Macallan 25 or Oban STAT. :)

While the Macallan and Oban are great (I lived in Oban for 9 years!), HP, 
Laphroig and Bowmore are the best for me. 15 yo Glenfarclas is up there too.
Highland Park uniformly scores 9+ out of 10 on reviews I've read. BTW the 
25 yoear old was 99 pounds a bottle at Oddbins at Glasgow Airport Duty 
Free in June ... thats over $200 US. I was tempted ... :)

:> "If it's not Scottish it's CRRRRAAAAAAAPPPPPP!"

: Being English and working with a few Scots it is KRAP!!!! with K babe :)

You lucky thing!

: Join us or die not knowing the joy of a beautiful highland single malt
: before dying is a crime. :) We shall intern you until you find the way
: of THE SCOTCH. "I am scottish and I luv ewe!!!" heh. Single Malt is your
: friend. Scotch is a beautiful thing. 

Indeed it is. I love the stuff. I agree - haven't met a blended that'd 
keep me going back

Scotty
-- 
Steve Howie					root@127.0.0.1
Netnews and Listserv Admin			519 824-4120 x2556
University of Guelph			
"If it's not Scottish it's CRRRRAAAAAAAPPPPPP!"


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

Date: Wed, 21 Oct 1998 04:07:22 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Scotch drinkers Unite! [was] Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <362D5B73.44E86FFA@bbnplanet.com>

Steve Howie wrote:

> While the Macallan and Oban are great (I lived in Oban for 9 years!), HP,
> Laphroig and Bowmore are the best for me. 15 yo Glenfarclas is up there too.
> Highland Park uniformly scores 9+ out of 10 on reviews I've read. BTW the
> 25 yoear old was 99 pounds a bottle at Oddbins at Glasgow Airport Duty
> Free in June ... thats over $200 US. I was tempted ... :)

Bowmore! I just bought a bottle last weekend! mmmmmm. Glenfarclas is
right up there Highland park is good too but I prefer a The Macallan 25
if I can :). Laphroig takes a special mood. A peaty one.

> Indeed it is. I love the stuff. I agree - haven't met a blended that'd
> keep me going back

Indeed. Single malts are so inspiring. Blends are so-so.

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: Tue, 20 Oct 1998 21:48:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Scotch drinkers Unite! [was] Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <MPG.1097076a41a1c3c29898d3@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <362D5B73.44E86FFA@bbnplanet.com> on Wed, 21 Oct 1998 
04:07:22 GMT, Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> 
says...
 ... 
> Indeed. Single malts are so inspiring. Blends are so-so.

You are now involved in three (3) threads without a shred of Perl 
content.  Isn't it time to give the rest of us a break?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 21 Oct 1998 01:43:47 +0500
From: assa@assa.tlt.ru (Alexander Trump)
Subject: Re: serial port IO? module?
Message-Id: <3msi07.bn2.ln@assa61.assa.tlt.ru>

Peter Griessl (griessl@ihs.ac.at) wrote:
: I need to talk to an external device connected to the serial
: port using XON/XOFF flow control and I want to do this out
: of perl (since the application is written in perl). 
: Does anyone know how to do it :-) ?

man POSIX

POSIX::Termios do all the things need to handle terminal lines. XON/XOFF
discipline handling is one of them.


--
Sincerely, Alexander


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

Date: 21 Oct 1998 01:40:29 GMT
From: jkekoni@cc.hut.fi (Joonas Timo Taavetti Kekoni)
Subject: Re: serial port IO? module?
Message-Id: <70je2d$5up$3@news.cs.hut.fi>

Tom Christiansen (tchrist@mox.perl.com) wrote:
: Why do people expect to learn everything about all manners of programming
: solely in the Perl documentation?

Becouse there is a goof module for about anything else with perl...

I think what would be needed is a module for serial communications,
becouse the posix
1) is not portable outside posix
2) is quite complicate.
3) there is not standard way of handling speeds over 38400 
( correct if i am wrong)

Something like:

$port = SERIAL->new( port=>1,
		     speed=>38400,
		     handshake=>"Xon",
		     cbreak=true ,
		     linemode=false );
$port->getch();
$port->print( sprintf (" Line disconnected on port %d",$pn));
$port->dtr(0);
sleep 1;
$port->dtr(1);

-- 
	_-  Joonas Kekoni       OH2MTF	    I                           -_
	_-internet:	jkekoni@cc.hut.fi   I       DO NOT EAT.         -_
	_-slowmail:	j{mer{ntaival 7a176 I                           -_
	_-		02150Espoo          I      It is a monitor      -_
	_-		Finland/Europe      I                           -_


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

Date: 21 Oct 1998 09:49:03 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: serial port IO? module?
Message-Id: <la1zo22w40.fsf@erh.ericsson.se>

nouser@nohost.nodomain (Thomas) writes:
> In article <lau310oci7.fsf@erh.ericsson.se> Michal Rutka <erhmiru@erh.ericsson.se> writes:
>    Jonathan Feinberg <jdf@pobox.com> writes:
>    > Peter Griessl <griessl@ihs.ac.at> writes:
>    > 
>    > > I need to talk to an external device connected to the serial
>    > > port using XON/XOFF flow control and I want to do this out
>    > > of perl
>    > 
>    > perlfaq8: "How do I read and write the serial port?"
> 
>    Not very helpfull. Specially if somebody is trying this on Win32 machine.
> 
> But "somebody" didn't ask about Win32...

I know. This was just educated guss. In our lab, we are using suns and PCs
as well. Suns are used for disigning work, wheras PC for testing. All 
serial ports, we are driving, are done from PC's. It is much cheeper to
put e.g. 4 serial ports on one PC than on Sparc. Although, I can be wrong,
I think that win32 is the platform that Peter is looking for.

>    Moreover, ther is nothing in the FAQ about flow controll. How can you 
>    do hardware flow control?
> 
> Same way you do with any serial device on UNIX.  The easiest is
> to use the "stty" command with appropriate redirections, altough
> you can make the system call directly from Perl if you must.

The point was that the 'perlfaq8: "How do I read and write the 
serial port?"' does not contain the answer for 'XON/XOFF flow control'.
It can be good start, however, because the post is answered, it
lowers its chance for a full answer.

Personaly, I don't want to make serial connections, as I already did. I
used to do it in almost every langage that I use. Last time I used Perl
and found Win32::SerialPort very usefull.

> Thomas.

Michal


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

Date: Wed, 21 Oct 1998 11:56:44 +0100
From: Peter Griessl <griessl@ihs.ac.at>
Subject: Re: serial port IO? module?
Message-Id: <362DBDEC.B44C2846@ihs.ac.at>

Thanks to everyone for giving hints. After looking at some C code,
reading 
termios(3), select(2), Camel(Book) I ended up with this script, allowing
me to say "AT" to my modem an receiving "OK". Whow!
Maybe this short example is useful for someone.

----------------------------
#!/usr/bin/perl -w

use POSIX qw(:termios_h :fcntl_h);

sysopen ( MODEM, "/dev/ttyS1", O_RDWR | O_NONBLOCK ) || die "cannot
sysopen";  

$in = POSIX::Termios->new;   
$insave = POSIX::Termios->new;  
$mo = POSIX::Termios->new;  

#  STDIN: raw 

$in->getattr(fileno(STDIN)); 
$insave->getattr(fileno(STDIN));

$in->setiflag(0);          #  XON, XOFF goes here
$in->setoflag(0);
$in->setlflag(0);
$in->setcc(VMIN, 1);
$in->setcc(VTIME, 0);
$in->setattr(fileno(STDIN), TCSANOW);


#  Modem: like STDIN plus baudrate

$mo->getattr(fileno(STDIN));

$mo->setcflag(CREAD | CS8 | B9600 | HUPCL);
$mo->setattr(fileno(MODEM), TCSANOW);


my $rbits = "";                            
vec($rbits, fileno(STDIN), 1) = 1;
vec($rbits, fileno(MODEM), 1) = 1;

my $n = 0;  

do {
   
  $n = select($selrbits = $rbits, undef, undef, undef);    # BLOCKING 
  die "cannot select" if ($n == -1);

  if (vec($selrbits, fileno(STDIN), 1)) {
    $len = sysread(STDIN, $buf, 100 );
    syswrite(MODEM, $buf, $len );
  }
  if (vec($selrbits, fileno(MODEM), 1)) {
    $len = sysread(MODEM, $buf, 100 );
    syswrite(STDOUT, $buf, $len );
  }

} while ( $buf ne "q" );   


close MODEM;

$insave->setattr(fileno(STDIN), TCSANOW);     # restore terminal
settings

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


Peter Griessl, griessl@ihs.ac.at


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

Date: 21 Oct 1998 03:57:47 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Socket Listner
Message-Id: <70jm3s$ejv$1@marina.cinenet.net>

Martien Verbruggen (mgjv@comdyn.com.au) wrote:
: I still am not sure in which way perlipc (section 'Sockets:
: Client/Server Communication') and the Socket module documentationis
: not sufficient information. It does tell you how to set up a process
: that listens on a socket, it also tells you how to check the
: information. Multiplexing connections is probably also covered in
: that, but I am not sure.

Bidirectional sockets are indeed covered, at least in the 5.004_04
perlipc.  Coincidentally, I was just reading this section today (I also
found a minor bug in some example code in this section of the doc, which
I'm going to look for in 5.005 tomorrow, and report if it's there too.) 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Tue, 20 Oct 1998 22:39:30 +0200
From: "Josep Jover" <jjover@andorra.ad>
Subject: Testing a date
Message-Id: <70ivv7$l2s$1@duke.telepac.pt>

Hello everybody,

How can I verify if a date dd/mm/yyyy is a correct data ?

Thanks for helping me.

Josep Jover
jjover@andorra.ad




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

Date: Wed, 21 Oct 1998 08:59:05 GMT
From: dwiesel@my-dejanews.com
Subject: undef $1 ???
Message-Id: <70k7oo$469$1@nnrp1.dejanews.com>

Hi,

I've got the following situation:

$htmlpage =~ /Arial">(.*)&nbsp;<\/TD>/g;
$value1 = $1;

$htmlpage =~ /Arial">(.*)&nbsp;<\/TD>/g;
$value2 = $1;

If the other expression does not succeed i $value2 will end up with the exact
value as $value1. How can I prevent this? I've tried to undef $1 between the
both expression and it does'nt work. I've also tried $1 = "" but i does'nt
work either.

Thank you,

// Daniel

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 21 Oct 1998 10:09:35 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: uri@camel.fastserv.com
Subject: Re: what is strlen() in perl?
Message-Id: <lazpaq1glc.fsf@erh.ericsson.se>

Uri,

we have some problems with compability of our englishes. Read on.

Uri Guttman <uri@camel.fastserv.com> writes:
> >>>>> "MR" == Michal Rutka <erhmiru@erh.ericsson.se> writes:
>   MR> Mehdi Beygi <mjb@voodoo.ca.boeing.com> writes:
>   >> Perl is wonderful!
>   MR> What so wonderful about it?
>
> why do you make comments like that after helping someone out? 

It is not a comment. It is a question. I know why I love Perl, and all
I want to know is why, a begginer (I guss), like Mehdi is finding Perl
wonderfull.

My personal software experince is 14 years. I work in a lab where I
have ten other programmers. Only I am using Perl :-(, moreover I am
not a programmer but a system engineer. Especcialy, young programmers,
are not attracted by Perl. All I want is to gather some arguments form
others.

> if you
> don't like perl, than why do you use it? 

I LOVE PERL. You are too fast with your conclusions.

> and why do you follow this
> group? 

I've already explained this.

> we know plenty of people who dislike perl for various reasons and
> that is fine. but to denigrate it while actually answering a query in
> the group can get a little irritating to the rest of us. we like the
> language and like helping out others with it.

Me too. Didn't you notice that I am helping others too. A nice thing
about it is that in the morning I have a lot of credidts in mail mail
box, from all over the world, from guys which I helped :-)

> there have been plenty of flame wars about perl as you have seen so
> please keep comments about you perl love/hate to those threads. and keep
> the language answers focused on just the problem. i know the poster said
> "perl is wonderful" but they probably didn't expect your retort.

God and heaven, please keep me out from flame wars. I never took part in
any, and I do not want. Neither I want to start one.

> and this is not like the rtfm and other responses to newbies that get
> bandied about here. it is just jarring seeing an answer juxtaposed with a
> negative comment like that.

It is not a negative comment! It is just a question. I think, that the first
part of my post (which you cut), should show my intention and positive
thinking about Perl.

Hope this explains my point of view, and hope this will decrease my
missunderstanding ratio with you.

Regards,

Michal

> uri
> 
> 
> -- 
> Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
> uri@fastengines.com                                  http://www.fastengines.com

Oh, I have a signature too:
-- 
Dr. Ir. Michal Rutka         Ericsson Radio Systems BV
Senior System Engineer       P.O. Box 2015
Wide Area Pagers             7801 CA  Emmen
Bluetooth                    The Netherlands


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

Date: Tue, 20 Oct 1998 21:44:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: What isn't Perl good for?
Message-Id: <MPG.109706934b9a00fa9898d1@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <362D594B.A7680BFA@bbnplanet.com> on Wed, 21 Oct 1998 
03:58:10 GMT, Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> 
says...
> > How about the flavored coffees?  Hazelnut?  Vanilla Almond?  Perl?
> 
> Flavoured coffees?!?!? Heathen!

You are now involved in three (3) threads without a shred of Perl 
content.  Isn't it time to give the rest of us a break?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 21 Oct 1998 03:18:02 -0600
From: Scott Wedel <swedel@spiff.tymnet.com>
Subject: Re: What isn't Perl good for?
Message-Id: <362DA6CA.1DB89021@spiff.tymnet.com>

Elaine -HappyFunBall- Ashton wrote:
> 
> > How about the flavored coffees?  Hazelnut?  Vanilla Almond?  Perl?
> 
> Flavoured coffees?!?!? Heathen!
> 
> e.

Coffee flavored with liquors with enough alcohol is certainly worth
contemplating drinking and will be consumed regardless if enough other
drinks have already been consumed.

BTW, I live in Steamboat Springs, Colorado where the daily meeting at the
local brewpub of the local perl users community consists of only myself
and thus the time spent conversing on perl is rather brief.  I will buy
a round of drinks for the first perl users meeting at the Steamboat
Brewery and Tavern that consists of more than just myself.  Ask anyone
that works there about the computer guy and you will be pointed to me.
Okay, yes I am envious of all the fun I read you all having at your
meetings.  And unlike Vail, none of our ski lifts were torched so you will
be able to ski the entire mountain.


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

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

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