[8641] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2258 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 6 11:07:18 1998

Date: Mon, 6 Apr 98 08:00:26 -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           Mon, 6 Apr 1998     Volume: 8 Number: 2258

Today's topics:
        -comparing the values of 2 arrays- <james@cydaps.co.uk.NOSPAM>
    Re: -comparing the values of 2 arrays- <quentin.fennessy@amd.com>
    Re: accessing variables EXPORTed then "use"d (Andrew M. Langmead)
    Re: Anon Scalar Expression (was: Evaluate expression in (M.J.T. Guy)
        Any ideas, expert opinions?? about.. (Lalit Jairath)
        Beta-Testers wanted for my TIEHASH module <3hmuelle@informatik.uni-hamburg.de>
    Re: bitbucket for (,$b,,,$e,,)=split(/\,/,$string) <jhi@alpha.hut.fi>
    Re: changing perms w/CHMOD. (M.J.T. Guy)
    Re: chdir in UNIX: problem with the ~ (M.J.T. Guy)
    Re: chdir in UNIX: problem with the ~ <merlyn@stonehenge.com>
    Re: contexts: is there such a thing as array? (M.J.T. Guy)
    Re: contexts: is there such a thing as array? <merlyn@stonehenge.com>
    Re: current week <quentin.fennessy@amd.com>
    Re: file locking in perl <smubit1@gl.umbc.edu>
    Re: How do I strip newlines from a var (Abigail)
    Re: How do I strip newlines from a var (Joergen W. Lang)
        If "=~" means match what is doesn't match? <poohba@io.com>
    Re: linux, perl, and microsoft access (Andrew M. Langmead)
    Re: Multidimensional hashes (M.J.T. Guy)
        Perl code to generate MS Excel and Access files ? <mikeg@slpma8.ed.ray.com>
    Re: Perl/Tk presentation at the Perl Conference (Nathan V. Patwardhan)
    Re: Please help me <merlyn@stonehenge.com>
    Re: Post - is lwp the only answer? <merlyn@stonehenge.com>
        Q: CGI authentication ? <man@digsys.bg>
    Re: Random numbers (Perl fails this test) (M.J.T. Guy)
    Re: Running a perl script with root privilges (Andrew M. Langmead)
    Re: what is a bucket? (Mike Stok)
        Why a FAQ is irritating (was Re: How do I strip newline <merlyn@stonehenge.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 6 Apr 1998 14:22:18 +0100
From: "James" <james@cydaps.co.uk.NOSPAM>
Subject: -comparing the values of 2 arrays-
Message-Id: <891870098.4378.0.nnrp-05.c2de3f1b@news.demon.co.uk>

Hi

I am trying to compare the values of two arrays, and combining them in
another array, ensure that no duplicates are entered.

For example:

@array1 = ("12 ","13 ","14 ","15 ");
@array2 = ("14 ","15 ","16 ","17 ");

The end result should look like this:

@newarray = ("12 ","13 ","14 ","15 ","16 ","17 ");


I am trying to keep this as fast as possible, so I am considering using the
push function such as:

push(@newarray, $item_from_array1_or_array2);

So it would work something like:

unless ($value_of_item_from_array1 == $value_of_item_from_array2) {
    push(@newarray, $item_from_array1_or_array2);
}


I guess there is an easy way of doing this, but I cannot for the life of me
think how! :-)

TIA for any help with this!


James

Please remove NOSPAM if replying by email!






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

Date: 06 Apr 1998 09:10:41 -0500
From: Quentin  Fennessy <quentin.fennessy@amd.com>
Subject: Re: -comparing the values of 2 arrays-
Message-Id: <xim3efr3use.fsf@shaddam.tx.amd>

>>>>> "James" == James  <james@cydaps.co.uk.NOSPAM> writes:

    James> Hi I am trying to compare the values of two arrays, and
    James> combining them in another array, ensure that no duplicates
    James> are entered.

James - check out  perlfaq4, in the section entitled:

How do I compute the difference of two arrays?  
How do I compute the intersection of two arrays?

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: Mon, 6 Apr 1998 14:23:58 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: accessing variables EXPORTed then "use"d
Message-Id: <EqzxBy.7B1@world.std.com>

"Eric Winter" <ewinter@pop3.stx.com> writes:

>    Are these constants in intent only, or are they constants as defined by
>Constants.pm? If the former, then PF_INET should be replaced by $PF_INET.

Constants returned by modules that were created by h2xs like Socket.pm
(and constants created by constant.pm) are subroutines, not
variables. This means that &PF_INET or PF_INET() (or &PF_INET())
should work, but $PF_INET will not.

Which has me curious, since the constants are fetched and the
subtroutine created in an AUTOLOAD, which means at runtime, does it
get the "subroutine returning a constant gets its value inlined"
optimization? My guess would be that it would be inlined if exported,
(which then would be comile time) but not inlined if it wasn't
exported.

-- 
Andrew Langmead


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

Date: 6 Apr 1998 12:15:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Anon Scalar Expression (was: Evaluate expression inside print "")
Message-Id: <6gah19$86q$1@lyra.csx.cam.ac.uk>

In article <3524E7A9.53CB@min.net>, John Porter  <jdporter@min.net> wrote:
>
>Now let's look at what's really going on here.
>	\($x,$y,$z)
>is equivalent to 
>	(\$x,\$y,\$z)
>in every case.  It is *not* dependent on context.

That is currently the case, but it's a bug.   \ is meant to evaluate its
argument in the same context as it was called in.

I believe this will be mended in 5.004_05.

Note that \($x,$y,$z) will then be equivalent to ($x,$y,\$z) in a scalar
context, but it's rather hard to tell the difference.


Mike Guy


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

Date: 6 Apr 1998 14:35:13 GMT
From: ljairath@wright.aps.uoguelph.ca (Lalit Jairath)
Subject: Any ideas, expert opinions?? about..
Message-Id: <6gap71$p0o$2@ccshst05.cs.uoguelph.ca>


Q: i've an HTML text file-  ~/gev.html part of which looks like as below.
(the original text, pl. see below).

Please, read the entire e-mail before replying!

Every month we update the HTML text file (~/gev.html) wiht new information 
and we have to
replace the value of the checked month (e.g. April here) with the value
of the new month (e.g. in next month April will be replaced by May).

Also, we've to add another line (pull down) for April, the replaced month
(unchecked now). So, the new file should look like as below.

(Please see both the original and updated text (as it should look) below.


i've to do this at several places in the file and for several files. 

your help and time is greatly appreciated!

Thanks,

Lalit
~~~~~~

ps: you may please e-mail me at:

ljairath@wright.aps.uoguelph.ca


Original text:
~~~~~~~~~~~~~

<li> how are you?
<li> i am fine. <br>

<input type="radio" name="-e" value="april1998" checked> April 1998<br>
<table>
<tr valign top>
<td>
<input type="radio" name="-e" value="march1998" > March 1998<br>
<input type="radio" name="-e" value="february1998" > February 1998<br>



Updated text:
~~~~~~~~~~~~~

<li> how are you?
<li> i am fine. <br>

<input type="radio" name="-e" value="may1998" checked> May 1998<br>
<table>
<tr valign top>
<td>
<input type="radio" name="-e" value="april1998" > April 1998<br>
<input type="radio" name="-e" value="march1998" > March 1998<br>
<input type="radio" name="-e" value="february1998" > February 1998<br>



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

Date: 6 Apr 1998 13:05:19 GMT
From: Hanno Mueller <3hmuelle@informatik.uni-hamburg.de>
Subject: Beta-Testers wanted for my TIEHASH module
Message-Id: <6gajuf$e3l$1@rzsun02.rrz.uni-hamburg.de>


Hello,


I wrote a little module that I think is useful enough to
be sent to CPAN. But before submitting it to the archive,
I'd like to ask for your help and your opinion about it.


You can download it from
http://vsys-www.informatik.uni-hamburg.de/~3hmuelle/DictFile.pm


It is a TIEHASH module. It allows you to store and read
data in a dictionary file, like this:

	key1	value1
	key2	value2
	key3	value3
	...


Thanks to Perltie(3), the interface to using this file
format is straightforward and easy to use. I's not very
fast, but simple and useful.

Let me know what you think.


Greetings,

Hanno


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

Date: 06 Apr 1998 14:59:12 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: bitbucket for (,$b,,,$e,,)=split(/\,/,$string)
Message-Id: <oeeg1jrxisv.fsf@alpha.hut.fi>


Robert Lopez <Robert.Lopez@abq.sc.philips.com> writes:
> Do I have to do something like
>   ($junk,$b,,,$e,,) ...
>   undef($junk);
> or is there some option I am missing? Is there a $bit_bucket ?

Use an array slice, this way you get much clearer code because you
don't have to count the `junk' elements to know which elements you
choose:

($b,$e) = (blah($xyzzy))[3,5];

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: 6 Apr 1998 12:46:29 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: changing perms w/CHMOD.
Message-Id: <6gair5$93q$1@lyra.csx.cam.ac.uk>

In article <35265A66.EEE91646@hpl.hp.com>, Larry Rosler  <lr@hpl.hp.com> wrote:
>M.J.T. Guy wrote:
>>     You need to write
>> 
>>      ($dev, $ino, $mode, $nlink, $uid) = stat "$i/$j";
>> 
>> (assuming a Unix platform  -  otherwise set the path separator accordingly).
>
>This is not sound advice.  The forward-slash directory separator works
>fine using Perl on all platforms.  The back-slash works on some
>platforms only, and requires noise-polluting extra escapes.

You're putting words into my mouth.   I didn't say "use a backslash on
Windows platforms", because that would be bad advice.   I merely noted
that path separators are platform dependent, so beware.   In particular
"/" is not universally portable.


Mike Guy


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

Date: 6 Apr 1998 12:51:59 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: chdir in UNIX: problem with the ~
Message-Id: <6gaj5f$99q$1@lyra.csx.cam.ac.uk>

Mike Lacey <Mike_Lacey@Cargill.Com> wrote:
>I think that this is because the ~ constructions are Korn shell and not
>Bourne based; Perl uses /bin/sh to do that kind of expansion as I remember.

No.   Perl uses csh (or whatever masquerades as that) for glob
expansion.    So an explicit glob ought to work:

        chdir glob "~user/dir";


Mike Guy


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

Date: 06 Apr 1998 06:59:45 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: chdir in UNIX: problem with the ~
Message-Id: <8cd8evvyni.fsf@gadget.cscaper.com>

>>>>> "M" == M J T Guy <mjtg@cus.cam.ac.uk> writes:

M> Mike Lacey <Mike_Lacey@Cargill.Com> wrote:
>> I think that this is because the ~ constructions are Korn shell and not
>> Bourne based; Perl uses /bin/sh to do that kind of expansion as I remember.

M> No.   Perl uses csh (or whatever masquerades as that) for glob
M> expansion.    So an explicit glob ought to work:

M>         chdir glob "~user/dir";

But only on systems that *have* csh -- otherwise, it falls back to
using /bin/sh for glob expansion.  And then you don't get ~ again. :-)

And future versions of Perl will most likely *not* be calling an
external program for expansion... meaning that only /bin/sh constructs
will be guaranteed to work.  Caveat Executor.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 148 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: 6 Apr 1998 12:41:02 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: contexts: is there such a thing as array?
Message-Id: <6gaigu$915$1@lyra.csx.cam.ac.uk>

Randal Schwartz  <merlyn@stonehenge.com> wrote:
>>>>>> "M" == M J T Guy <mjtg@cus.cam.ac.uk> writes:
>
>M> Although you say "by definition" above, I can't actually find a
>M> definition of the behaviour in this case in the Perl documentation.
>
>I do.  It's right in "man perldata", by example:
>
>         @days{'a','c'}      # same as ($days{'a'},$days{'c'})
>
>And "same as" seems to be fairly literal.  It's intuitive that this
>comma there in a scalar context becomes the "evaluate left, discard,
>evaluate right" operator.  And thus it works.

Nope.  That's not what happens.   perldata is wrong, at least in scalar
context.   Try this experiment:

        sub w { print wantarray ? "List\n" :
                      defined wantarray ? "Scalar\n" :
                      "Void\n";
                shift;
        }
        @a{w(1),w(2)}

The subscripts are evaluated in list context.

So you see why I wanted "the behaviour in this case" explicitly documented.
It's not intuitively obvious, and even catches out experts.


Mike Guy


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

Date: 06 Apr 1998 06:43:21 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: contexts: is there such a thing as array?
Message-Id: <8clntjvzeu.fsf@gadget.cscaper.com>

>>>>> "M" == M J T Guy <mjtg@cus.cam.ac.uk> writes:

>> And "same as" seems to be fairly literal.  It's intuitive that this
>> comma there in a scalar context becomes the "evaluate left, discard,
>> evaluate right" operator.  And thus it works.

M> Nope.  That's not what happens.   perldata is wrong, at least in scalar
M> context.   Try this experiment:

M>         sub w { print wantarray ? "List\n" :
M>                       defined wantarray ? "Scalar\n" :
M>                       "Void\n";
M>                 shift;
M>         }
M>         @a{w(1),w(2)}

M> The subscripts are evaluated in list context.

Right.  I didn't contradict that.  It evaluates them sequentially,
each in a list context.  At no time is the collected *list of lists*
concatenated, used as keys, getting a *list* of values, only to be
discarded in favor of getting the final element of that list.

At no time does a list of values appear.  That's what I said in the
first place.

M> So you see why I wanted "the behaviour in this case" explicitly documented.
M> It's not intuitively obvious, and even catches out experts.

Nope.  Didn't catch me.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 148 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: 06 Apr 1998 08:52:04 -0500
From: Quentin  Fennessy <quentin.fennessy@amd.com>
Subject: Re: current week
Message-Id: <xim67kn3vnf.fsf@shaddam.tx.amd>

>>>>> "FG" == FRANCOIS GERT <GERT.FRANCOIS@SD.BE> writes:

    FG> Can anyone can give me a piece of code, or just a method I can
    FG> use to calculate the current weeknumber (1 - 52) ?

Here is some working perl code that gets you the week number,
using Date::DateCalc (from CPAN of course), and then munging the
output to agree with what my company uses for workweek.

If your idea of week number agrees with Date::DateCalc you do not
have to do such munging.  All you would have to do is run:

    ($ww, $yr)  = week_number($year,$mon+1,$mday);

use Date::DateCalc qw( week_number );

sub lf_ww {
    # Return ($work_week, $year) for today
    # This uses DateCalc::work_week() and is then
    # munged to conform with the AMD business calendar

    my ($ww, $fyr, $yr, $fww, $mday, $mon, $year);

    ($mday,$mon,$year) = (localtime(time))[3,4,5];
    $year += 1900;

    ($fww, $fyr) = week_number($year,1,1);
    ($ww, $yr)  = week_number($year,$mon+1,$mday);

    # normalize to AMD practices
    #
    if ($fww == 53) { $ww ++; }
    if ($ww > 52)   { $ww = 1; $yr ++; }

    return ($ww, $yr);
}

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: Mon, 6 Apr 1998 09:54:35 -0400
From: Stephen Mubita <smubit1@gl.umbc.edu>
Subject: Re: file locking in perl
Message-Id: <Pine.SGI.3.96.980406095330.3027A-100000@jig.gl.umbc.edu>

Well, thank you for all your help, Russ and Larry. I really appreciate the
trouble you took.


On 5 Apr 1998, Russ Allbery wrote:

=> Larry Rosler <lr@hpl.hp.com> writes:
=> 
=> > Offhand, I don't know of any convenient 'mandatory' locking mechanisms.
=> > I guess one could kludge something by taking permissions away while the
=> > file is locked, then restoring them when the file is unlocked.  Any
=> > other thoughts or pointers would be appreciated.
=> 
=> Unix does not, in general, implement mandatory file locking.  That ability
=> exists on other platforms (VMS being one of them), but there isn't any
=> solution for that on Unix without nasty cludges to my knowledge.  (Modulo
=> possible vendor extensions that are highly unlikely to be portable.)
=> 
=> -- 
=> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
=> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
=>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
=> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
=> 
=> 

 Stephen Mubita                                      smubit1@umbc.edu 
======================================================================
'God opposes the proud, but gives grace to the humble.'
							  James 3 : 6b
----------------------------------------------------------------------
 |      UCS is not responsible for any opinions contained here      | 
====================******************************====================



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

Date: 6 Apr 1998 14:11:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How do I strip newlines from a var
Message-Id: <6ganqc$4fb$1@client2.news.psi.net>

Lloyd Zusman (ljz@asfast.com) wrote on MDCLXXIX September MCMXCIII in
<URL: news:lu90pjiibh.fsf@asfast.com>:
++ Ronald J Kimball <rjk@coos.dartmouth.edu> writes:
++ 
++ > Lloyd Zusman wrote:
++ > > 
++ > > If there was no "Open to the Public" sign on the door, or if the
++ > > existence and location of the pamphlet could somehow magically be made
++ > > known to people even *before* their first entrance into the Forum,
++ > > then I would agree with you.
++ > 
++ > The automatic mailing (pamphlet) does not contain the answer to any of the
++ > questions people ask in clpm (the Forum).  It merely directs them to the
++ > sources of the answers; the manual, the FAQ, CPAN, etc.  Posters have access
++ > to these before they ever post to the newsgroup, and should presumably already
++ > be aware of some or all of them.
++ 
++ I would be willing to bet that a high percentage of the people who
++ enter clpm and post the frequently asked questions that many here find
++ so annoying are *not* aware of CPAN or the existence or location of
++ the FAQ at the time they post the questions.


That is *their* fault. Twice. First of all because Perl comes with
the FAQ and the manuals, secondly because it is against Usenet
guidelines to post without reading the FAQ.

If people think they are important enough to ask questions here which
are trivially answered by the manual and/or FAQ, they shouldn't be
surprised at the answers they get.


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Mon, 6 Apr 1998 16:37:52 +0200
From: joergen.lang@schwaben.de (Joergen W. Lang)
Subject: Re: How do I strip newlines from a var
Message-Id: <1d72k6h.dx1ax7fkmgdiN@host021-206.seicom.net>

Bob Gwynne <gwynne@utkux.utk.edu> wrote:

> Perhaps you haven't been clued into irony yet, Joergen 
> (or perhaps English is not your first language). 
> I know that computers are literalists, but
> humans think in more complex ways. The problem with software developers is
> that they know how computers process information, but are clueless when it
> comes to how people process information.  

I know some software developers who have a very strong ability to convey
information to other humans. Some even have a sense of humour. :-)

> So, explain Abby's code using the
> KISS method. I'll give you an A for clarity.

(ASAMF English is not my first language, so I had to do a quick search
of the net. This is the first thing, AltaVista came up with, searching
for "the KISS method":)

In "Business Objects - Total Quality Management with Object
Orientation", 
Gerald Kristen writes the following about the KISS method:

"In the KISS approach software can be generated from the analysis models
software by means of transformation rules. When the models are validated
by the end users, the realization is dependent upon the transformation
process.
The software quality as such is determined mainly by the understanding
of the natural language specification by the end user. With the
transformational approach the software developer can better judge "last
minute changes" made by the end user. The other advantage of the KISS
method is that objects are described and implemented as autonomous
entities with their own behavior."

By taking this in to consideration, I suppose, Abigail was intentionally
*not* using the KISS method to point someone to the manual. I'm not so
sure if the KISS method would really be of good help to satisfy your
demand for "instant enlightenment".

all the best,
Joergen ;-)
 
