[17523] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4943 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 21 18:07:16 2000

Date: Tue, 21 Nov 2000 15:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974847913-v9-i4943@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 21 Nov 2000     Volume: 9 Number: 4943

Today's topics:
    Re: (newB): What would cause line 1 fail? nobull@mail.com
    Re: /s and $1 (Tad McClellan)
    Re: A Small Problem Any Sugestions? <infro@yahoo.com>
    Re: A Small Problem Any Sugestions? <todd@mrnoitall.com>
        Accessing a WinNT window <neil@alaweb.com>
    Re: Addition vs. concatenation [was: Beginners Blues II (Jon Ericson)
    Re: Closing a window [non flame response :-)] <todd@mrnoitall.com>
    Re: Command Line Perl (Martien Verbruggen)
    Re: Eurodate mysteries (Tom Christiansen)
    Re: Eurodate mysteries <bart.lateur@skynet.be>
    Re: Eurodate mysteries <flavell@mail.cern.ch>
        HELP! bring variables out of a subroutine? webbgroup@my-deja.com
    Re: how do I delete initial and final spaces in a strin <uri@sysarch.com>
    Re: how would you call a subrountine using a button in  <todd@mrnoitall.com>
    Re: I am sorry for posting this so many times! (Tad McClellan)
    Re: Modifying array references <polar@cloud9.net>
    Re: Modifying array references nobull@mail.com
    Re: Most easy way to get IP from a local NIC by device  (Martien Verbruggen)
    Re: OT:Re: Eurodate mysteries <gm@magpage.com>
    Re: OT:Re: Eurodate mysteries (Tom Christiansen)
    Re: OT:Re: Eurodate mysteries (Martien Verbruggen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 21 Nov 2000 19:12:20 +0000
From: nobull@mail.com
Subject: Re: (newB): What would cause line 1 fail?
Message-Id: <u9aeat87hn.fsf@wcl-l.bham.ac.uk>

earlie <earlie@my-deja.com> writes:

> I am running a file that says only:
> #! usr/bin/perl -wcT
> 
> and I get the following:
> The specified CGI application misbehaved by not returning a complete set
> of HTTP headers. The headers it did return are:
> 
> Too late for "-T"

Perl error messages are explained in the "perldiag" manual.  This
error is no exception.

> This is on winNT

That's no excuse for not reading the manuals.  NT doesn't understand
#! so whatever application is calling perl.exe is going to have to
start it with the -T switch.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 21 Nov 2000 14:27:25 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: /s and $1
Message-Id: <slrn91lj4t.jba.tadmc@magna.metronet.com>

On Mon, 20 Nov 2000 17:59:09 GMT, randy.galbraith@pegs.com 
   <randy.galbraith@pegs.com> wrote:

>$count = $contents =~ s/\)((\s*[A-Za-z0-9,_ 
>\t\*\[\]\n]{2,};)*)(\s*)\{/
>"\)".&wash($1).&wash($2)."{"/goe;
                               ^
                               ^
                               ^

You should not include worthless options. It slows down understanding.

s///o affects what perl does with the variables in the pattern...

 ... but you do not _have_ any variables in the pattern!



I think you miscounted parens, don't you want a $3 instead of $2?

$2 will hold only the value from the "last go-round" of the ()* that
contains it.


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


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

Date: Tue, 21 Nov 2000 14:29:40 -0600
From: dan <infro@yahoo.com>
Subject: Re: A Small Problem Any Sugestions?
Message-Id: <3A1ADB34.FF388CE0@yahoo.com>




> Could my problem be in the form? Should I be using something between the words?

       <input type="text" name="gears box">
        <br>
        <input type="checkbox" name="2" value="gear box" >




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

Date: Tue, 21 Nov 2000 13:46:25 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: A Small Problem Any Sugestions?
Message-Id: <3A1AD10E.765A9BE@mrnoitall.com>



nobull@mail.com wrote:

> dan <infro@yahoo.com> writes:
>
> > Subject: A Small Problem Any Sugestions?
>
> OK you ask for sugestions - here goes.
>
> I suggest you use the Subject line in your posts to describe what you
> are posting about rather than use it for cutsie non-information.
>
> >
> > This is leeon.txt
> > 100|AB Smith Company|Abit Smith|info@company.com|there location
> > here|there url here.htm
> > 135|johnson toys|Jane McNere|jmc@toys.com|there town|there url.htm
> > 127|cogslys cogs|Mr. Withersmay|witer@cogs.com|spacelys
> > sproket|cogslys.htm
> >
> > This is leeon2.txt
> > Big Cars|111|263|143
> > Small Cars|142,1",2',Red|532,-,-,-|162,_,2',Blue
> > Buses|314|534|121|212
> >
> > Now my problem is that when I have a space in the key words for
> > leeon2.txt the script will not add the extra catagorys (1",2',Red). But
> > when I take the space out the script works fine.
> >
> > The script is as follows:
> > #!/usr/bin/perl
>
> I suggest enabling warnings and setting strict mode.
>
> > print "Content-type: text/html\n\n";
> >
> > if($ENV{"REQUEST_METHOD"} eq 'GET')
> >     {$cat = $ENV{"QUERY_STRING"};
> >      $cat =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> >     }
> > else{
> > read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> >
> > @pairs = split(/&/,$buffer);
> > foreach $pair(@pairs) {
> >   ($name, $value) = split(/=/,$pair);
> >   $value =~ tr/+/ /;
> >   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> >   $FORM{$name} = $value;}
> > }

Good grief...
just use...
$FORM{$name} =~ s/ //g;




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

Date: Tue, 21 Nov 2000 13:34:39 -0600
From: "Neil Trenholm" <neil@alaweb.com>
Subject: Accessing a WinNT window
Message-Id: <t1ljf3i9abclb0@corp.supernews.com>

Hi,

I am in need of a module that I can monitor WinNT with, so that if a certain
window pops up, I an interact with it...for example: If app X pops up a
window saying "Not enough resources to continue - <OK><CANCEL>", then I can
programmatically "click" <OK> and restart the app X service.

I know this is stricly a perl group - so if someone knows of a
perl.Windows.NT. group - please let me know.

I have looked at many of the CPAN modules - but am a bit perplexed as to
which one *may* be the right one to use.

Many Thanks
Neil




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

Date: 21 Nov 2000 20:52:08 GMT
From: Jonathan.L.Ericson@jpl.nasa.gov (Jon Ericson)
Subject: Re: Addition vs. concatenation [was: Beginners Blues II]
Message-Id: <8FF38939DJonathanLEricsonjpln@137.78.50.25>

On 21 Nov 2000, geoff-at-farmline-dot-com@127.0.0.1 (Geoff Winkless)
wrote: 

>"Ilmari Karonen" <iltzu@sci.invalid> wrote in message
>news:974812727.2114@itz.pp.sci.fi...
>> In article <8vbjjb$alf$1@soap.pipex.net>, Geoff Winkless wrote:
>> >No. Addition of numbers is associative and commutative.
>>
>> ..and it would make sense to expect anything that is called addition,
>> or uses the addition operator "+", to follow those laws as well.
>
>Why? It's =patently= obvious that you _cannot_ have a (useful) addition
>function which follows those rules for strings. It is still clear what
>most people's perception of "adding two strings together" would be.

In Perl, scalars can be both strings and numbers, depending on context:

$ perl -e '$x = 1; $y = "0"; print $x+$y, "\n", $x.$y, "\n";'
1
10

+ and . determine context.  Unless you are into strong typing (and Perl 
isn't), you need two clearly different operators to do two clearly 
different operations.

>> Of
>> course you can call anything you want "addition", but if it's nothing
>> like the regular kind of addition, don't expect your definition to be
>> considered useful.
>
>Your definition is restrictive. Mine is useful. :-)

Not in Perl.

>> >Why is -that- silly? In -either- respect, either -(5%3) or (-5)%3 it
>makes
>> >perfect sense...
>>
>>  1. Mathematical reason: x%y should equal (x+y)%y for all x and y.
>
>Explain to me how (-5 + 3) MOD 3 (ie -2) is not the same as (-5) MOD 3
>ie -2...
>
>The only time when this will not work is when you cross over the
>boundary from positive to negative numbers, ie -1 MOD 3 gives -1 whereas
>(-1 + 3) MOD 3 gives 2.

But that's exactly the point.  In modulus arithmetic, this behaviour make 
programs complicated and error prone.  What do you use % for?

Jon


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

Date: Tue, 21 Nov 2000 13:03:30 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: Closing a window [non flame response :-)]
Message-Id: <3A1AC6FB.CD07F388@mrnoitall.com>



Jodrell wrote:

> You seem to have missed a fairly fundamental concept of web design, that
> is, of the difference between "client-side" and "server-side" scripting.
>
> > > I have an ASP page that calls a PL page
> > > as a separate window.
>
> What you have is some JavaScript embedded into the HTML produced by an
> ASP script that opens the URL of a Perl script into a new window.
> JavaScript is a "client-side" language, that means it's used by the web
> browser to control its behaviour, and various elements on the page.
>
> > > All I was asking was what is the equivalent Perl
> > > script command to close a window.
>
> Perl, like ASP, is used on the "server-side" to generate HTML that's
> sent to the user. The perl code is executed for the webserver and the
> output, a stream of (usually) HTML text is then sent on to the browser.
> Therefore perl cannot control the behaviour of the browser, only the
> HTML it receives from the server.
>
> To solve this problem, you will need change the Javascript in the HTML
> produced by either the ASP script or the perl script so that (1) the
> page isn't opened in the first place or (2)there's a link that allows
> the window to be closed, as below:
>
> <html>
> .
> .
> .
>
> <p><a href="JavaScript:window.close()">Click here to close this
> window.</a></p>
> .
> .
> .
> </html>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

perl script...
print "Click the little square window to close the window";



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

Date: Tue, 21 Nov 2000 21:57:56 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Command Line Perl
Message-Id: <slrn91lru4.r2.mgjv@verbruggen.comdyn.com.au>

On Tue, 21 Nov 2000 04:21:30 GMT,
	Chris Fedde <cfedde@fedde.littleton.co.us> wrote:
> In article <slrn91jqq4.r2.mgjv@verbruggen.comdyn.com.au>,
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>>
>># perl -le 'print -A for <.* *>'
> 
> I thought to post one that used /bin/ls. That would get around the alias
> issue.  But it has the same score as your previous post.
> 
> I guess that if we are going to be truely cross platform then we'll
> probably have to use opendir and its friends.  Drat, There goes my
> handicap. :-)

