[11093] in Perl-Users-Digest
Perl-Users Digest, Issue: 4693 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 19 20:05:26 1999
Date: Tue, 19 Jan 99 17:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 19 Jan 1999 Volume: 8 Number: 4693
Today's topics:
byteperl woes <kj0@mailcity.com>
Re: Calling a sub <aqumsieh@matrox.com>
Re: Can I manipulate Win apps using Perl? <address@web.page>
Clueless Newbie..... <elephant@atlantic.net>
Copying Filetrees / Perl Win32 (Stieglitz Tom)
Re: error handling <kprice@cardinal.co.nz>
Finding who's logged into remote computer eugenes@exchange.ml.com
flock <mmorgan@gladstone.uoregon.edu>
fork help needed. <mwatkins@promotion4free.com>
Re: Formatting in Perl <aqumsieh@matrox.com>
Help sought with complex extraction/report (Eric Schiller)
Re: How to determine time? (Sam Holden)
Is there a way in perl for children to survive their pa <arnej@fc.hp.com>
Is there a way to create self contained perl executable <neilpaku@paradise.net.nz>
location of the faq (was append to beginning) <jewell@OnlineRAGE.com>
newbie - endless loop on simple program. <rjohn@raptor.com>
Re: newbie - endless loop on simple program. <uri@home.sysarch.com>
Newbie question about running aps <lee@canwave.com>
Re: Newbie question about running aps (Martien Verbruggen)
perl and /dev/ttyS1 (Scott Knight)
perl and /dev/ttyS1 (Scott Knight)
Re: perl and /dev/ttyS1 (Martien Verbruggen)
Re: Perl Criticism <staffan@ngb.se>
Re: Perl Criticism (Sam Holden)
Re: Perl problem :(Offline mode... (Sam Holden)
POP3 server in perl ? <mcd@datacourse.com>
Re: problem with: use module; <aqumsieh@matrox.com>
Remove all %0A's from string??? (Ken Williams)
Re: Remove all %0A's from string??? (Larry Rosler)
text indexes from lists sno@ais.org
variable scoping question <blavender@spk.usace.army.mil>
Re: Verify an email address <henk@crash.nu>
Win32 extentions eugenes1@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Jan 1999 00:45:18 GMT
From: kj0 <kj0@mailcity.com>
Subject: byteperl woes
Message-Id: <7838uu$m1q$1@news.panix.com>
Is there a simple (undocumented) way to build byteperl? I've tried
everything I can think of, and nothing works. This is in sharp
contrast with perl5.005_02, which went without a hitch. Crazy.
Thanks in advance,
KJ
------------------------------
Date: Tue, 19 Jan 1999 14:06:35 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Calling a sub
Message-Id: <x3yiue3t744.fsf@tigre.matrox.com>
richfunk@hotmail.com writes:
>
> What are you trying to achieve ?
Using symbolic references to call subroutines.
> $mysub = "function1"; simply assigns the string function1 to the variable
> $mysub.
> You call the subroutine using &function1.
or, you can call it using the symbolic reference $mysub:
&$mysub;
Side note: there is more than one way to call a subroutine:
from perlsub:
To call subroutines:
NAME(LIST); # & is optional with parentheses.
NAME LIST; # Parentheses optional if predeclared/imported.
&NAME; # Passes current @_ to subroutine.
> $mysub would be assigned the value 1, if the subroutine was successful.
How? where does it do that?
>
> Rich
> email: richfunk@hotmail.com
>
>
> In article <36A48B2E.CCBF6039@cat.at>,
> Gernot Homma <gernot@cat.at> wrote:
> >
> > Hello,
> >
> > I'm looking for a solution for the following problem
> >
> > $mysub = "function1";
> >
> > sub function1
> > {
> > print "Hello";
> > }
> >
> > I want to call "function1" though the scalar $mysub.
> > Is there a gobal solution? I know I could solve this problem with "if" -
> > statements, but I do'nt want to work this way.
> >
> > Many thanks in advance,
> > Gernot
Allow me to suggest another approach. Use hashes of anonymous
subroutines. The keys of the hashes would be the names of the
subroutines, and the values would be reference to the subroutines
bodies.
$hash{function1} = sub { print "Hello" }
then, you can invoke subroutines like so:
$mysub = "function1";
&{$hash{$mysub}};
Hope this helps,
Ala
------------------------------
Date: 19 Jan 1999 14:26:18 PST
From: "Phlip" <address@web.page>
Subject: Re: Can I manipulate Win apps using Perl?
Message-Id: <7830qa$6a4@journal.concentric.net>
Eric Bohlman escribis:
>mere_mortal@my-dejanews.com wrote:
>: I am about to start the scripting journey...
>
>: I have to implement a script that needs to manipulate Windows apps
to make
>: them output files. Can I use Perl to manipulate these apps? For
example, can
>: I launch WINFOO.EXE, make WINFOO save a document, then close
WINFOO?
>
>If they're OLE Automation servers, then you can use Win32::OLE to
control
>them.
Here's a question: Win32's response to shell scripts like 'bash' is
the Windows Scripting Host. It use the ActiveX Script interface to
plug into any conforming language. Of course the two available from MS
are the VBScript and JScript interpreters.
If you miss Perl that badly, couldn't you point the Host at
ActiveState's PerlScript interpreter?
(A related question - what problem could this possibly solve better
than other solutions? ;-)
-- Phlip at politizen dot com (address munged)
======= http://users.deltanet.com/~tegan/home.html =======
-- Personally qualified to snub Mensa --
------------------------------
Date: Tue, 19 Jan 1999 19:12:20 -0500
From: "Glyn" <elephant@atlantic.net>
Subject: Clueless Newbie.....
Message-Id: <Vb9p2.1394$n3.2043@news1.atlantic.net>
heres the call.... <!--#exec cgi="/cgi/banlink.pl"-->
heres the script:
#!c:/perl/bin
$|=1;
$mypic[0]="/bannerimages/test/banner1.gif WIDTH=400 HEIGHT=40";
$myurl[0]="http:///index.shtml";
$mypic[1]="/bannerimages/test/banner3.gif WIDTH=400 HEIGHT=40";
$myurl[1]="/index.shtml";
$mypic[2]="/bannerimages/test/banner2.gif WIDTH=400 HEIGHT=40";
$myurl[2]="/index.shtml";
$mypic[3]="/bannerimages/test/banner3.gif WIDTH=400 HEIGHT=40";
$myurl[3]="/index.shtml";
srand(time ^ $$);
$pick = rand(@mypic);
print "Content-type: text/html\n\n";
print "<A HREF=\"$myurl[$pick]\"> <IMG SRC=$mypic[$pick]></A>";
What am I doing wrong??? When I go to the URL
"http://www.hernandocountyrealty.com/airports/page.shtml" it trys to load
the graphic, but just dosn't seem to do it......
------------------------------
Date: Wed, 20 Jan 1999 00:00:06 +0100
From: Thomas.Stieglitz@t-online.de (Stieglitz Tom)
Subject: Copying Filetrees / Perl Win32
Message-Id: <7833at$b0$1@news00.btx.dtag.de>
Hi all,
I know, this question was discussed here about half a year ago, but I don't
find any old remarks; neither in dejanews nor in my local database, also I
find no answer in the known FAQs. So I hope I'm not boring you ....
I have to copy a whole tree from one directory to another. A possiblity to
copy only newer files would be great, but is not absolute necessary. I there
a perl module, similar to file, which can handle whole filetrees. I have
also tried to use 'xcopy from to' or system (xcopy from to) but this doesn't
work.
Who has experiance with copying filetrees under NT and can help? I'm using
the actual distribution of Active Perl under NT WS 4.0 (SP3).
Thanks for all advices,
Tom
------------------------------
Date: Wed, 20 Jan 1999 12:50:19 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: error handling
Message-Id: <36A51A3B.79DA8E80@cardinal.co.nz>
Vyacheslav Volodchenko wrote:
>
> I am trying to convert postscript image file into gif format.
>
> The programme for doing this is called "pstogif". Problem is that
> when running this programme, it produces output that I am not concerned
> about and just want to redirect it to /dev/null. It works
> fine when I type command in linux command prompt.
>
> The following script generates a run time error.
> It says "sh: Bad number".
>
> #!/usr/local/bin/perl
>
> $ps_file = "picture.ps"; # postscript file
> `pstogif $ps _file >& /dev/null`;
^^
You are redirecting STDOUT to a file named &, which is probably not what
you intended. RTFM IO redirection
>
> I think shell misinterprets redirection and considers it as a part of
> the command.
>
> Can anyone suggest me a way to run srcipt in the context of different
> shell or a different way to avoid output from this program being printed on
> the screen.
>
> Thanks in advance.
> Slava
------------------------------
Date: Wed, 20 Jan 1999 00:08:24 GMT
From: eugenes@exchange.ml.com
Subject: Finding who's logged into remote computer
Message-Id: <7836pg$uiv$1@nnrp1.dejanews.com>
Hello..
I am not sure whether my first message posted or not, but I am trying to find
a way to see who's logged in on the remote computer on an NT network
(Netbios). Is something like this possible with Perl-Win32?
Many thanks,
Eugene
email: eugenes@exchange.ml.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 19 Jan 1999 16:48:19 -0800
From: "M. Morgan" <mmorgan@gladstone.uoregon.edu>
Subject: flock
Message-Id: <7838r5$1q7$1@pith.uoregon.edu>
Anyone here know about flock?
In the case of a HTML guestbook, it will prevent any errors that might
happen if two people try to write to the
guestbook at the same time. For example:
open(LOG, ">>logfile.txt") || die "an error occured";
flock(LOG,2);
print LOG $comments;
flock(LOG,8);
close(LOG);
I do not know the reason behind the 2 and 8, but I know that flock(FILE,2);
begins the flock and flock(FILE,8); ends the flock.
My question is if I have two files that need to be written to are both safe
with flock if I do the following:
open(LOG, ">>logfile.txt") || die "an error occured";
flock(LOG,2);
print LOG $comments;
flock(LOG,8);
close(LOG);
open(DATA, ">>datafile.txt") || die "an error occured";
flock(DATA,2);
print DATA $comments;
flock(DATA,8);
close(DATA);
Or do I need to do this:
open(LOG, ">>logfile.txt") || die "an error occured";
flock(LOG,2);
print LOG $comments;
open(DATA, ">>datafile.txt") || die "an error occured";
flock(DATA,2);
print DATA $comments;
flock(DATA,8);
close(DATA);
flock(LOG,8);
close(LOG);
Or would one file close as soon as I open another one? Can you offer any
help on this?
-Mike Morgan
------------------------------
Date: Tue, 19 Jan 1999 23:27:29 -0000
From: "Mike Watkins" <mwatkins@promotion4free.com>
Subject: fork help needed.
Message-Id: <O77PwMAR#GA.273@ntawwabp.compuserve.com>
Hi there,
Have a little problem here. I created a script with which contains a large
database of users. I want to add in the feature so that the Admin can send
all users a personalized messages. So the script will gather up all of the
e-mail addresses, and info needed.
All I need to know, is how do you "fork" it, so while the script is e-mailng
everyone, it shows a web page which refreshes say every 10 seconds? Then
once it's done e-mailng, when the web page refreshes again, it'll say
"E-Mail Sent Successfully!"
Basically, how do I run a background process, while something in the
"foreground" is taking place?
Thanks,
Mike
------------------------------
Date: Tue, 19 Jan 1999 13:54:27 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Formatting in Perl
Message-Id: <x3yk8yjt7od.fsf@tigre.matrox.com>
richfunk@hotmail.com writes:
> as possible, I want to format this text.
>
> Is the Perl Format funtion the best/ only option ?
Perl's FORMAT is very powerful. I believe it should do what you
want. You can also look at printf(). But remember that the "rl" in
Perl stands for "Report Language".
Also, there is no *ONLY* (one) option to do anything in Perl. TMTOWTDI.
<snip>
> How do i now assign this formatted text 4to the variable $emailbody ?
read perldoc perlform for the answer.
> Any help or tips would be much appreciated......
the manuals are your friend in this case.
HTH,
Ala
------------------------------
Date: Wed, 20 Jan 1999 00:12:44 GMT
From: nospam@chessworks.com (Eric Schiller)
Subject: Help sought with complex extraction/report
Message-Id: <36a51f46.15997849@nntp.best.com>
In order to make a substantial database of chess games available over
the
net, I need to translate from the Portable Game Notation format (PGN)
to a
database format. There are some challenges here that exceed my
abilities.
As you can see in the examples below, the header fields may vary in
number
and form. My goal is to create a report in the form:
FIELDNAME;VALUE (where ; is a delimiter)
e.g. [Event "Midwest Masters"] --> Event;Midwest Masters
for each header tag, followed by the move record. Header tags vary in
length, as do the values, which are enclosed in quotes. The move
recored
is the material starting with 1. on a newline, ending at the blank
line
(end of record). The move record sometimes contains control characters
(a
result of output from one popular software package) which may not
appear
in this post.
I'd greatly appreciate any help I can get get. When I have a script
that
works, I intend to post it to the various chess usenet groups so that
programmers can convert the PGN format to various database formats.
There are some generally useful aspects to the problem, including
extracting the field names and values, so it would be useful to post
replies to the newsgroup. if possible, I'd appreciate a copy by email
to
author@chessworks.com. Thanks to all who can help!
Here are three records in PGN format. The data collection includes
approximately
1.5 million games, most of which resemble the first example.
[Event "Midwest Masters"]
[Site "Chicago"]
[Date "1987.??.??"]
[Round "?"]
[White "Hanken, Jerome"]
[Black "Schiller, Eric"]
[Result "0-1"]
[ECO "A13"]
[PlyCount "92"]
[EventDate "1987.??.??"]
1. c4 e6 2. g3 d5 3. Bg2 c6 4. Nf3 Bd6 5. b3 f5 6. Bb2 Nf6 7. d3 Qe7
8. O-O e5
9. e3 O-O 10. Nc3 Nbd7 11. cxd5 Nxd5 12. Nxd5 cxd5 13. Nd2 Nf6 14. f4
Kh8 15.
Nf3 e4 16. dxe4 dxe4 17. Nd4 Rd8 18. Qe2 Bd7 19. Rfd1 a6 20. Bh3 g6
21. Rac1 h6
22. Rc2 Kh7 23. Rdc1 Nd5 24. a3 $2 Bxa3 25. Bxa3 Qxa3 26. Rc5 b6 27.
R5c2 Qd6
28. Rd2 Rac8 29. Ra1 a5 30. Kf2 Nb4 31. Bf1 Qf6 32. Qd1 Be8 33. Rc1
Bf7 34.
Rxc8 Rxc8 35. Nb5 Kg7 $1 36. Rd7 Qb2+ 37. Kg1 Rc1 38. Qd6 Nd3 39. Qd4+
Qxd4 40.
Nxd4 Nc5 41. Rc7 Nxb3 $1 42. Rxf7+ Kxf7 43. Nxb3 Rc3 44. Kf2 a4 45.
Nd2 a3 46.
Bc4+ Rxc4 0-1
[Event "Simul"]
[Site "?"]
[Date "1972.??.??"]
[Round "?"]
[White "Reshevsky"]
[Black "Schiller"]
[Result "0-1"]
[ECO "D25"]
[WhiteElo "1770"]
[BlackElo "2450"]
[PlyCount "84"]
[EventDate "1972.??.??"]
1. d4 d5 2. c4 dxc4 3. Nf3 Nf6 4. e3 g6 5. Bxc4 Bg7 6. O-O O-O 7. Nc3
Nfd7 {
Smyslov's system.} 8. Qe2 (8. e4 Nb6 9. Be2 Bg4 10. Be3 Nc6 {was
played in
Evans - Smyslov, Helsinki Olympiad 1952, which was a game I had
studied in
preparation for this contest. Black has a lot of pressure on the
center. Play
continued} 11. d5 Bxf3 12. Bxf3 Ne5 13. Be2 Nec4 {
with pressure on the long diagonal. After 14.Bc1 c6! Black had a
strong game.})
8... Nb6 9. Bb3 Nc6 $5 {
An attempt to improve on Golombek - Smyslov, Budapest 1952, which saw
9...a5.}
10. Rd1 Bg4 11. h3 Bxf3 12. Qxf3 Qe8 {This move has the goal of
blasting open
the center. After the king moves to the h-file Black can advance both
e- and
f-pawns.} 13. Nb5 $6 {Gligoric improved against me a week or two later
with 13.
Ne4!, with the threat of Nc5. Serves me right for getting the game
published
in the New York Times!} 13... Rc8 14. Bd2 a6 15. Na3 Kh8 16. Rac1 e5
$1 17. d5
e4 18. Qf4 { Now it is clear that the Nc6 is headed for e5, with the
possibility of jumping into f3. If only the g-file were open and a
rook stood
on g8...} 18... g5 $1 19. Qxg5 Ne5 20. Bc3 {
The pin looks strong - but checks have been known to break pins!}
20... Nf3+
$3 21. gxf3 Bxc3 22. Kh1 (22. bxc3 Rg8) 22... Rg8 23. Qf4 Qd7 24. Qh4
Qf5 $1 {
Black continues to make threats while improving the position of his
queen,
before capturing the pawn at b2.} 25. f4 Bxb2 26. Rg1 Bxc1 27. Rxc1
Qg6 28. Qg4
Qxg4 29. hxg4 Rxg4 {White could have resigned here.} 30. Rg1 Rxg1+ 31.
Kxg1 Rd8
32. d6 Rxd6 33. Bxf7 Rd3 34. Nc2 c5 35. Be6 Rc3 36. Ne1 Rc1 37. Kf1
Nc4 38. Ke2
b5 39. Bd5 Ra1 40. Bxe4 Rxa2+ 41. Kd1 Rxf2 42. Nd3 Rd2+ 0-1
[Event "Eastern HS Championship"]
[Site "New York City"]
[Date "1970.??.??"]
[Round "8"]
[White "Schiller"]
[Black "Jacobs"]
[Result "1-0"]
[SetUp "1"]
[FEN "b4r2/p2qn2p/3p3k/2p3p1/5N2/2Q1N1P1/PP5P/3R2K1 w - - 0 29"]
[PlyCount "1"]
[EventDate "1970.??.??"]
28. Rxd6+ (28. Rxd6+ Qxd6 29. Ng4#) 1-0
------------------------------
Date: 20 Jan 1999 00:10:48 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to determine time?
Message-Id: <slrn7aa7o8.mma.sholden@pgrad.cs.usyd.edu.au>
On Tue, 19 Jan 1999 13:39:03 -0600, Michael Kangas <kangas@anlon.com> wrote:
>($s,$m,$h,$d,$mo,$yr,$wk,$yd,$i) = localtime(time);
>
>print "seconds: $s\n";
>print "minutes: $m\n";
>print "hour: $h\n";
>print "day of month: $d\n";
>print "month: $mo\n";
>print "year: $yr\n";
>print "weekday: $wk\n";
>print "Day of Year: $yd\n";
>print "isdst: $i\n";
Or maybe just print scalar localtime;
--
Sam
Just don't create a file called -rf. :-)
--Larry Wall
------------------------------
Date: Tue, 19 Jan 1999 16:02:11 -0700
From: Arne Jamtgaard <arnej@fc.hp.com>
Subject: Is there a way in perl for children to survive their parent?
Message-Id: <36A50EF2.20DA@fc.hp.com>
I'm trying to do some concurrent programming, generating
information with one process and doing some manipulation
with another. I know how to launch child processes using
fork/exec. However, if the first process finishes before
the child, it causes the child to die as well.
If the answer is merely to have the parent wait until the
child is done, I can do that. I'm hoping for some sort of
NOHUP in perl. If there's a way to pull this off, I'd
really appreciate a pointer towards where to look.
Arne
------------------------------
Date: Wed, 20 Jan 1999 13:10:08 -0800
From: neilpaku <neilpaku@paradise.net.nz>
Subject: Is there a way to create self contained perl executable?
Message-Id: <36A64630.60D9@paradise.net.nz>
Hi all,
I couldn't find in the faqs a solution to my problem. I would like to
create a script that also contained the perl interpreter so that I could
place this script on any machine and run it without having to install
perl. Is this possible? The intended platform is nt. If it is possible,
where can I find examples?
Thanks for your time,
Neil.
------------------------------
Date: Tue, 19 Jan 1999 19:36:24 -0500
From: "Ronnie D. Jewell" <jewell@OnlineRAGE.com>
Subject: location of the faq (was append to beginning)
Message-Id: <36A52508.64D0DB18@OnlineRAGE.com>
Thanks guys and girls....
I figured out how "to add as a supplement or appendix", "attach",
"affix", "prepend", "whatever the heck you want to call it" my text to
the file....
For future reference; where do I find a copy of the FAQ everyone
mentioned?
Thanks!!
--
RAGE Enterprises
Ronnie D. Jewell jewell@onlinerage.com
voice: 304-525-1898
http://www.onlinerage.com
------------------------------
Date: Tue, 19 Jan 1999 18:12:46 -0500
From: "Robert E. John" <rjohn@raptor.com>
Subject: newbie - endless loop on simple program.
Message-Id: <7833jc$2dg$1@news.raptor.com>
Hi, I am new to Perl (2 weeks). Here is my problem:
The following code fragment produces an endless loop?
# CODE FRAGMENT
$num=0;
$increment=0.1;
until ($num == 1.1) {
print("$num ");
$num = ($num + $increment); #Am I doing something bad here??
} #END OF CODE FRAGMENT
The program is simply supposed to output 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
1.0
Why doesn't the until expression ever become true, and end the loop?
Notice the following curious output when $num gets to 5.9
5.7
5.8
5.9
5.99999999999999
6.09999999999999
6.19999999999999
This suggests to me that the issue is related to floating point. But
my SAMS "Teach Yourself Perl in 21 Days" solves the problem a different
way, and hence doesn't shed light on my wrong solution.
By the way, here is their solution, which works fine, is:
#SAMS solution
$count = 1;
$number = 0.1;
until ($count == 10) {
print ("$number\n");
$number = $number + 0.1;
$count = $count + 1;
}
#END of Sams solution
I think I am missing a fundamental concept related to Perl, strings, scalars
and floats.
Thank you in advance.
Robert John
Lexington, MA
------------------------------
Date: 19 Jan 1999 18:30:04 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: newbie - endless loop on simple program.
Message-Id: <x7g196et8j.fsf@home.sysarch.com>
>>>>> "REJ" == Robert E John <rjohn@raptor.com> writes:
REJ> $num=0;
REJ> $increment=0.1;
REJ> until ($num == 1.1) {
^^
use >=
REJ> This suggests to me that the issue is related to floating point.
REJ> But my SAMS "Teach Yourself Perl in 21 Days" solves the problem a
well 14 days have passed by andhave you learned 2/3 of perl? :-)
get a better book. any by o'reilly and stay aways from any perl book
with a time limit in its title.
REJ> I think I am missing a fundamental concept related to Perl,
REJ> strings, scalars and floats.
^^^^^^
yes you are. never test for equality with floats after arithmetic
operations, in any language. always compare with <, >, or <=, >=.
hth,
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Tue, 19 Jan 1999 22:52:06 GMT
From: "Lee" <lee@canwave.com>
Subject: Newbie question about running aps
Message-Id: <q08p2.549$5W2.158056@client.news.psi.net>
Hi,
Could you show me how to run one application, sending two parameters with
that aps then
waiting util it returns some parameters?
Thanks.
------------------------------
Date: Wed, 20 Jan 1999 00:45:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie question about running aps
Message-Id: <HG9p2.97$7g1.6076@nsw.nnrp.telstra.net>
In article <q08p2.549$5W2.158056@client.news.psi.net>,
"Lee" <lee@canwave.com> writes:
> Could you show me how to run one application, sending two parameters with
> that aps then waiting util it returns some parameters?
>From a perl script, I presume?
# perldoc -f system
or in other words: Read up on the system() builtin in the perlfunc
documentation.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Tue, 19 Jan 1999 18:09:27 -0600
From: scott@tech.chhs.chuh.org (Scott Knight)
Subject: perl and /dev/ttyS1
Message-Id: <scott-1901991809280001@p10-clv-ts6.en.net>
I know this question was jsut asked, and i know its in the faqs, but if
any perl experts out there can jsut give me a hand I d apprecaite it. I
have a simple thing id like to do, at least i think it soudl be simple. I
have a weather device on my linux box to read temperature on one of the
com prts, /dev/ttyS1 I need to write ":" to it and then it should give me
a ">" back then i need to write "DMP" to it and it should give me a long
tring back full of tempoeratures and windspeed and such. I would think
this would be simple input output stuff, but im only begging with perl and
wopuld lvoe some help. If anyone can give me some stuff to get me going
and maybe a little more info than in the perfaq8 about it, id really
apprecaite it. Thanks a lot.
Scott Knight
------------------------------
Date: Tue, 19 Jan 1999 18:50:39 -0500
From: scott@tech.chhs.chuh.org (Scott Knight)
Subject: perl and /dev/ttyS1
Message-Id: <scott-1901991850390001@p10-clv-ts6.en.net>
I need some quick help with serial interface stuff with perl and i
didnt seem to find what i wanted in prelfaq8. I have a weather device
hopoke dup to like com2 on my linux box. Accesed on /dev/ttyS1 but
possibly ttyS0 anywaythats not the point. I need to write ":" to it and
wait for it to give me ">" back then i need to write "DMP" at which point
it should give me something like
"03/15 24:03 62 30.68 280 000 99.99 20" back. I need some
way to do this. I know all this because ive done this in C but i would
like to do this in perl so as to make some of this data availibale on the
web, and im leanring perl, so i figure its a good thing to know. If anyone
can offer an suggestions and mroe reading besides perfaq8 itd be much
appreciated. Thanks
Scott Knight
------------------------------
Date: Wed, 20 Jan 1999 00:56:48 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl and /dev/ttyS1
Message-Id: <kR9p2.108$7g1.6076@nsw.nnrp.telstra.net>
[You posted this twice, both times with different spelling error. It
would probably do you no harm to read your post before sending it, and
making sure you make sense.]
In article <scott-1901991809280001@p10-clv-ts6.en.net>,
scott@tech.chhs.chuh.org (Scott Knight) writes:
> I know this question was jsut asked, and i know its in the faqs, but if
> any perl experts out there can jsut give me a hand I d apprecaite it. I
Which part of the perl faq, section 8 do you have problems with? What
have you tried? Where is your test code?
> have a simple thing id like to do, at least i think it soudl be simple. I
> have a weather device on my linux box to read temperature on one of the
> com prts, /dev/ttyS1 I need to write ":" to it and then it should give me
> a ">" back then i need to write "DMP" to it and it should give me a long
You want to read and write. So you open the device for update.
# perldoc -f open
[read, and note that opening with '+<' seems to be the best way for
this]
You will probably also need to send end-of-line characters. The faq
talks about that.
Anyway, you mention in your other post that you have done all this in
c. What is the problem with just taking that code as a template, and
translating it to perl? It's not that incredibly different.
> tring back full of tempoeratures and windspeed and such. I would think
> this would be simple input output stuff, but im only begging with perl and
yep. print and read functions would be appropriate.
> wopuld lvoe some help. If anyone can give me some stuff to get me going
> and maybe a little more info than in the perfaq8 about it, id really
> apprecaite it. Thanks a lot.
Again: In what way is the perl faq not clear enough? If you tell us
what you don't understand, then maybe we can help. If you show us what
you tried, maybe we can point out problems.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: Wed, 20 Jan 1999 00:18:52 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Perl Criticism
Message-Id: <36A512DC.52867B92@ngb.se>
Tad McClellan wrote:
>
> Staffan Liljas (staffan@ngb.se) wrote:
> : topmind@technologist.com wrote:
>
> : > ththththaaaattzzit = thththfileoppzen(<ffffilehandle>,"name.ththat")
> ^^^^^^^^^^^^^^^^^^
>
> : Interesting. This is the first piece of perl code we see from topmind.
> : I'm not surprised he's mad at perl. WHY DOESN'T THIS WORK???
>
> perl says:
>
> "Can't modify constant item in scalar assignment at..."
Hmm. I was only kidding. I guess I have to remember the ;) even in
obvious cases. Sorry to waste your time....
Staffan
------------------------------
Date: 20 Jan 1999 00:35:11 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Criticism
Message-Id: <slrn7aa95v.mma.sholden@pgrad.cs.usyd.edu.au>
On Tue, 19 Jan 1999 17:06:12 GMT, topmind@technologist.com wrote:
>In article <slrn7a5hcr.dj5.sholden@pgrad.cs.usyd.edu.au>,
> sholden@cs.usyd.edu.au wrote:
>> On Sat, 16 Jan 1999 20:46:38 GMT, topmind@technologist.com wrote:
>> >
>> >
>> >But people who use a lot of languages will keep forgetting
>> >the ":" and accidently make them booleans.
>>
>> Of course people will also mistype 'eq' as '=' so there really is no
>> solution if you assume that the programmer is a complete and utter
>> moron as you assume to.
>>
>
>
>Come on now. I switch between dozens of languages. Every now and
>then I put Java in VB and visa versa. Without certain restrictions,
>it may just run, but be interpreted as a boolean or something
>unintended.
I seriously doubt you switch between 'dozens' of languages...
Please list at least 24 languages which you 'switch between'. I know
a fairly large number of programming languages in comparison with most
programmers I know (probably because they interest me in and of themselves),
but I be pressed to list 24 of them that I would say I 'switched' between.
I have used prolog, but I would never say I switch between it and perl, seeing
I have only used it for about 6 months in total, and need a manual every step
of the way. Same with lisp, and python even...
I can probably list 10 languages that I can program in well enough, and another
10 that I have used in the past, or am learning now. But I won't bore
everyone... Probably another 10 if you count things that I don't count as
languages...
>
>Am I the only one with this problem? Do you all use only one
>language and/or always keep them strait? (I am sure a few
>do keep them strait, but don't exprapolate your greatness
>in such a narrow area to everybody else.)
I mix a few things up when I swap from one language to another (especially
from c++ to c - those // comments get me every time). However, I can honestly
say I've never had a bug in some code that was caused by using a construct from
a different language in code - compile errors yes, but not a bug.
--
Sam
Remember that the P in Perl stands for Practical. The P in Python
doesn't seem to stand for anything.
--Randal Schwartz in <8cemsabtef.fsf@gadget.cscaper.com>
------------------------------
Date: 20 Jan 1999 00:08:46 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl problem :(Offline mode...
Message-Id: <slrn7aa7ke.mma.sholden@pgrad.cs.usyd.edu.au>
On Tue, 19 Jan 1999 21:46:50 +0000, Andrew Fry <andrewf@beausys.demon.co.uk>
wrote:
>
>Doh! You're right. I converted my non-CGI program so that it could
>run in non-CGI or CGI mode, tested as CGI and then returned to
>testing as non-CGI ... which is when I came across the problem.
>I guess the "name=value pairs" should have given me a clue.
>Just inexperience!
Just not bothering to read the manual!
--
Sam
PC's are backwards ... throw them out! Linux is ok though.
--Rob Pike (on the subject of CR/LF etc)
------------------------------
Date: Tue, 19 Jan 1999 14:49:18 -0800
From: Michael Dabrowski <mcd@datacourse.com>
Subject: POP3 server in perl ?
Message-Id: <36A50BEE.240A4D29@datacourse.com>
Does anyone know of a pop3 server written in perl or one which
accomodates for a file containing user id's and the corresponding
location of that user's mbox? Basically, I need to find a pop3 server
with virtual host support for DNS aliasing, and I'd prefer not to have
to code it :)
Thanks.
- Michael
_________________________________
Webmaster -- Datacourse Internet Solutions
email: mcd@datacourse.com
------------------------------
Date: Tue, 19 Jan 1999 14:26:27 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: problem with: use module;
Message-Id: <x3yhftnt670.fsf@tigre.matrox.com>
Julien 'Jay' Tane <jtane@etu.info.unicaen.fr> writes:
> it stops the compilation and prints:
> Module.pm did not return a true value at mainfile.pl
>
> BEGIN failed-- compilation aborted at mainfile.pl line 13
add the following line as the last line of your module:
1;
Modules have to return true values when use()d. perldoc perlmod for
more info.
You should also check out perldoc perldiag.
> And I a not the only one to whom that happened.
some sort of fan club?
------------------------------
Date: Tue, 19 Jan 1999 23:37:05 GMT
From: tekkin@hotmail.com (Ken Williams)
Subject: Remove all %0A's from string???
Message-Id: <36a516f6.0@news.cgocable.net>
I have a string:
%23+%0D%0A%23
How do I get rid of all the "%0A"'s?
I tried $string =~ tr/[%0A]//d;
but it don't do what I want.
Thanks.
------------------------------
Date: Tue, 19 Jan 1999 16:26:35 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Remove all %0A's from string???
Message-Id: <MPG.110ec2978f7783499899a7@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36a516f6.0@news.cgocable.net> on Tue, 19 Jan 1999 23:37:05
GMT, Ken Williams <tekkin@hotmail.com> says...
> I have a string:
>
> %23+%0D%0A%23
>
> How do I get rid of all the "%0A"'s?
>
> I tried $string =~ tr/[%0A]//d;
>
> but it don't do what I want.
That says "delete all characters '[' '%' '0' 'A' ']'".
I can't think of an easier or faster way than with a simple regex:
$string =~ s/%0A//g;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 19 Jan 1999 23:49:00 GMT
From: sno@ais.org
Subject: text indexes from lists
Message-Id: <7835l9$tgj$1@nnrp1.dejanews.com>
I'm not as frequent a reader of this newsgroup as I should be, so
if this is a lamer question, please point me in the right direction.
My desire is to have values in a regular array become a text key to
positions in another array.
For example:
@list_of_keys ('id', 'name', 'address', 'home phone', 'work phone');
@list_of_arrays = (
['1', 'George', '333 Way Way', 'none', '555-5555'],
['2', 'Pattie', '123 Orchard', '555-5555', '555-5555'],
['3', 'Gary', '4444 Forest', '555-5555', '555-5555']
);
I would like to be able to acquire a column of data from all lists using
the key name by position value.
So that conceptually:
$list_of_arrays[$num]['id'] would always reference the zero'th list position
of all records. 'name' would reference list position '1', etc.
The caveat to this is that depending on the table, the list of keys might
be different. Thus, for $list_of_another_array[] the table might be
altogether different, while still using the same code to process the
list.
Essentially, the desire is to reference a position with something like this:
$list_of_arrays[$num]->[*keyname from alternate source*] without having to
force a look-up compare loop for each call.
I hope this is clear. Anyway, I'm not a total moron when it comes to
Perl. The deeper concepts that might help me figure out a solution
to this are not yet understood.
My current project has to do with developing a tk-forms system for viewing
MySQL relational databases. I've designed a rudimentary Views DB, and have
sucessfully taken Views information and turned it into a very weak
display system for data stored in a relational system.
I'm not very far along on the actual record display, selection, or
editing/updating of records. My hope is that the above shortcut would
simplify that phase.
Thanks for the helpful responses.
--
Stephen N. Opal
sno@ais.org
www.ais.org/~sno
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 19 Jan 1999 23:18:50 GMT
From: Brian Lavender <blavender@spk.usace.army.mil>
Subject: variable scoping question
Message-Id: <7833sg$rvr$1@nnrp1.dejanews.com>
I am having some difficulty with "my". I have a while loop which grabs a list
array from an object. I print the data using a format. In the "First
Instance" I assign the variables which get sent to the format statement with
"my". In the "Second Instance" I do not. The "Second Instance" works while
the "First Instance" does not. The "First Instance" output from the write is
blank. Why is this?
brian
First Instance
---------------
while (my @row_ary = $sth->fetchrow_array) {
my ($coemis, $wi_code,$sum_atp_amt,$sum_paid_amt) = @row_ary;
# notice the my above
$woruntotob += $sum_atp_amt; $woruntotpd += $sum_paid_amt;
$~ = ACCOUNTS;
write;
}
Second Instance
---------------
while (my @row_ary = $sth->fetchrow_array) {
($coemis, $wi_code,$sum_atp_amt,$sum_paid_amt) = @row_ary;
# notice the lack of my
$woruntotob += $sum_atp_amt; $woruntotpd += $sum_paid_amt;
$~ = ACCOUNTS;
write;
}
format ACCOUNTS = @<<<<<<<<<<<<<<<<< @<<<<<<< @>>>>>>>>>> @>>>>>>>>>>
@>>>>>>>>>> ___________ __________ __________ _____________ __________
$coemis, $wi_code,$sum_atp_amt,$sum_paid_amt, $sum_atp_amt-$sum_paid_amt .
Brian E. Lavender
US Army Corps of Engineers -- Programmer / Systems Analyst
Sacramento, CA (916) 557-6623
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 20 Jan 1999 01:37:06 +0100
From: "Henk Slaaf" <henk@crash.nu>
Subject: Re: Verify an email address
Message-Id: <7838m3$nsm$1@dinkel.civ.utwente.nl>
http://www.perl.com/CPAN-local/
Go there and you will find what you're looking for. However, you could have
found this by yourself, by looking at www.perl.com....
------------------------------
Date: Wed, 20 Jan 1999 00:01:22 GMT
From: eugenes1@my-dejanews.com
Subject: Win32 extentions
Message-Id: <7836cc$u6h$1@nnrp1.dejanews.com>
Hello.
I am writing a small network administration script that will go out and
search an NT domain for all computers and then display who is logged into
each active computer. Is there a function that I can use that can return a
username of the person logged into remote computer? This is similar to
'NBSTAT -a computer' only I am looking for Perl-native solution. Any help
would be appreciated.
email: eugenes@exchange.ml.com
Thanks!
-Eugene
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4693
**************************************