> RTFM Jonathan Swift,
> Bob Gwynne
> 
> Joergen W. Lang wrote in message
> <1d70uis.1kogmen1s7pd9aN@host037-206.seicom.net>...
> ><gwynne@utkux.utk.edu> wrote:
> >
> >> We want enlightenment--NOW!!!
> >
> >I've heard of a special offer at K-Mart. They have enlightenments in all
> >sizes and colors. Some even come in sixpacks. ;-)
> >
> >The other way consists of years of practice and study...
> >
> >
> >Joergen
> >--
> >-------------------------------------------------------------------
> >   "Everything is possible - even sometimes the impossible"
> >             HOELDERLIN EXPRESS - "Touch the void"
> >-------------------------------------------------------------------


-- 
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"
-------------------------------------------------------------------


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

Date: Mon, 6 Apr 1998 07:44:21 -0500
From: Chocolate <poohba@io.com>
Subject: If "=~" means match what is doesn't match?
Message-Id: <Pine.BSI.3.96.980406073817.7640A-100000@pentagon.io.com>

Hello,
	I have this script that goes a little like this:

open (FILE, "$file") || die "Can't open $file:   $!\n";
@lines=<FILE>;
close(FILE);
                
open (THEFILE, ">$thefile") || die "Can't open $thefile:   $!\n";
                        
