[7786] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1411 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 5 01:08:43 1997

Date: Thu, 4 Dec 97 22:00:27 -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           Thu, 4 Dec 1997     Volume: 8 Number: 1411

Today's topics:
     ? on localtime(time); <jfoss@jonesinternet.com>
     Re: Contract Programmers Needed! (Steven W McDougall)
     Re: Forced to use brain-dead perl 4 -- how do I accompl (Bart Lateur)
     Re: Forced to use brain-dead perl 4 -- how do I accompl (Steven W McDougall)
     Re: Getting rid of non-Y2K Perl4 (was Re: Pattern match <billg@networkapparel.com>
     Re: Getting rid of non-Y2K Perl4 (was Re: Pattern match <Falcon@darkwave.org.uk>
     Re: Help for a beginner!!! (convert binary number to he (Bart Lateur)
     Re: HELP ME!!! (Tad McClellan)
     Re: Ignore a "bad free"? (Tad McClellan)
     Re: Intermediary compiled perl? tobez@plab.ku.dk
     Re: JPL on FreeBSD (Honza Pazdziora)
     Re: looking for script like guestbook, boards , etc. <ceh@sunspot.sce.carleton.ca>
     Re: Making crontabs (Was: switch stdout and stderr) <seh@pecc.co.uk>
     Newbie Help Installing Perl <freud@freud.et.tudelft.nl>
     oraperl <daftary@_remove_to_send_email_.cisco.com>
     Package closure(?) question <tayers@bridge.com>
     Re: Pattern matching (or not....) (Bart Lateur)
     Re: Pattern matching (or not....) <markm@nortel.ca>
     Re: Perl editor needed <billg@networkapparel.com>
     Re: Perl editor needed (Jeremy D. Zawodny)
     Problem with setting timezone through $ENV{TZ} (Maurice L. Marvin)
     Re: Q: lambda fun, loop, string to expr <bowlin@sirius.com>
     Re: Q: lambda fun, loop, string to expr <eike.grote@theo.phy.uni-bayreuth.de>
     Re: read from end of file (by line) (Keith Willis)
     Re: READING the last few lines of a HUGE FILE. (Keith Willis)
     Re: Removing Files older than 14 days <nobroin@esoc.esa.de>
     same perl & linux probs <s2154158@cse.unsw.edu.au>
     storage of IO::Socket::INET instance in a module (Clinton Wong)
     struct or something similar??? (CoffeeBean)
     Re: struct or something similar??? (Jeremy D. Zawodny)
     Re: struct or something similar??? <qdtcall@esb.ericsson.se>
     Re: switch stdout and stderr <seh@pecc.co.uk>
     Re: truncating a string <r.goeggel@atos-group.de>
     Re: Use perl to access Microsoft SQL ! (Jeremy D. Zawodny)
     Using Excel95 with Perl (Jvrn Bodemann)
     Re: Using Excel95 with Perl (Jeremy D. Zawodny)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 04 Dec 1997 16:36:46 -0700
From: Webmaster <jfoss@jonesinternet.com>
Subject: ? on localtime(time);
Message-Id: <34873E8D.94882D2D@jonesinternet.com>

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

If I set these variable anyone know how to tell what $Yesterdays date
was?

I.e if $Today is (January) 1st, $Yesterday=(December) 31.

Thanks in advance.  I sure there is a snippet out there somewher but I
can't find it.

jim



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

Date: Wed, 3 Dec 1997 14:01:39 GMT
From: swmcd@world.std.com (Steven W McDougall)
Subject: Re: Contract Programmers Needed!
Message-Id: <EKM9Mr.6u8@world.std.com>

MARK MANGUM <markmangum@ibm.net> writes:

>Web Blueprints is launching a national advertising campaign to sell web
>design services.  We need 150 skilled programmers and graphic artists to

You're talking about a $30M business.
Do you have any capitol? staff? customers? revenue?

- SWM


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

Date: Wed, 03 Dec 1997 11:02:25 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Forced to use brain-dead perl 4 -- how do I accomplish task that is simple in perl 5 ?
Message-Id: <348633f7.5086055@news.tornado.be>

pojo@gte.net.nospam (Eric) wrote:

>	ARGHHH!  I cannot even find any documentation for perl4 ... =c  Does
>anyone know how to do references in Perl 4??

References are a new thing for Perl5.

You could rewrite the code avoiding all references. A "solution" would
be to join array elements into a string, and split it again after
retrieval.

Or, change from provider. ;-)

HTH,
Bart.


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

Date: Wed, 3 Dec 1997 13:56:55 GMT
From: swmcd@world.std.com (Steven W McDougall)
Subject: Re: Forced to use brain-dead perl 4 -- how do I accomplish task that is simple in perl 5 ?
Message-Id: <EKM9Ev.4I4@world.std.com>

bart.mediamind@tornado.be (Bart Lateur) writes:

>Or, change from provider. ;-)

No smileys.
If it's your ISP, get a new one.
If it's your school, just grab Perl5 and install it yourself.
If it's your employer, tell them you can't do the job without Perl5.

- SWM


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

Date: Wed, 03 Dec 1997 06:53:02 -0500
From: Bill Guindon <billg@networkapparel.com>
Subject: Re: Getting rid of non-Y2K Perl4 (was Re: Pattern matching (or not....))
Message-Id: <3485481E.A94EED83@networkapparel.com>

John M. Klassa wrote:
> 
> Falcon@darkwave.org.uk writes:
> -> With Perl4 (yes I know it's not 5, but what can you do when the
> -> management won't upgrade?) [...]
> 
> I've seen lots of people cite this as a reason for not upgrading... From a
> management perspective, what's the point of sticking with a piece of
> software (that's obsolete) when something better is available (for free,
[snip]

> Do these same managers run several-year-old version of GCC, too?

Of course they do.  It's all they can find that will run on their
Commodore 64's.  Or should that be Vic 20's? <G>

> 
> Perplexed,
> John
> 
> --
> John Klassa / Alcatel Telecom / Raleigh, NC, USA <><
> 
>         All those who believe in psychokinesis, raise my hand...


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

Date: Wed, 03 Dec 1997 13:27:37 +0000
From: -=Falcon=- <Falcon@darkwave.org.uk>
Subject: Re: Getting rid of non-Y2K Perl4 (was Re: Pattern matching (or not....))
Message-Id: <34855E49.49C8@darkwave.org.uk>

Bill Guindon wrote:
> 
> John M. Klassa wrote:
> >
> > Falcon@darkwave.org.uk writes:
> > -> With Perl4 (yes I know it's not 5, but what can you do when the
> > -> management won't upgrade?) [...]
> >
> > I've seen lots of people cite this as a reason for not upgrading... From a
> > management perspective, what's the point of sticking with a piece of
> > software (that's obsolete) when something better is available (for free,
> [snip]
> 
> > Do these same managers run several-year-old version of GCC, too?
> 
> Of course they do.  It's all they can find that will run on their
> Commodore 64's.  Or should that be Vic 20's? <G>

Nope, our reason is that most of our software (CGI) runs on a virtual
server,
which from day 1 was running Perl 4.....all our CGI code was written 
by a contractor for that box, and subsequently in testing on Perl 5 had
a few
hiccups (chop/chomp or whatever is one)...as I'm not yet suitably
"perled" up
to re-code it for Perl 5 (and havent actually used it yet either) it's
stuck
on Perl 4.....

Our secure server however is running Perl 5.....(but thats another
virtual
server...)

Peter Truman
-- 
      .---.        .-----------     Peter James Truman
     /     \  __  /    ------           -=Falcon=-
    / /     \( -`-,   -----           
   //////    '~ (    ---          Falcon@darkwave.org.uk
  //// / // :    ; ---      http://www.falcon.darkwave.org.uk/      
 // /   /  /)   / --        
/          //..\\ 
==========UU====UU===========================================================
          '//||\\`    And if you bore me...you lose your soul to me...
            ''``




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

Date: Wed, 03 Dec 1997 11:02:29 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Help for a beginner!!! (convert binary number to hex)
Message-Id: <3487368e.5749439@news.tornado.be>

"IOU" <iou@writeme.com> wrote:

>Is there any easy way to convert binary number to hex number?
>(1010111101010000 -> af50)

This one seems to work, though I'm unsure about what the intermediate
result represents:

$bin = "1010111101010000";
$hex = unpack("H4",pack("B*",$bin));
print "$bin -> $hex\n";

HTH,
Bart.


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

Date: Wed, 3 Dec 1997 06:34:15 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP ME!!!
Message-Id: <7kj366.0i.ln@localhost>

James BeVard (dweller@traknet.com) wrote:
: Is there a Freeware/Shareware version of perl? 


Perl is free.


: can someone tell me whare
: to get it.


The Perl FAQ can ;-)


-----------------------------
=head2 What machines support Perl?  Where do I get it?

The standard release of Perl (the one maintained by the perl
development team) is distributed only in source code form.  You can
find this at http://www.perl.com/CPAN/src/latest.tar.gz, which is a
gzipped archive in POSIX tar format.  This source builds with no
porting whatsoever on most Unix systems (Perl's native environment),
as well as Plan 9, VMS, QNX, OS/2, and the Amiga.

Although it's rumored that the (imminent) 5.004 release may build
on Windows NT, this is yet to be proven.  Binary distributions
for 32-bit Microsoft systems and for Apple systems can be found
http://www.perl.com/CPAN/ports/ directory.  Because these are not part of
the standard distribution, they may and in fact do differ from the base
Perl port in a variety of ways.  You'll have to check their respective
release notes to see just what the differences are.  These differences
can be either positive (e.g. extensions for the features of the particular
platform that are not supported in the source release of perl) or negative
(e.g. might be based upon a less current source release of perl).

A useful FAQ for Win32 Perl users is
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
-----------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 2 Dec 1997 23:24:02 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Ignore a "bad free"?
Message-Id: <idq266.g24.ln@localhost>

Alan Fahrner (sherlock.holmes@worldnet.att.net) wrote:

: I've written a perl program that is sometimes causing an error message I
: never got before about a bad free being ignored.
                           ^^^^^^^^
                           ^^^^^^^^

: Research leads me to believe that this is an internal perl error.

: Is this bad free safe to ignore?  Is it safe to ignore if the program is
: going to run as root (I have the -T flag going)?


>From the 'perldiag' man page (that describes all of the error messages
perl might issue):

------------------------
=item Bad free() ignored

(S) An internal routine called free() on something that had never been
malloc()ed in the first place. Mandatory, but can be disabled by
setting environment variable C<PERL_BADFREE> to 1.

This message can be quite often seen with DB_File on systems with
"hard" dynamic linking, like C<AIX> and C<OS/2>. It is a bug of
C<Berkeley DB> which is left unnoticed if C<DB> uses I<forgiving>
system malloc().
------------------------


Maybe that helps?


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 03 Dec 1997 13:59:05 +0100
From: tobez@plab.ku.dk
Subject: Re: Intermediary compiled perl?
Message-Id: <34855799.2FCA@plab.ku.dk>

Malcolm Beattie wrote:

> >I know someone is working on a perl compiler. I was wondering something else,
> >namely: is it possible to store the result of perl *after* perl compiles your
> >script, but before perl starts executing it (a sort of perl bytecode)?
> 
> That's what the Bytecode backend of the compiler does.

Sometimes this is not convenient.  The typical situation:

An interactive program embeds perl interpreter.  On startup it evals
"use HUGE1; use HUGE2;" etc...
Than it launches main script.  HUGE*.pm almost never change, and it
seems very appropriate
to have them precompiled;  not for the purpose of source hiding - just
to speed up things.

Is THIS possible somehow?

Anton.


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

Date: Wed, 3 Dec 1997 11:24:25 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: JPL on FreeBSD
Message-Id: <adelton.881148265@aisa.fi.muni.cz>

spidaman@well.com (Ian Kallen) writes:

> Honza Pazdziora (adelton@fi.muni.cz) wrote:
> : I bet you did not set your LD_LIBRARY_PATH before running make ;-)
> 
> What? '.' should be in LD_LIBRARY_PATH??

Hmm, INSTALL says:

> To actually build perl, you must add the current working directory to your
> LD_LIBRARY_PATH environment variable before running make.  You can do
> this with
> 
>    LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
> 
> for Bourne-style shells, or
> 
>    setenv LD_LIBRARY_PATH `pwd`
> 
> for Csh-style shells.  You *MUST* do this before running make.
> Folks running NeXT OPENSTEP must substitute DYLD_LIBRARY_PATH for
> LD_LIBRARY_PATH above.

and since without it the make did not work and with it it worked,
I have no reason not to believe ;-)

Hope this helps,

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 03 Dec 1997 08:15:38 -0500
From: Curtis Hrischuk <ceh@sunspot.sce.carleton.ca>
Subject: Re: looking for script like guestbook, boards , etc.
Message-Id: <wkdpvne36v9.fsf@sunspot.sce.carleton.ca>

Yes, line 118 is the line that was quoted.  Nope, I am not using a
tied variable, just a simle hash.

Curtis
-- 
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ Curtis Hrischuk (PhD Cand)  "in reality that comes from above      _/
_/ ceh @ sce . carleton . ca    God is calling                        _/
_/ Carleton University          there's no bigger love                _/
_/ Ottawa, On., Canada, K1S-5B6 It's his reality that welcomes us back_/
_/ Ph  (613) 520-2600 x1762     Trust and obey                        _/
_/ FAX (613) 520-5727           there is no other way..." the newsboys_/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


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

Date: Wed, 03 Dec 1997 10:55:14 +0000
From: Stuart Hughes <seh@pecc.co.uk>
To: James Richardson <jamesr@aethos.co.uk.nospam>
Subject: Re: Making crontabs (Was: switch stdout and stderr)
Message-Id: <34853A92.36A4@pecc.co.uk>

James Richardson wrote:
> 
> You are going about this the wrong way (IMHO)
> 
> Crontabs are just plain old text files, on my system (HPUX10) they are in
> /var/spool/cron/crontabs.
> Why not just give your script the correct permissions (normally crontabs
> are written as root), and then write the file there directly.
[snip]

Not such a good idea, the solaris man page (crontab (1))says:


               Note:  All crontab jobs should be submitted  using
               crontab;  you  should not add jobs by just editing
               crontab file because cron will  not  be  aware  of
               changes made this way.


Thanks for the idea though

Stuart


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

Date: Wed, 3 Dec 1997 14:34:49 +0100
From: Sigmund Freud <freud@freud.et.tudelft.nl>
Subject: Newbie Help Installing Perl
Message-Id: <Pine.LNX.3.95.971203142831.16548A-100000@freud.et.tudelft.nl>

Hello all,

I have been trying to install perl for some time now, and it is just not
working right. Lemme tell you what happens.
First of all, I am trying to install it on NT4.0, with 32 mb of ram. I am
also using IIS. Now, i downloaded the latest binary, and installed it,
just the way they say how to install it. Then, they say that install.bat
automatically installs the right registry, which it doesnt do with me, so
I have to do that all manually. The Data type of every new value is set
to reg_sz. This all goes ok, when i try to run a script from the dos
prompt, it all goes the right way. When I try to start a cgi script from
my browser (netscape or ie) it just keeps loading, and i only try to do
the Helloworld.pl to see if it all works. All the dirs are set the right
way (i think), but all that my browsers do, is keep loading, and IE gives
a timeout error after a while...I really need some help...
Thanks in advance...

Jaron Frenk

*** If u have a difficult task, give it to a lazy person - 
                              they will find an easier way to do it ***



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

Date: Thu, 04 Dec 1997 15:37:37 -0800
From: Kuntal Daftary <daftary@_remove_to_send_email_.cisco.com>
Subject: oraperl
Message-Id: <34873EC1.27C0635C@_remove_to_send_email_.cisco.com>

hi guys

i was trying to use oraperl but the script fails at ora_login itself
i think the problem is that i m not exactly sure what to put in where
the database name goes.

using sqlplus, i login using the following:

% sqlplus user/pass@db

but if i use 

$lda = &ora_login("db", "user", "pass") || die "login failed\n";

it fails.

i saw some example scripts give

$lda = &ora_login("t:some-host-name:db", "user", "pass");

but i dont know what does this syntax mean and how to find
out what i should put in for the "t:some-host-name" part.

obviously i m try oraperl for the first time in my life. :-)

any help or suggestions welcome.


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

Date: Wed, 03 Dec 1997 07:27:33 -0600
From: Tim Ayers <tayers@bridge.com>
Subject: Package closure(?) question
Message-Id: <34855E45.269534C1@bridge.com>

I'm new to using packages and am hoping someone would tell me
why the following doesn't work. (I'm using Perl5.003.)

  #!/usr/local/bin/perl5 -w

  package foo;
  
  sub compare {
    return $b <=> $a;
  }

  package bar;

  @list = qw(1 3 2);
  @sortedList = sort foo::compare @list;

  print "@sortedList\n";

Output is:
  > foo.pl
  Use of uninitialized value at ./foo.pl line 6.
  Use of uninitialized value at ./foo.pl line 6.
  Use of uninitialized value at ./foo.pl line 6.
  Use of uninitialized value at ./foo.pl line 6.
  Use of uninitialized value at ./foo.pl line 6.
  Use of uninitialized value at ./foo.pl line 6.
  Use of uninitialized value at ./foo.pl line 6.
  Use of uninitialized value at ./foo.pl line 6.
  1 3 2

Thanks very much and
Hope you have a very nice day, :-)
Tim Ayers                                        tayers@bridge.com
St. Paul, Minnesota
Bridge, Inc.                                        www.bridge.com


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

Date: Wed, 03 Dec 1997 11:02:21 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Pattern matching (or not....)
Message-Id: <34883a46.6701069@news.tornado.be>

mgjv@comdyn.com.au (Martien Verbruggen) wrote:

>if ($Description =~ /\Q$word\E/i) {
>
>(BTW, this will also match things like "C++-like languages", which
>might not be what you want. Look for word boundary tokens in the
>perlre documentation, which is also where you will find an explanation
>of \Q..\E)

Posting without thinking, huh? Note that a "word boundary" ("\b") will
match only on a transition between a word character "\w" and a
non-word-character ("\W") (or a string end).

So, this will print "no match":

	$_ = "Currently, C++ is a very popular programming language.";
	$search = 'C++';
	if (/\b\Q$search\E\b/) {
		print "match\n";
	} else {
		print "no match\n";
	}

because there is NO word boundary between "+" and " ".

HTH,
Bart.


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

Date: 03 Dec 1997 06:47:19 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Pattern matching (or not....)
Message-Id: <lq1g1oar6m0.fsf@bmers2e5.nortel.ca>

bart.mediamind@tornado.be (Bart Lateur) writes:
> mgjv@comdyn.com.au (Martien Verbruggen) wrote:
> >if ($Description =~ /\Q$word\E/i) {
> >(BTW, this will also match things like "C++-like languages", which
> >might not be what you want. Look for word boundary tokens in the
> >perlre documentation, which is also where you will find an explanation
> >of \Q..\E)
> Posting without thinking, huh? Note that a "word boundary" ("\b") will
> match only on a transition between a word character "\w" and a
> non-word-character ("\W") (or a string end).
> So, this will print "no match":

You both lose... the original author said "using perl4 unfortun'" :-)

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Wed, 03 Dec 1997 07:38:00 -0500
From: Bill Guindon <billg@networkapparel.com>
To: Larry Hanlon <pcpower@kiski.net>
Subject: Re: Perl editor needed
Message-Id: <348552A8.C7CE3913@networkapparel.com>

(Sender CC'd via email)

Larry Hanlon wrote:
> 
> Hello, just found first lesson in PERL. I need to find a editor that doesn't
> add a CR to the end of each line. What I am doing is the programming in a
> WIN95/DOS environment and when the scripts are run on a UNIX platform the
> CR's create errors. Please reply to e-mail as the news server is sometimes
> buggy.

That's more likely caused by FTPing your files in binary mode.  Make
sure you use ASCII for ALL CGI files (.pl, .cgi, .pm, etc).

If you'd like to take a look at a GREAT (although DOS based) editor, I
highly recommend Boxer.  I've used it for about 5 years now, and it can
do things that NO other win/dos editor can.  And yes, it's windows
friendly (works with the clipboard for cut and paste).

www.tiac.net/users/dhamel

If you just can't handle DOS <G>, try UltraEdit.  It's about as close to
Boxer as you can get.  (Sorry, you'll have to search for it).

Good luck.
Bill Guindon

BTW... comp.lang.perl, is now: comp.lang.perl.misc


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

Date: Wed, 03 Dec 1997 13:01:05 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Perl editor needed
Message-Id: <34855767.1114654358@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On Wed, 03 Dec 1997 07:38:00 -0500, Bill Guindon
<billg@networkapparel.com> wrote:

>(Sender CC'd via email)
>
>Larry Hanlon wrote:
>> 
>> Hello, just found first lesson in PERL. I need to find a editor that doesn't
>> add a CR to the end of each line. What I am doing is the programming in a
>> WIN95/DOS environment and when the scripts are run on a UNIX platform the
>> CR's create errors. Please reply to e-mail as the news server is sometimes
>> buggy.
>
>That's more likely caused by FTPing your files in binary mode.  Make
>sure you use ASCII for ALL CGI files (.pl, .cgi, .pm, etc).
>
>If you'd like to take a look at a GREAT (although DOS based) editor, I
>highly recommend Boxer.  I've used it for about 5 years now, and it can
>do things that NO other win/dos editor can.  And yes, it's windows
>friendly (works with the clipboard for cut and paste).

YES! Someone else who still rememberers BOXER!

One of the few things I miss about my old DOS/Win31 environment is
BOXER. I'd *love* to see an NT-native version of Boxer. I had taught
it so many cool tricks that made editing Perl/HTML/etc. vastly easier.

Oh well, such is "progress"...

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 3 Dec 1997 04:51:40 -0800
From: maurice@cs.pdx.edu (Maurice L. Marvin)
Subject: Problem with setting timezone through $ENV{TZ}
Message-Id: <663kks$1hu$1@sirius.cs.pdx.edu>

  I need to display UTC times in the user's local timezone.
I know that the TZ environment variable can be set, to control
the result of localtime().  However, it doesn't seem to work
within Perl.  If I set TZ in the shell, and then execute a
Perl program which calls localtime(), it works fine though.

  But, I'd rather not have the overhead of an exec whenever I
want to get localtime for a specific zone.  

  I wrote a little C program, which set TZ and then called
localtime(), and that seemed to work fine.  However, further
testing revealed that you can only set TZ once ... setting
it again to a different value has no effect.
  
  Can anyone explain exactly what's going on here?  Is the
kernel creating its on environment, and only allowing TZ to
be set once or something?  Any suggestions on how I can
solve this?

  If it's a kernel/user-space issue, would taking the
localtime source, munging it to accept a zone specification,
and turning it into an extension work?  A quick look at the
localtime source reveals a tzset() function ... 

  Any suggestions would be greatly appreciated.  I'm groping.

Thanks,

Maurice <maurice@hevanet.com> 


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

Date: Wed, 03 Dec 1997 02:19:20 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: Xah <xah@best.com>
Subject: Re: Q: lambda fun, loop, string to expr
Message-Id: <34853228.4A28736A@sirius.com>

> Question: what's the theoretical advantage of a loop with a middle exit?

This is not a Perl question per se, but it makes coding easier and can
prevent repeating blocks of code and other groovy things. Do it when you
need it.

> Must anonymous subroutine always be bound to a variable? If so, isn't the
> advantage of ANONYMOUS routine lost?

No. Yes.
 
> Question: How to convert a string to an expression or vice versa? For
> example, how to construct "$ext eq htm || $et eq html || $ext eq shtml"
> given "@a" where "@a = qw(htm html shtml)"?

$extensions = join('|', qw(html htm shtml));
$ext =~ /($extensions)/o and print "matched\n";

or even

$file =~ /\.($extensions)$/o


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

Date: Wed, 03 Dec 1997 11:06:07 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Q: lambda fun, loop, string to expr
Message-Id: <34852F0F.167E@theo.phy.uni-bayreuth.de>

Hi,

Xah wrote:
> 
> Hi, I have 3 perl beginner's questions and I'm posting them together here to
> reduce traffic. Thanks in advance for any help.
> 
> Question: what's the theoretical advantage of a loop with a middle exit?

Hm, I rarely use this. Sometimes it's just more convenient to do
something like

   while(<FILE>) {
       if(/^#/)   { next }   # ignore comments
       if(/^END/) ( last }   # stop here
       # process line
   }

> 
> Question: In Perl, an anonymous subroutine at runtime is defined like:
>     $subref = sub BLOCK;
> 
> Must anonymous subroutine always be bound to a variable? If so, isn't the
> advantage of ANONYMOUS routine lost?

In your example the subroutine doesn't have a name - there exists just
a _reference_ to the _anonymous_ subroutine.

   sub name { print "Hello !\n" }
       ^^^^
     name of (non-anonymous) subroutine

Example of a subroutine without any name/reference:

   @a = sort { $a <=> $b } $b;
             ^^^^^^^^^^^^^

> 
> Question: How to convert a string to an expression or vice versa? For
> example, how to construct "$ext eq htm || $et eq html || $ext eq shtml"
> given "@a" where "@a = qw(htm html shtml)"?

You may use 'eval(...)'. Example:

   @a = qw( htm html shtml );

   foreach (@a) { $_ = "\$ext eq '$_'" }  # construct the line
   $s = join(' || ',@a);                  # to be eval-uated

   $ext = 'html';
   if(eval($s)) { print "matches\n" }
      ^^^^^^^^

Bye, Eike
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: Wed, 3 Dec 1997 11:32:04 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: Re: read from end of file (by line)
Message-Id: <348742ca.94806113@elf.bri.hp.com>

On Sat, 29 Nov 1997 17:58:25 GMT, patrickq@hotmail.com (Patrick)
wrote:

>vi trick:
>
>:g/^/m0
>
>reverses the file

I _like_ that!

----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.


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

Date: Wed, 3 Dec 1997 11:39:06 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: Re: READING the last few lines of a HUGE FILE.
Message-Id: <34884478.95236272@elf.bri.hp.com>

On Sat, 29 Nov 1997 16:26:40 GMT, Guy Doucet <gdoucet@ait.acl.ca>
wrote:

>But what if I want to read only the last few lines of an enourmously
>large log file. I'm talking a few MBytes or maybe 10MBytes. I don't want
>to write to it, only read it. The lines in the file are all different
>lengths.

I think I'd be tempted simply to pipe the output from the 'tail'
command.  But then I am on a 'nix box...
----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.


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

Date: Wed, 03 Dec 1997 13:26:23 +0000
From: Niall O Broin <nobroin@esoc.esa.de>
To: Hugh <hnews@harvest-lodge.demon.co.uk>
Subject: Re: Removing Files older than 14 days
Message-Id: <34855DFF.3FF9@esoc.esa.de>

Hugh wrote:
> 
> I am having difficulty writing an efficient script to delete all files in a
> preset directory over a certain age. If a file is older than 14 days I want
> to delete it.

This should do what you want

#!/usr/local/bin/perl

require "find.pl";
 
# Traverse desired filesystems
 
&find('directory_name');
 
exit;
 
sub wanted {
    /^.*\.ABC$/ &&
    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    (int(-M _) > 14) &&
    (unlink($_) || warn "$name: $!\n");
}

This code was the output from the following simple find2perl command
line : 

find directory_name -name "*.ABC" -mtime +14 -exec rm {} \;

-- 
Kindest regards,


Niall  O Broin		

UNIX Network Administrator 		 	nobroin@esoc.esa.de
Ground Systems Engineering Department		Ph./Fax  +49 6151 90 3619/2179
European Space Operations Centre, Darmstadt, Germany


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

Date: Thu, 04 Dec 1997 00:16:09 +1100
From: Struan Buchanan <s2154158@cse.unsw.edu.au>
Subject: same perl & linux probs
Message-Id: <34855B99.941CA0F2@cse.unsw.edu.au>

G'day,
    Whenever I run a perl (5.004) script I get the following warnings.
(basically same as Bernard M. Piller a few posts before)
-----------
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LC_ALL = (unset),
        LANG = "us"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
------------

so obviously my two ENV variables,  LC_ALL and LANG seem to be wrong...
but when I check them I don't think they are, they are set to what the
abouve warnings say it should be set to.... ??!?
Any ideass welcome, cheers

Struan



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

Date: Wed, 3 Dec 1997 08:26:48 GMT
From: clintdw@netcom.com (Clinton Wong)
Subject: storage of IO::Socket::INET instance in a module
Message-Id: <clintdwEKLu4o.88H@netcom.com>

At some point in a module, I do this:

  $self->{'fh'} = new IO::Socket::INET ( ... );

Somewhere else in the module, I want to do this:

  print $self->{'fh'} "hi there\n";

But perl reports a syntax error and really wants to see a comma
between  '}' and '"'.  Is there any way to get around this?
It seems silly to do the following in every method of the module:

$a=$self->{'fh'}; 
# ....
print $a "hi there\n";



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

Date: 3 Dec 1997 12:59:09 GMT
From: shea@red.seas.upenn.edu (CoffeeBean)
Subject: struct or something similar???
Message-Id: <663l2t$5dr$1@netnews.upenn.edu>

Hello,
	I am learning Perl and I am trying to decide if it is useable
for my senior design project.  I have the llama book, but not the
camel (book store sold out of it, I'm getting it next week) I wanted
to know if there is a way I could define a data structure in Perl.
Other than using an array with the formatting kept track of in my
head.  (It reminds of fun with fixed point arithmetic =)  I am
currently trying to decide between Python or Perl.  I like Perl alot
but I'm not sure if I might be stretching its intended usage. =)
	I might also add I know C intimately and the only reason I'm
not using is I want to learn more languages to expand my gray matter.
I have also considered Java but have decided I rather try my hand at
something new.  Any pointers are greatly appreciated.

Regards,
	Dan

--
" The combination of Red Hat and Crack will allow Linux users to have an
  uncompromised multimedia gaming experience. " 
						Research Triangle Park, NC
						Monday, October 6th, 1997
 


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

Date: Wed, 03 Dec 1997 13:15:49 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: struct or something similar???
Message-Id: <34865a51.1115400220@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On 3 Dec 1997 12:59:09 GMT, shea@red.seas.upenn.edu (CoffeeBean)
wrote:

>	I am learning Perl and I am trying to decide if it is useable
>for my senior design project.  I have the llama book, but not the
>camel (book store sold out of it, I'm getting it next week) I wanted
>to know if there is a way I could define a data structure in Perl.

Certainly!

>Other than using an array with the formatting kept track of in my
>head.  (It reminds of fun with fixed point arithmetic =)  I am
>currently trying to decide between Python or Perl.  I like Perl alot
>but I'm not sure if I might be stretching its intended usage. =)

See the Perl Data Structures Cookbook (PDSC) at:

ftp://theory.uwinnipeg.ca/pub/CPAN/doc/FMTEYEWTK/pdsc/index.html

I think you'll find that it contains much of the info you're looking
for.

Similarly, you can see the perldsc manpage.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: 03 Dec 1997 15:14:57 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: struct or something similar???
Message-Id: <isg1oah5su.fsf@godzilla.kiere.ericsson.se>

shea@red.seas.upenn.edu (CoffeeBean) writes:

> I wanted to know if there is a way I could define a data structure
> in Perl.

Use hashes:

$structure{element}="Foo\n";

> I like Perl alot but I'm not sure if I might be stretching its
> intended usage. =)

Impossible! :-)

> I might also add I know C intimately and the only reason I'm not
> using is I want to learn more languages to expand my gray matter.

When learning Perl, try your best *not* to think in C. Coding C with
perl syntax is quite easy to do and a nice way to create som truly
abysmal code.

> I have also considered Java but have decided I rather try my hand at
> something new.  Any pointers are greatly appreciated.

Have you looked at INTERCAL? ;-)
-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Wed, 03 Dec 1997 10:50:42 +0000
From: Stuart Hughes <seh@pecc.co.uk>
To: Zenin <zenin@best.com>
Subject: Re: switch stdout and stderr
Message-Id: <34853982.4BD@pecc.co.uk>

Zenin wrote:
> 
> [ posted & mailed ]
> Stuart Hughes <seh@pecc.co.uk> wrote:
> : I'm trying to append to a crontab, and it may not exist, so I want to
> : capture the stderr.  The stdout on the other hand is always re-directed
> : to a temp file so I can use if for the append.
> 
>         perldoc -f open | more
>         And keyword search for "dupe".
[snip]

I should have said, I already tried this approach, e.g

open ORI_STDOUT, ">&STDOUT";
open ORI_STDERR, ">&STDERR";
open STDOUT,">&STDERR";
open STDERR,">&ORI_STDOUT";
$resp = `crontab -l >mycron`;
if($resp) { warn "error was $resp"         }  # redirect not propagated
else      { print "okay ",`cat mycron`     }
unlink "mycron";

But as backtick runs in a sub-shell, and doesn't get the redirection,
I'm not sure why, but I read this in an earlier post when I found it
didn't work.

[snip]
> 
> : In the line marked '### I need stderr' , I want the possible stderr
> : ouput to be fed into $resp.
> 
>         Hmm, well you have a couple options:
> 
>         1) Reopen stderr to a file and read it back later. -Easiest.
>         2) Use a tied handle class to redirect data into a scalar. -Harder
[snip]
> --
> -Zenin
>  zenin@best.com

Thanks for your suggestion, I have wimped out and used 1) via

system("crontab -l > $tmpcron 2>$tmpcron.err");

but I really would have liked just to have swiched stderr/stdout from
the point of view of the thing in the backticks.

Thanks for your help

Stuart


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

Date: Wed, 3 Dec 1997 11:25:43 +0100
From: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: truncating a string
Message-Id: <663c40$ao4$1@news.pop-stuttgart.de>


Matthew Rice wrote...
>Tom <beans@bedford.net> writes:
>
>> "Ronald G\"oggel" <r.goeggel@atos-group.de> writes: >
>> > Bill Eberle wrote <65i7t1$8c0$1@news.inficad.com>...
>> > >I have a problem with limiting the size of a string variable.  I want
to
>> > >take the first ten characters and delete the rest.  Does anyone know
an
>> > >easy way to do this, short of reading the first ten characters into an
>> > >array?  Thanks.
>> > >
>>
>> How about:
>>
>> $myvar =~ s/(.{0,10}).*/$1/;
>
>or
>$myvar = substr($myvar, 0, 10);
>


I thought of this possibility too, but it implies that $[ has the value of
0.
So
$myvar = substr($myvar, $[, 10);
is the exact solution - but I don't like this kind of coding.

Ronald




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

Date: Wed, 03 Dec 1997 12:55:02 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Use perl to access Microsoft SQL !
Message-Id: <3485561a.1114320488@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On 3 Dec 1997 09:19:36 GMT, cskhyuen@ug.cs.ust.hk (Yuen Kwok Hung)
wrote:

>    I would like to ask can I use Perl to write CGI to access
>the Microsoft SQL server ??
>    I knew that it's possible to use perl to access Sybase but
>how about Microsoft SQL ??

This *ought* to go into a FAQ somewhere.

In any case, you have two basic options:

Win32::ODBC
or
DBI::ODBC?

That is to say there's a Win32::ODBC module
(http://www.roth.net/odbc/) which does the trick for many of us (I'm
updating table in Oracle as I write this). I've heard that there's a
DBI::ODBC module that some folks use, too.

It's rumored that some of the Sybase-specific stuff works with SQL
Server, too, but I have no direct experience with it.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Wed, 3 Dec 1997 12:37:45 +0100
From: bodemann@do.isst.fhg.de (Jvrn Bodemann)
Subject: Using Excel95 with Perl
Message-Id: <MPG.eef62f7e1130e59989683@news>


Hi,

I want to save an ASCII column in Excel 4.0
format. For that I have to open Excel95,
transfer the data into it, and ask Excel
to save the data in a specific format.

In one sentence: I want to control Excel
(something that can't be done :-)
form Perl.

Any ideas?

Jvrn


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

Date: Wed, 03 Dec 1997 12:55:49 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Using Excel95 with Perl
Message-Id: <348756b8.1114478956@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On Wed, 3 Dec 1997 12:37:45 +0100, bodemann@do.isst.fhg.de (Jvrn
Bodemann) wrote:

>I want to save an ASCII column in Excel 4.0
>format. For that I have to open Excel95,
>transfer the data into it, and ask Excel
>to save the data in a specific format.
>
>In one sentence: I want to control Excel
>(something that can't be done :-)
>form Perl.
>
>Any ideas?

OLE automation, if version 4.0 supports it. If not, you'll need to
upgrade your Excel first.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

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

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