Not since perl 5.6.0. Globbing is now internal, and _should_ give the
same results on all platforms. Older perls used to spawn an external
shell. It uses the POSIX glob() (or actually a FreeBSD superset of
that) to resolve the pattern. It's actually a lot more flec\xible than
the old ways, and my reservations against usign glob() have decreased
a lot since this happened.

So, the quoted solution above should be portable :)

I'd still use opendir/readdir in any non-trivial program, though.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.   | enough features yet.
NSW, Australia                  | 


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

Date: 21 Nov 2000 13:55:59 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Eurodate mysteries
Message-Id: <3a1ae15f@cs.colorado.edu>

In article <Pine.GHP.4.21.0011211505390.25778-100000@hpplus03.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:

>> I do mean to imply any moral justification here, merely explanation.
>There's a negative missing here...

Guilty, your honor.

>> The ISO date format is nice in many ways.  It is not ambiguous, and
>> it is easy to parse and sort.  But it is also not realistic. 
>
>OK, so what's wrong with 21 Nov 2000 (this is what Messy Windows tells
>me right now, for example) ?

Nothing whatsoever.  In fact, I virtually always write it that way myself.

>> people start speaking in ISO, then fine, but until then, you can't
>> expect it of them.  
>
>That's not the point.  You have already admitted that USA-readable
>format is potentially ambiguous.