foreach $line (@lines) {

	        if($line =~ "Phone:") {
        	        ($info, $phone) = split(/: /, $line);
        	        chop($phone);
        	        $phone =~ tr/()/ /;
        	        $phone =~ s/\s//g;
        	        $phone =~ s/-//g;
        	        $areacode = substr($phone, 0, 3);
        	        $exchange = substr($phone, 3, 3);
        	        $extension = substr($phone, 6);
        	        print THEFILE "$areacode::$exchange::$extension\n";
        	}
I have tried to do:
		else {
			print THEFILE "\n";
		}
And I have tried:
		elsif($line != "Phone") {
			print THEFILE "\n";
		}
And:
		elseif($line ne "Phone") {
			print THEFILE "\n";
		}
But none of this works.  How do I make it work?  I want it to print a
newline if the person doesn't have a phone number listed.

Please help.

  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

			_/_/_/		     _/     _/
		       _/  _/	            _/     _/		
  Web Page Designs    _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/_/_/ 
    Small Programs   _/     _/   / _/  _/ _/  _/ _/  _/ _/  _/  poohba@io.com
www.io.com/~poohba  _/	   _/_/_/ _/_/_/ _/  _/ _/_/_/ _/_/\_ 	(919)506-5883

  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



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

Date: Mon, 6 Apr 1998 14:26:22 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: linux, perl, and microsoft access
Message-Id: <EqzxFz.98I@world.std.com>

jaws@atl.mindspring.com (John Armsby) writes:

>Is there any reason why I can't access microsoft access via the win32
>perl module from Linux?  Linux sees the dos partition.

The Win32 modules contain code that calls operating sytem calls
specific to Windows and do not exist in Linux. Just being able to see
the files would not be enough.

-- 
Andrew Langmead


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

Date: 6 Apr 1998 12:05:07 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Multidimensional hashes
Message-Id: <6gagdj$7uo$1@lyra.csx.cam.ac.uk>

 <webmaster@dataplusnet.com> wrote:
>I'm using perl5.002 and need to know how to handle a multidimensional
>associative array.
>I'm using:
>$hash{$foo}{$bar} = $answer;
>and the error occurs:
>syntax error in file ./stats.cgi at line 253, next 2 tokens "}{"

Nope.  You're not using perl5.002  -  that's a Perl4 error message.

Check perl -v and also your #! lines.


Mike Guy


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

Date: Mon, 06 Apr 1998 08:51:22 -0400
From: Michael Genovese <mikeg@slpma8.ed.ray.com>
Subject: Perl code to generate MS Excel and Access files ?
Message-Id: <3528CFCA.6886@slpma8.ed.ray.com>

I'm sure it's been done before, I just don't know where to find
the appropriate file(s).  I need to be able to take data I've
already read in and write out the data in a format easily
read into MS Excel and MS Access.


I *could* write things out in a CSV file, but if there's a way to
write out a barebone EXCEL and/or ACCESS file I'ld like to be able
to do that.

Anyone with any ideas ?




-- 
Mike Genovese
508-490-3891
My opinions are my own, and not necessarily those of my employer.


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

Date: 6 Apr 1998 13:08:51 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl/Tk presentation at the Perl Conference
Message-Id: <6gak53$fbp@fridge.shore.net>

plambert$1@plambert.org wrote:

: The problem is, not only do I forget who the presenter was (a very pleasant
: fellow from England) but I have also misplaced a large chunk of my 
: materials from the conference.

Nick Ing-Simmons, perhaps?  I believe that his mail address is
included with the pTk distribution somewhere.  Like INSTALL or README?

I can't remember it off-hand.

There's also links to conference materials at www.oreilly.com.

--
Nathan V. Patwardhan



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

Date: 06 Apr 1998 07:53:15 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Haaino Beljaars <Beljaars@fys.ruu.nl>
Subject: Re: Please help me
Message-Id: <8cu387uhlw.fsf@gadget.cscaper.com>

>>>>> "Haaino" == Haaino Beljaars <Beljaars@fys.ruu.nl> writes:

Haaino> --------------744D8037AF8BBD66BE674A85
Haaino> Content-Type: text/plain; charset=us-ascii
Haaino> Content-Transfer-Encoding: 7bit

Please don't use MIME to post to Usenet.  Ugly.

Haaino> On the bottem of this E-mail I have a simple script that
Haaino> deletes all empty directories. The problem is that it deletes
Haaino> ALL empty directories.  How can I chance this program that it
Haaino> only deletes empty directories from the user 'guest' but not
Haaino> the directory "/home/guest"?

Haaino> If anybody can help me, I would be greatfully apprisiated!!!

Haaino> #!/usr/bin/perl

Haaino>     &smash("/");
Haaino>     sub smash {
Haaino>       my $dir = shift;
Haaino>       opendir DIR, $dir or return;
Haaino>       my @contents =
Haaino>         map "$dir/$_",
Haaino>         sort grep !/^\.\.?$/,
Haaino>         readdir DIR;
Haaino>       closedir DIR;
Haaino>       foreach (@contents) {
Haaino>         next unless !-l && -d;
Haaino>         &smash($_);
Haaino>         rmdir $_;
Haaino>       }
Haaino>     }

First, don't use that routine. (I know I wrote the basis of it,
but I also said not to use it in practical code.)

