[10031] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3624 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 2 23:05:14 1998

Date: Wed, 2 Sep 98 20:00:21 -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, 2 Sep 1998     Volume: 8 Number: 3624

Today's topics:
    Re: [Perl] How to find the Perl FAQ (Martien Verbruggen)
    Re: a pesky perl runtime problem <jdf@pobox.com>
    Re: Best way to "reset" $1? (Alan Barclay)
    Re: Better Regular Expressions (Abigail)
    Re: Encryption & File Locking (Abigail)
    Re: Encryption & File Locking (Alan Barclay)
    Re: FMTEYEWTK on Switch Statements in Perl (was: No swi (Peter Scott)
    Re: FMTEYEWTK on Switch Statements in Perl (was: No swi <tchrist@mox.perl.com>
    Re: Help create a fileupload script scottd@logx.com
    Re: In search of Intellegint Life... HELP!! <mpersico@erols.com>
    Re: Parsing XML and HTML (was: Re: Better Regular Expre (Abigail)
    Re: Parsing XML and HTML (was: Re: Better Regular Expre (Abigail)
    Re: Perl & Java - differences and uses (Abigail)
    Re: Perl & Java - differences and uses (Martien Verbruggen)
    Re: Perl subprocesses (Matthew Bafford)
        POP3 Server 0.7 (Aahz Maruch)
    Re: printing bitmap of integer <zenin@bawdycaste.org>
    Re: Problem: Opening Word (ack!) doc w/ OLE (Ernie Mercer)
        Programmer Needed: Develop Ordering & Tracking System <nate@cyberiasystems.com>
        Question <sh_ori@netvision.net.il>
    Re: Question (Larry Rosler)
        sockets <sh_ori@netvision.net.il>
    Re: Tom Phoenix: ANSWERS WANTED! (Martien Verbruggen)
    Re: typeglobs and references... (re: Prog Perl, p 117) <b.d.low@unsw.edu.au>
    Re: US-NY-LI 516 PERL Programmer/Analyst <mpersico@erols.com>
    Re: Where can I find a Perl script for a non-Java, non  (Martien Verbruggen)
    Re: Why Perl ? (Matthew Bafford)
        win32, dbi, and msql (Dustin Puryear)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 03 Sep 1998 02:23:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: [Perl] How to find the Perl FAQ
Message-Id: <A4nH1.294$N02.2634@nsw.nnrp.telstra.net>

In article <6sjkq4$pbl$1@news.ml.com>,
	mwang@tech.cicg.ml.com (Michael Wang) writes:
> Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>>
>>> There is a newer version posted by someone called tchrist dated
>>
>>Someone called tchrist?
>>
>>How funny.
> 
> OK, I have corrected the phrase to "someone whoes username is tchrist".
> It is not funny to refer someone by username. It is part of internet
> culture. 

I think you misunderstood why I thought it's funny. Check dejanews for
this username on the perl newsgroups. Check the perl documentation.
Check the perl web site.  Check out the authors on a.o. the 'Perl
Cookbook', 'Programming Perl' and 'Learning Perl'.

If you still don't understand why I thought it was funny after that,
then I don't know what to say anymore.

:)

Martien

-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 02 Sep 1998 22:03:51 -0400
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: a pesky perl runtime problem
Message-Id: <m3d89elzp4.fsf@joshua.panix.com>

Brad Murray <murrayb@vansel.alcatel.com> writes:

> John Porter <jdporter@min.net> writes:
> 
> > Jonathan Feinberg wrote:
> > > 
> > > "E Mills, software scientist" <eam@starfire.mlb.semi.harris.com> writes:
> > > 
> > > > I just chased down a bug which was innocuous.
> > > 
> > > I do not think that word means what you think it means.
> > 
> > Prepare to die...
> 
> Inconceivable!

I do not think that word means what you think it means.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 3 Sep 1998 02:40:54 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Best way to "reset" $1?
Message-Id: <904790450.763761@elaine.drink.com>

In article <35ED4FD5.C794CED3@shell.com>, yong  <yong@shell.com> wrote:
>I posted the original question. Thanks for everybody's response.
>
>Indeed after I looked at my code again, I could simply re-write it by moving the
>#do_something_else to $1 in the following to the inside of the if-block (as Tad
>McClellan says):
>
>while(<INFILE>)
> { if (/(string)/)
>    { #do_something to $1;    #really just a further manipulation of the string
>    }
>   #do_something_else to $1;    #there's some database work done here
> }
>
>I didn't see that initially because #do_something_else was a little too long. It
>may be a good idea to use a sub in place of it.
>

Another approach is to do something like this


while(<INFILE>){
	if(/string/){
		$a=$1;
	}
	do_something_with($a);
}

copying $1 into another variable, which you can reset & so on.


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

Date: 3 Sep 1998 01:08:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Better Regular Expressions
Message-Id: <6skq68$o32$3@client3.news.psi.net>

Zenin (zenin@bawdycaste.org) wrote on MDCCCXXVIII September MCMXCIII in
<URL: news:904713671.220656@thrush.omix.com>:
++ Craig Berry <cberry@cinenet.net> wrote:
++ : Tom Phoenix (rootbeer@teleport.com) wrote:
++ : : Naw. Parsing XML is _much_ simpler than parsing HTML, since you don't have
++ : : to worry about how to parse bogus code. Cheers!
++ :
++ : What do you mean by that?  (Honest question, I'm not familiar enough with
++ : XML to see why this would be the case.)
++ 
++         XML has a very strict definition of both the data structure as
++         well as how parsers should respond when they find error conditions
++         of differing levels.  Basically, the parser is expected to blow
++         chunks at the first sight of trouble and report it.  This is
++         a Good Thing.  It not only makes parsers easier to implement, but
++         also makes the data they return more reliable as there is no
++         question about how the data was parsed or by who's set of rules.
++ 
++         HTML is a complete mess.  Just the fact that <P> may, or may not
++         balance with a </P> tag and how to parse and handle perfectly valid
++         code like "foo <P> bar <P> doggy </P>" (eg, does that closing </P>
++         match to the first <P>, or the second?) makes it a nightmare to

Huh? That's well defined. HTML is not a mess, and in fact, rather easy
to parse. Using Perl, I have written HTML parses in less than a day,
including parsing marked sections, elements with CDATA declared content
and comments-the-right-way. There are only a handful of tokens you have
to deal with.

++         parse.  That's before any of the extra tags which may or may not
++         take a closing tag and may or may not take attributes that may
++         or may not be required or of a particular type...  Blagh...
++ 
++         I think the forced use of <Tag></Tag> or <Tag/> for empty tags is
++         the best thing that could have happened to SGML.

If a main reason of XML is because so many programmers have problems
parsing HTML - then the programming world is in a sad state.

Tools that have no problem parsing SGML outdate Perl 1.


Abigail
-- 
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
          for (??;(??)x??;??)
              {??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'


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

Date: 3 Sep 1998 01:17:47 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Encryption & File Locking
Message-Id: <6skqnr$o32$4@client3.news.psi.net>

Randal Schwartz (merlyn@stonehenge.com) wrote on MDCCCXXVIII September
MCMXCIII in <URL: news:8c67f62qez.fsf@gadget.cscaper.com>:
++ >>>>> "Jim" == Jim Michael <jim.michael@gecm.com> writes:
++ 
++ Jim> system "cat /myserver/mydir/$myfile | des -dk $mypassword >
++ Jim> /myserver/mydir/$mydecryptedfile";
++ 
++ Jim> Then when you are done with the file, write it back to the encrypted
++ Jim> file:
++ 
++ Jim> system "cat /myserver/mydir/$mydecryptedfile | des -ek $mypassword >
++ Jim> /myserver/mydir/$myfile";
++ 
++ If this had been comp.unix.questions or comp.unix.shell, you would
++ have recieved one of my "useless use of cat" awards.

But with "cat /myserver/mydir/$mydecryptedfile | des -ek $mypassword >
          myserver/mydir/$myfile"
you don't have to change your system command if you change $mydecryptedfile
to include shell wild cards such that it matches more than one file.

          "command < file" 

doesn't scale trivially to more files.

          "cat file | command"

does.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: 3 Sep 1998 02:30:19 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Encryption & File Locking
Message-Id: <904789817.408867@elaine.drink.com>

In article <35ED775A.7AD2@gecm.com>, Jim Michael  <jim.michael@gecm.com> wrote:
>Vinay Gidwaney wrote:
>>     I'm trying to encrypt a data file in perl... is there a way to do that?
>> Like when the script wants to access the file, it unencrypts it, and then
>> does what it needs to do, and then encrypts it again... are there any
>> examples i can take a look at...
>
>Depends on the strength of encryption you need. If DES is sufficient,
>and you have des installed, then you might use something like:
>
>system "cat /myserver/mydir/$myfile | des -dk $mypassword >
>/myserver/mydir/$mydecryptedfile";

It's not a good idea to put the password on the command line like that.
If someone happens to be doing a ps with the right options at the same
time, then they're going to see your password. Kind of defeats the
point of encryption.

pgp has the facility to have the password written on a suitable file
descriptior. This is much more secure, though it will still be possible
to see the password if the 'snoop' or 'strace' or similar program is used
to trace the system calls used. 

Of course, you still have the problem of making the perl program know the
correct password in a secure way. This has been discussed to death in the
past week here.


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

Date: 2 Sep 1998 18:51:32 GMT
From: psk@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: FMTEYEWTK on Switch Statements in Perl (was: No switch statement in Perl??)
Message-Id: <6sk43k$7uu@netline.jpl.nasa.gov>

Tom Christiansen wrote:
> 
> CASE 9:
> 
>     ($msg, $defstyle) = do {
>         $i == 1 ? ("First", "Color" )  :
>         $i == 2 ? ("Then",  "Rarity")  :
>                   ("Then",  "Name"  )
>     };

Just to clarify, the do{} in this case is there for visual effect
only, right?  'Cos this example works without it.  It was mentioned in
some later examples that the do{} was for appearance's sake but not
this one.

Thank you!!!  That was very helpful.

-- 
This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
brain on news.  Any questions?   |  (psk@euclid.jpl.nasa.gov)

Disclaimer:  These comments are the personal opinions of the author, and 
have not been adopted, authorized, ratified, or approved by JPL.


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

Date: 3 Sep 1998 00:26:33 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FMTEYEWTK on Switch Statements in Perl (was: No switch statement in Perl??)
Message-Id: <6sknnp$obb$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, psk@euclid.jpl.nasa.gov (Peter Scott) writes:
:Just to clarify, the do{} in this case is there for visual effect
:only, right?  

Yes.

--tom
-- 
	  "And I don't like doing silly things (except on purpose)."
		--Larry Wall in <1992Jul3.191825.14435@netlabs.com>


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

Date: Wed, 02 Sep 1998 18:30:07 -0700
From: scottd@logx.com
Subject: Re: Help create a fileupload script
Message-Id: <35EDF11F.68B6C942@well.com>

The Recruitment Database wrote:

> Can someone help me create a cgi script (solution), I am not a programmer
> but understand web site HTML
>
> I am trying to create a situation on my web site (I run a small
> recruitment site) where a candidate (job-seeker) would be able to
> enter a few details on a form, maybee also select some key skills and
> then add their CV (resume) as an attachment (upload a file). We would
> also like them to be able to download some information from the form
> page.
>
> Any help would be appreciated
> Best Derek Alexander
> recruitmentdb@enterprise.net

 Well I'm not sure that anyone would be available to do this for you without
compensation, however, If you're determined to roll up the sleeves and
attempt this yourself, you can tale a look at some of the various free CGI
programs (www.cgi-resources.com,)that use cgi-lib.pl  to accomplish this
task via http PUT (If enabled on your webserver).   Another interesting and
informative page to take a gander at is as follows:

  http://cgi-lib.stanford.edu/cgi-lib/

Good Luck!
~scott





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

Date: Wed, 02 Sep 1998 22:35:28 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: In search of Intellegint Life... HELP!!
Message-Id: <35EE0070.4687A6FB@erols.com>

No, he was not hammering you down. He was giving you one of the best
explanations I've ever seen posted here on how to most efficiently use
the group. Which is, "look locally, exhaustively and then ask." This is
advice which, if more posters followed it, would significantly increase
the value of the newsgroup.


Ripcord104 wrote:

> I don't know but I find  it humorous how much time you wasted trying to hammer
> me down, when all that was required was this small tiny line that was already
> posted by 4 other users with less of a need to mark their territory with
> derogatory remarks.  I salute and move on.

-- 
#!/usr/bin/perl -- Matthew O. Persico
print "Just Another Perl Neophyte\n";
## Simplicity is a blessing when you're 
## supporting the program at 2AM


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

Date: 3 Sep 1998 00:53:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Parsing XML and HTML (was: Re: Better Regular Expressions)
Message-Id: <6skp9q$o32$1@client3.news.psi.net>

Tom Phoenix (rootbeer@teleport.com) wrote on MDCCCXXVII September
MCMXCIII in <URL: news:Pine.GSO.4.02A.9809011435370.21048-100000@user2.teleport.com>:
++ On 1 Sep 1998, Craig Berry wrote:
++ 
++ > Date: 1 Sep 1998 20:55:22 GMT
++ > From: Craig Berry <cberry@cinenet.net>
++ > Newsgroups: comp.lang.perl.misc
++ > Subject: Re: Better Regular Expressions
++ > 
++ > Tom Phoenix (rootbeer@teleport.com) wrote:
++ > : Naw. Parsing XML is _much_ simpler than parsing HTML, since you 
++ > : don't have to worry about how to parse bogus code. Cheers!
++ > 
++ > What do you mean by that?  (Honest question, I'm not familiar enough
++ > with XML to see why this would be the case.)
++ 
++ There's a lot of bogus HTML out there. For example...
++ 
++     <b><i>I'm mismatched!</b></i>
++ 
++     <b><i>I'm unterminated!</b>

That of course has nothing to do with HTML vs XML. XML isn't going
to make authors smart. Both examples with be invalid XML as well.

++     <a src=unquoted.gif alt=how can you parse this? >

That would be invalid XML as well.

++ The browser wars became a competition as to who could make the
++ best web pages out of bogus HTML. :-P
++ 
++ Of course, that's why we have standards. So how about this?
++ 
++     <!-- -- -->
++ 	<b>Can you see this, or is it an HTML comment?</b>
++     <!-- -- -->

There is no such thing as "an HTML comment". Comments are an *SGML*
construct.

++ Some browsers interpret that as a comment, some don't. I've heard that the
++ new version of the HTML standard is going to be defined according to how
++ some popular browsers (mis-)parse HTML. I hope that was just a sick joke.

As Dan Connolly would say after someone would utter "I've heard"

        Always, always, always, alwaysAlways, ALWAYS, ALWAYS
        (what I mean is, EVERY FRIGGIN TIME!) cite a source.         [1]
        Just Do It. Do The Right Thing. Keep the Faith.
        Cite A Source!

But note that the XML *does* define comments much in the same way certain
earlier versions of Netscape parsed comments.
                                  
++ In any case, XML's standard is much tighter. In particular, it requires
++ that the parser choke on bogus code. So any errors should be caught at
++ once, and parsers can be much simpler.

But HTML and SGML validators choke on errors as well. And it's considered
a feature that browsers try to do the right thing on broken HTML. Just
like Perl is very forgiving. After all, it's not the readers fault the
author of the page made mistakes. Would you want a television that goes
blank when it receives a signal that's not 100% clear, or a computer
that reboots whenever an application encounters an error?

Documents written in an XML-based language parse/tokenize different
then documents written in an SGML-based language (like HTML). For the
following reasons:

 1) There are no optional open or end tags. Every element that can have
    content *must* have a closing tag.

    This makes parsing easier, but it doesn't matter for tokenizing,
    and that's what's being discussed here.

 2) Tags for contentless elements are distinct from open tags of elements
    with possible content.

    See above.

 3) No shorttags. Which means:
    a) All attributes have a value.

       This will make tokenizing slightly easier. Not much.

    b) All attribute values have to be quoted.

       See above.

    c) No nettags.

       This makes tokenizing easier. But that's hardly supported in HTML
       processors anyway.

 4) No CDATA declared content.

    This makes tokenizing easier, as no knowledge of a DTD is needed
    (together with 1) and 2)).

 5) Tags and attributes are case sensitive.

    Does this make things easier? Maybe.

 6) '<' and '&' are not allowed anywhere where markup can be expected.
    The string ']]>' isn't allowed either.

    This will make tokenizing a bit easier.

 7) Character sets.
    
    Various character sets are allowed for XML documents, including 
    ASCII, ISO-8859-*, UTF-8, UTF-16, EBCDIC and USC-4. UTF-8 support is
    only supported in the newest development releases of Perl, and there's
    no sign of UTF-16 or USC-4 support. UTF-8 and UTF-16 support is a
    requirement for XML parsers.

 8) Marked sections and processing instructions.

    Current HTML parsers don't support this - but it will be important
    for many XML applications that parsers do this correctly.

 9) Only one comment per comment section is allowed.
    <!-- Foo -- -- Bar --> is not valid. 

    I guess this makes tokenizing a little easier. But it was never hard.