I never advocate dd/dd/dd formatting.  I prefer dd/mon/yyyy myself.
Then there's the old dd/ROMAN/yy format.  You remember that?  Where
you write the month in Roman numerals, so today is 21-XI-2000.  This
is also not ambiguous, but I wouldn't really suggest it be used apart
from cuteness.

>> Never store dates meant to be read by computers in localtime()
>> format; at the very least, use gmtime().  Preferably use something
>> more readily sortable, like raw time() or the ISO format.  But don't
>> expect people to read that
>
>This still isn't the point. You need to choose a human-readable format
>that isn't doomed to being misunderstood.  Dragging-in irrelevances
>about machine-internal formats suggests that you haven't any real
>arguments to support your use of USA-specific formats, any more than I
>would be able to justify using formats that are only comprehensible in
>my own country.  Well, I just wrote 21/11/2000 in my logbook, but I'm
>not asking you to read it: if I were typing it into a web page I would
>plan to format it differently.

It seems you have misunderstood my intent.  You're right that I
wasn't addressing the direct statement that was being made.  I was
trying to explain why something was happening, and also giving some
advice.

I am certainly not saying that one should use (numeric)month/day/year
in a program.  Heaven forbid!  That would, I think, be pretty stupid.
I was trying to explain *why* people write that.  I wouldn't even
want a program to produce it, no matter what, but neither do I ever
want it to produce day/(numeric)month/year.  There is a good reason
that strftime has a %x and a %X format.