Do this instead:

    use File::Find qw(finddepth $name);
    my $guest = getpwnam "guest";
    finddepth sub {
	return if $name eq "/usr/guest";
	return if (stat $_)[4] != $guest;
	rmdir $_; # ignore errors
    }, "/";

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 148 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: 06 Apr 1998 07:04:13 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Marcia L Sussman <pi83@dial.pipex.com>
Subject: Re: Post - is lwp the only answer?
Message-Id: <8c90pjvyg2.fsf@gadget.cscaper.com>

>>>>> "Marcia" == Marcia L Sussman <pi83@dial.pipex.com> writes:

Marcia> I know that the lwp module will do this, but our host
Marcia> wont/can't let me install it...

I always hear that as "I need to fly, but I have to use something
other than an airplane, a helicopter, a balloon, or even something
like a glider.  What can I do?" I suppose your only option left is to
jump. :-)

Marcia> Any other ideas?

Yes, get a different host.  You really *don't* want to be coding this
all up from scratch on your own.  There are many person-years of work
that have been put in to make modules like LWP very robust and usable.
Please do not attempt to reinvent the wheel.

And you *do* realize that you can install LWP in your own area -- it
doesn't need sysadmin assistance.  Right?

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 148 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: Mon, 6 Apr 1998 15:35:05 +0300
From: Margarit Nickolov <man@digsys.bg>
Subject: Q: CGI authentication ?
Message-Id: <Pine.BSI.3.95.980406152145.6368A-100000@school.digsys.bg>


 Can anyone post an example of doing CGI authentication from within
 a Perl script?

