[7271] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 896 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 20 16:17:24 1997

Date: Wed, 20 Aug 97 13:00:26 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 20 Aug 1997     Volume: 8 Number: 896

Today's topics:
     Catching SIGTSTP/SIGCONT in Perl? (Emerick Rogul)
     Re: Chars into Array <jefpin@bergen.org>
     Child Labour <thielmann@11.kblz1.telekom400.dbp.de>
     conjugating Portuguese verbs (Etienne Grossmann)
     Re: emacs?  No thank you (HTD)
     Re: Field Length (Jim Trocki)
     Help on 'system' function <dhayden@ford.com>
     HELP!!!!Please..... (Nilay Jhaveri)
     homepage maker needed <chrisall@dtc.net>
     Re: how to parse only the lines between <pre> and </pre (Elf Sternberg)
     Re: HTML --> Perl conversion (Bart Lateur)
     Re: Is there a perl IDE? <rjo100@york.ac.uk>
     ISQL from within a Perl script <pegit.swedmap@mbox300.swipnet.se>
     Re: Java and Perl together (Terje Bless)
     Re: oracle->perl frontend <MoenckB@Noranda.com>
     Re: Perl for Win32 and COM port calls (SJK)
     Perltk execution???? <rudedog@pld.com>
     Project on Perl and Email Ticket Generator (Jerome Schevingt)
     Re: Project on Perl and Email Ticket Generator (Matthew Cravit)
     Re: Reading a string, splitting it, and using it <tw36027@glaxowellcome.com>
     Re: Right shift (">>") in 5.00401 <prt@Teleglobe.CA>
     Script Help <jbrunker@ams.dhs.texas.gov>
     Re: Script Help (Eric Bohlman)
     Re: split perl string (SJK)
     split() with capturing parantheses doesn't work correct <mschilli@mission.base.com>
     Re: TCL 8.0: A whole lot of perl <tom@mitra.phys.uit.no>
     Re: unexpected foreach value (Andrew D. Arenson)
     Win32 Perl -> C Compiler <codie@concentric.net>
     Re: Win95 + Perl back-quotes or fx(<system command>) as <alten@dial.pipex.com>
     Re: Year 2038 (was Re: Help! - Reformatting Date) (Terje Bless)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 20 Aug 1997 14:25:42 -0400
From: emerick@csa.bu.edu (Emerick Rogul)
Subject: Catching SIGTSTP/SIGCONT in Perl?
Message-Id: <vuobu2sr9sp.fsf@csa.bu.edu>


Hi,

I'm trying to write a program in Perl that can refresh its display
when it continues after receiving a suspend signal.  In C, I would
trap SIGTSTP and then longjmp back to the piece of code I left.  I'm
not sure how to do this in Perl, though.  I see from the manual that
eval/die can be used to emulate setjmp/longjmp, but most of the
examples involve trapping alarms, and I'm not sure how to extend that
to what I'm trying to do. Does anyone have any information on this or
code snippets that they code share?

Thanks,

-Emerick
-- 
-------------------------------------------------------------------------
Emerick Rogul        /\/   "...a crummy commercial?  son of a BITCH!"
emerick@cs.bu.edu    /\/             -ralphie parker, 'a christmas story'
-------------------------------------------------------------------------


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

Date: Wed, 20 Aug 1997 12:57:04 -0400
From: Anagrams of the Word 'A' <jefpin@bergen.org>
To: John Grimm <ken1@earthlink.net>
Subject: Re: Chars into Array
Message-Id: <Pine.SGI.3.95.970820125555.7435A-100000@vangogh.bergen.org>

>How can I get a variable (say $x) into an array (say @p)?
>I want to get a number like -1.942 so it's like @p = (-,1,.,9,4,2)