% perl -MPOSIX -le 'print strftime("%d-%b-%Y", localtime)'
21-Nov-2000

% perl -MPOSIX -le 'print strftime("%B %d, %Y", localtime)'
November 21, 2000

Those are both adequate formats for people to read, sometimes even
desirable ones.  They aren't very nice for computers, of course, when
it comes to manipulation.  time() is much better for that.

I was also trying to say not to use localtime for recording things.
Otherwise you'll eventually have timezone and DST issues.

Please don't read too much into what I was saying.  I was not
trying to advocate that xx/yy/zz be the preferred date format.
I don't want to figure out what 01/02/03 is, and neither do you.
I was only trying to explain to the confused Continentals why
we write it that way: because it mimics the order of speech.

--tom


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

Date: Tue, 21 Nov 2000 21:18:11 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Eurodate mysteries
Message-Id: <tjpl1tsp2kterltqpqqmub129sd3st7u61@4ax.com>

Tom Christiansen wrote:

>>OK, so what's wrong with 21 Nov 2000 (this is what Messy Windows tells
>>me right now, for example) ?
>
>Nothing whatsoever.  In fact, I virtually always write it that way myself.

> I prefer dd/mon/yyyy myself.
>Then there's the old dd/ROMAN/yy format.  You remember that?  Where
>you write the month in Roman numerals, so today is 21-XI-2000.  This
>is also not ambiguous, but I wouldn't really suggest it be used apart
>from cuteness.

What strikes me is that all of these "alternatives" use the European
order: the month in the middle.

-- 
	Bart.


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

Date: Tue, 21 Nov 2000 22:24:26 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Eurodate mysteries
Message-Id: <Pine.GHP.4.21.0011212207520.2132-100000@hpplus03.cern.ch>

On 21 Nov 2000, Tom Christiansen wrote:

> It seems you have misunderstood my intent. 

OK, let's concede I misunderstood your intention of doing no more than
to explain it, to be a tacit defence (or in your case, presumably
defense) of the practice (or practise).

If so, then I apologice  (woops ;-)

But it's a frequent practical problem, which triggered the
keyboard-jerk reaction.  OK?

> % perl -MPOSIX -le 'print strftime("%d-%b-%Y", localtime)'
> 21-Nov-2000
> 
> % perl -MPOSIX -le 'print strftime("%B %d, %Y", localtime)'
> November 21, 2000
> 
> Those are both adequate formats for people to read, sometimes even
> desirable ones. 

That's fine by me.  Of course this all pre-supposes we're conversing
in English.  Otherwise the numbers become attractive again ;-)

> I was also trying to say not to use localtime for recording things.

FWIW, I went to the effort to tell my web servers to run on GMT all
year around; they would have happily cut all their logs on local time
if I hadn't.

> Otherwise you'll eventually have timezone and DST issues.

Absolutely.

> I don't want to figure out what 01/02/03 is, and neither do you.

Right...

Neither do I particularly advocate 2000/02/03, but at least it is
unlikely to be misunderstood.  Nobody would suppose it to be
yyyy/dd/mm, surely?? 

all the best



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

Date: Tue, 21 Nov 2000 20:41:27 GMT
From: webbgroup@my-deja.com
Subject: HELP! bring variables out of a subroutine?
Message-Id: <8vemlm$544$1@nnrp1.deja.com>

I have been able to use

return 1;

but how do I bring variables that I set within the subroutine out of
it?? Doesn't using the return kill the subroutine after it is used??


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 21 Nov 2000 20:52:06 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how do I delete initial and final spaces in a string?
Message-Id: <x71yw5dp55.fsf@home.sysarch.com>

