[19628] in Perl-Users-Digest
Perl-Users Digest, Issue: 1823 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 26 14:05:35 2001
Date: Wed, 26 Sep 2001 11:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1001527508-v10-i1823@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 26 Sep 2001 Volume: 10 Number: 1823
Today's topics:
Re: [ASK[ Perl and Windows <skj@iobox.fi>
Re: a "private" installation of Perl <Peterca@btopenworld.com>
A pack() question (Stan Brown)
Re: Creating modules (Anno Siegel)
Re: Help: mail script (WIN) (Logan Shaw)
Re: Managing Child Processes nobull@mail.com
Re: MIME::Lite problem <randy@theoryx5.uwinnipeg.ca>
Net::FTP help for login & script <ldk006@email.mot.com>
Re: ONE QUESTION (remove the obvious)
Re: Peek and Poke on Perl? (Logan Shaw)
Re: Single line if Statement <whatever@nevermind.invalid>
Re: Single line if Statement <whatever@nevermind.invalid>
Re: String Comparison Problem <dtweed@acm.org>
time and win32 perl <inna@raykhman.com>
Re: time and win32 perl <rob_13@excite.com>
Re: Transforming HTML <iltzu@sci.invalid>
Re: What does ||= do ? <peb@bms.umist.ac.uk>
Re: What does ||= do ? (Stan Brown)
Re: What's wrong with this code ? (Ken Laird)
Re: What's wrong with this code ? (David Wall)
Re: Works sometimes - tmadmin <Thomas@Baetzler.de>
Re: XML::Writer question... how to write output to file <julius_mong@hotmail.com>
Re: XML::Writer question... how to write output to file <epa98@doc.ic.ac.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Sep 2001 18:54:40 +0300
From: Sami Jarvinen <skj@iobox.fi>
Subject: Re: [ASK[ Perl and Windows
Message-Id: <MPG.161c26a6f1c96cf9896c3@news.yhteys.mtv3.fi>
Bob Walton <bwalton@rochester.rr.com> wrote
> Sami Jarvinen wrote:
> > Indeed there is. ActivePerl comes with a nice program called 'wperl.exe'
> > which, unlike 'perl.exe', is not a console application, I.e. it won't
> > create a shell window.
> Thanks! Not a lot of docs on that one. How did you ever find out about
> it?
Just out of curiosity I looked through all the files in perl\bin. The
name resembled 'javaw.exe' (which is similar in function to 'wperl.exe'),
so I just tried it :)
------------------------------
Date: Wed, 26 Sep 2001 17:47:49 +0100
From: "Peter Cameron" <Peterca@btopenworld.com>
Subject: Re: a "private" installation of Perl
Message-Id: <9ot0t1$69f$1@plutonium.btinternet.com>
I've discovered what I want to do isn't yet possible. Searching for
"relocatable perl" provided me with the current status at:
http://www.perl.com/pub/a/2001/05/p5pdigest/THISWEEK-20010506.html
Oh well :)
Peter
------------------------------
Date: 26 Sep 2001 11:08:55 -0400
From: stanb@panix.com (Stan Brown)
Subject: A pack() question
Message-Id: <9osr27$ne3$1@panix2.panix.com>
Could someon explain the following line to me?
my @row = unpack( "w/a*" x $num_of_fields, $rest );
I;v looked at the pack() section the O'Rielly "Programing Perl" book, and I
don see what the "w/" portion does. The rest (if I understand corectly)
says to unpack num_of_fields null pqdded records inot an array, from the
contents of teh $rest variable, correct?
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: 26 Sep 2001 16:40:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Creating modules
Message-Id: <9ot0dq$rlg$1@mamenchi.zrz.TU-Berlin.DE>
According to Bart Lateur <bart.lateur@skynet.be>:
> nobull@mail.com wrote:
>
> >> > >+ *{"${callpkg}::EXPORT_OK"} = \@{$arg{EXPORT_OK} || []};
> >> >
> >> > This does not do what you think it does.
> >>
> >> It's possible that it simply does not do what *you think* he thinks it
> >> does.
> >>
> >> In particular, if the user passes a string or a glob, then \@$foo will
> >> create an arrayref out of it. I can't think of too many situations when
> >> this would be useful, but I don't see a problem with doing it.
> >>
> >> Oh, I can sorta think of one... if somebody passes in something other
> >> than an arrayref as an argument, doing this will catch that mistake by
> >> raising an error.
> >
> >Yep, Benjamin is bang on. I often use \@$ref as an assertion to
> >raise an error if $ref not an arrayref.
>
>
> Yuck. If there's an error, the error message will point to this line in
> the module, not to the line of the script using the module, as it
> should. You ought to be something along the lines of (which only accepts
> unblessed array references):
>
> if(my $ref = $arg{EXPORT_OK}) {
> unless(ref $ref eq 'ARRAY') {
> require Carp;
> Carp::croak("Argument for EXPORT_OK is not an array ref");
> }
> }
Other arguments aside, this is functionally different. An object
doesn't have to be an arrayref to function as such, since @{} can be
overloaded. Nobull's test would accept that while yours wouldn't.
I guess it depends what is right, but if possible I'd prefer to allow
objects to disguise as refs of any kind. It's an open interface for
old code to call new code, I don't want to close that.
On the other hand, @\$ is not a no-op in this situation. It implicitly
freezes what the overloaded call returned at the time and transforms
it into a real arrayref. But that's for the overloader to worry about,
not the unsuspecting user of these objects.
[snip]
Anno
------------------------------
Date: 26 Sep 2001 10:57:51 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Help: mail script (WIN)
Message-Id: <9osttv$dkr$1@charity.cs.utexas.edu>
In article <9osl5q$21e$1@panix3.panix.com>,
bill <bill02115@hotmail.com> wrote:
>Emacs somehow finds out what SMTP server to use when
>sending my mail, so I figured it must be able to get that information
>from the OS somehow.
If emacs is written like most applications, it doesn't figure out what
SMTP server to use, because it doesn't use one. Instead, when it wants
to send mail, it calls the command for sending mail: sendmail.
In fact, I bet if you were to look at the RMAIL elisp, you'd see the
word "sendmail" in it. Actually, looking at the emacs installation
here, it seems to call stuff in sendmail.el, which seems to want to run
/usr/lib/sendmail. (Or maybe /bin/mail in some circumstances, which is
sort of the same principle even though it's a bad idea.)
The point is that the usual Unix interface for sending mail is to run a
program. Systems that replace sendmail (like qmail or exim) provide a
program called "sendmail" that provides the same interface. You can
send mail all day without ever using SMTP, and in fact I believe that
sendmail predates the existence of SMTP, although it could just be the
case that it predates its widespread use.
- Logan
--
"Everybody
Loves to see
Justice done
On somebody else" ( Bruce Cockburn, "Justice", 1981 )
------------------------------
Date: 26 Sep 2001 17:52:32 +0100
From: nobull@mail.com
Subject: Re: Managing Child Processes
Message-Id: <u9r8stvqr3.fsf@wcl-l.bham.ac.uk>
kschmidt@mindspring.com (Kevin J. Schmidt) writes:
> ... am unable to get this hanging problem fixed with the right
> combination of wait, waitpid, and $SIG{CHLD} code. The basic structure
> of my code is as follows:
[snip]
> Obviously I left out the calls to wait, waitpid, etc., mainly because
> I'm not sure if I have them in the right places or not.
So let's get this clear... you have deliberately left out the bit of
your code where you think the problem is? Like, uh?
Actually I think despite your best efforts you have failed to not give
us sufficient information (sic). Your problem is that you don't check
that the fork() succeded. Consider what your code will do if fork() fails?
> To recap, I'm trying to do the following:
>
> 1. fork many children from the parent (this works)
> 2. the parent doesn't care if any children die (exit). It should
> continue processing as normal, i.e. make it to its infinite loop (this
> doesn't work)
> 3. if a child does die, the parent needs to be made aware of that and
> re-fork a new child. The parent needs to somehow get a hold of the PID
> of the dead child, since a specific child is responsible for getting
> log data from a single host. I create a hash of PID to host mappings,
> and I need to make sure that the new child knows which host to talk
> to.
>
> If anyone can help me with numbers 2 and 3, I would greatly appreciate
> it.
Well doing 2 is trivial - simply don't not do it. The way to ignore
something is not to do anything about it.
To do 3 then put a waitpid(-1,&WNOHANG) in your polling loop to find
out which children have failed.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 26 Sep 2001 17:45:33 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: MIME::Lite problem
Message-Id: <9ot47t$d2l$1@canopus.cc.umanitoba.ca>
In comp.lang.perl.misc, bill <bill02115@hotmail.com> wrote:
> I'm having a problem with MIME::Lite.
[ ... ]
> Everything works fine, including the attachment, but, at the receiving
> end, the e-mail (as presented by Eudora) shows an unsightly header of
> directives, like this:
> Content-Disposition: inline
> Content-Length: 326
> Content-Transfer-Encoding: binary
> Content-Type: text/plain
[ .. ]
> Any ideas on how to suppress the first set of headers?
See the FAQ section of the MIME::Lite documentation, particularly
the scrub method.
best regards,
randy kobes
------------------------------
Date: Wed, 26 Sep 2001 10:43:42 -0400
From: David Kowal <ldk006@email.mot.com>
Subject: Net::FTP help for login & script
Message-Id: <3BB1E99E.5E94E4F1@email.mot.com>
Hi,
I've a question as how to do the following:
1) after successfully logging to a remote server using $ftp->login('username','password'), I then to
to run a UNIX script (basically a version of su) where I need to supply the above password. After I
have authenticated as this user, I need to do some file manipulation using the system 'command'. Any
samples or links of reference would be helpful.
BTW - This is all being done on UNIX boxes running SunOS and HP-UX.
Regards,
DaveK
--
-
*******************************************
David E. Kowal
Vanguard Managed Solutions
SCM Engineering/Administration
575 West Street, Mansfield, MA 02048
Email: LDK006@email.mot.com
Phone: (508) 261-5649 / Fax: (508) 261-4545
*******************************************
------------------------------
Date: Wed, 26 Sep 2001 17:59:41 GMT
From: "--Rick" <no_trick@my-de(remove the obvious)ja.com>
Subject: Re: ONE QUESTION
Message-Id: <hIos7.9331$WW.920451@bgtnsc05-news.ops.worldnet.att.net>
"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn9r2mp8.eug.mgjv@verbruggen.comdyn.com.au...
| On 25 Sep 2001 21:04:50 -0700,
| hugh1 <weiwe1@yeah.net> wrote:
| > IN BOOK <<advanced programming perl >>
| >
| > charpe six package auto load .
|
| This almost sounds as incomprehensible as the "Big Berta Thing" posts.
| I've been looking at it for almost a whole minute now, and I still
| have absolutely no clue what this is supposed to mean. Four of the
| five words are recognisable, but they make no sense together... Oh
| well..
|
Perhaps OP is referring to chapter six which deals with package,
autoload.
I'm a touch typo-ist myself.. ;)
--
--Rick
------------------------------
Date: 26 Sep 2001 12:56:50 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Peek and Poke on Perl?
Message-Id: <9ot4t2$eif$1@charity.cs.utexas.edu>
In article <3BB210B5.413A@mpinet.net>, Gary <gamtci1@mpinet.net> wrote:
>The relevance is: YOU are thinking in terms of what is
>happening in the CPU and I'M talking about what happens
>on the address bus, which happens to be point of this
>entire thread: Having an ability within Perl to read/write
>to memory-mapped cards on the bus.
Well, it's very important to think about what happens in the CPU,
because that's where the Perl code runs.
Generally speaking, people in your position solve the problem by
writing a device driver. This provides an interface to the hardware
that can actually be used by a program that runs within the normal
environment that programs run in, i.e. a virtual memory space instead
of a real one.
In general, most programs don't have the ability to generate arbitrary
addresses on the bus. Modern operating systems (unlike MS-DOS) work on
the assumption that programs *shouldn't* have this ability because of
its potential for abuse. This is an important part of the technique of
building a system that remains stable overall even when some of the
code it's running is broken.
If you choose to use an operating system that uses this paradigm, your
life will be a LOT easier if you work with the design and write a
device driver instead of working against the design.
Most device drivers provide a somewhat higher-level interface to the
hardware so that the user-level program calling the device driver
doesn't have to deal with issues it doesn't want to worry about. For
example, some register might be mapped at different locations in
different revisions of a board, and the device driver might hide this
detail from the user-level software. That's normally a good way to do
it, but if you want, you can write a very simple device driver that
does nothing but allow the user-level software the access to do the
things it wants to do. Then write a Perl module (that's linked to C
code) to interface with that device driver, and you write Perl code to
talk to the device.
(See, my post *did* have some Perl content. Right there at the end!)
- Logan
--
"Everybody
Loves to see
Justice done
On somebody else" ( Bruce Cockburn, "Justice", 1981 )
------------------------------
Date: Wed, 26 Sep 2001 15:53:10 GMT
From: asif <whatever@nevermind.invalid>
Subject: Re: Single line if Statement
Message-Id: <3BB1D314.5060405@nevermind.invalid>
David Wall wrote:
> darkon@one.net (David Wall) wrote on 25 Sep 2001:
>
>
>>"Victor Menendez" <nomail@please.com> wrote on 25 Sep 2001:
>>
>>
>>>I would like to print an item based on an expression that is true.
>>>print OUT if expression returns TRUE other wise skip goto next line."
>>>Content "\n";
>>>Is there a way to do this using just a single line command?
>>>
>>You could do something like
>>
>>while ( <> ) {
>> print and next if EXPRESSION;
>>}
>>
>>where EXPRESSION is what you're testing.
>>
>
> Oops, I should have read the original post more carefully.
>
> while ( <> ) {
> EXPRESSION ? print : next;
> # other stuff happens here when EXPRESSION is true
> }
>
> prints the input line if EXPRESSION is true, otherwise it goes to the next
> line. And "Laocoon" has already showed you another example of statement
> modifiers that may be exactly what you want.
>
> "Laocoon"? Are you telling us to beware of emails bearing attachments?
> Remind me not to be around when the worms come for you... :-)
>
>
I've used:
while(<>){ EXPRESSION && print; }
/whatever
------------------------------
Date: Wed, 26 Sep 2001 15:53:28 GMT
From: asif <whatever@nevermind.invalid>
Subject: Re: Single line if Statement
Message-Id: <3BB1D5B3.2070203@nevermind.invalid>
David Wall wrote:
> darkon@one.net (David Wall) wrote on 25 Sep 2001:
>
>
>>"Victor Menendez" <nomail@please.com> wrote on 25 Sep 2001:
>>
>>
>>>I would like to print an item based on an expression that is true.
>>>print OUT if expression returns TRUE other wise skip goto next line."
>>>Content "\n";
>>>Is there a way to do this using just a single line command?
>>>
>>You could do something like
>>
>>while ( <> ) {
>> print and next if EXPRESSION;
>>}
>>
>>where EXPRESSION is what you're testing.
>>
>
> Oops, I should have read the original post more carefully.
>
> while ( <> ) {
> EXPRESSION ? print : next;
> # other stuff happens here when EXPRESSION is true
> }
>
> prints the input line if EXPRESSION is true, otherwise it goes to the
next
> line. And "Laocoon" has already showed you another example of statement
> modifiers that may be exactly what you want.
>
> "Laocoon"? Are you telling us to beware of emails bearing attachments?
> Remind me not to be around when the worms come for you... :-)
>
>
I've used:
while(<>){ EXPRESSION && print; }
/whatever
------------------------------
Date: Wed, 26 Sep 2001 17:49:37 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: String Comparison Problem
Message-Id: <3BB213EA.84CB3248@acm.org>
Matt Uhrich wrote:
> The results of "if ( $first == "-" )" is always true. Is this not the
> proper way to compare strings?
Nope. Try "if ( $first eq "-" )"
-- Dave Tweed
------------------------------
Date: Wed, 26 Sep 2001 11:34:53 -0500
From: <inna@raykhman.com>
Subject: time and win32 perl
Message-Id: <lAms7.4$VQ3.7254@news.nyc.globix.net>
Hi,
i am using the time() function on win2k machine, with activestate perl
5.6.0, binary build 623.
the problem is that the time function doesn't get updated properly, i.e. if
i reload the page cgi/perl that calls the function, the value that the
function return doesn't change, i.e. doesn't get updated properly.
does anyone know if there is anything i can do to make sure that every time
the time() function is called it returns the current value, or is there
another function or a module that would be better suited for this purpose.
thanks,
inna
------------------------------
Date: Wed, 26 Sep 2001 16:38:49 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: time and win32 perl
Message-Id: <Xns91288096946F2rock13com@64.8.1.227>
<news:lAms7.4$VQ3.7254@news.nyc.globix.net>:
> i am using the time() function on win2k machine, with
> activestate perl 5.6.0, binary build 623.
>
> the problem is that the time function doesn't get updated
> properly, i.e. if i reload the page cgi/perl that calls the
> function, the value that the function return doesn't change,
> i.e. doesn't get updated properly.
Sounds like a caching issue by the browser. Force an update,
perhaps by holding CTRL while pressing refresh.
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: 26 Sep 2001 17:03:33 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Transforming HTML
Message-Id: <1001523361.21239@itz.pp.sci.fi>
In article <1001515548.1252.0.nnrp-12.c2d95a2c@news.demon.co.uk>, Raj wrote:
><nobull@mail.com> wrote in message news:u97kunw3sg.fsf@wcl-l.bham.ac.uk...
>>
>> That would be your error. As we point out in this newsgroup several
>> times a week trasforming HTML is not simple. That's why we have
>> modules to do it.
>
>I'm sorry. I'm quite new to Perl and I was hoping that this could be done
>without the need for modules. Do they not carry any sort of overhead?
>Also, I'd like to learn exactly how I would do this rather than let a module
>cover up the detail (which I know is their function!).
In that case, start by reading the HTML spec at http://www.w3.org/. You
don't need to get into the details about particular tags, but you should
understand the way HTML is defined in terms of SGML.
Once you understand HTML syntax -- and also understand the ways in which
this syntax is often abused -- you can start thinking about parsing it.
>If anyone can think of a way to acheive what I want without the use of a
>module, and has the time for me, please feel free to contact me.
In specific cases, where you know what the HTML you're processing looks
like, simple regex solutions work just fine. But they can't be used to
implement a general-purpose solution.
If you want to write your own parser for something that is almost, but
not quite, valid HTML, I suggest looking at Parse::RecDescent. I would
*not* recommend doing recursive-descent parsing, or indeed any other
kind of advanced parsing, without an existing module to handle the hard
and dirty work.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Wed, 26 Sep 2001 16:21:50 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: What does ||= do ?
Message-Id: <3BB1F28E.19217D41@bms.umist.ac.uk>
Stan Brown wrote:
>
> I ran across the ||= construct in some examle code, and I can't figure out
> what it does. I'm familiar wiht += & -=, etc for C, but this ones got me
> stumped. I looked in the O'rielly "Programing Perl" book, and found it
> listed in a table, but no explabation as to what it does.
It means 'or equals'
e.g.
my $a;
my $b = 2;
$a ||= 5;
$b ||= 10;
print "$a $b\n";
prints
5 2
So if an lvar evaluates as false it will be assigned the value on the
right hand side of the expression. But if it evaluates as true, it is
left alone.
HTH
Paul
------------------------------
Date: 26 Sep 2001 11:10:09 -0400
From: stanb@panix.com (Stan Brown)
Subject: Re: What does ||= do ?
Message-Id: <9osr4h$nrj$1@panix2.panix.com>
In <cpp3rtslntm9ofv61ph5nk0pecq1dc1duk@4ax.com> Bart Lateur <bart.lateur@skynet.be> writes:
>Stan Brown wrote:
>> I ran across the ||= construct in some examle code, and I can't figure out
>> what it does. I'm familiar wiht += & -=, etc for C, but this ones got me
>> stumped. I looked in the O'rielly "Programing Perl" book, and found it
>> listed in a table, but no explabation as to what it does.
>It makes the following equivalence:
> $a ||= expr();
> $a = $a || expr();
>expr() is only evaluated, and assigned to $a, if $a was false before
>(zero, empty string, undef).
Got it. Thanks.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: Wed, 26 Sep 2001 16:10:41 GMT
From: kenlaird@yahoo.com (Ken Laird)
Subject: Re: What's wrong with this code ?
Message-Id: <56ns7.10725$8m2.701470@amsnews02.chello.com>
This seems interesting but may you please put down the entire code,
because for example
open (DATA,"data");
while (<DATA>) {
next unless my @names = m/(name-\S+)/g ;
for my $name (@names) {
next unless /^service\s+(\S+)/ ;
print "name = $name\nservice = $1\n";
}
}
doesn't produce anything.
Cordially
Ken
In article <x78zf2c467.fsf@home.sysarch.com>, uri@sysarch.com says...
>
>>>>>> "DW" == David Wall <darkon@one.net> writes:
>
> DW> I suppose I should have polished it a bit. How's this?
>
> DW> while ( <DATA> ) {
> DW> if ( my @names = m/(name-\S+)/g ) {
> DW> for my $name (@names) {
> DW> $_ = <DATA>;
> DW> if ( /^service\s+(\S+)/ ) {
> DW> print "name = $name\nservice = $1\n";
> DW> }
> DW> else {
> DW> next;
> DW> }
> DW> }
> DW> }
> DW> }
>
>much better. a style trick i like is when you have a conditional clause
>with next/last is to make a statement modifier instead. it saves those
>precious braces and indents:
>
> next unless my @names = m/(name-\S+)/g ;
>
> for my $name (@names) {
>
> next unless /^service\s+(\S+)/ ;
> print "name = $name\nservice = $1\n";
> }
>
> DW> It still makes lots of assumptions, though.
>
>yes, and that is the OP's problem.
>
>uri
>
>--
>Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
>SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
>Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 26 Sep 2001 17:10:09 -0000
From: darkon@one.net (David Wall)
Subject: Re: What's wrong with this code ?
Message-Id: <Xns912885D90A0A3darkononenet@207.126.101.97>
kenlaird@yahoo.com (Ken Laird) wrote on 26 Sep 2001:
> This seems interesting but may you please put down the entire code,
> because for example
>
[snip partial code]
>
> doesn't produce anything.
Ok.
use strict;
use warnings;
open DATA, "datafile" or die "Error opening datafile: $!";
while ( <DATA> ) {
next unless my @names = m/(name-\S+)/g ;
for my $name (@names) {
$_ = <DATA>; # this is the missing line
next unless /^service\s+(\S+)/ ;
print "name = $name\nservice = $1\n";
}
}
Maybe I shouldn't have told you, and instead let you figure it out. :-)
BTW, I only used DATA as the filehandle because it made it easier for me to
test. If you put __DATA__ at the end of your program (on a line by
itself), it tells perl that's the end of the program. The lines after the
__DATA__ token can be read using the DATA filehandle. (You don't have to do
an explicit open()) While I was testing, I just put your test data at the
end of my program so I wouldn't have to create an extra file to open.
(See perldata and the SelfLoader docs for more info on __DATA__, or pages
68 and 660 of _Programming Perl_, 3rd ed.)
(Apologies if you already knew this)
--
David Wall - darkon@one.net
"Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring and
he eats fish for an age." -- stolen from someone else's .sig
------------------------------
Date: Wed, 26 Sep 2001 17:42:16 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Works sometimes - tmadmin
Message-Id: <ait3rtg6sbbi3mpljo62t2hv8dtrnk94hg@4ax.com>
On 26 Sep 2001 07:47:59 -0700, redace1919@yahoo.com (Brian) wrote:
>open(TUX,"tmadmin <<EOF\nv\npsr\nEOF\n|") ||
> die "Unable to open TUXEDO\n";
>@tux = <TUX>;
>close TUX;
[...]
>The reason I believe it is something in my script is that while this
>is happening, if I simply type :
>tmamdin
>v
>psr
>from unix, I get the info that I expect.
Looks like your external command chokes at time because you feed it
its input too fast. A more reasonable way to run this could be to use
open2 (see perlipc for details) to run your tmadmin program. You could
then feed it a "v\n" on startup, wait for the expected output and only
then send the "psr\n". Of course, if tmadmin uses buffered I/O, you
may be in a fix because you won't see any output from your first
command - in that case, you could skip that step and instead sleep
for a few seconds.
Just my $0.02,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Wed, 26 Sep 2001 16:08:47 +0100
From: "Dr Joolz" <julius_mong@hotmail.com>
Subject: Re: XML::Writer question... how to write output to file?
Message-Id: <9osr29$jvp$1@oyez.ccc.nottingham.ac.uk>
Dont' mind me, I've got it. Thanx anyway.
------------------------------
Date: 26 Sep 2001 18:30:51 +0100
From: Edward Avis <epa98@doc.ic.ac.uk>
Subject: Re: XML::Writer question... how to write output to file?
Message-Id: <xn9wv2l6er8.fsf@owl.doc.ic.ac.uk>
"Dr Joolz" <julius_mong@hotmail.com> writes:
>Dont' mind me, I've got it. Thanx anyway.
If you found the answer to your own question you could post what you
found. Then if someone else has the same problem later and goes to
Google Groups (formerly dejanews) to look for it, he'll find the
answer.
(The exception is if you realize that the question you asked was
meaningless anyway, due to being too tired / drunk / whatever.)
--
Ed Avis <epa98@doc.ic.ac.uk>
Finger for PGP key
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 1823
***************************************