Thank YOU in advance.

Reply-To: man@school.digsys.bg



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

Date: 6 Apr 1998 12:24:23 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Random numbers (Perl fails this test)
Message-Id: <6gahhn$8ep$1@lyra.csx.cam.ac.uk>

Excession <dac@NOSPAM.pcug.org.au> wrote:
>On 3 Apr 1998 15:11:53 -0800, rokicki@cello.hpl.hp.com (Tom Rokicki) wrote:
>
>>Perl's random numbers (from rand()) are atrocious---almost useless.
>>They just aren't very random.
>
>Try this:
>$s1 = time();
>$m=2147483647;
>$q=127773;
>$a=16807;
>$r=2836;
>
>for(1..100){print &r()};
>
>sub r{
>   $h=$s1/$q;$l=$s1%$q;$t=$a*$l-$r*$h;if($t>0){$s1=$t}else{$s1=$t+$m}
>}

I suspect that doesn't do the same as the Fortran original.   I think you
want

    $h=int($s1/$q);$l=$s1%$q;$t=$a*$l-$r*$h;if($t>0){$s1=$t}else{$s1=$t+$m}

(or judicious use of "use integer;").


Mike Guy


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

Date: Mon, 6 Apr 1998 13:33:31 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Running a perl script with root privilges
Message-Id: <Eqzuzv.KCH@world.std.com>