>>>>> "CB" == Christopher Burke <craznar@hotmail.com> writes:

  CB> uri@sysarch.com (Uri Guttman) wrote in <x7hf52eh0j.fsf@home.sysarch.com>:

  >> \1 is a backreference and should only be used in the regex itself and
  >> not in the replacement string. it is supported but not proper. use $1
  >> and brethren as that is what they are designed for.

  CB> You mean 'or even better supported' because the above DOES work.

from perlre:


WARNING on \1 vs $1

	Some people get too used to writing things like:

	    $pattern =~ s/(\W)/\\\1/g;

	This is grandfathered for the RHS of a substitute to avoid
	shocking the sed addicts, but it's a dirty habit to get
	into.  That's because in PerlThink, the righthand side of a
	s/// is a double-quoted string.  \1 in the usual double-
	quoted string means a control-A.  The customary Unix meaning
	of \1 is kludged in for s///.  However, if you get into the
	habit of doing that, you get yourself into trouble if you
	then add an /e modifier.

	    s/(\d+)/ \1 + 1 /eg;        # causes warning under -w

	Or if you try to do

	    s/(\d+)/\1000/;

	You can't disambiguate that by saying \{1}000, whereas you
	can fix it with ${1}000.  Basically, the operation of
	interpolation should not be confused with the operation of
	matching a backreference.  Certainly they mean two different
	things on the left side of the s///.


that says it all. i would hope \1 in the RHS is dropped in perl6 (and it
may be) as it is wrong.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 21 Nov 2000 12:51:42 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: how would you call a subrountine using a button in a web browser?
Message-Id: <3A1AC439.2947C470@mrnoitall.com>



pape_98@my-deja.com wrote:

> Hi,
> I've been stuck on this problem for quite a while now, and was
> wondering if you could help me. I am writing a script with several
> different subroutines, but the scripts generate HTML pages.
>
> What I really want to do is to be able to call a subroutine using a
> button on the page.
>
> How do I do this??
>
> I've tried:
>
> $button1->Button(name=>'Add', value=>'Add A User', OnClick=>"add()");
>
> but this doesn't work.
>
> and,
>
> print start_form(add());
>
> print p(submit("Add User"));
>
> print end_form;
>
> calls the subroutine automatically.
>
> Can you please help?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

<a href="your.cgi?&add_user=on">Add Your Name</a>
or
<form action="your.cgi'>
<input type="submit" name="add_user" value="ADD ME">
</form>

script=

if($input{add_user} ne ""){
    &subroutine;
}



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

Date: Tue, 21 Nov 2000 14:32:08 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: I am sorry for posting this so many times!
Message-Id: <slrn91ljdo.jba.tadmc@magna.metronet.com>

On 21 Nov 2000 12:30:39 -0600, Kent Perrier <kperrier@blkbox.com> wrote:
>"Johan M. Ditmar" <johan.ditmar@telia.com> writes:
>
>> I apologize for posting this message so many times. I donīt think itīs my
>> fault, it must have something to do with the newsgroup server at my work or
>> outlook. I did not do it to get more attention.
>
>Get a better news reader.


Surely you meant get _a_ newsreader.

Outlook is not a newsreader (despite being able to read news with it).

Driving a nail with a wrench often works, but a hammer makes
it ohhh so much easier.


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


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

Date: Tue, 21 Nov 2000 14:16:56 +0000
From: brian <polar@cloud9.net>
Subject: Re: Modifying array references
Message-Id: <3A1A83D8.B250D674@cloud9.net>

Sorry - I posted the problem in haste and was unclear.

Basically I am using
    push @{$list{$thekey}} , $firstdate, $lastdate, $numoccur
to set each key on the first occurrence a conditional test is true.
I am trying to the modify $lastdate and $numoccur on successive passes if
the conditional test for that key value is found to be true.

For example I can read
        abc   19990202  19990202  1
        def    20000302  20000302  1
        xyz    19970402  11970402  1

 I then used
    @xyz = @{$list{$thekey}}
    $number_increment = pop ( @xyz )
    $new_last_date = pop ( @xyz )

    $number_increment += 1
    $new_last_date = $current_date    ## set to todays date earlier

    push @xyz , $number_increment
    push @xyz $new_last_date

    @{$list{$thekey}}= @xyz


