[10746] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4344 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 2 17:07:23 1998

Date: Wed, 2 Dec 98 14:00:30 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 2 Dec 1998     Volume: 8 Number: 4344

Today's topics:
        $! type variables (Gregory Snow)
    Re: $! type variables (Sam Holden)
        Alarm Function Equivalent for Win32 kennedy@classifieds2000.com
        Any way to get drive letters on Win95 Machines? <garethj@cableregina.com>
        awk system call (Lance Miller)
    Re: awk system call (Sam Holden)
    Re: Behavior of C<for $var (..)> <r28629@email.sps.mot.com>
    Re: Behavior of C<for $var (..)> <Allan@due.net>
        Debugger and pager option <ketung.Hsiao@losangeles.af.mil>
    Re: die() message available at END time? (Matthew Bafford)
    Re: die() message available at END time? (Martien Verbruggen)
    Re: Extracting version/type information from DLL's? <tripp.lilley@perspex.com>
        field sorting question j.cook@ion.ucl.ac.uk
    Re: field sorting question (Sam Holden)
        Help with - Dynamic HTML loading an applet???? <rmurthy@plexstar.com>
    Re: Help... broken dbmopen going from 5.004 to 5.005_02 (Martien Verbruggen)
    Re: how to determine child pid ?? (Erik)
    Re: how to determine child pid ?? (Andrew M. Langmead)
    Re: How to use Perl-script as filter? <ckuskie@cadence.com>
    Re: more on cookie problem reported earlier (Bart Lateur)
    Re: more on cookie problem reported earlier (Martien Verbruggen)
    Re: Need Perl programming -- please advise... <r28629@email.sps.mot.com>
    Re: New idiom? <r28629@email.sps.mot.com>
    Re: New idiom? <jeffp@crusoe.net>
        Okay, I took the advice -- now what? (Jim Mooney)
    Re: PERL is TOO flexible <r28629@email.sps.mot.com>
    Re: PERL is TOO flexible (Sam Curren)
    Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)? <removeMike@SinglepointSys.com>
    Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)? (Martien Verbruggen)
        Prgmr detection of redirection of STDOUT (James McHutchion)
    Re: Problems with 'setenv' within .sh and .pl scripts u (Martien Verbruggen)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 2 Dec 1998 20:36:05 GMT
From: snow@biostat.washington.edu (Gregory Snow)
Subject: $! type variables
Message-Id: <7448bl$1dg0$1@nntp6.u.washington.edu>


I remember reading somewhere how to make variables like $!, that
return different values in string context and numeric context.  I've
spent the last hour pouring through the docs and faq but have not
found it (and DejaNews won't search for $! and other searches have
been useless).  Can anyone point me to the correct doc or post?

Thanks
-- 
-------------------------------------------------------------------------------
     Gregory L. Snow         |    Matter cannot be created or destroyed,
     (Greg)                  |  nor can it be returned without a receipt.
snow@biostat.washington.edu  |


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

Date: 2 Dec 1998 21:32:40 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: $! type variables
Message-Id: <slrn76bcfo.bl5.sholden@pgrad.cs.usyd.edu.au>

On 2 Dec 1998 20:36:05 GMT, Gregory Snow <snow@biostat.washington.edu> wrote:
>
>I remember reading somewhere how to make variables like $!, that
>return different values in string context and numeric context.  I've
>spent the last hour pouring through the docs and faq but have not
>found it (and DejaNews won't search for $! and other searches have
>been useless).  Can anyone point me to the correct doc or post?

I've never needed to do that so I could be wrong but I suspect :

perldoc overload