[1] Dan Connolly in `Table Syntax'. www-html@w3.org: archive/latest/7888
    <mid:199704161901.PAA27276@www19.w3.org>



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: 3 Sep 1998 00:59:31 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Parsing XML and HTML (was: Re: Better Regular Expressions)
Message-Id: <6skplj$o32$2@client3.news.psi.net>

Zenin (zenin@bawdycaste.org) wrote on MDCCCXXVIII September MCMXCIII in
<URL: news:904715023.541186@thrush.omix.com>:
++ Craig Berry <cberry@cinenet.net> wrote:
++         >snip<
++ : Is this economically realistic, though?  Won't there be enormous pressure
++ : on browser vendors to provide some 'slop' (per the old Net maxim 'produce
++ : conservatively, consume liberally') to deal with bad XML markup, and for
++ : precisely the same reasons they currently deal with bad HTML markup?
++ 
++         I don't think so.  XML is much more then HTML on crank or SGML
++         on downers.
++ 
++         The main point of XML is to set in stone what XML is, how
++         it should be processed, and in what strict ways it can be allowed
++         to grow beyond that.  The main problem with SGML is that it is
++         simply huge, too many things are allowed to be optional, and
++         extending it is to create of a nightmare because of those
++         options.  Total freedom isn't always a Good Thing.

Note that XML *is* SGML as well. Any XML validating document *will*
be SGML validating as well. XML is a subset of SGML, unlike HTML
which is an SGML *application*.

XML certainly is *not* HTML on crank (crack??). Seeing XML as a replacement
for HTML doesn't make sense. Just like an alternative for BNF doesn't
make that alternative a replacement for C.




Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: 3 Sep 1998 01:20:52 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6skqtk$o32$5@client3.news.psi.net>

Randal Schwartz (merlyn@stonehenge.com) wrote on MDCCCXXVIII September
MCMXCIII in <URL: news:8czpci1baj.fsf@gadget.cscaper.com>:
++ >>>>> "David" == David Cantrell <NukeEmUp@ThePentagon.com> writes:
++ 
++ David> Make it C(\+{2}){0,1} just to add a fe more bizarro characters ;-)
++ 
++ How about C([+]{2})?  ? :)

C(\+?)\1



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Thu, 03 Sep 1998 02:38:40 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl & Java - differences and uses
Message-Id: <QinH1.664$N02.2634@nsw.nnrp.telstra.net>

In article <35ed93c2.0@news.netcom.co.uk>,
	"Jim" <-> writes:
> I was originally only going to ask clpm but didn't want a biased opinion,
> thats also why I asked for references to info. We're all big boys, I'm sure
> we can discuss these things maturely, isn't that what usenet is all about?
> 
> I do admit though, provocative question.

That is exactly the point. Together with the fact that this question
comes up many, many times in all of the programming groups.

It's too provocative, especially when cross-posted.

It's been discussed, many times, without any meaningful result.

It's meaningless. It's meaningless because you can't just compare
programming languages in a global and general way. One programming
language does this better, the next does that better. Find and use the
one that suits your requirements best.

Please, let's not do this again.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Wed, 2 Sep 1998 21:09:27 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Perl subprocesses
Message-Id: <MPG.1057b60be85db986989686@news.south-carolina.net>

In article <35EDBCFB.E1045E84@harp.gsfc.nasa.gov> on Wed, 02 Sep 
1998 21:47:39 +0000, Jim Amrhein (amrhein@harp.gsfc.nasa.gov) 
pounded in the following text:
=> Hello,
=>     I'm  trying  to have a perl program call a second perl program and
=> have it use the same version
=>     of  perl as  it's parent ???
=> 
=> The following
=> 
=> #  This program uses 2 versions of perl , one in mycopy and the system's
=> version of perl
=> #!/usr/people/mycopy/bin/perl -w
=> 
=> # This can't be hardcoded and I can't add  the  perl path to the second
=> file.
=> system "perl Makefile.PL";
=> 
=>                                                                 Thanx,
=> 
=> Jim Amrhein
=> 
=> 

Here's an idea...

#!/usr/bin/perl -w

# DATA points to the text after the __END__ or __DATA__
# Move it to the beginning.
seek DATA, 0, 0;

$CommandLine = <DATA>;
chomp $CommandLine;
$CommandLine = substr($CommandLine, 2, length $CommandLine);

print "Perl called as: $CommandLine\n";

# The next end is _very_ important.  If the __END__ or __DATA__ 
# isn't present, the DATA filehandle is not opened.
__END__


'Course, what your wanting to do is probably not best handled in 
the way you specify...  But, I'm just here to answer the question 
you asked... :)

Also, this doesn't handle a script being called with the command 
interpreter. (Ie: perl ./myscript)

Hope This Helps,

--Matthew


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

Date: Thu, 3 Sep 1998 00:11:17 GMT
From: aahz@netcom.com (Aahz Maruch)
Subject: POP3 Server 0.7
Message-Id: <aahzEyoLut.2My@netcom.com>

{I'm not familiar with the comp.lang.perl.* hierarchy, so please forgive
me if I'm posting in the wrong groups.}

Here's a script I wrote recently because I needed a POP3 server that
could handle a random mbox-style folder.  It works with Net::POP3 and
Netscape 3.0/4.0; it does not work with Outlook 98 or fetchmail for
reasons I'm not sure about.

WARNING: this script is a security risk because it performs zero
authentication.  OTOH, it requires that you specify a port (which I
recommend be something other than 119) and it only accepts one
connection before terminating.

I'm labeling this version 0.7 arbitrarily.  I don't know if I'll ever
update it; I disclaim all ownership.  If the formatting annoys you, set
your tabstop to four spaces.


#
# This script implements a subset of the POP3 server spec defined in
# RFC-1939 to serve a read-only Unix-style mbox folder.  It only accepts one
# client connection and terminates when that session is finished.
# 
# Set $Debug=1 to get an audit trail of client commands.
#
# Currently only the required commands plus UIDL are implemented.
# TOP should probably be implemented because several clients seem to
# demand it.
#
# Usage: pop3folder.pl <port> <folder>
#

require 5.004;

use strict;
use English;

use IO::Socket;
use Mail::Folder::Mbox;

my $Debug = 1;

my $CRLF = "\cM\cJ";
my $pop3ok = '+OK';
my $pop3err = '-ERR';
my $pop3term = ".\n";

$| = 1;

my $port = shift @ARGV or die "Need port as first argument";
my $folder = shift @ARGV or die "Need path to folder as second argument";

my $socket = IO::Socket::INET -> new (
		Proto => 'tcp',
		LocalPort => $port,
		Listen => 1,
		Reuse => 1) 
	or die $!;

$socket -> listen (1);
my $client = $socket -> accept();

my $mbox = new Mail::Folder ( 'mbox', $folder ) or die "Can't open $folder";
my $numMsg = $mbox -> qty;
my $mboxSize = getFileSize ( $folder );

$client->print ("$pop3ok$CRLF");
processLogin() or die "Client failed to log in";

#
# RFC-1939 states that POP3 commands are case-insensitive
#

while ( <$client> ) {
	$Debug && print;

	if ( /^quit/i ) {
		$client->print ("$pop3ok$CRLF");
		exit;
	}

	if ( /^dele/i ) {
		#
		# You may need to uncomment the OK message if your POP3 client 
		# complains about not being able to delete messages.  Otherwise,
		# this *should* return an error because we're read-only.
		#
		$client->print ("$pop3err This POP3 server read-only$CRLF");
		#$client->print ("$pop3ok$CRLF");
		next;
	}

	if ( /^rset/i or /^noop/i ) {
		$client->print ("$pop3ok$CRLF");
		next;
	}

	if ( /^stat/i ) {
		$client->print ("$pop3ok $numMsg $mboxSize$CRLF");
		next;
	}

	if ( /^list/i ) {
		if ( /^list (\d+)/i ) {
			my $msg = $1;
			if ( $msg <= $numMsg ) {
				my $msgSize = getFileSize ( $mbox -> get_message_file ( $msg ) );
				$client->print ("$pop3ok $msg $msgSize$CRLF");
				next;
			} else {
				$client->print ("$pop3err $numMsg message(s) in box$CRLF");
				next;
			}
		} else {
			$client->print ("$pop3ok $numMsg messages ($mboxSize octets)$CRLF");
			for ( my $msg=1 ; $msg<=$numMsg ; $msg++ ) {
				my $msgSize = getFileSize ( $mbox -> get_message_file ( $msg ) );
				$client->print ("$msg $msgSize$CRLF");
			}
			$client->print ("$pop3term");
			next;
		}
	}

	#
	# UIDL is supposed to provide a unique key.  I just use $PID plus
	# the message number.
	#
	if ( /^uidl/i ) {
		if ( /^uidl (\d+)/i ) {
			my $msg = $1;
			if ( $msg <= $numMsg ) {
				$client->print ("$pop3ok $msg $PID$msg$CRLF");
				next;
			} else {
				$client->print ("$pop3err $numMsg message(s) in box$CRLF");
				next;
			}
		} else {
			$client->print ("$pop3ok$CRLF");
			for ( my $msg=1 ; $msg<=$numMsg ; $msg++ ) {
				$client->print ("$msg $PID$msg$CRLF");
			}
			$client->print ("$pop3term");
			next;
		}
	}

	if ( /^retr (\d+)/i ) {
		my $msg = $1;
		if ( $msg <= $numMsg ) {
			$client->print ("$pop3ok$CRLF");
			open ( MSG, $mbox -> get_message_file ( $msg ) );
			my $line;
			while ( defined ( $line = <MSG> ) ) {
				$client->print ($line);
			}
			$client->print ("$pop3term");
			next;
		} else {
			$client->print ("$pop3err $numMsg message(s) in box$CRLF");
			next;
		}
	}

	$client->print ("$pop3err$CRLF");
}

1;


sub processLogin() {
	my $input;
	my $is_connected = 0;

	while ( ! $is_connected ) {
		$input = <$client>;
		$Debug && print $input;
		if ( $input =~ /^quit/i ) {
			$client->print ("$pop3ok$CRLF");
			return undef;
		}
		if ( $input =~ /^user/i ) {
			$client->print ("$pop3ok$CRLF");
			$input = <$client>;
			$Debug && print $input;
			if ( $input =~ /^quit/i ) {
				$client->print ("$pop3ok$CRLF");
				return undef;
			}
			if ( $input =~ /^pass/i ) {
				$client->print ("$pop3ok$CRLF");
				$is_connected = 1;
			} else {
				$client->print ("$pop3err$CRLF");
			}
		} else {
			$client->print ("$pop3err$CRLF");
		}
	}
	return 1;
}

sub getFileSize () {
	my $file = shift;

	my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat $file;
	return $size;
}
-- 
                      --- Aahz (@netcom.com)

Hugs and backrubs -- I break Rule 6     <*>     -=> http://www.rahul.net/aahz
Androgynous poly kinky vanilla queer het

'Modern American "libertarianism": the political expression of
borderline autism.'  --PNH


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

Date: 3 Sep 1998 01:04:40 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: printing bitmap of integer
Message-Id: <904784613.379471@thrush.omix.com>

[posted & mailed]


hintze.k@amstr.com wrote:
: $i = 8;
: print unpack("B*", $i), "\n";
: 
: I get 00111000 instead of 00001000 like I would expect.

        Pack/unpack work on raw data. From the perlfunc man
        page for unpack(), "it takes a string representing
        a structure and expands it out into a list value".

        You need to convert that ASCII "8" string to an int
        (or short) first:

        print unpack ("B*", pack ("i", 8)), "\n";

        returns 00001000000000000000000000000000 on my machine
-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Thu, 03 Sep 1998 00:12:15 GMT
From: emercer@wma.com (Ernie Mercer)
Subject: Re: Problem: Opening Word (ack!) doc w/ OLE
Message-Id: <35eddd6a.440511672@news.wma.com>

Try escaping the backslashes in the path of the file, e.g.
"C:\\DOCS\\MYDOC.DOC".

-Ernie Mercer


On Wed, 02 Sep 1998 15:21:12 -0500, Charles Sherman
<euschsh@am1.ericsson.se> wrote:

>Ok I've got NT, I've got Active PERL 5.00502, I've got Randals books
>(you name it I've got it or at least its with in walking distance). With
>all of this and a good bit of surfing and reading of MS docs, I cannot
>figure out how to map the following bit of VB code to PERL. I tried
>various combinations but I have no idea about how the method should be
>invoked from PERL. The "FileName:=" is throwing me.
>
>VB code:
>
>	Application.Documents.Open FileName:="C:\DOCS\MYDOC.DOC"
>
>PERL (I think this would work or some variation):
>	use OLE;
>	$wd = CreateObject OLE "Word.Application.8" || die "CreateObject: $!";
>	$wd->{visible}=1;
>	$wd->Documents->Open('FileName:="C:\DOCS\MYDOC.DOC"'); 
>		#I've tried without '' also
>
>This will launch Word but does not bring up the document.
>If you have any suggestions, ideas, etc. I would like to know.
>
>Thanks
>
>	Charlie



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

Date: Tue, 1 Sep 1998 18:24:33 -0400
From: "Nathaniel McMullin" <nate@cyberiasystems.com>
Subject: Programmer Needed: Develop Ordering & Tracking System
Message-Id: <35edeafb.0@news.cyberzone.net>

I am in need of an experienced programmer to develop an customized online
ordering and tracking program that can link to an automated CC verfication
service and after the CC is verified provide a custom URL to download the
software program.  The software should be accessible only through a script
so others can not steal it.

This will take sometime, but I have an idea of what I want and the pay would
be on-going as you provide support and implement new features in the future.

This project would pay a flat-rate.  I.e. no hourly fees.  If your
interested, please contact nate@cyberiasystems.com  Send resume, contact
information, examples of work, etc ...












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

Date: Thu, 03 Sep 1998 02:39:02 +0300
From: Ori Shmolovsky <sh_ori@netvision.net.il>
Subject: Question
Message-Id: <35EDD716.5283@netvision.net.il>

Is it possible using perl to create a socket to a server lets say
members.xoom.com and read a file from that server lets say
/aladdin1/index.html? If yes can you tell me how?


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

Date: Wed, 2 Sep 1998 18:02:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question
Message-Id: <MPG.10578a6b4f48d0d298978d@nntp.hpl.hp.com>

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

In article <35EDD716.5283@netvision.net.il> on Thu, 03 Sep 1998 02:39:02 
+0300, Ori Shmolovsky <sh_ori@netvision.net.il> says...
> Is it possible using perl to create a socket to a server lets say
> members.xoom.com and read a file from that server lets say
> /aladdin1/index.html? If yes can you tell me how?

Do `perldoc perlipc` on your system, or find the 'perlipc' man page from 
<URL:http://www.perl.com>.  In the section "Sockets: Client/Server 
Communication" you will find several fairly straightforward examples.

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


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

Date: Thu, 03 Sep 1998 02:55:47 +0300
From: Ori Shmolovsky <sh_ori@netvision.net.il>
Subject: sockets
Message-Id: <35EDDB03.33E0@netvision.net.il>

Hello

My name is Ori Shmolovsky and I have a question:
Is it possible using perl to create a socket to a server lets say
members.xoom.com and read a file from that server lets say
/aladdin1/index.html? If yes can you tell me how?

   Thank you in advance O.Shmolovsky. mailto:sh_ori@netvision.net.il


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

Date: Thu, 03 Sep 1998 02:25:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Tom Phoenix: ANSWERS WANTED!
Message-Id: <K6nH1.360$N02.2634@nsw.nnrp.telstra.net>

In article <35ED6476.D80083FC@bbnplanet.com>,
	Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:
>> Only Hitler-types think they can end a thread
>> by simply declaring it ended.
> 
> hmmm...well, i am half german and love leather boots. does that count?
> ;) don't bandy that name about so casually. 
> 
> i merely meant that the thread had grown tiresome.

Invoking the name of that certain despote, or the movement he headed
is a traditional Usenet way of making sure the thread will live on.

I am surprised to see it still works :)

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Thu, 03 Sep 1998 12:36:15 +1000
From: Benjamin Low <b.d.low@unsw.edu.au>
Subject: Re: typeglobs and references... (re: Prog Perl, p 117)
Message-Id: <35EE009F.C8B58788@unsw.edu.au>

Thanks for the replies, everyone!

For those that wondered why I'd want to do what I was asking about, well
it was mostly an academic excercise spawned from the example in "Prog
Perl". I get the impression typeglobs are generally superseded by being
able to pass refs around :-) Presumably the book's example is a carry
over from the previos edition, though they do note typeglobs are useful
for passing around file handles...

-- 
 Benjamin Low, BEng (Elec)
 Communications Unit, University of New South Wales, Australia
 (02) 9385 1138  b.d.low@unsw.edu.au  b.d.low@ieee.org


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

Date: Wed, 02 Sep 1998 22:29:59 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: US-NY-LI 516 PERL Programmer/Analyst
Message-Id: <35EDFF27.8039558@erols.com>

Jim Michael wrote:
> 
> Matthew O. Persico wrote:
> 
> > SQL is a language. Informix is a DBMS. Sounds like someone in marketing
> > ate the jargon file for lunch yet again!
> 
> Sounds to me like they will be writing perl scripts to run on a Unix
> platform, making SQL queries to an Informix DB.
> 
I'd have phrased it as 
"Informix"
"SQL in Informix"
"Informix best, any SQL ok"

On second read, I'm nit picking. Ignore me.

-- 
#!/usr/bin/perl -- Matthew O. Persico
print "Just Another Perl Neophyte\n";
## Simplicity is a blessing when you're 
## supporting the program at 2AM


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

Date: Thu, 03 Sep 1998 02:35:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Where can I find a Perl script for a non-Java, non frames, text/browser based chat room?
Message-Id: <KfnH1.652$N02.2634@nsw.nnrp.telstra.net>

In article <6sj9l9$71f$1@nnrp1.dejanews.com>,
	bewitchd@my-dejanews.com writes:

> Where can I find a Perl script for a non-Java, non frames,
> text/browser based chat room for my web site??  I do not want

This groups really isn't the place to ask if you're looking for
scripts or ready made solutions.

In this particular case you probably should check out
http://www.cgi-resources.com/

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: Wed, 2 Sep 1998 21:09:25 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Why Perl ?
Message-Id: <MPG.10579c6088e623db989685@news.south-carolina.net>

In article <6skb9c$226$1@news.ml.com> on 2 Sep 1998 20:54:04 GMT, 
Michael Wang (mwang@tech.cicg.ml.com) pounded in the following 
text:
=> >Yes, I read the Camel book too and found
=> >#!/usr/bin/perl
=> >while(<>) {
=> >   print eval $_;
=> >   die $@ if $Q;
=> >}
=> >
=> >                        This interactive Perl is great
=> 
=> Why is it so great? If it can not interpret 
=> - print "a"; - correctly? 
=> 
=> print "a";
=> a1
=> 

Simple.

Change it to:

#!/usr/bin/perl -w
while(<>){
    eval $_;
    die $@ if $@;
}
__END__

DUH...

--Matthew :)


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

Date: Wed, 02 Sep 1998 23:54:41 GMT
From: *NO*dpuryear*SPAM*@usa.net (Dustin Puryear)
Subject: win32, dbi, and msql
Message-Id: <35edd92f.2990549@news.surfree.com>

  I would like to use my win32 computer to write scripts that can
access a mSQL database. I have mSQL running. Unfortunately, I am
having problems getting the DBI/DBD::mSQL pair to install (like every
other module under win32).
  Has anyone successful installed it on win32 using the CPAN
distribution? In fact, I am consistently having problems getting any
module to install using the "perl Makefile.PL, make..." routine used
for installing a perl module. I installed Sprite a number of months
ago by dumping Sprite.pm into my perl directory. I also had to
manually move files to get ConfigReader to install.
  Any and all help is GREATLY appreciate. Email is preferred, but I do
troll this newsgroup.

Thanks, Dustin

======================================================================
Dustin Puryear, student and lover, Louisiana State University 
----------------------------------------------------------------------
dpuryear@usa.net * ICQ 6644253 
LSU Computer Science student and loving it.
Help Crack Government Encryption: www.distributed.net
Eat red meat before it eats you!
======================================================================


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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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