this works and places the key and new values bcak in @{$list{$thekey}} but
when I
loop thru at the end of the file run there are numerous occurrences of the
keys - values

    foreach $kevalue ( keys %list )
    {
        print "$keyvalue"
        my @fields = @{$list{$keyvalues}}
        print join ', ', @fields
    }

    assuming abc occurred 7 times, def 3 and xyz 1 - at the end of the run
I get

        abc   19990202  19990217  7
        def    20000302  20000311  3
        xyz    19970402  11970402  1
        abc   19990202  19990217  7
        def    20000302  20000311  3
        abc   19990202  19990217  7
        def    20000302  20000311  3


Can anyone tell me why this prints out multiple times when there is only (
hopefully ) one copy of each key.

Brian





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

Date: 21 Nov 2000 19:06:39 +0000
From: nobull@mail.com
Subject: Re: Modifying array references
Message-Id: <u9d7fp87r4.fsf@wcl-l.bham.ac.uk>

brian <polar@cloud9.net> writes:

> Sorry - I posted the problem in haste ans was unclear.
> 
> Basically I am using
>     push @{$list{$thekey}} , $firstdate, $lastdate, $numoccur
> to set each key on the first occurrence a conditional test is true.

The use of push in this context is obfucation.  It would be much
clearer to say:

 @{$list{$thekey}} = ( $firstdate, $lastdate, $numoccur );

 ...or...

 $list{$thekey} = [ $firstdate, $lastdate, $numoccur ];


> I am trying to the modify $lastdate and $numoccur on successive passes if
> the conditional test for that key value is found to be true.
> 
> For example I can read
>         abc   19990202  19990202  1
>         def    20000302  20000302  1
>         xyz    19970402  11970402  1
> 
>  I then used
>     @xyz = @{$list{$thekey}}
>     $number_increment = pop ( @xyz )
>     $new_last_date = pop ( @xyz )
> 
>     $number_increment += 1
>     $new_last_date = $current_date    ## set to todays date earlier
> 
>     push @xyz , $number_increment
>     push @xyz $new_last_date
> 
>     @{$list{$thekey}}= @xyz
> 
> 
> this works and places the key and new values bcak in
> @{$list{$thekey}}

There's no need to copy the array into @xyx, pull it appart, put it
back together an copy it back.  You can simply modify elements in
place:

  $list{$thekey}[2]++;
  $list{$thekey}[1] = $current_date;

Oh, and BTW get into the habit of using my() now - don't wait until
your failure to use it causes you wo waste a day looking for a bug in
the wrong place.

> loop thru at the end of the file run there are numerous occurrences of the
> keys

A hash cannot contain duplicate keys.  More likely you've managed to
get some non-printing characters into your keys so that there appears
to be duplicate heys.

>     foreach $kevalue ( keys %list )
>     {
>         print "$keyvalue"
>         my @fields = @{$list{$keyvalues}}
>         print join ', ', @fields
>     }

Please do not transcribe by hand.  There are so many obvious
transcription errors above that I don't see any point even trying to
guess what the real code looks like.

BTW: Congrats on only missing out half the my()s that time.  Rather
spoilt by the fact that the one variable you did my() was a useless
use of a temporary variable in the first place.

> Brian

Me too.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 21 Nov 2000 22:02:39 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Most easy way to get IP from a local NIC by device name (eth0,eth1...)
Message-Id: <slrn91ls6v.r2.mgjv@verbruggen.comdyn.com.au>

On Tue, 21 Nov 2000 17:27:02 GMT,
	mexicanmeatballs@my-deja.com <mexicanmeatballs@my-deja.com> wrote:

[slightly rewrapped to make it fit]

> In article <slrn91guqi.q2.mgjv@verbruggen.comdyn.com.au>,
>   mgjv@tradingpost.com.au wrote:
>> On Mon, 20 Nov 2000 01:00:27 GMT,
>> 	Mats Pettersson <mats.pettersson@falukuriren.se> wrote:
>>>
>>> I'm trying to get the IP from one of my NICs (eth1) from perl
>>> (running on FreeBSD).
>>>
>>> I'm using DHCP so the IP may change from time to time and when my
>>> script run i need to know what the adress is.
>>>
>>> Is there any other way than extracting it from nestat or
>>> something like that?
>>
>> No portable way. The best thing to do is just call ifconfig. You might
>> want to wrap the call in some sub, so that you can easily add to
>> it/change it for other platforms.
>>
> 
> Well, I don't know how portable it is, but it works on Linux and
> everything seems fairly standard in it:
[snip]
>  If you have multiple adapters (Hence multiple addresses) you can get
> the address of the interface for a specific network by supplying a host
> address for that network (not necessarily an actual host) in place of
> the '27.0.0.1'.