@p = split(//,$x); # this does what you want!

----------------
| "I don't contemplate it, I just sit and think about it."
| 	- Sonia Balsky
----------------
Jeff "TechMaster" Pinyan | http://users.bergen.org/~jefpin
I do: HTML!! CGI!! Perl!! JavaScript!! jefpin@bergen.org
Got a JavaScript/CGI/Perl question or problem?  Let me know!

webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS



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

Date: Wed, 20 Aug 1997 20:43:23 +0200
From: Marcus Thielmann <thielmann@11.kblz1.telekom400.dbp.de>
Subject: Child Labour
Message-Id: <33FB3ACB.7348BD59@11.kblz1.telekom400.dbp.de>

Hello folks,
I'm writing a programm that should split work to its child and then
collect the datas from pipes, connected with the children. I do synchron
I/O multiplexing with select(,,,,).

The program shows really weird behaviour, and there are some system
calls I don't understand.

Every child is started with a parameter 1..10 and writes as many lines
in the PIPE with syswrite (so child1 1line .. child10 10 Lines)

The strace shows some return values in select, that I can't explain. Why
is the exception field filled ? (See strace output at the end)

Why are some lseek commands in the strace and why are all the reads
empty at this part?

Why aren't all datas read back? (See resulat at behind the listing)

I have tested it with perl 5.003 on linux and perl 4.036 on SINIX
(SVR4). On SINIX it caused a memory dump.
On AIX (perl 5.002)it runs without getting a usable result.


Here is the source:

#!/usr/bin/perl
# Child Labour
#
# 18.08.97 MTH

sub fork_kids {
# Start Kids and connect PIPE with every child process
#
    undef(%kid_parameter);
    undef(%kid_handle);
    undef(@handle_parameter);
    undef(@handle_fileno);

    local($func,@para_list)=@_;
    local($counter,@fh_list);
    for (@para_list) {
        $counter++;
        local($parameter)=$_;
        # Every handle is H_n, where n is incermented
        pipe("H_${counter}",PIPE);
        $pid=fork;
        if ($pid) { # Parent
            close(PIPE);
            # We save some datas from the child (Handle, PID etc.)
                $kid_parameter{$pid}=$parameter;
                $handle_parameter[fileno("H_${counter}")]=$parameter;
                $handle_fileno[fileno("H_${counter}")]="H_${counter}";
                $kid_handle{$pid}=fileno("H_${counter}");
        }
        else { # Child
            close("H_${counter}");
            # we start the function with eval
            local($cmd)="$func(\$parameter)";
            local($ret)=eval($cmd);
            $@?exit(-1):exit($ret);
        }
    }
    # All kids are running
    # We wait for datas with select(,,,,)
    @fh_list=values(%kid_handle);
    return unless @fh_list;
    $rin=&fhbits(@fh_list);
   $un=unpack("b*",$rin);
    while (select($rout=$rin,undef,$eout=$rin,3)>0) {
        $bit_string=unpack('b*',$rout);
        print "Select read Bitmask:$bit_string\n";
        for (@fh_list) { #Test all handles
            if (vec($rout,$_,1)) { # das Bit ist gesetzt
                local($data_read)=&read_it($_);
                # No data read -> EOF
                close($handle_fileno[$_]) if (length($data_read) == 0);
                # We save the answers in an assoziative array
                $kid_answer{$handle_parameter[$_]}.=$data_read;
            }
        }
        # Let us check which handles are still opened
        for (keys(%kid_handle)) {
            delete($kid_handle{$_}) if
eof($handle_fileno[$kid_handle{$_}]);
        }
        @fh_list=values(%kid_handle);
        $rin=&fhbits(@fh_list);
        return unless @fh_list;
    }
}

sub read_it {
#
# Sysread (Prgramming Perl says, no C-Lib read/write with select(,,,,)
    local($handle)=@_;
    local($buf,$erg);
    local($len);
    while($len=sysread("$handle_fileno[$handle]",$buf,4096)) {
        print "\tsysread:l=$len h=$handle b=$buf\n";
        $erg.=$buf;
    }
    if(!defined($len)) {
        # next if $!=~ /^Interrupted/;
        die "System call interrupted: $!\n";
    }
    $erg;
}

sub write_it {
#
# Syswrite
        local($buffer)=@_;
        local($len)=length($buffer);
        local($written);
        local($offset)=0;
        while($len) {
                $written=syswrite(PIPE,$buffer,$len,$offset);
                die "System write Error:$!\n" unless $written;
                $len-=$written;
                $offset+=$written;
        }
}


sub fhbits {
# Set Bits (from Programming Perl) for select(,,,,)
    local(@fhlist)=@_;
    local($bits);
    for(@fhlist) {
        vec($bits,$_,1)=1;
    }
    $bits;
}

sub wait_func{
# This is our Test func.
    local($time)=@_;
    for(1..$time) {
        &write_it("Hello, Kid ($time) is working for you ($_/$time)\n");
    }
    close(PIPE);
    sleep(10);
    0;
}

sub child_dead {
    $SIG{CHLD}='child_dead';
    local($pid)=wait;
    print "Child $pid ist dead($?) (Handle:$kid_handle{$pid})\n";
}


$SIG{CHLD}='child_dead';


# @list=(1,2,3,4,5,6);
@list=(1,2,3,4,5,6,7,8,9,10);

print "Start Kids to work...\n";
&fork_kids('&wait_func',@list);
print"All kids have finished ...\n";


for (sort(keys(%kid_answer))) {
        print ">$_:$kid_answer{$_}\n";
}


------ Ouput: ------

Start Kids to work...
Select read Bitmask:0001100000000000
        sysread:l=40 h=3 b=Hello, Kid (1) is working for you (1/1)

        sysread:l=80 h=4 b=Hello, Kid (2) is working for you (1/2)
Hello, Kid (2) is working for you (2/2)

Select read Bitmask:0000011111101000
        sysread:l=80 h=5 b=Hello, Kid (3) is working for you (2/3)
Hello, Kid (3) is working for you (3/3)

        sysread:l=280 h=10 b=Hello, Kid (8) is working for you (2/8)
Hello, Kid (8) is working for you (3/8)
Hello, Kid (8) is working for you (4/8)
Hello, Kid (8) is working for you (5/8)
Hello, Kid (8) is working for you (6/8)
Hello, Kid (8) is working for you (7/8)
Hello, Kid (8) is working for you (8/8)

Select read Bitmask:0000010000100000
Select read Bitmask:0000000000010000
        sysread:l=40 h=11 b=Hello, Kid (9) is working for you (2/9)

        sysread:l=40 h=11 b=Hello, Kid (9) is working for you (3/9)

        sysread:l=40 h=11 b=Hello, Kid (9) is working for you (4/9)

        sysread:l=40 h=11 b=Hello, Kid (9) is working for you (5/9)

        sysread:l=40 h=11 b=Hello, Kid (9) is working for you (6/9)

        sysread:l=40 h=11 b=Hello, Kid (9) is working for you (7/9)

        sysread:l=40 h=11 b=Hello, Kid (9) is working for you (8/9)

        sysread:l=40 h=11 b=Hello, Kid (9) is working for you (9/9)

Select read Bitmask:0000000000010000
All kids have finished ...
>1:Hello, Kid (1) is working for you (1/1)

>10:
>2:Hello, Kid (2) is working for you (1/2)
Hello, Kid (2) is working for you (2/2)

>3:Hello, Kid (3) is working for you (2/3)
Hello, Kid (3) is working for you (3/3)

>4:
>5:
>6:
>7:
>8:Hello, Kid (8) is working for you (2/8)
Hello, Kid (8) is working for you (3/8)
Hello, Kid (8) is working for you (4/8)
Hello, Kid (8) is working for you (5/8)
Hello, Kid (8) is working for you (6/8)
Hello, Kid (8) is working for you (7/8)
Hello, Kid (8) is working for you (8/8)

>9:Hello, Kid (9) is working for you (2/9)
Hello, Kid (9) is working for you (3/9)
Hello, Kid (9) is working for you (4/9)
Hello, Kid (9) is working for you (5/9)
Hello, Kid (9) is working for you (6/9)
Hello, Kid (9) is working for you (7/9)
Hello, Kid (9) is working for you (8/9)
Hello, Kid (9) is working for you (9/9)

----------------- strace-----------------------------
 ....
read(9, "Hello, Kid (7) is working for yo"..., 4096) = 280
read(10, "Hello, Kid (8) is working for yo"..., 4096) = 40
read(11, "Hello, Kid (9) is working for yo"..., 4096) = 40
read(12, "Hello, Kid (10) is working for y"..., 4096) = 421
select(16, [5 6 7 8 9 10 11 12], NULL, [5 6 7 8 9 10 11 12], {3, 0}) =
14 (in [5 6 7 8 9 10 12], except [5 6 7 8 9 10 12], left {3, 0})
                                 ^  !!!!! why ? !!!!
write(1, "Select read Bitmask:000001111110"..., 37) = 37
read(5, "Hello, Kid (3) is working for yo"..., 4096) = 80
write(1, "\tsysread:l=80 h=5 b=Hello, Kid "..., 101) = 101
read(5, "", 4096)                       = 0
read(6, "", 4096)                       = 0
lseek(6, -160, SEEK_CUR)                = -1 ESPIPE (Illegal seek)
close(6)                                = 0
read(7, "", 4096)                       = 0
lseek(7, -200, SEEK_CUR)                = -1 ESPIPE (Illegal seek)
close(7)                                = 0
read(8, "", 4096)                       = 0
lseek(8, -240, SEEK_CUR)                = -1 ESPIPE (Illegal seek)
close(8)                                = 0
read(9, "", 4096)                       = 0
lseek(9, -280, SEEK_CUR)                = -1 ESPIPE (Illegal seek)
close(9)                                = 0
 ....


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

Date: 20 Aug 1997 19:03:36 GMT
From: etienne@isr.isr.ist.utl.pt (Etienne Grossmann)
Subject: conjugating Portuguese verbs
Message-Id: <5tff28$dgi@ci.ist.utl.pt>


   Hello,

	my name is Etienne Grossmann, I study in Lisbon (Portugal), an since
I am not Portuguese, I wanted to learn the language. With that in
mind, I wrote a perl script that drills me on conjugation, and a perl
module with a verb-conjugating function. 

	I think it is quite close to correction : It works for the tenses :

present, perfeito, imperfeito, futuro,mais-que-perfeito,conjuntivo
presente, conjuntivo imperfeito, conjuntivo futuro, condicional,
imperativo, partic'ipio passado,gerundivo, 

	at all persons except second plural (which I've almost never seen in
use). It knows about all (I think; in reality, "all" must mean "most")
the irregular verbs that I found in the "Guia Pr'atico dos Verbos
Portugueses" by Deolinda Monteiro and Beatriz Pessoa, and about the
"abundant" and "defective" verbs.

	Is anyone interested?

	If so, I can try to document the code properly, and make it
available as a module.


	Etienne


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

Date: 18 Aug 1997 18:02:55 GMT
From: htd-ibhd@t-online.de (HTD)
Subject: Re: emacs?  No thank you
Message-Id: <5ta2of$5lh$1@news02.btx.dtag.de>

On 13 Aug 1997 13:37:46 GMT, gabor@vinyl.quickweb.com (Gabor) wrote:

>Kenneth Vogt (KenVogt@rkymtnhi.com) wrote:
>
>: Thanks to everyone that suggested emacs for Windows.  However, it is one
>: of the UGLIEST things I have ever seen!  (I'm not trying to start an
>
>There are things in life that should be pretty.  An editor is not one
>of them.  I expect an editor to be functional, don't you?
>

The only thing that a good editor should have that a good wife doesn't
need is a documented API.

Hans 
>And don't tell me there isn't one bit of difference between null and space,
>because that's exactly how much difference there is.  :-)
>        --Larry Wall in <10209@jpl-devvax.JPL.NASA.GOV>
>



Hans Dermot Doran
ing. buro h doran
beim pfarrwdldle 7
72813 st. johann upfingen

htd-ibhd@t-online.de


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

Date: 20 Aug 1997 18:37:24 GMT
From: trockij@transmeta.com (Jim Trocki)
Subject: Re: Field Length
Message-Id: <5tfdh4$urp$1@palladium.transmeta.com>

In article <33FAF1F9.3583F411@iti-oh.com>,
Joshua Marotti  <jpm@iti-oh.com> wrote:
>John Grimm wrote:
>
>> How do I determine the length of a variable?
>
>I can't remember if this is totally correct... I may be wrong, but I
>believe, if it is a string, you can place it into an array with a simple
>assign declaration (@string = $string).  Then you find the count simply
>by $count = $#string.
>Hope that helps,
>-Josh

Here's the better way to do this:

$a = "Hello";
$n = length $a;
print "$n\n";

-- 
Jim Trocki
Computer System and Network Engineer
Transmeta Corporation
Santa Clara, CA trockij@transmeta.com


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

Date: 20 Aug 1997 15:48:52 GMT
From: "John Spencer" <dhayden@ford.com>
Subject: Help on 'system' function
Message-Id: <01bcad80$7d84b700$6502a713@fce04438.jubilee.ford.com>

I would be grateful if anyone could help this problem:-

First Program  first.pl
 .....
system("second.pl",$amount);
print "Amount Now =$amount";
 ......



Second Program  second.pl
 ......
$input=<STDIN>;
$amount = $amount + $input
 ......



The first program "first.pl" should jump to the second program "second.pl"
with $amount as an arguement. It should then take an input amount and add
to $amount and pass back to "first.pl" upon completion of "second.pl"

How to I pass back the new value of $amount????

Or is there a better way of doing this?????


Many thanks

David Hayden









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

Date: 20 Aug 1997 19:36:56 GMT
From: jhaveri@hops.cs.jhu.edu (Nilay Jhaveri)
Subject: HELP!!!!Please.....
Message-Id: <5tfh0o$99r@foobar.cs.jhu.edu>


I have a Perl Question for anyone kind enough to help me.
I have an array of words, say @fields...
But since this array is dynamically allocated, I do not know how many
words are in it before run time.
Is there a regular expression that basically looks for those words in
sequence, but allowing unlimited spaces(\s)+ between words?
so if  @fields is("joe", "jack");
it will match
joe jack
or 
joe          jack
or joe


jack
but if @fields is("joe", "jack", "jill")
it will match
joe jack
    jill


etc...etc..


If I know the words that are in sequence  before run time, i could do
$word1[\s]+$word2[\s]+$word3

but dynamically I am not too sure....

Thank you so much.
Nilay Jhaveri
jhaveri@hops.cs.jhu.edu




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

Date: 20 Aug 1997 17:07:53 GMT
From: "Chris Allen" <chrisall@dtc.net>
Subject: homepage maker needed
Message-Id: <01bcad8b$cb8239e0$1482b7cd@chrisall>

I need to find a free home page maker that I can put on my web site. Do any
one have any suguestion.

Please send a message to cyo@cyo.org


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

Date: 20 Aug 1997 15:52:32 GMT
From: elf@halcyon.com (Elf Sternberg)
Subject: Re: how to parse only the lines between <pre> and </pre>
Message-Id: <5tf3s0$een$1@news2.halcyon.com>

In article <5t9g6o$l78@nuscc.nus.sg> 
    scip7075@leonis.nus.sg (Xu Chu) writes:

>i wanna parse only the lines between a <pre> and </pre>. Look at the 
>original files like this:

><html>
><head>head</head>
><body>
><map name="header">
><AREA SHAPE=RECT COORDS="21,8,29,16" HREF="http://some.place.com/">
></map>
><pre>
><a href="http://www.example.com/">example</a>
></pre>

	$document =~ m{\<pre\>(.*?)\</pre\>} && print $1;

	if you've got more than one <pre>...</pre> set in your document
and you're willing to destroy a copy of the document:

	$_ = $document;
	while(s{\<pre\>(.*?)\</pre\>}{}) { print "$1\n" }

		Elf !!!

--
Elf Sternberg            Balkanize Usenet!
elf@halcyon.com          www.halcyon.com/elf
Public key available     


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

Date: Wed, 20 Aug 1997 17:44:46 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: HTML --> Perl conversion
Message-Id: <33fc26ca.1968347@news.tornado.be>

Tom Phoenix <rootbeer@teleport.com> wrote:

>And thus I said in my original posting. It was explicitly not intended to
>do more than that.

In which case I can simplify it, to this CGI script:

    #!/usr/bin/perl -w
    my $filename = "foo.html"; 
    open HTML, $filename or die "Can't read '$filename': $!";
    print "Content-type: text/html\n\n";
    while (<HTML>) {
         print;
    }
   

As I said, converting HTML pages to Perl code is only useful in order to
use a HTML page as a template. A program that only gives an exact
replica of an original HTML page, without easy adaptation to use it as a
template, doesn't make sense. Neither does my proglet.

	Bart.


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

Date: Tue, 19 Aug 1997 20:45:41 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Is there a perl IDE?
Message-Id: <33F9F7E5.67CD1D97@york.ac.uk>

Scott McMahan wrote:
> 
> : Is perl not worthy of anything more robust that Notepad?
> 
> I'm honestly stunned that anyone actually *USES* notepad.
> It's little more than a joke, a throwaway example of an
> edit control.

Try Programmer's File Editor from
http://www.lancs.ac.uk/people/cpaap/pfe/

Much better.

Russ

PS Don't I know you from somewhere? Ah yes, the Windows 95 Book FAQ...

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[    mailto:rjo100@york.ac.uk    ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Wed, 20 Aug 1997 20:53:08 +0200
From: Pinne <pegit.swedmap@mbox300.swipnet.se>
Subject: ISQL from within a Perl script
Message-Id: <33FB3D14.5322@mbox300.swipnet.se>

Hi,

I use Perl.exe 5.003_307 on NT S 4.0 with IIS 3.0.
I'm trying to use ISQL and read the resulting pipe
from within a Perl script.
I do this on two machines, on w both IIS and SQL server
installed on it and it works fine.
But on another machine which has only the SQL-server
client software installed it won't work at all.
It works if I call the Perl-interpreter from the command-
line, I can call a batch which just types a plain text-
file through the pipe in IIS.
But when I try to invoke ISQL from the script in IIS
othing happens, no error messages, nothing.
I've used the SQL-monitor but it shows nothing.
The calling line looks like this:
open(ISQLPIPE, "ISQL /i sqlfile.sql |") || &CgiDie("SUCKER !");
Any suggestions ?


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

Date: Wed, 20 Aug 1997 20:51:14 +0200
From: link@tss.no (Terje Bless)
Subject: Re: Java and Perl together
Message-Id: <link-2008972051140001@news.uit.no>

In article <Pine.GSO.3.96.970806142344.12246B-100000@kelly.teleport.com>,
    Tom Phoenix <rootbeer@teleport.com> wrote:

>Come to the Perl Conference

*sob* *snif* *sob*
But it's so far away and so expensive when your cheap tyrannical employer
(who wouldn't know USENET from a hole in his head ;D) won't sponsor you.
:-(


>and expect to hear more about this!

So? What's been said so far? At least _some_ of y'all have to read news
while at the conference; what's going on? The suspense is *killing* me!

-- 
Party? Party, lord? Yes, lord. Right away, lord.
        - Beopunk Cyberwulf


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

Date: Wed, 20 Aug 1997 12:17:59 -0400
From: Bob Moenck <MoenckB@Noranda.com>
Subject: Re: oracle->perl frontend
Message-Id: <33FB18B7.4F39@Noranda.com>

Kevin Luff wrote:
> 
> Hi all,
> before I go and reinvent the wheel........
> has anybody got scripts that enable you (in a format easy for users to
> understand) to select an oracle table from a selection of those
> available, then select fields required, with optional condition
> statements and display|print|save the results.
> Pref http based....
> all the relevant dbi/dbd stuff is installed
> 
> cheers
> Kevin
> ps Making the tea and coffee would be handy as well ;-)Check out WDB in CPAN.
It is written for Sybase with examples for Informix,
but is quite easy to adapt to DBI::Oracle.


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

Date: Wed, 20 Aug 1997 16:54:42 GMT
From: knetsch@golden.net.no.spam (SJK)
Subject: Re: Perl for Win32 and COM port calls
Message-Id: <33fb2096.15327247@news.golden.net>

On Mon, 18 Aug 1997 11:41:01 -0700, danielg@ea.com (Dan Greenblatt) wrote:

>I'm pretty decent with standard UN*X perl, but now I'm currently checking
>out Perl for Win32's ability to listen to COM ports.  Right now I have a
>simple script (with help from the Win32 for Perl FAQ, thankyouverymuch)
>that should listen to my COM1 port and spit out material as it comes in. 
>Currently, a modem is receiving data constantly and piping it directly into
>my serial port.
>
>Problem is, it's grabbing the port OK (when I run the script I can't go in
>through HyperTerminal and access the port again) but it just sits and
>hangs, producing no output.
>
>Here's the script:
>
>open (PORT, "<COM1:") || die "Can't open COM1: $!";
>while (1)
>{
>    read (PORT, $buffer, 1) || die "COM port error: $!";
>    print "$buffer";
>}
>
>I have to ctrl-C out of this, even in debug mode.
>Any suggestions from Win32 Perl hackers out there who've successfully
>listened to a serial port?

Ummm.. forgive me if this seems like a stupid question.  Are you sure you are
listening to the right port?  Most PCs have a mouse attached to COM1 and the
modem is on COM2.  The modem on COM1 caught me as being unusual....

Otherwise, no I don't have anything useful to add...

Cheerfully ducking flames

Stuart K.


Stuart Knetsch

Remove the you know what from my address to send me E-mail


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

Date: 20 Aug 1997 16:27:37 GMT
From: "Matthew Wagley" <rudedog@pld.com>
Subject: Perltk execution????
Message-Id: <01bcad96$094be640$9123fdce@matthews>

 How do I execute a pl script with TK????   I am writing a script but don't
know how to execute it.  I tried   perl  myscript.pl   and it acts like it
runs but then goes right back to the option arrow at dos.  I don't get no
exceptions or errors.
Your help is appreciated.
Thanks.
And also, any resources to perltk will also be appreciated.



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

Date: 20 Aug 1997 12:05:06 GMT
From: jpc@avo.fr (Jerome Schevingt)
Subject: Project on Perl and Email Ticket Generator
Message-Id: <5temhi$42i$1@news.aurecvideo.fr>

	Hi All

	I want create a software for Support Center, before start develloping, 
i want know if that don't exist !! (running on Linux)

	I want a software for :


First :
	Users ===> support@domaine.com

	The user send a email to the technical support


20 :
	support@domain.com ===> Users	(Auto-Answer)

	The Ticket Server sent a email of confirmation at the user with a
	mention 	TICKET NUMBER = 
			STATUS = Waiting Answer Technical Support
	
30 :
	support@domaine.com ===> tech1@domaine.com and tech2@domaine.com

	The Ticket Server sent the email of the user at all technician
	with TICKET NUMBER and STATUS

40 :
	Technician ==> Ticket Server

	The Technician sent to the ticket server the answer with Ticket Number

50 	Ticket Server ==> Users

	The Ticket Server sent to the user the answer of technician and a mail
	with a STATUS = CLOSED



We want that the Ticket Server sent all days the question at the technician if 
he don't have a answer

The users can answer the ticket server for STATUS , etc ...

Thanks for your help



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

Date: 20 Aug 1997 10:59:10 -0700
From: mcravit@best.com (Matthew Cravit)
Subject: Re: Project on Perl and Email Ticket Generator
Message-Id: <5tfb9e$rrf$1@shell3.ba.best.com>

In article <5temhi$42i$1@news.aurecvideo.fr>,
Jerome Schevingt <jpc@avo.fr> wrote:

>We want that the Ticket Server sent all days the question at the technician if 
>he don't have a answer
>
>The users can answer the ticket server for STATUS , etc ...
>
>Thanks for your help

You're basically asking for an email-based request tracking system. There
are any number of those out there, some free, others quite expensive. I'd
probably look at the gnats software from GNU, which I think will do what
you need.

/MC

-- 
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@taos.com (work)     | time you make it.


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

Date: Wed, 20 Aug 1997 12:55:59 -0400
From: Thad Welch <tw36027@glaxowellcome.com>
To: temp.ed.vanderbush@bentley.com
Subject: Re: Reading a string, splitting it, and using it
Message-Id: <33FB219F.4FE9C9BD@glaxowellcome.com>

change
    split(/|/,7);
to
    split /\|/;

why? the split function takes a reg. exp. as a first arg, and an
optional scalar to
be parsed as the second. the default second arg is $_.  Also, need to
escape the
'|'.



Ed Vander Bush wrote:

> I am reading information from a database I created into an aray
> A line of data in the Database woulde be in this format
> var1|var2|var3|var4|var5|var6|var7
> With Var 1 being a specific id number
> $id = $Cookies{'itg'};
> open(USERDATABASE, "$database")||die "Database cannot be opened";
> @database = <USERDATABASE>;
> close(USERDATABASE);
> foreach (@database){
> if(/^$id/) {
> ($idn,$name,$itemone,$itemtwo,$itemthree,$itemfour,$itemfive) =
> split(/|/,7);
> open(LOG, ">$logfile");
> print LOG $name, $itemthree;
> close(LOG);
> My problem is that the variable are not being returned.... Why?





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

Date: Wed, 20 Aug 1997 14:18:02 -0400
From: Pierre Thibaudeau <prt@Teleglobe.CA>
To: Paul A Sand <pas@unh.edu>
Subject: Re: Right shift (">>") in 5.00401
Message-Id: <Pine.HPP.3.96.970820131934.14190A-100000@alpha.Teleglobe.CA>

On Wed, 20 Aug 1997, Paul A Sand wrote:

>    In comp.lang.perl.misc you write:
>    
>    >After upgrading from Perl5.003 to 5.00401, I discovered a rather annoying
>    >behaviour.
>    
>    >   mtts01% perl -e 'print "Version$] : ", (-1 >> 24), "\n";'
>    >   Version5.00401 : 255
>    
>    This is (kind of) documented. You can get the old result with `use integer':
>    
>        % perl -e 'use integer; print "Version$] : ", (-1 >> 24), "\n";'
>        Version5.00401 : -1

And with it another (possibly undesired, but clearly documented) effect:

   mtts01% perl -e 'print "Version$] : ", int(2/3+0.5), "\n";'
   Version5.00401 : 1
   mtts01% perl -e 'use integer; print "Version$] : ", int(2/3+0.5), "\n";'
   Version5.00401 : 0

Which is as expected and consistent with earlier Perl:

   mtts01% /opt/local/perl5.003/perl -e 'print "Version$] : ", int(2/3+0.5), "\n";'
   Version5.003 : 1
   mtts01% /opt/local/perl5.003/perl -e 'use integer; print "Version$] : ", int(2/3+0.5), "\n";'
   Version5.003 : 0

Reading "integer.pm" did not help me to understand the connexion with
">>". But anyway I dont like the idea of having to decide which parts of
my programs have to be rewritten. 

Cheers.
__

Pierre Thibaudeau                     |   e-mail: <prt@Teleglobe.CA>
TELEGLOBE CANADA                      |
1000, rue de La Gauchetiere ouest     |      Tel: +1-514-868-7257
Montreal, QC   H3B 4X5                |
Canada                                |      fax: +1-514-868-8446





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

Date: Wed, 20 Aug 1997 10:37:37 -0500
From: Jay Brunker <jbrunker@ams.dhs.texas.gov>
Subject: Script Help
Message-Id: <33FB0F41.757CD7F3@ams.dhs.texas.gov>

Hi Folks!


Would anyone be able to tell me why the following bit of code
bombs?


foreach $dev (glob('/dev/rdsk/c*t*d*s2']]
{
  open(PIPE,"/usr/sbin/prtvtoc -h $dev|"} die "Can't pipe: $!\n"};


*Note please note...my right paren key doesn't seem to function.

Is there a better way to include system calls to UNIX?
It doesn't seem to work when I do a system call and then store the
result in a variable like so:

@device_list = system "ls -l /dev/rdsk/c*t*d*s2";

The 'ls -l' works,but the result never gets stored in
@device_list.

Any suggestions?


JayB.


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

Date: Wed, 20 Aug 1997 17:11:59 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Script Help
Message-Id: <ebohlmanEF82G0.A8B@netcom.com>

Jay Brunker (jbrunker@ams.dhs.texas.gov) wrote:
: Would anyone be able to tell me why the following bit of code
: bombs?


: foreach $dev (glob('/dev/rdsk/c*t*d*s2']]
: {
:   open(PIPE,"/usr/sbin/prtvtoc -h $dev|"} die "Can't pipe: $!\n"};

: *Note please note...my right paren key doesn't seem to function.

Looks like you're missing an "or" there.

 : Is there a better way to include system calls to UNIX?
: It doesn't seem to work when I do a system call and then store the
: result in a variable like so:

: @device_list = system "ls -l /dev/rdsk/c*t*d*s2";

Please consult perlfunc(1).  It will tell you that system() returns a 
single number, which is the exit status of the process invoked by it.  
Also consult the Perl FAQ, which will tell you how to accomplish what you 
want.

: The 'ls -l' works,but the result never gets stored in
: @device_list.

Oh, but it does.  It's just that you and system() have different ideas of 
what "result" means.



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

Date: Wed, 20 Aug 1997 16:45:52 GMT
From: knetsch@golden.net.no.spam (SJK)
Subject: Re: split perl string
Message-Id: <33fb1813.13147627@news.golden.net>

On Wed, 13 Aug 1997 09:24:01 -0500, Danny LaPrade <dannyl@computize.com> wrote:

>How do I split at string like
>
>"here1here2here3here4here5here6here7"
>
>every 5th character?
>
>And all are char (s).
>
>I want to be able to take this string
>and split it every five chars and the string
>can be anywhere from 0 to 100 chars long.
>Also want to be able to compare each to a string.
>
>Can anyone help ?
>Need something efficient.

Try this, does this give you the results you are looking for?

$instring="here1here2here3here4here5here6here7";
@splitstring = ($instring =~ /\w{5}/g);

foreach $string (@splitstring)
{
   print ("$string\n");
}

This searches for sequences of 5 characters falling in the range [_0-9a-zA-Z]
throught the entire string, regardless of length.  Every match is stored in the
list @splitstring.

Stuart K.
Stuart Knetsch

Remove the you know what from my address to send me E-mail


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

Date: Wed, 20 Aug 1997 09:52:16 -0700
From: Michael Schilli <mschilli@mission.base.com>
Subject: split() with capturing parantheses doesn't work correctly!
Message-Id: <33FB20C0.B8458B7@mission.base.com>

Hi Folks,

the match operand with split() doesn't work as I would expect with
capturing parantheses when an alternative is given. Let me explain this
real quick:

You know splitting:

split(/ /, "a b c");

-> ("a", "b", "c");


You also know splitting with capturing parantheses that preserve
the matched seperators in the result fields:

split(/( )/, "a b c");

-> ("a", " ", "b", " ", "c");


But the following doesn't work: I want either split on blanks OR some
other string. In case the string is matched, I wanna preserve it, if
the blank is matched, I don't.
This, however,

@a = split(/(b)|\s+/, "a b c");

produces

> a 
Use of uninitialized value at ./t line 5.
>
> 
> b
>
Use of uninitialized value at ./t line 5.
>
> c

Any ideas?


-- Michael

----------------------------------------------------------
  Michael Schilli         http://mission.base.com/mschilli
----------------------------------------------------------


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

Date: 20 Aug 1997 16:40:29 +0000
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: TCL 8.0: A whole lot of perl
Message-Id: <nqoiux0ajuq.fsf@mitra.phys.uit.no>

ajs@lorien.ajs.com (Aaron Sherman) writes:

> TCL 8.0 has just been released [...]

> TCL 8.0 now handles binary data, [...]. This is interesting because
> it is practically a point-for-point response to my (rather
> perl-positive) comparison of TCL and perl.

Yes, they had to get their act together sometime, didn't they?

> I would still put perl out ahead if only for:
> 
> 	Better variable handling, esp. in argument passing
> 
> 	A more robust parser, esp. for block handling
> 
> 	Slicker regex syntax (e.g. $string =~ /regex/ and $_ default)
> 	This is really the single point that puts perl in the
> 	lead of anything else on the command-line.
> 
> 	More sophisticated handling of variables leads to many
> 	other features. e.g. closures, simple object model, etc.

You forgot one:

	Perl handles lists with a lot of grace, where Tcl has none.
	(If the README news list was comprehensive, Tcl still carries
	a O(n) penalty on trivial list indexing, thus multiplying
	complexities on all algorithms using lists or arrays by O(n).)

> Of course, TCL has:

	... a long way to go?  :-)	

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 20 Aug 1997 12:30:56 -0500
From: arenson@hen.imgen.bcm.tmc.edu (Andrew D. Arenson)
Subject: Re: unexpected foreach value
Message-Id: <wqlo1wyd67.fsf@hen.imgen.bcm.tmc.edu>

arenson@hen.imgen.bcm.tmc.edu (Andrew D. Arenson) writes:
> Platform: Solaris2.5, perl-5.003
> 
> I have a simple loop:
> 
> 	foreach $trace (@traces) {
> 	    $result = &filter($trace);
> 	}
> 
> That is doing something quite unexpected. In a fully reproducable
> fashion, but for no reason I've been able to discern, the last time
> the variable '$trace' is set, instead of actually getting the value
> of $traces[$#traces], it gets either 8 or 0.
> 
> The above is a simplification of the code. I'd be more than happy
> to expand on it, but I didn't want to scare people off right away.
> I've used the debugger to get to the inner code above and am stunned
> to see:
> 
>   DB<11> p $trace
> 8
>   DB<12> p $traces[$#traces]
> Bcm::PM_Trace=HASH(0x76f260)


Well, I didn't figure out _exactly_ why this is failing, but I've come
close. It seems that there is a seek/read pair which is using
the wrong seek value, and thus reading the wrong value. I would
love to hear any comments about whether people think this _kind_
of thing should happen. If you give seek a totally bogus value and
the try to read from that filehandle, should your other variables be
at risk like this?

Andy

 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .

-- 
Andrew D. Arenson            | http://gc.bcm.tmc.edu:8088/cgi-bin/andy/andy
Baylor College of Medicine   | arenson@bcm.tmc.edu        (713)  H 520-7392
Genome Sequencing Center, Molecular & Human Genetics Dept.     | W 798-4689
One Baylor Plaza, Room S903, Houston, TX 77030                 | F 798-5386


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

Date: Wed, 20 Aug 1997 14:55:41 -0400
From: John Hardegree <codie@concentric.net>
Subject: Win32 Perl -> C Compiler
Message-Id: <33FB3DAD.4CAF@concentric.net>

Can anyone tell me if there is a "perl to C" compiler that runs
under windows 95?

I want to write some scripts in perl but I have to run them on
hundreds of PC's and I just cannot afford to install the
interpreter on all of them.

Thanks
-- 
*====================================================================*
|                John Hardegree - Gandalf Development                |
|  (205)824-0056 (voice)  (205)995-0224 (Fax)  Codie@concentric.net  |
*====================================================================*


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

Date: Wed, 20 Aug 1997 16:43:52 +0000
From: Alten Limited <alten@dial.pipex.com>
Subject: Re: Win95 + Perl back-quotes or fx(<system command>) assignment not working.
Message-Id: <33FB1EC8.75AD@dial.pipex.com>

Gordon McDorman wrote:
> 
> >>>>> "AL" == Alten Limited <alten@dial.pipex.com> writes:
> 
>     AL> I've downloaded Perl 5 (build 307) from ActiveWare and
>     AL> installed it on the Windows 95 machine I'm using (for my
>     AL> sins).
> 
>     AL> My problem is that in the statement:
> 
>     AL> @catch_variable = `dir`;
> 
> I can't say much about using Perl on Win95, but you might
> at least consider replacing the `dir` statement with:
> 
> --------------
> 
> opendir NEWDIR, "." || die "Could not open directory: $!";
> 
> @catch_variable = (readdir NEWDIR);
> 
> closedir NEWDIR;
> 
> --------------
> 
> And thus avoiding the backtick problem (as well as many
> others).

Thanx Gordon - 

That looks like a fine solution to the
what's-the-content-of-the-current-working-directory problem.  However,
the use of "dir" was only to give example of the my root problem which
is getting back-quotes or fx( ) to work.  Though, by implication, you do
make a good point that the direct use of system-commands is non-open
programming, i.e. I couldn't run the same script on Solaris, atleast not
without making another script to emulate "dir".

Anyhow, I'm still interested in getting back-quotes or fx( ) to work,
mostly so I can run the build-110 test scripts which use the feature ...
I guess I could always re-write the scripts to remove the use of
back-quotes (**groan**), but since they're targeted at Win95 (which is
what I'm blessed with), there must be some deeper problem stopping them
from working as-they-are.

Ian Ashton-Reader
-- 
Alten Ltd, Linton House
164/180 Union Street - Waterloo		Tel: 0171 401 8222
London SE1 OLH - United Kingdom		Fax: 0171 401 3553
alten@dial.pipex.com & http://dialspace.dial.pipex.com/alten




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

Date: Wed, 20 Aug 1997 21:32:38 +0200
From: link@tss.no (Terje Bless)
Subject: Re: Year 2038 (was Re: Help! - Reformatting Date)
Message-Id: <link-2008972132380001@news.uit.no>

In article <slrn5v9ge3.4en.bet@waltz.rahul.net>,
    bet@network.rahul.net (Bennett Todd) wrote:

>If you get impatient, just switch to Linux on an alpha.

I suppose you'll be paying for this impatience?

-- 
He wrote, while looking speculatively at the unused A300 in the corner. :-)


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

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

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