might have the answers you want (of course it's quite possible that
that is the extremely long and comlicated way to do it in which case I
guess it won't jog your memory anyway)...


-- 
Sam

Perl was designed to be a mess (though in the nicest of possible ways). 
	--Larry Wall


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

Date: Wed, 02 Dec 1998 20:15:33 GMT
From: kennedy@classifieds2000.com
Subject: Alarm Function Equivalent for Win32
Message-Id: <744751$8mt$1@nnrp1.dejanews.com>

In porting some unix perl over to NT, found a section of code that uses
Alarm. What it is doing is waiting 5 sec.( alarm 5; ) to receive a package,
if the package is not received the routine finishes and the script continues
on.  Just commenting that portion of the code out leaves my script hanging
every so often:

if ($self->GetSys() eq "nt"){ }
else{
  alarm 5;
}

Does any one know of a Win32 solution with out having to spawn a child process
with Win32::Process::Create(); (it gets really messy this way)?
BTW: I couldn't get sleep to work in this situation.

thanks

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 02 Dec 1998 13:19:20 -0600
From: Gareth Jones <garethj@cableregina.com>
Subject: Any way to get drive letters on Win95 Machines?
Message-Id: <366592B8.DC98F996@cableregina.com>

I am trying to write a script to send out to my 95 boxes.  They don't
have the active com fix on them, so I can't use the active version, just
the standard version.

I have purchased perl2exe to compile the scripts, but I need a way to
get the local hard drives.

I cannot use the Win32::AdminMisc because it requires NT.  Any other
ideas??


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

Date: Wed, 02 Dec 1998 20:32:55 GMT
From: lemiller@us.ibm.com (Lance Miller)
Subject: awk system call
Message-Id: <3665a307.190771014@ausnews.austin.ibm.com>

I've been trying to use awk in a system statement in my perl program

examlple

(  !system," /usr/bin/awk '{print$1}'  filename );

I believe it has to do something with $1 variable, and awk and perl
are mis-translating it.

Anybody have any ideas I could use to solve this problem of mine?

Thanks in advance,


Lance


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

Date: 2 Dec 1998 21:26:26 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: awk system call
Message-Id: <slrn76bc42.bl5.sholden@pgrad.cs.usyd.edu.au>

On Wed, 02 Dec 1998 20:32:55 GMT, Lance Miller <lemiller@us.ibm.com> wrote:
>I've been trying to use awk in a system statement in my perl program
>
>examlple
>
>(  !system," /usr/bin/awk '{print$1}'  filename );

If you had something that even vaguely looked like perl then maybe someone
could help you...

If you are really going to do something as simple as the awk above you are
better off doing it from within perl. In fact unless you are using an
already existing awk script then it would be better to just write a perl
subroutine to do it instead, since future maintenance will be easier
if fewer languages are used (since if the job is suited to awk, it is also
suited to perl).

Anyway since I'm in a good mood for once you could try :

system('/usr/bin/awk','{print $1 }', $filename)
	&& die "oops system gave a strange return value of $!";

Though that is untested and quite possibly completely wrong so you should
just go and read the documentation on the system function in perl (since
I certainly wouldn't trust some starnger on a newsgroup more than the
documentation that comes with perl):

perldoc -f system

-- 
Sam

So I did some research. On the Web, of course. Big mistake...
	--Larry Wall


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

Date: Wed, 02 Dec 1998 14:53:17 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Behavior of C<for $var (..)>
Message-Id: <3665A8BD.25AF209@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Jeff Pinyan wrote:
> 
> In debugging a script of mine recently (a variable had an unexpected
> value), I came to a point where I thought I had found an error.  The
> variable $x had an unexpected value, and I thought these lines were the
> problem:
> 
> for $x (0..10){
>         # something done
>         # etc...
> }
> 
> I decided to say C<for my $x (0..1)>.  However, upon later inspection, I
> noticed that the following code produces the following results:
> 
> =for code
> $var = "jeff";
> for $var (0..10){ print $var; }
> print $var;
> 
> # PRINTS
> 
> 012345678910jeff
> =end code
> 
> So.  I use Perl 5.004_04 (I'll be installing 5.005 soon, I hope).  I
> wasn't able to find this behavior documented in the camel or perldoc... is
> it?

=pod
perldoc perlsyn:

      Foreach Loops

      The foreach loop iterates over a normal list value and sets the
      variable VAR to be each element of the list in turn.  If the
variable
      is preceded with the keyword my, then it is lexically scoped, and
is
      therefore visible only within the loop.  Otherwise, the variable
is
      implicitly local to the loop and regains its former value upon
exiting
      the loop.  If the variable was previously declared with my, it
uses
      that variable instead of the global one, but it's still localized
to
      the loop.  (Note that a lexically scoped variable can cause
problems
      if you have subroutine or format declarations within the loop
which
      refer to it.)
=cut

Or Blue Camel pg 100.

So, you did check the document, didn't you?

-TK


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

Date: Wed, 2 Dec 1998 16:32:08 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Behavior of C<for $var (..)>
Message-Id: <744bgo$mp4$1@camel21.mindspring.com>

Jeff Pinyan wrote in message ...
>In debugging a script of mine recently (a variable had an unexpected
>value), I came to a point where I thought I had found an error.  The
>variable $x had an unexpected value, and I thought these lines were the
>problem:
>
>for $x (0..10){
> # something done
> # etc...
>}
>I decided to say C<for my $x (0..1)>.  However, upon later inspection, I
>noticed that the following code produces the following results:
>
>=for code
>$var = "jeff";
>for $var (0..10){ print $var; }
>print $var;
>
># PRINTS
>
>012345678910jeff
>=end code
>
>So.  I use Perl 5.004_04 (I'll be installing 5.005 soon, I hope).  I
>wasn't able to find this behavior documented in the camel or perldoc... is
>it?


This seems to performing as I understand the documentation in perlsyn
describing the behavior of for and foreach.  "The foreach keyword is
actually a synonym for the for keyword...."   And "...the variable is
implicitly local to the loop and regains its former value upon exiting the
loop."

If you wrote your example as
$var = $jeff;
foreach $var (0..10) {print $var;}
print $var;
is the behavior more intuitive?

As I see it (0..10) creates an array of the numbers 0 to 10.  Then, as the
loop is executed, $var is set to each value in turn and printed.  Finally
$var is jeff once again.

Then again, I may be completely missing your point.  It has been known to
happen.

HTH

AmD




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

Date: Wed, 02 Dec 1998 12:43:05 -0800
From: Ketung Hsiao <ketung.Hsiao@losangeles.af.mil>
Subject: Debugger and pager option
Message-Id: <3665A659.9D5D3CC2@losangeles.af.mil>

I set O pager=more, but it O pager still said '1'.
How to resolve this ?



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

Date: Wed, 2 Dec 1998 15:07:32 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: die() message available at END time?
Message-Id: <MPG.10cf6814b470375e98974b@news.scescape.net>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <743okr$r74$1@nnrp1.dejanews.com>, chess@watson.ibm.com 
says...
=> In article <MPG.10ce2f87f6c6916f98974a@news.scescape.net>,
=>   dragons@scescape.net (Matthew Bafford) wrote:
=> 
=> >
=> > $SIG{__DIE__} = sub { # msg in @_
=> > 	# ...
=> > 	# ...
=> > };
=> >
=> > be of any use?
=> 
=> Thanks!  I have an irrational fear of $SIG.  Also, I'd like to have all
=> the end-time processing code together, regardless of the reason for ending
=> (hence my desire to do it in an END{}).  It occurs to me that this
=> should work:

Well, there are two kinds of signals:

1) The ones generated by your operating system.
2) The ones generated by Perl.

__DIE__ falls into the second category, and is really quite safe.  AFAIK 
(but don't quote me on this), __DIE__ is not asynchronous, so you don't 
have to worry about those kinds of problems.

=> eval {
=> 
=>    # absolutely everything goes here
=> 
=> };
=> $diemsg = $@;
=> 
=> END {
=> 
=>   # stuff using $diemsg
=> 
=> };
=> 
=> Any caveats in that?  

Well, it's what I use in a lot of my programs that have to generate 
specific headers and footers, and I feel it cleans the code up a lot.  
'or die "blah"' just doesn't cut it all the time.  And, hey, Randal 
Schwartz uses it (the eval wrapper) too! [1] ;-)

It also encourages me to check the return value of every single system 
call (ie: open, flock, print, etc), and give meaningful error messages.

=>                      Or, if I weren't afraid of $SIG, I could use
=> your suggestion instead of one big eval, and do
=> 
=> $SIG{__DIE__} = sub { $diemsg = shift };
=> 
=> # stuff
=> 
=> END {
=> 
=>   # stuff using $diemsg
=> 
=> }

Yeah, but not quite.

Observe:

#!/usr/bin/perl -w

my $msg;

$SIG{__DIE__} = sub { $msg = "@_"; };

die "FOOBAR";

END {
    print "Died with $msg!\n";
}
__END__
FOOBAR at - line 7.
Died with FOOBAR at - line 7.
!

You really need:

#!/usr/bin/perl -w

my $msg;

$SIG{__DIE__} = sub { $msg = "@_"; exit; }; # along those lines

die "BAROFFOO";

END {
    print "Died with $msg!\n";
}
__END__
Died with BAROFFOO at - line 7.
!

HTH!

=> DC

--Matthew

[1] I'm referring to Randal's Web Techniques articles.  
<URL:http://www.stonehenge.com/merlyn/>.


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

Date: Wed, 02 Dec 1998 21:10:55 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: die() message available at END time?
Message-Id: <z1i92.14$Fw3.133@nsw.nnrp.telstra.net>

In article <743okr$r74$1@nnrp1.dejanews.com>,
	chess@watson.ibm.com writes:
> In article <MPG.10ce2f87f6c6916f98974a@news.scescape.net>,
>   dragons@scescape.net (Matthew Bafford) wrote:

>> $SIG{__DIE__} = sub { # msg in @_

> 
> Thanks!  I have an irrational fear of $SIG.  Also, I'd like to have all

In the case of __DIE__, it's a an internal hook in perl internally,
not a signal in the traditional sense. There's much less need to feel
irrational fears over that :)

# perldoc perlvar
/SIG

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.       | password?
NSW, Australia                      | 


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

Date: Wed, 02 Dec 1998 15:24:37 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: Extracting version/type information from DLL's?
Message-Id: <3665A205.B068A7AD@perspex.com>

elcaro@my-dejanews.com wrote:

> Does anyone know how one might extract DLL version and type (16/32 bit)
> information from Windows DLL files?
>
> This work has to be done under Unix (with Perl naturally) and the DLL's are
> local on a unix filesystem, so they are directly accessible for reading. Is
> this information available in a set place within a DLL that can be simply
> extracted, or does it have to go through the windoze subsytem to get this
> info out, in which case it might be a problem under Unix.

This is more of a WinDOZE executable format question than a Perl
question. Have you searched the Microsoft Knowledge Base for relevant
articles? Though I don't suspect they'll necessarily have information about
that in particular, they sometimes surprise me. You might also look at the
WINE project (the GPL'ed Windows Emulation for UNIX). If nothing else,
I'd expect that they have some code that handles DLLs, and you might be
able to reverse engineer it from there.

Oh! Duh, check out the source for the Cygwin libraries from
http://sourceware.cygnus.com/cygwin/ , since the versions of gcc/egcs
shipped with that kit generate Win32 DLLs, at least, and probably have
something that would approximate docs.

My recollection is that DLLs do, indeed, encode a bit of basic metadata
in their header/stub/whatever it's called.



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

Date: Wed, 02 Dec 1998 20:07:27 GMT
From: j.cook@ion.ucl.ac.uk
Subject: field sorting question
Message-Id: <7446ls$86n$1@nnrp1.dejanews.com>

Hi All,

I have a text file with fields arranged as tab-separated columns. It can be
sorted on multiple fields with the unix sort command as in the following
example:

sort -k 1,1 -k 3n,3n -k 5,5     -or whatever-

My question is: is there an easyish way to do this in perl without resorting
to the non-standard Sort::Fields module?

cheers,

Jon

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 2 Dec 1998 21:13:26 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: field sorting question
Message-Id: <slrn76bbbm.bl5.sholden@pgrad.cs.usyd.edu.au>

On Wed, 02 Dec 1998 20:07:27 GMT, j.cook@ion.ucl.ac.uk
	<j.cook@ion.ucl.ac.uk> wrote:
>Hi All,
>
>I have a text file with fields arranged as tab-separated columns. It can be
>sorted on multiple fields with the unix sort command as in the following
>example:
>
>sort -k 1,1 -k 3n,3n -k 5,5     -or whatever-
>
>My question is: is there an easyish way to do this in perl without resorting
>to the non-standard Sort::Fields module?'

Just write the appropraite subroutine and use it as the comparison
function... The last example (aside from the package interaction
discussion) in the perldoc for sort is an obvious enough
specialisation of what you are after...

'perldoc -f sort'

A pretty obvious thing to read first if you are trying to work out
how to sort. If you did look up it, then post your attempted code that
isn't working so we can have something to work with...

-- 
Sam

Remember that the P in Perl stands for Practical.  The P in Python
doesn't seem to stand for anything.
	--Randal Schwartz in <8cemsabtef.fsf@gadget.cscaper.com>



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

Date: Wed, 02 Dec 1998 03:29:08 -0500
From: Rama Murthy <rmurthy@plexstar.com>
Subject: Help with - Dynamic HTML loading an applet????
Message-Id: <3664FA54.7CBEF852@plexstar.com>

Everytime I run this perl script from CGI script the applet seems to be
loading the cached class file instead of a newly created one. How do I
make it so that it
loads the newly created class file.
My code:

#!/perl/bin/perl
print <<EOF;
Content-type: text/html

<HTML>
    <HEAD>
    </HEAD>
    <BODY>
        Bannermatics Ad<p>
        Processing...<br>
EOF


  I do other stuff here

print <<EOF;
        <APPLET codebase="http://fitch/proc/ad2" code="admatic1.class"
width=468 height=60>
        </APPLET>
    </BODY>
</HTML>
EOF

Can anybody help with this. Any help is appreciated.

Thanks
Rama



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

Date: Wed, 02 Dec 1998 21:41:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help... broken dbmopen going from 5.004 to 5.005_02
Message-Id: <cui92.20$Fw3.133@nsw.nnrp.telstra.net>

In article <743ueb$4nb$1@alpha.insolwwb.net>,
	"Mike" <mgrommet@insolwwb.net> writes:
> dbmopen(%addresses,'/cgi-bin/christianmovies/emails',0666);

Have you tried:

dbmopen(%addresses,'/cgi-bin/christianmovies/emails',0666) || 
	die "Cannot open dbm: $!";

> no errors, no anything...
> 
> what am I missing here?

Error checking?

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd.       | am.
NSW, Australia                      | 


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

Date: 2 Dec 1998 18:55:54 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: how to determine child pid ??
Message-Id: <7442fq$3g$1@news.cyberhighway.net>

In article <36658585.50D60E59@cisco.com>,
	Keith Kaple <kak@cisco.com> writes:
>                         print "$buf -by pid:$pid";  #<----what variable
> id's me as "child 3" or "child 1"

$$ will give you the current pid.

-- 
Erik Nielsen, Cyberhighway Internet Services NOC
Hmm, doubtful.  The source code generally wasn't there when I needed it.
             -- Larry Wall when asked if he learned Perl from the perl source


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

Date: Wed, 2 Dec 1998 20:25:43 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: how to determine child pid ??
Message-Id: <F3Cu2v.68q@world.std.com>

Keith Kaple <kak@cisco.com> writes:

>Subject: Re: how to determine child pid ??

It seems to me that it isn't the child pid that you are looking for,
but once you're script forks off a child, the child itself needs to
know its own pid.

A process' PID is in the special variable "$$".
-- 
Andrew Langmead


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

Date: Wed, 2 Dec 1998 12:52:33 -0800
From: Colin Kuskie <ckuskie@cadence.com>
To: k.molkenthin@amdiv.de
Subject: Re: How to use Perl-script as filter?
Message-Id: <Pine.GSO.3.96.981202124549.17154D-100000@pdxue150.cadence.com>

[posted and emailed]

On 2 Dec 1998, Karlon West wrote:

> Kay Molkenthin (k.molkenthin@amdiv.de) wrote:
> > Hi,
> 
> > I need to modify a text, I write in vi (my standard editor). After
> > writing the text i want to pipe it through this script and want the
> > modified text in vi instead of the old one.

First, if you're using a vi clone (vim or nvi in particular) it's possible
to compile in the Perl interpreter to use it in command mode:

:1,$ perldo s/foo/bar/g;

For more information about those vi's, check out www.vim.org

> > Q2: How do I redirect the input?
> 
> 1) Move the cursor to the top of the file:  "1G" in cmd mode
> 
> 2) Pipe-replace the whole file:  "!Gperl-script-name" in cmd mode

Or in general:

:[x,y]!perl_script_name

:[x,y]!perl -pe 's/foo/bar/g;'

Good luck!
Colin



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

Date: Wed, 02 Dec 1998 20:14:49 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: more on cookie problem reported earlier
Message-Id: <36669e27.817229@news.skynet.be>

Warren Baker wrote:

>BUT all it does is print
>"Set-Cookie ...blah blah"  and it doesn't set the cookie.

The cookie header must be in the HEADERS section. NOT in the body. this
means it must come before the very first empty line.

And this isn't a Perl question. :-)

   HTH,
   Bart.


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

Date: Wed, 02 Dec 1998 21:46:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: more on cookie problem reported earlier
Message-Id: <azi92.22$Fw3.133@nsw.nnrp.telstra.net>

In article <8Ge92.1970$Q92.2094696@news.rdc1.bc.wave.home.com>,
	"Warren Baker" <WeAreUs@Ibm.net> writes:

> use CGI qw(:standard);
> print header(), start_html(' '),, h1(" ");
> print "<BODY>";
> print "Set-Cookie:IDENT=5; path=/; expires='Wednesday, 02-Dec-98 23:12:40
> GMT' ";

The cookie has to be part of the header of the HTTP response. If you
are using CGI.pm, you may as well use its support for cookies.

# perldoc CGI
[snip]
     CREATING A STANDARD HTTP HEADER:
[snip]
NETSCAPE COOKIES
[snip]

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd.       | why kamikaze pilots wore helmets - Dave
NSW, Australia                      | Edison 


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

Date: Wed, 02 Dec 1998 13:55:50 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Rick Ciaccio <rick@mesagroup.nospam.com>
Subject: Re: Need Perl programming -- please advise...
Message-Id: <36659B46.4683B2E2@email.sps.mot.com>

[posted to c.l.p.m and copy emailed]

Rick Ciaccio wrote:
> 
> Greetings,
> 
> A client is thinking of putting up an instant confirmation for their
> reservations page in their Website whereby guests will get an instant
> reservation number upon submitting their request.
> 
> The following are their concerns:
> 
[...]
> 
> We would like the scripts to be totally configurable and flexible so that
> all parameters can be scaled as needed.
> 
> Please let us know asap if you can do this.

No offence, but are you looking to hire someone to writing this program
for you? this ng is really _not_ a free-and-quick consultation service,
but for people who are having problem/questions when _writing_ _perl_
programs to seek advice.

-TK


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

Date: Wed, 02 Dec 1998 13:09:14 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Sean McAfee <mcafee@waits.facilities.med.umich.edu>
Subject: Re: New idiom?
Message-Id: <3665905A.EAE95E64@email.sps.mot.com>

[posted to clpm and copy emailed]

Sean McAfee wrote:
> 
> When working with a hash-of-hashes, I found myself writing code like this:
> 
> while (($host, $param) = each %paramhash) {
>     foreach $key (keys %$param) {
>         print "host $host: param $key = $param->{$key}\n";
>     }
> }
> 
> It occurred to me that the above could also be written like this:
> 
> while (($host, *param) = each %paramhash) {
>     foreach $key (keys %param) {
>         print "host $host: param $key = $param{$key}\n";
>     }
> }
> 

The one thing I don't quite like is that it doesn't let me do this:

use strict;
my %paramhash = ();

while (my ($host, *param) = each %paramhash) {
    foreach my $key (keys %param) {
        print "host $host: param $key = $param{$key}\n";
    }
}

your sample code suggests that this might come from a reasonably complex
piece of code, in which 'use strict' might be a good idea.

-TK


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

Date: Wed, 2 Dec 1998 15:20:48 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: New idiom?
Message-Id: <Pine.GSO.3.96.981202151934.20391B-100000@crusoe.crusoe.net>

> > When working with a hash-of-hashes, I found myself writing code like this:
> > 
> > while (($host, $param) = each %paramhash) {
> >     foreach $key (keys %$param) {
> >         print "host $host: param $key = $param->{$key}\n";
> >     }
> > }
> > 
> > It occurred to me that the above could also be written like this:
> > 
> > while (($host, *param) = each %paramhash) {
> >     foreach $key (keys %param) {
> >         print "host $host: param $key = $param{$key}\n";
> >     }
> > }
> > 

Interesting idea...

The reply, however:
> while (my ($host, *param) = each %paramhash) {
This line, in and of itself, doesn't work.
my() variables do not work with the symbol table, therefore, you can't
my() a typeglob.  You CAN local()ize them, though.

--
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
973-882-1022
www.crusoe.net



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

Date: Wed, 02 Dec 1998 21:32:01 GMT
From: gemhound@gemhound.com (Jim Mooney)
Subject: Okay, I took the advice -- now what?
Message-Id: <3665b15e.26041575@news.primeline.com>

I just got the welcome message to this Ng, and tried using some of the
suggestions.  When I included <use diagnostics;> in my source, I got
the following long message (I am using activestate's win32 perl.)

couldn't find diagnostic data in
C:\ActivePerl\5.00502\lib/pod/perldiag.pod C:\A
CTIVEPERL\5.00502\lib/MSWin32-x86-object C:\ACTIVEPERL\5.00502\lib
C:\ACTIVEPERL \site\5.00502\lib/MSWin32-x86-object
C:\ACTIVEPERL\site\5.00502\lib C:\ACTIVEPER L\site\lib . hello.pl at
C:\ACTIVEPERL\5.00502\lib/diagnostics.pm line 229, <POD _DIAG> chunk
533. 

Is there something I can do to get this data package for win32 perl,
so I can use diagnostics?

Second question. I also tried <use strict;> and got a message like the
one below for Every data item:

Global symbol "$dataitem" requires explicit package name at hello.pl
line ##.

What's an explicit package and again, how do I get this working so I
can use full diagnostics and warnings?

Thanks. 

Jim Mooney


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

Date: Wed, 02 Dec 1998 13:26:55 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: PERL is TOO flexible
Message-Id: <3665947F.8430D09B@email.sps.mot.com>

Jerome O'Neil wrote:
> 
> Dirk Kaufmann wrote:
> 
> > > I would go so far as to say that for any given non-perl programmer, perl
> > > is far more readable than most other languages.  I try to write
> > > maintainable code, knowing that the person maintaining it behind me
> > > might not be so perly.  It's a great language as far as that goes.
> >
> > think about that there are always beginners, otherwise the laguage is gonna
> > die.
> 
> I think that depends on what our beginner is beginning.  If a person has
> no programming experience at all, perl might be easier to learn than,
> say C/C++ or COBOL, but for someone with no perl, but experience with
> C/C++ or COBOL, perl has a very low learning curve.

I agree. I used to spent much more time picking up C++ than I did on
perl (still learning, of course ;-), and I still don't have a good
reason in using C++, apart from it being a better-C, becouse I spend
much less time solving my problem using Perl. The question is not which
language is better, but which language works better for you.

-TK


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

Date: Wed, 2 Dec 1998 12:22:17 -0800
From: samc@empirewest.com (Sam Curren)
Subject: Re: PERL is TOO flexible
Message-Id: <MPG.10cf415688a813719896af@news.sonic.net>

In article <3665947F.8430D09B@email.sps.mot.com>, 
r28629@email.sps.mot.com says...
> Jerome O'Neil wrote:
> > 
> > Dirk Kaufmann wrote:
> > 
> > > > I would go so far as to say that for any given non-perl programmer, perl
> > > > is far more readable than most other languages.  I try to write
> > > > maintainable code, knowing that the person maintaining it behind me
> > > > might not be so perly.  It's a great language as far as that goes.
> > >
> > > think about that there are always beginners, otherwise the laguage is gonna
> > > die.
> > 
> > I think that depends on what our beginner is beginning.  If a person has
> > no programming experience at all, perl might be easier to learn than,
> > say C/C++ or COBOL, but for someone with no perl, but experience with
> > C/C++ or COBOL, perl has a very low learning curve.
> 
> I agree. I used to spent much more time picking up C++ than I did on
> perl (still learning, of course ;-), and I still don't have a good
> reason in using C++, apart from it being a better-C, becouse I spend
> much less time solving my problem using Perl. The question is not which
> language is better, but which language works better for you.

I've found programming to be very similar to foreign languages in that 
respect. The first you learn you usually revert back to, unless you 
discontinue use entirely, and each language is easier to learn after 
that. One that understands C,perl,and VB would have an easier time 
learning another then one that only understands C.

Although people are different, and some take to different languages then 
others.

-Sam


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

Date: Wed, 2 Dec 1998 14:44:34 -0500
From: "Mike Marshall" <removeMike@SinglepointSys.com>
Subject: Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)?
Message-Id: <7445uv$ke@sjx-ixn9.ix.netcom.com>

Thanks for all the replies, I DO appreciate everyone taking the time.

>> Typical perl environment?  This is a joke, right?
<<

Apparently, so.   LOL!   Oh well, a boy can dream, can't he?






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

Date: Wed, 02 Dec 1998 21:19:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)?
Message-Id: <F9i92.17$Fw3.133@nsw.nnrp.telstra.net>

In article <912609181.225884@scarlatti>,
	mayer1b@unisys.co.at ( hans mayer ) writes:

> if you have a lot of perl-scripts for example with #!/usr/bin/perl 
> create a symbolic link as root:
> ln -s /opt/LWperl/bin/perl /usr/bin/perl 

This approach of course requires a symlink for every tool that perl
installs. There are quite a few, and the number is growing :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.       | cynical. It's perfectly easy to be
NSW, Australia                      | cynical.


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

Date: Wed, 2 Dec 1998 21:16:45 GMT
From: jim.mchutchion@compaq.com (James McHutchion)
Subject: Prgmr detection of redirection of STDOUT
Message-Id: <3665ad63.506147852@news.compaq.com>

I am using Perl5 for NT.

I would like to be able to programmatically determine if the STDIN/
STDOUT files have been redirected in a command like 
	perl file.txt <infile >outfile.

Reason being that I would like to determine if I have an interactive
or batch execution of file.txt and take different actions in each
case.  Are there any special variables or routines that can tell me
the name of the files associated with STDIN and STDOUT in this
case?

Jim (new to Perl5 on WIN32).


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

Date: Wed, 02 Dec 1998 21:07:39 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Problems with 'setenv' within .sh and .pl scripts under AIX
Message-Id: <v_h92.13$Fw3.133@nsw.nnrp.telstra.net>

[Adapted newsgroup list: alt.perl gone. clp.modules irrelevant.
c.security.unix irrelevant c.unix.aix irrelevant]

In article <Pine.HPP.4.02.9812021231390.8096-100000@wk0c02g6.krf.noaa.gov>,
	John LaGue <jjl@wk0c02g6.krf.noaa.gov> writes:

>   From within your perl script, try:
>   
>   ENV{ORACLE_SID} = $instance;

$ENV{'ORACLE_SID'} = $instance;

The quotes are optional, but I prefer them stylistically. The $ at the
beginning, however, is mandatory.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd.       | reflects this.
NSW, Australia                      | 


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

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

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