But how do you know that that is eth1 or eth0? I think the question
was to find the IP address that are tied to a specific interface.
I took that to mean that given nothing else but the name of the
interface, find its IP address. In other words, you don't know any
network or host addresses. That's what you're trying to find out.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | values of Beta will give rise to dom!
NSW, Australia                  | 


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

Date: 21 Nov 2000 20:02:54 GMT
From: "~greg" <gm@magpage.com>
Subject: Re: OT:Re: Eurodate mysteries
Message-Id: <8vekde$15v$0@216.155.33.16>


"Michael Carman" <mjcarman@home.com> wrote in message news:3A1A9DEA.7853393D@home.com...
> coluche@my-deja.com wrote:
> > 
> >   tchrist@perl.com (Tom Christiansen) wrote:
> >
> > > While there are alternate ways of speaking of the date, this first
> > > of these here [in the USA] is by far the most common:
> > >
> > >     October twenty-fourth, nineteen ninety-three
> > >
> > >     October twenty-fourth
> > >
> > >     October the twenty-fourth, nineteen ninety-three
> > >
> > >     The twenty-fourth of October, nineteen ninety-three
> > >
> > >     The twenty-fourth day of October, nineteen hundred and ninety-
> > >     three
> >
> >   What was the title of that movie again, Born on July fourth or Born
> > on the 4th of July?
> 
> Hey! We Americans reserve the right to be inconsistent. :) It is, of
> course, a bit of subtle irony that we chose to use the "European" style
> date to speak of a holiday celebrating American independance from
> Europe, when we use our own for most everything else.
> 
> One thing Tom didn't mention is the level of formality, which is roughly
> opposite to the ordering of his list. We'd say "October twenty-fourth"
> in casual conversation, but write "The twenty-fourth day of October" on
> an invitation to a black-tie affair. Maybe that's why it's "The Fourth
> of July."
> 
> > Anyways, this reminds me of some Information Theory lectures I took
> > aaages ago. For the day of the week, there are seven possibilities
> > whereas for the month of the year there are 12 possibilities. Does it
> > not make sense to start with the most information bearing element? As
> > for the year, well, I guess it's information content is 1 in most
> > context.
> 
> Seems logical to me, but one could also argue that we should specify
> dates in YYYY/MM/DD format, as that most closely represents our
> numbering system.
> 
> -mjc


I did a hack recently - I used a hash
like this:
%Day =
(
  'Jan' => '01',
    'Feb' => '02',
    'Mar' => '03',

etc -- with
  'Sep' =>   '09',
  'Sept' => '09,
  'September' => '09',

etc - because the target text is inconsistent that way.


The idea was to match lines like: "Date:  09 Aug 1999 ..."
by   /^Date: (\S+) (\S+) (\S+) / 

and then to use  $3 . $Month{$2} . $Day{$1} 
for sorting by date.

Of course it didn't work  -- because Perl converts string '01' 
to numeric 1 and then back to string '1'.  Easy enough to fix,
- once it's realized what was happening.
I'm new to perl (or perl is new to me - depending on how you
read dates) - but it just makes it that much clearer why so much 
thought was put into the problems of automatic casting
in C++. 


I like the information theoretic approach to this. I remember 
years ago spending way too much time trying to 
figure out questions of style in programming - such as best
naming conventions. One thing I did conclude was that a 
last name/ first name order is always best -- at least in cultures 
that read from left to right - because that  way draws the attention 
in from the general to the particular in the right time order, 
- because unless you're writing poetry you should not jump 
right in talking details without  first saying what it is you're talking about. 

In other words, I think 'Coluche' is absolutely right about month/day
order, and the low info content of 'year' - although he winks about it - and 
also that mjc is right about formality - because 'formal' always means 
archaic and contrary to the expected and expedient and normal and 
sensible order of things - really just in order to slow things down - just 
to emphasize the solemnity of the occasion. Which also explains the use 
of 50 year old IBM punch-cards in presidential elections - not to be funny 
- they're not trying to be funny  - on the contrary - somebody down there
means it to be a quite serious and solemn thing. 

