[9168] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2786 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 2 11:17:32 1998

Date: Tue, 2 Jun 98 08:00:37 -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           Tue, 2 Jun 1998     Volume: 8 Number: 2786

Today's topics:
    Re: .= food for thought? (Mark-Jason Dominus)
    Re: ARGV? (Tom Grydeland)
    Re: CGI mail form format problem <andy@interactive.net>
    Re: How do you send .htaccess username and pass? (Josh Kortbein)
    Re: How to Get Index if given a value in the array??? <merlyn@stonehenge.com>
    Re: HOWTO: GDBM and passwd files... (Bbirthisel)
    Re: Is he a kook or merely a troll?  Who cares? - I do! <quednauf@nortel.co.uk>
    Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start <jdporter@min.net>
        map in void context regarded as evil - suggestion (Tom Grydeland)
        Nested Subs: Lexical? (was Re: Visibility of "my" vars) <jdporter@min.net>
    Re: Nested Subs: Lexical? (was Re: Visibility of "my" v <tchrist@mox.perl.com>
    Re: Nested Subs: Lexical? (was Re: Visibility of "my" v (Chris Nandor)
    Re: Perl class for newbie? <dfrancoDONTSPAM@fore.com>
        Perl module for doing a unix 'which'? <bjs@iti-oh.com>
    Re: Perl on Windows32 <andy@interactive.net>
    Re: Perl Standard In/Out/Error on NT <andy@interactive.net>
        Perl, ODBC and OLE help <gmorgan@photographics.co.uk>
    Re: Perl-Frage <r.goeggel@atos-group.de>
        Problem reading from child process hugill_david@jpmorgan.com
    Re: Project using Perl - Learning Opportunity - perl.tx <jdporter@min.net>
        Save me a few days work of cut'n paste !! <kdsull@softmagic.co.kr>
        Setting buffering mode on file handle -- how? (Morten Welinder)
    Re: simple question <andy@interactive.net>
        Sorting a Perl hash of complex records... wiklund@my-dejanews.com
    Re: Sorting a Perl hash of complex records... <jdporter@min.net>
    Re: User System Info. <jdporter@min.net>
    Re: Why is `undef' a unary op and not a list op? (Charlie Stross)
    Re: WIN32 <andy@interactive.net>
    Re: winNT non-blocking Sockets how-to? guyrj@my-dejanews.com
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 2 Jun 1998 09:51:40 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: .= food for thought?
Message-Id: <6l101c$iqn$1@monet.op.net>
Keywords: censor decelerate hereafter vacationland

In article <6kb64m$bqr@hplntx.hpl.hp.com>, Larry Rosler <lr@hpl.hp.com> wrote:
>It is perfectly clear what is meant by the operation 'done in reverse':

I thought that maybe that was what the original poster meant, and then
decided that I couldn't be sure, so I didn't say anything.

I'm glad it was perfectly clear to you, but it certainly wasn't
perfectly clear.  Maybe it would have been perfectly clear if it had
been accompanied by an example.



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

Date: 2 Jun 1998 14:14:40 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: ARGV?
Message-Id: <slrn6n826g.opj.Tom.Grydeland@mitra.phys.uit.no>

On Thu, 28 May 1998 14:48:50 -0500,
Ric Alcazar <alcazar@netcomp.net> wrote:
>     Hello all,
> 
>     I'm relatively new to perl and have a few questions maybe you could help
> me with. <ARGV>?  What it is and how is it used?  What is a minimalist
> script?  I'm seem to be extremely confused with these terms.

There's a perl tutorial at
<URL:http://www.it.kth.se/labs/ts/media/mms/perl/start.html>,
perhaps it'll help

>     Ric.

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
      - Do radioactive cats have 18 half-lives? -


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

Date: 2 Jun 1998 10:03:48 +0400
From: Andy Murren <andy@interactive.net>
Subject: Re: CGI mail form format problem
Message-Id: <35740644.0@208.192.224.3>

In comp.lang.perl.misc Bobby <bob@simplydigital.com> wrote:
> I have a pretty large form (100 text fields) on a clients site that I am

Ow!

> using as a mailto order form run by a basic Perl cgi. Everything works
> well except the output in the email message is not sorted in any specific
> way. 

Are you using putting the name=value pairs into a hash?  (If you are
usin CGI.pm you probably are)  If so, you can try sorting the keys
using something like this:

foreach $field (sort keys(%fields))
{
    ......
}

-- 
Andy Murren                           andy@murren.org
http://www.murren.org


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

Date: 2 Jun 1998 14:22:48 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: How do you send .htaccess username and pass?
Message-Id: <6l11ro$hb1$1@news.iastate.edu>

Ric Alcazar (alcazar@netcomp.net) wrote:

:     Hello,

:     I'm trying to run an authorization script for a section of my website.
: I've created a script which prompts user for login and password (and if
: correct) sends them on to another page within my website.  Unfortunately...
: this does not provide as much security as I like.  (A user could simply just
: enter the URL of the page and get sent right there.)  I've, therefore,
: implemented a server authentication (.htaccess) to protect those documents.

:     This bring up another piece to my puzzle.  Now the user has to
: authenticate twice (once for my script and again for the server) to get to
: the page.  I'd like for the user only to have to authenticate once.  Is
: there anyway that I can pass the username and password from my perl script
: to the server authentication?  This would help to solve the dilemma of
: having to enter your login and password twice.  Please help!

[This isn't a perl question.]

Why not just use htaccess - it seems that it should remove the need
for an authentication script.


Josh
NP: Pink Floyd, _Dark Side of the Moon_

____________________________________________________________________
"In Zen they say: If something is boring after 2 minutes, try it for
4. If still boring, try it for 8, 16, 32, and so on. Eventually one
discovers that it's not boring at all but very interesting."
                      - John Cage



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

Date: Tue, 02 Jun 1998 12:37:42 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: How to Get Index if given a value in the array???
Message-Id: <8c90ngughc.fsf@gadget.cscaper.com>

>>>>> "Tad" == Tad McClellan <tadmc@flash.net> writes:

Tad> : @months = ("January","February","March","April","May","June","July","August","September","October","November","December");


Tad>    for ($i=0; $i<@months; $i++) {
Tad>       $months{$months[$i]} = $i;
Tad>    }

Ewww.  why not just:

	@months{@months} = 0..$#months;

There's too many things that you can be "off by one" on your code,
while admittedly you got it right. :)  But a hash slice works
nicely for this kind of initialization.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 91 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 02 Jun 1998 13:30:51 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: HOWTO: GDBM and passwd files...
Message-Id: <1998060213305100.JAA23905@ladder03.news.aol.com>

Hi Suave:

>tie %PASS, "GDBM_File", "/mypath/passwd", 1, 1 || die
>       "couldn't open the passwd file: $!";

The "not so good" is probably right here. You don't say if you got the "die"
message - but you DID "die".

I looked up some of my GDBM_File code, and the "1, 1" you use above are
really "ACCESS_MODES, PERMISSIONS". (e.g.  "GDBM_READER, 444").
I didn't look up the ACCESS_MODE constants - possibly "1" would resolve
to something legal. But "001" as a permission field will lock you out!

I'm not sure it is significant, but the Camel under "tie" uses "or" instead of
"||"
in the example. You can also enclose the tie arguments. Try:

tie (%PASS, "GDBM_File","/mypath/passwd",GDBM_READER,0444) || die...

>foreach $key (keys %PASS) {
>print "$key has value of $PASS{$key}\n";
>}
>#so far not so good

Remember to put an "untie" here when it works.

-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)


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

Date: Tue, 02 Jun 1998 13:39:22 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Is he a kook or merely a troll?  Who cares? - I do!
Message-Id: <3573F279.3A31F731@nortel.co.uk>

Per Abrahamsen wrote:

> Can you ever really judge another person for what he is?  Or can you
> only judge his actions?  If the later, what use is the distinction?

Ah, philosophy. Or fact? Under any circumstances you will only be able to
judge a person by interacting with the person. This can happen rationally,
visually, emotionally, or through body odours (and many more things...).
However, a newsgroups restrains me to interact with the people purely with
words. So what we see in the newsgroups is a subset of the person, as we
cannot see the other levels of interaction. So yes, you can judge a person
by its actions, but you shouldn't make the mistake and apply the judgement
to the whole person. However, under normal conditions the subset of the
person which is perceived through his / her writing should usually be in
harmony with all the other ways that particular person interacts with the
world. We can't tell, though as we are unable to perceive any harmony if we
only hear one tone...Well, anyway, jugde the actions, not the person.

--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________





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

Date: Tue, 02 Jun 1998 13:18:17 GMT
From: John Porter <jdporter@min.net>
Subject: Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start-up 80K+>+Equity
Message-Id: <3573FD44.43FA@min.net>

Earl Hood wrote:
> 
> In article <3573174E.1EBA@min.net>, John Porter  <jdporter@min.net> wrote:
> >But the whole point is why (and how) employers are justifying keeping
> >wages low.  If I were an employer, and that were my objective, I
> >would be saying, "Sorry, I won't pay programmers any more than this,
> >because there's a glut of programmers."
> 
> But that is not true statement, and people know it, so companies
> cannot state it.  Companies have to be more clever at it.

Bzzzt.  Companies can state whatever they want, apparently; that's
the premise of the "hoax" theorists.


> >But they're saying the opposite,
> >so therefore that's not their objective.
> 
> And how does that prove it's not their objective. 

It's simply supply and demand.  If I want to artificially deflate
prices, then I artificially overstate supply.  (Certainly no one
would believe me if I understated demand, in this case.)
What the hoax theorists (e.g. the econ profs at UCDavis) are
saying is utterly counter to basic principles of the capitalist
market.


> What is the incentive for a company to hire good talent at
> higher wages when they can still sell their products with lesser
> talented people at lower wages?

Many companies, especially in my sector (government contracting),
are wiser than that.  They've played that game before (or seen it
played), and they know it's more painful in the long run.  The
government, especially the military, is a very demanding customer.
If you give them crap product, they don't give you any more money.
There have been companies (so I've heard) who have been barred from
competing on any more contracts because they perfomed miserably
on one.

There is also some truth -- as many employers know -- to the notion
that one engineer at $60k can be worth far more than twice two
engineers at $30k (just to pick arbitrary numbers ;-).

But when the 60k guy is no more qualified than the 30k guy, why
shouldn't I prefer the 30k guy?


> There is a pool of potential employees out there.  However, with
> downsizing, many of those employees are very experienced.  Hiring them
> back into the work force would defeat the whole purpose of the
> downsizing/cost-cutting movement.  

Bzzzt again.  If it were merely a case of not hiring for the sake of
"downsizing", then there would be no push to swell the ranks of 
programmers from universities and foreign countries.  Fact: companies
need more bodies, wherever they can get them.  There is a shortage.
Fact #2: downsizing is passe.  Downsizing is partially to blame for
the current shortage.  Now, companies are hiring, not firing.

> Therefore, the companies complain
> that there is a lack of skill out there inorder to get political favor
> to create an environment where lower wage workers can be hired (foreign
> employees and recent college/vocational graduates).

I agree that perhaps more emphasis could be placed on employing
the "more mature" technical people, who perhaps have a hard time
getting technical work now.  But that does not change the fact that
there is a shortage.  Even if all the folks whose skillsets are
obsole[te|scent], whose brains are rusty, were hired back and
retrained, that would be a short-term stop-gap measure; there would
still be a shortage.


> Today, companies are working in the mode of what can give us the most
> profit *now*.  What can we do to satisfy our share holders *now*.
> Starting to hire people at higher wages counters this, even though it
> may be good policy in the long term. 

That's how I know your premises are faulty: employers are hiring;
they're paying whatever they have to.  This is my experience and
my observation; I don't need any ivory-tower economist to tell me
it ain't happening, because I've seen it myself.

> When company departments are
> evaluated based upon the next quartely profit, they are very
> apprehensive to perform any action that will cut into the profit (or
> department managers may lose their jobs).  It is uncommon to find
> companies willing to make an investment (in employees) that may hurt
> profits in the short-term, but pay-off in the long-term.  We are in the
> age of instant gratification.

You have got an active imagination.  Maybe you're just working in
the wrong part of the country. :-)  Many MANY companies are
making exactly those kinds of investments, even impacting quarterly
earnings, in order to attract and keep employees.  Each company
is looking for ways to distinguish itself from the pack, so that
bodies will prefer to work there instead of elsewhere.  Do you
think there would be so much competition, at such high cost, if
there were an oversupply of bodies?  Regardless of what the
gov't might or might not do in the future, corporate America is
bearing a huge burden of cost to attract and keep skilled labor.


> What high-tech companies are stating is a partial truth.  What is
> probably more accurate is, "There is a shortage in the high-tech
> skilled labor market at the wages we are willing to pay." 

Sure.  What's so unreasonable about that?  By saying that, you are
admitting that there is a shortage; because what they are willing
to pay, for the most part, is reasonable.  What is unreasonable is
for a person with 20 years of experience and no current applicable
skills to demand $100k (arbitrary number, please).  There's
always consulting...


> I have yet to experience this "shortage" of software/engineering labor.

What, so therefore it's a hoax?  I *have* experienced the shortage,
so it's real AFAIC, regardless of what corporations and professors
are saying for political reasons.

I think it's also worth looking at this whole issue from the
perspective of "What's best for America is the long term".
Putting aside the greed of employers/employees for a sec,
what would we like to see happen in America in the next
20 or 50 years?  Should we increase the supply of well-
educated scientists and engineers, or let the numbers stay
low?  Ultimately the critical problem we have is that
education -- technical secondary education -- is a mere ghost
of what it could be, what it once was.  How can America hope
to remain a world leader unless this situation is reversed?

John Porter


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

Date: 2 Jun 1998 12:56:47 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: map in void context regarded as evil - suggestion
Message-Id: <slrn6n7tkf.opj.Tom.Grydeland@mitra.phys.uit.no>


Many OPs in Perl know what context they're called in and modify their
behaviour to fit the requirement.  For instance, C<scalar keys %hash>
will not need to create the list of keys in %hash and then count it; it
will simply grab the number of keys from somewhere.

The major complaint about using C<map> in void context is that it
creates a (possibly large) return value which is then discarded.

Wouldn't it be possible to make C<map> recognise when it's called in
void context and *not* create the return list in these cases?

To me, C<map> is such a useful tool and idiom that having to redress my
mindset to C<foreach> should be unnecessary.  After all, TMTOWTDI, no?

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
      - Do radioactive cats have 18 half-lives? -


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

Date: Tue, 02 Jun 1998 13:23:59 GMT
From: John Porter <jdporter@min.net>
Subject: Nested Subs: Lexical? (was Re: Visibility of "my" vars)
Message-Id: <3573FE9E.3B63@min.net>

sub foo {
  sub bar { }
}

So, are nested subroutines, such as bar in this example, like
'my' vars, in that they are bound to the lexical scope, rather
than stuck in a symbol table?  I assume they're not in a symbol
table; so if they're not 'my', then what is their substrate?
And how does the debugger support them, if at all?

Thanks,
John Porter


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

Date: 2 Jun 1998 13:44:00 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Nested Subs: Lexical? (was Re: Visibility of "my" vars)
Message-Id: <6l0vj0$6l5$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, jdporter@min.net writes:
:sub foo {
:  sub bar { }
:}

*DON'T DO THAT*

:So, are nested subroutines, such as bar in this example, like
:'my' vars, in that they are bound to the lexical scope, rather
:than stuck in a symbol table?  I assume they're not in a symbol
:table; so if they're not 'my', then what is their substrate?
:And how does the debugger support them, if at all?

They're hosed.  You can't do that.  Here's a Perl Cookbook excerpt
I've posted before.

--tom

=head1 Nesting Subroutines

=head2 Problem

Your use of nested subroutines is making Perl give warnings about some
variables that will not stay shared.

=head2 Solution

Instead of the interior functions being normal subroutines, make them
closures and temporarily assign them to the typeglob of the right name
to create a localized function.

=head2 Discussion

If you are accustomed to using nested subroutines in other programming
languages with their own private variables, you'll have to work at it a
bit in Perl.  The intuitive coding of this kind of thing incurs mysterious
warnings about ``will not stay shared''.  For example, this won't work:

    sub outer {
	my $x = $_[0] + 35;
	sub inner { return $x * 19 }   # WRONG
	return $x + inner();
    } 

A work-around is the following:

    sub outer {
	my $x = $_[0] + 35;
	local *inner = sub { return $x * 19 };
	return $x + inner();
    } 

Now inner() can only be called from within outer(), because of the
temporary assignments of the closure (anonymous subroutine).  But when
it does, it has normal access to the lexical variable $x from the scope
of outer().

This has the interesting effect of creating a function local to another
function, something not normally supported in Perl.

This kind of thing is not necessarily going to win you any awards for
clarity of programming unless your program is being maintained by a
Scheme programmer.
-- 
"There is no reason for people to have computers in their homes."
			 -- Ken Olsen, president of Digital, 1977


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

Date: Tue, 02 Jun 1998 14:51:11 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Nested Subs: Lexical? (was Re: Visibility of "my" vars)
Message-Id: <pudge-0206981045320001@192.168.0.3>

In article <3573FE9E.3B63@min.net>, jdporter@min.net wrote:

# sub foo {
#   sub bar { }
# }
# 
# So, are nested subroutines, such as bar in this example, like
# 'my' vars, in that they are bound to the lexical scope, rather
# than stuck in a symbol table?  I assume they're not in a symbol
# table; so if they're not 'my', then what is their substrate?
# And how does the debugger support them, if at all?

  package A;
  sub foo { sub bar {} }
  foreach (keys %A::) {print "$_\n"}

Returns:

  foo
  bar

Simply nesting a sub has nothing to do with how it can be accessed.  You
can call bar() without calling foo() first.  All it changes is what may be
available to the subroutine.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Tue, 02 Jun 1998 09:24:09 -0400
From: Dan Franco <dfrancoDONTSPAM@fore.com>
Subject: Re: Perl class for newbie?
Message-Id: <3573FCF9.4E85C68@fore.com>

Tom Phoenix wrote:
> 
> On Mon, 1 Jun 1998, Dan Franco wrote:
> 
> > Can anyone recommend a good Perl course for a non programmer?  Perhaps
> > something that teaches the basics of Perl along with general
> > programming concepts?
> 
> I don't recommend that. Perl is a very powerful, flexible language. Perl
> lets you break the rules when you know better. But how can you know better
> unless you first learn the rules?
> 
> A good introductory course on programming will teach you important
> concepts which will make learning Perl easier and more useful in the long
> run. For a first programming language, I usually recommend Pascal - not
> because it's a great language that you'll want to use for everything, but
> because it's generally taught at your local community college by
> competent, patient instructors who will teach you how good programming is
> done for a nominal fee.
> 

Tom,

Thanks for your advice.  I understand what you are saying; however I
have been tasked by my boss to learn Perl, and the company will pay
for a class.  I need to take it this quarter.  Any recommendations?

By the way, I did check into the local community college; they don't
offer Pascal but there is an introductory course in C, which I am
thinking of enrolling in.  Do you think that would be a good
substitute?

> Please remove the DONTSPAM from your email address to get email courtesy
> copies of replies. :-)

I mind checking the newsgroup for replies less than I mind deleting
spam.  :)  Don't you get a lot of spam when you post in the clear?


----------------------------------------------------------------------
Please remove the DONTSPAM from my email address to reply to me.
----------------------------------------------------------------------
Dan Franco                 UNIX System Administrator
FORE Systems, Inc.         Direct:  (724) 742-7685
3000 FORE Drive            Email:   dfranco@fore.com
Warrendale, PA 15086       Fax:     (724) 742-7474
URL:  http://www.fore.com  Main:    (724) 742-4444
----------------------------------------------------------------------
"One can never consent to creep when one feels an impulse
 to soar."
    - Hellen Keller
----------------------------------------------------------------------


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

Date: Tue, 2 Jun 1998 10:34:07 -0400
From: "Brian J. Sayatovic" <bjs@iti-oh.com>
Subject: Perl module for doing a unix 'which'?
Message-Id: <6l12p6$nnn$1@malgudi.oar.net>

    Has anyone come across a comprehensive module to do the equivalent of a
UNIX which in Perl for UNIX/Win32?

    Essentialy, which looks for an executable file or command in a users
'PATH' matching a given command.  On UNIX, "which ls" will be the path to
the ls command, or perhaps a statement that it is an alias.  Various NT
implementations will work similarly.  However, I'd like to find a
comprehensive module that does this and more.  For example, on NT with
Command Extensions, one have have any extension be executable instead of
just .exe, .com, .bat and .cmd.

    I suppose if one doesn;'t exist I can write one, but I'd rather use a
pre-existing one if there is one out there.

Brian Sayatovic.




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

Date: 2 Jun 1998 09:41:19 +0400
From: Andy Murren <andy@interactive.net>
Subject: Re: Perl on Windows32
Message-Id: <357400ff.0@208.192.224.3>

In comp.lang.perl.misc L. Weynand <herbert.weynand@fiscalnet.be> wrote:
> Hello !

> I want to check my CGI Scripts offline... So I wanted to know how to do
> that. It seems I have to use a Server program and a perl program.

If you want to test your script as a CGI script you will need Perl and
a web server.  I use and recommend Apache for Win32.  You can get it
from http://www.apache.org  I am using 1.3b6 but 1.3b7 is out.  If are
going to run the script on both Unix and Win32, Apache is the way to
go.  If you are unlucky enough to be forced into using IIS, get IIS
and write for it.  IIS for requires that you modify (ie. rewrite
almost completely) your script if you are coming from unix or Apache
if you do anything except for plain http.

> Where can I download theses and what do I have to do ?

http://www.apache.org for the Apache server
http://www.microsoft.com for IIS    # avoid if possible

> Can someone help me please ???

First, RTFM, then ask if more questions.

> Emmanuel

-- 
Andy Murren                           andy@murren.org
http://www.murren.org/andy/


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

Date: 2 Jun 1998 09:53:48 +0400
From: Andy Murren <andy@interactive.net>
Subject: Re: Perl Standard In/Out/Error on NT
Message-Id: <357403ec.0@208.192.224.3>

In comp.lang.perl.misc Dave Kenny <dk@tundra.winternet.com> wrote:
> Brian J. Sayatovic <trin@1.net> wrote:
> <snip>
> : redirection does work on NT as it does on UNIX (except that you can't radily
> : redirect STDERR in NT using the 2>&1 redirection syntax.)  However, if you
>                                   ^^^^
> FWIW: 2>&1 works for me in Win95 under the Mortice Kern Toolkit kornshell.

If you want to redirect STDERR in your program without using a unix
shell port, see the camel book where is describes 'open', it has an
example of redefining STDOUT and STDERR.  That is the only way I know
how do redirect in a reliable and portable manner.

-- 
Andy Murren                      andy@murren.org
http://www.murren.org           


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

Date: Tue, 2 Jun 1998 13:33:48 +0100
From: "Glenn Morgan" <gmorgan@photographics.co.uk>
Subject: Perl, ODBC and OLE help
Message-Id: <6l0r9k$nev$1@news.u-net.com>

I have created a database using MS Access that I can happily access with the
ODBC module from my Perl code. One of the fields I've created is for storing
a jpeg graphic file and hence has a data type of OLE object.  Can anyone
give me an example of how I can read in a jpeg file from Perl and 'INSERT'
it into my database.  Do I need the OLE module to wrap the data I've read
in?  I've had a look at it but I can't see how to tie it all together.


Thanks in advance

Glenn




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

Date: Tue, 2 Jun 1998 15:47:17 +0200
From: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: Perl-Frage
Message-Id: <6l0vt3$79m$1@news.pop-stuttgart.de>


wolfram.oehms schrieb in Nachricht
<01bd8bd1$654fdb80$61cca8c1@default>...
>Hallo Newsleser
>
>Vielleicht kann mir jemand von Euch weiterhelfen:
>
use de.comp.lang.perl





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

Date: Tue, 02 Jun 1998 13:35:52 GMT
From: hugill_david@jpmorgan.com
Subject: Problem reading from child process
Message-Id: <6l0v3p$eji$1@nnrp1.dejanews.com>

I am trying to speed up a database utility by spawning child processes to
query the various servers in parallel. FYI, I am using the Sybase::CTlib
module. The processes are forked using open,() as shown in my sample code.
They connect to the server and extract the required information, sending back
the details line by line until a line containing 'END'.

The problem is that the parent process only ever reads the first line returned
by the child. On the second iteration of the loop, the -w output shows 'Read
on closed filehandle'.

Sample code:
# (generate a new handle)
# (save the handle in a global variable)
open($handle, "-|");
if ($pid) {
	return;	# this function kicks off the child processes
}
else {
	$| = $true;
	# (connect to database)
	# (extract data)
	foreach ( (code to retrieve next row) ) {
		print "DATA,etc\n";	# appears on parent's $handle
	}
	print "END\n";
	close STDOUT;	# added to try to force flushing
	exit;
}

# In the main program...
# (set $handle to a saved child's file handle)
while (<$handle>) {
	chomp;
	last if $_ eq 'END';
	print "got data: $_\n";
}


I get the 'got data' output for the first item printed by the child, then the
'read on closed filehandle'. This happens identically whether I kick off a
single child or many.

Nearby Unix gurus say that my approach seems correct. Any ideas on what's
going wrong?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 02 Jun 1998 13:35:24 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Project using Perl - Learning Opportunity - perl.txt [1/1]
Message-Id: <3574014C.555B@min.net>

Kevin R. Mullen wrote:
> 
> As a newbie to PERL, I wanted to jump right in and make something...

That's great, but here's a tip: when posting to usenet, each line
of your message should be no longer than 80 chars max, and preferably
shorter, say 70, to allow for quoting, etc.

> open(STOCKREAD, "lynx quote.yahoo.com\q?s=dell |");
> 
> this opens the Lynx program, goes to yahoo and gets a stock quote...

You need to check the command line options for lynx.
Specifically, the default mode of operation is to be interactive,
using your full screen. That's not what you want.  You want
lynx to grab the file, print it to stdout, and exit.  To do that:
	lynx -dump ...
or
	lynx -source ...
Use the former if you want lynx to format the file as it might
apppear on your screen (no links or other special features, of 
course).
The latter gives you the full html source (i.e. the file as it was
sent from the server).

hth,

John Porter


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

Date: Tue, 02 Jun 1998 23:07:28 +0900
From: Kidon Sull <kdsull@softmagic.co.kr>
Subject: Save me a few days work of cut'n paste !!
Message-Id: <35740720.EDA400A0@softmagic.co.kr>

Hi, anybody !

I got a tremendous help from this newsgroup last time,
in generating a Unicode table for Unified CJK Ideograph,
which consisted of a couple lines actually, and got so
impressed with the power of Perl. And I'd like another,
if somebody could spare a few minutes !!

I asked our developer about this problem, and was told
that it'd take 3-4 days with C and 1-2 days with Objective
C on Nextstep platform, but can't help thinking it should
be a few minutes if a perl brainer could give a look...

I need to process quite a few proprietary formatted, tagged
files, for search and replace job as follows :

1. Parse and extract string between E1 tag and [a or F or
l or g] tag ignoring everything between them, which leaves
a document title.

2. Repalce the result of 1 with EDT$result.

3. Leave everyting else intact and save as a new file.

 is Ascii 30 (start of a tag) and  is Ascii 31 (end of a tag).

The actual document looks like this :

EDSk 1 129 ???k 2 129 ???k 3 129 ???k 4 0 Times New Romank 5
0 Arialk 6 129 @???k 7 129 @???k 8 129 ??k 9 129 @??k 10 129
@???k 11 129 ??k 12 129 @??k 13 0 !Fi?in(English)EDTASS-S
???EDLSYS300-2ins
EDHC mov SECTION Yp 793g 86 94C ini SECTION YC ini PARA YC
ini ENDPARA YC ini COLY YW 0g 86 Yw 653a LC ini ROW0
YEWg 93 YZ d 2 344 310C ini CB Yw 330P SYS301.wmf; 1F 1 13
0 0 0s -6s +6
Z cEWw 296g CL 16+s -6s -6F 5 16 1 0 1s +6E1c
0HDCX-302 MSC f 2???f 5 f 2???
a JF 1 13 0 0 0s -6w 330Z rEWC ini ROW1 YG L 86 ROW1 344
2 0 0 2 0F 1 13 0 0 0s -6c 0l 2 24Z eC ini ROW0 YEWg 93
YZ d 5 184 160 172 72 68C ini CB Yw 170a LG L 86 ROW0 656 2 0
0 2 0F 1 8 0 0 0E3c 0???

Looks quite messy, doesn't it ?? Please do not pay
attention to the broken ascii character, which are Korean
characters if somebody is that curious.

I apologize if this kind of question is out of this newsgroup's
interest, but just thot somebody might enjoy cerebral acrobatics
after a lunch or something.. Otherwise, somebody will have to
open a few hunred files and copy/paste, a few hundred times !!

Many thanks,

Kidon Sull
kdsull@softmagic.co.kr








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

Date: 2 Jun 1998 14:31:08 +0200
From: terra@diku.dk (Morten Welinder)
Subject: Setting buffering mode on file handle -- how?
Message-Id: <6l0rac$i7k@tyr.diku.dk>

I have a file handle, FOO, that happens to be line buffered.
This causes slowness when writing, so I want to change it to
block (say 4K) buffering.

In C, I would use something like setbuf/setvbuf.  What do I
do in Perl?

Morten


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

Date: 2 Jun 1998 10:09:11 +0400
From: Andy Murren <andy@interactive.net>
Subject: Re: simple question
Message-Id: <35740787.0@208.192.224.3>

In comp.lang.perl.misc Mark-Jason Dominus <mjd@op.net> wrote:

> In article <356EC833.C36BF228@euroforum.nl>, a  <mvn@euroforum.nl> wrote:
> >What I want is check for a directory "c:\perl\scripts" and if it's not
> >there, create it.
> >
> >How could I do that?

> You use the `mkdir' function.

> If the directory already exists, then it'll fail, but who cares?


try using the -d file check to see if the directory exsists an is a
directory.  If it does not exsist then use the mkdir function.

-- 
Andy Murren                           andy@murren.org
http://www.murren.org 


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

Date: Tue, 02 Jun 1998 12:33:08 GMT
From: wiklund@my-dejanews.com
Subject: Sorting a Perl hash of complex records...
Message-Id: <6l0re4$a2f$1@nnrp1.dejanews.com>

Im stumped on this problem of sorting
a Perl hash of complex records on contained
values.

The definition of the hash is as follows:
%EXPERIMENTS = (
  "TestA" => {
    Result => [
     {
       Type => "A",
       Time => "14,7ak"
     },
     {
       Type => "B",
       Time => "13,5ak"
     }
    ]
  },
  "TestB" => {
    Result => [
      {
        Type => "A",
        Time => "16,2M"
      },
      {
        Type => "B",
        Time => "17,2M"
      }
    ]
  }
);

What I wish to do is sort the hash according to the
numeric value of "Time", the sorted result should look
like this:
TestA
 Type = B
 Time = 13,5ak
 Type = A
 Time = 14,7ak
TestB
 Type = A
 Time = 16,2M
 Type = B
 Time = 17,2M

So it's easy to see that first I wish to sort the whole
hash on "Test?", then the "Test?" should be sorted with a
numerical comparison on the field "Time" ignoring the
trailing "ak or M".

I've looked at the "perldsc" for direction on this problem
but I just don't seem to grasp it. So any help would be
highly appriciated.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 02 Jun 1998 14:39:18 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Sorting a Perl hash of complex records...
Message-Id: <3574103F.374D@min.net>

wiklund@my-dejanews.com wrote:
> 
> Im stumped on this problem of sorting
> a Perl hash of complex records on contained
> values.
> 
> The definition of the hash is as follows:
> %EXPERIMENTS = (
>   "TestA" => {
>     Result => [
>      {
>        Type => "A",
>        Time => "14,7ak"
>      },
>      {
>        Type => "B",
>        Time => "13,5ak"
>      }
>     ]
>   },
>   "TestB" => {
>     Result => [
>       {
>         Type => "A",
>         Time => "16,2M"
>       },
>       {
>         Type => "B",
>         Time => "17,2M"
>       }
>     ]
>   }
> );
> 
> What I wish to do is sort the hash according to the
> numeric value of "Time", the sorted result should look
> like this:
> TestA
>  Type = B
>  Time = 13,5ak
>  Type = A
>  Time = 14,7ak
> TestB
>  Type = A
>  Time = 16,2M
>  Type = B
>  Time = 17,2M
> 
> So it's easy to see that first I wish to sort the whole
> hash on "Test?", then the "Test?" should be sorted with a
> numerical comparison on the field "Time" ignoring the
> trailing "ak or M".

I hope it's also easy to see that you will have nested
loops: the outer loop iterates over the members of
%EXPERIMENTS, sorting by key; the inner loop iterates over
the 'Result' member (an array).

It looks like you can use the default sort method for the
outer loop, since it's lexicographic.

The sort method for the inner loop is sufficiently
complicated, we'll put it into a sub.

for my $exp ( sort keys %EXPERIMENTS ) {
  print "$exp\n";  # e.g. TestA
  for my $result ( sort by_time @{ $EXPERIMENTS{$exp}{Result} } ) {
    print " Type = $result->{Type}\n";
    print " Time = $result->{Time}\n";
  }
}

sub digits_of {
  my $s = shift;
  $s =~ s/\D//g; # remove all non-digits
  $s;
}

sub by_time {
  # each member of a 'Result' array is a hashref, having a
  # member named 'Time'.
  # compare them numerically, using all (and only) the digits:
  digits_of($a->{Time}) <=> digits_of($b->{Time})
}

hth,
John Porter


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

Date: Tue, 02 Jun 1998 12:39:55 GMT
From: John Porter <jdporter@min.net>
Subject: Re: User System Info.
Message-Id: <3573F44A.7973@min.net>

bobbybooby@my-dejanews.com wrote:
> 
> I'm sure that I have the totally wrong group, but I'll go for it anyway.

What courage, to go completely against what was otherwise a good
intuition.

JOhn Porter


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

Date: Tue, 02 Jun 1998 14:29:11 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <slrn6n838p.6e3.charlie@cs.ed.datacash.com>

In the name of Kibo the Compassionate, the Merciful,
on Mon, 01 Jun 1998 11:45:44 GMT,Michael Fowler
the supplicant <wolfm@pobox.alaska.net> implored:

>Can you find any examples of this?  It seems to me that that kind of
>operation would only be used in obfuscation, it's very unreadable.  I'm all
>for a list being accepted instead of an expression.

I have precisely zero examples of this construct being used intentionally;
but I can conceive of broken programs that will un-break, with unexpected
consequences, if the misfeature is rectified. (I'm reminded of the bone-
headed objections, years ago, to fixing the C shell's buggy ||/&& logical
operators -- which were the wrong way round, and stuck that way for so long
that correcting the lexer would have hosed any number of legacy scripts.)



-- charlie

"Given two unrelated technical terms, an internet search engine
 will retrieve only resumes." -- Schachter's Hypothesis   


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

Date: 2 Jun 1998 09:45:54 +0400
From: Andy Murren <andy@interactive.net>
Subject: Re: WIN32
Message-Id: <35740212.0@208.192.224.3>


> There's a beta Apache server that runs on Win32 now. I haven't tried it
> yet. Why not? Well, I am not in any hurry to try pre-beta crashware.


I am running Apache for Win32 (1.3b6) on a Win95 laptop, a production
NT4.0 web server, and 2 desktop NT machines for several months.  I
have yet to have _any_ problems.  Apache also is much closer to the
RFC than IIS4.0 is.  

Andy Murren                        andy@murren.org
http://www.murren.org/andy/




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

Date: Tue, 02 Jun 1998 13:01:38 GMT
From: guyrj@my-dejanews.com
Subject: Re: winNT non-blocking Sockets how-to?
Message-Id: <6l0t3h$c09$1@nnrp1.dejanews.com>



 I'm working with perl 5.004_02 from CPAN on windows NT.
 I'm having trouble setting the blocking mode on a socket connection.
 Can't set the socket to non blocking, I've tried several things with no luck
 so far setsockopt, ioctlsocket, and select to check for data.

 Thanks in advance

 Guy




-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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