"Crispin Tschirky" <ct@tschirky.ch> writes:
>I tried to run it with the owner set to root and then set the filemode s
>(chmod u+s blabla) but while starting the script I always got the error:
>Can't do setuid.

When you change the permissions of a file to be setuid, perl passes
the script to a special setuid version of perl. According to the
perldiag man page, (where _all_ of perl's diagnosting messages are
documented) this error occurs when this program is missing or the
execute bits are turned off.

-- 
Andrew Langmead


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

Date: 6 Apr 1998 12:59:36 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: what is a bucket?
Message-Id: <6gajjo$s3m@news-central.tiac.net>

In article <35286C4C.F75698D7@gidon.com>, gidon  <gidon@gidon.com> wrote:
>In the perl manual there is a warning that you cannot put more than a
>certain amount of bytes in a bucket in a dbm file.
>
>What exactly is a bucket?

You might find a reasonable explanation of what a bucket is and some
(possibly interesting) general history in 

  http://www.sleepycat.com/docs/hash.usenix.ps

The quick answer (incomplete, possibly inaccurate but intended to help) is
that a bucket is a chunk of storage on disc, and the db* uses the key
value you provide to figure out where to find or put the associated data. 

With some of the older db* there was a limit in size to this container, so
it would cause problems if the combined size of a key/value pair was
bigger than the container.  More modern db* designs handle overflow so
that you can put large key/value pairs in the database at the cost of the
database doing a little more work.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 06 Apr 1998 06:57:13 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Lloyd Zusman <ljz@asfast.com>
Subject: Why a FAQ is irritating (was Re: How do I strip newlines from a var)
Message-Id: <8chg47vyrq.fsf_-_@gadget.cscaper.com>