~Greg.

ps: the following is extracted from a completely different news group 
and subject. 

~~~~~~~~~~~~~~~~~~~~~

> > Yeah it's terribly irritating the way they do that - it
> > could lead to some serious misunderstandings too, I mean if
> > you had a very important meeting in New York on the 12th of
> > January (1/12) and you arrived for it on the 1st December
> > (12/1) you'd be really pissed off, and your American
> > business colleagues would be just pissed! It's O.K.
> > Americans/Canadians and all you other back to front people
> > we love you really ;)
 ....

> But back to this date confusion:
> Yes, how right you are, my dear. Thank you for a splendid
> example of how confusion can occur, and I hope no Americans
> come here and tell me that they're right and we're wrong,
> because that simply will not hold water. When abbreviating
> dates, one should always have the month in the middle,
> adhering to the same rule which applies when the date is not
> abbreviated. For example, when writing 12 January 99 the two
> numbers (12 and 99) are nicely separated by the word
> January. Failure to adhere to this European standard rule
> results in day and year numbers unnecessarily being
> separated by an almost indiscernible blank space. Let me
> show you;

> European way: 12 January 99.
> American way: January 12 99.

> Can you see my point, now? See that tiny little American
> blank space between the 12 and the 99? Not much to write
> home about, is it! It could very easily be confused with the
> 700 year-old date of January 1299 - when people who signed
> the Magna Carta were still alive. I like to think we've
> moved on since then. What I'd like to know is who did it
> first? Who started it? I don't think Christopher Columbus
> walked down the gangplank when he got to America and wrote a
> letter home dating it at the Post Office as 12/1 when he
> meant 1/12 - so that means it was somebody else - somebody
> who was already there, maybe - some mischief-maker hiding in
> the trees - I don't know - but it has to stop otherwise
> there's going to be trouble.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



















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

Date: 21 Nov 2000 13:59:39 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: OT:Re: Eurodate mysteries
Message-Id: <3a1ae23b$1@cs.colorado.edu>

In article <8ve26c$hs9$1@nnrp1.deja.com>,  <coluche@my-deja.com> wrote:
>Does it
>not make sense to start with the most information bearing element? As
>for the year, well, I guess it's information content is 1 in most
>context.

You can argue what one *SHOULD* do until you're blue in the face,
and it will get you exactly nowhere.  That's not what people do,
and you can't change them by applying computer-friedly and human-hostile
logic.  Just tell me when you get regular people speaking in time()
format, and then we can do something.

--tom


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

Date: Tue, 21 Nov 2000 22:42:36 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: OT:Re: Eurodate mysteries
Message-Id: <slrn91luhs.r2.mgjv@verbruggen.comdyn.com.au>

On 21 Nov 2000 20:02:54 GMT,
	~greg <gm@magpage.com> wrote:

> The idea was to match lines like: "Date:  09 Aug 1999 ..."
> by   /^Date: (\S+) (\S+) (\S+) / 

That won't match :). The number of spaces after the : get in the way.

/^Date: +(\S+) +(\S+) +(\S+) /;

> and then to use  $3 . $Month{$2} . $Day{$1} 
> for sorting by date.
> 
> Of course it didn't work  -- because Perl converts string '01' 
> to numeric 1 and then back to string '1'.  Easy enough to fix,
> - once it's realized what was happening.

No, it doesn't. It only does that if you use a string in a numeric
context, and then in a string context again.

$_ = "Date:  09 Aug 1999 ...";
/^Date: +(\S+) +(\S+) +(\S+) /;
print $1;
my $foo = $1;
print $foo;
$foo += 0;
print $foo;

09
09
9

> I'm new to perl (or perl is new to me - depending on how you
> read dates) - but it just makes it that much clearer why so much 
> thought was put into the problems of automatic casting
> in C++. 

In Perl the idea is that it almost always does what you want or mean.
Things stay strings until you use them as numbers or booleans. Then
Perl converts. It's not really possible to convert perl's behaviour
with anything that happens in C++. Automatic casting isn't the same
thing as Perl's maghical handling of scalar values.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.   | selective about its friends.
NSW, Australia                  | 


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4943
**************************************


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