>>>>> "Lloyd" == Lloyd Zusman <ljz@asfast.com> writes:

Lloyd> Well, this analogy doesn't quite cut it, either, since there is no
Lloyd> booklet handed out at the door here until *after* someone makes their
Lloyd> first post and receives the automatic emailing.

Yes, but everyone gets a booklet like that *with their watch*.  The
booklet at the door is merely a reminder that they got such a booklet
*with their watch*.

Lloyd> If there was no "Open to the Public" sign on the door, or if
Lloyd> the existence and location of the pamphlet could somehow
Lloyd> magically be made known to people even *before* their first
Lloyd> entrance into the Forum, then I would agree with you.

It is.  It's called "please first check the documentation *already*
provided with your tool before bugging the entire world with your
word-for-word FAQ".

It's also called "read the newsgroup for a week before posting your
first question, please."

Both of these are *clearly* stated netiquette.  Or are you telling
me that people aren't even reading the operating manuals for *Usenet*
either, as posted in news.announce.newusers?

Sheesh.  No wonder we get upset.  On the IRC EFNET #perl channel, we
call these people KLBs, as in Known Lazy B****rds.  And we're talking
the lazy of just "I'm clueless -- rescue me before I have to work at
it a bit", not "Lazy" in one of the three virtues of a good programmer
(see the Camel Glossary).

On Usenet, you read news.announce.newusers before your first post.
(Shame on those news admins that permit posting before reading the few
simple posts in the n.a.n group.)  One of *those* posts says that you
don't just walk into a newsgroup and post before reading for a week.
At least once a week, the mini-FAQ gets posted here, which is
identical to what someone gets by posting for the first time.  Also
here (and this is *why* the experts do it), is *repeated admonitions*
to those that post off-topic or from-the-FAQ-list.

So the only people that are making it past those barriers are all the
people that are in VIOLATION of NETIQUETTE and therefore CLUELESS.
Now, do you see how we could be angry at that?  I certainly hope so.
Even if we quote them the answer word-for-word out of the FAQ, they've
already demonstrated a lack of common sense, and will likely be back
with another lame question the next time they work with Perl.  Ugh!

I have *incredible* patience for people that have common sense.  I
don't care if they haven't a clue about how Perl works.  I
painstakingly answer each and every question in detail.  (You should
see the volume of private email consultation I do for free, not to
mention the the questions I answer each week I'm in front of a
classroom.)  But I must draw the line for KLBs, that demonstrate their
laziness by the posting of a FAQ or off-topic question to CLPM.  No.
Just say no.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 148 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: 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 2258
**************************************

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