[13867] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1277 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 4 12:06:17 1999

Date: Thu, 4 Nov 1999 09:05:18 -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: <941735118-v9-i1277@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 Nov 1999     Volume: 9 Number: 1277

Today's topics:
    Re: duplicates in an array <sumengen@hotelspectra.com>
    Re: GuestBook thing in CGI <peter@berghold.net>
    Re: help with simple registration CGI script <peter@berghold.net>
    Re: HELP! eval("\$val = \$this") != ($val=$this) ?????P <tobiasly@my-deja.com>
        Help? What are Black Squares? <queen7@gte.net>
    Re: Help? What are Black Squares? <slanning@bu.edu>
    Re: Hiding Perl Scripts? <peter@berghold.net>
    Re: How can I connect a net unit? <rootbeer@redcat.com>
    Re: How can I set reg. expresion to anchor at the end o lee.lindley@bigfoot.com
        how sort an array? skeeta@gmx.net
    Re: how sort an array? <moseley@best.com>
    Re: how sort an array? <mark.bluemelNOmaSPAM@siemens.co.uk.invalid>
    Re: how sort an array? <vincent.murphy@cybertrust.gte.com>
    Re: how sort an array? <lr@hpl.hp.com>
    Re: how sort an array? blah1725@my-deja.com
    Re: how sort an array? <lr@hpl.hp.com>
    Re: how sort an array? <mark.bluemelNOmaSPAM@siemens.co.uk.invalid>
    Re: how sort an array? <jhelgesen@my-deja.com>
    Re: how sort an array? (Randal L. Schwartz)
        HTML::Mason on NT <joshua@groundwaves.com>
        Is this a bug? (Grim)
    Re: Is this a bug? <rhomberg@ife.ee.ethz.ch>
    Re: Is this a bug? <lr@hpl.hp.com>
        localtime object y2k compliant? kenkhouri@my-deja.com
    Re: localtime object y2k compliant? (Chris Nandor)
    Re: localtime object y2k compliant? <gellyfish@gellyfish.com>
    Re: localtime object y2k compliant? <sb@sdm.de>
    Re: localtime object y2k compliant? <camerond@mail.uca.edu>
    Re: Lost in Splitting....... <rhomberg@ife.ee.ethz.ch>
    Re: Lost in Splitting....... <bwlang@usa.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 4 Nov 1999 07:32:58 -0800
From: "Baris Sumengen" <sumengen@hotelspectra.com>
Subject: Re: duplicates in an array
Message-Id: <7vs91k$9u$1@bgtnsc02.worldnet.att.net>

Joachim, Thanks,
It looks like last night I ended up writing something similar to your
function, but less elegant:

sub remove_dups{
 @sorted = sort(@_);
 my @outclean = qw();
 foreach $no (1..$#sorted){
  if($sorted[$no - 1] ne $sorted[$no]){
   push(@outclean,$sorted[$no - 1]);
  }
 }
 push(@outclean,$sorted[-1]);
 return @outclean;

}

Baris.

Joachim Pimiskern <Joachim.Pimiskern@de.bosch.com> wrote in message
news:7vrohf$fhe$1@proxy2.fe.internet.bosch.de...
> Baris,
>
> >Do you know an easy way to remove duplicates from an array.(If multiple
> >entries are identicle just keep one copy of it).
>
>
> Take a hash to determine whether an element has already
> been added to the result array. It goes like this:
>
> @a = (1,2,3,1,2, 5 ,6);
>
> sub uniqueArray
> {
>  my %h = ();
>  my @result = ();
>  my $i;
>  foreach $i (@_)
>    {
>     if (not defined $h{$i})
>        {
>         push(@result,$i);
>         $h{$i} = 1;
>        }
>    }
>  return @result;
> }
>
> print uniqueArray(@a);
>
> Regards,
> Joachim
> (Joachim.Pimiskern@de.bosch.com)
>
>
>




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

Date: Thu, 04 Nov 1999 14:27:49 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: GuestBook thing in CGI
Message-Id: <Pine.LNX.3.96.991104092618.17620A-100000@uboat.berghold.net>

Fredrik,

YOu might want to investigate the HTML META tag "Refresh". ( I think it's
"Refresh")  I don't remember the exact syntax but it something to look
for.

This isn't really on topic anyway....


-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           ICQ# 11455958



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

Date: Thu, 04 Nov 1999 14:52:31 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: help with simple registration CGI script
Message-Id: <Pine.LNX.3.96.991104094911.17620E-100000@uboat.berghold.net>


Schooner Technology Consulting generally charges $125 an hour for Perl
scripting services. If you have a complete program specification and we
can agree on a SOW then I can help you.

Without fully studying the problem I would say that 3 to 6 hours of labor
would cover it.  If you want ongoing support afterwards we would have to
negotiate. 

Can you afford to spend $750 on my services to get your class assignment
done??


-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           ICQ# 11455958



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

Date: Thu, 04 Nov 1999 13:57:42 GMT
From: Toby Johnson <tobiasly@my-deja.com>
Subject: Re: HELP! eval("\$val = \$this") != ($val=$this) ?????Perl BUG?
Message-Id: <7vs3ck$num$1@nnrp1.deja.com>

Dani,
  This seems very strange indeed... however, I am a little confused by
your wording. Using very simple objects (just blessing an empty hash
ref) I can't duplicate what you describe..
  When you say that $trace3 and $trace4 are different, do you mean that
printing them as a scalar reveal two different addresses?

Toby

In article <3820AF35.843F619F@3dsite.com>,
  Daniele Colajacomo <dani@3dsite.com> wrote:
> (there's a CLUE at the end of this message!)
>
> I've already posted a message asking for help, but here's a clearer,
> and more puzzling eval behavior:
>
> I have an object called $this
>
> the following lines, one after another:
> eval("\$trace3 = \$this");
> $trace4 = $this;
>
> yeld two different results. That is, I would think that
> $trace3 and $trace4 are the same, but instead they appear
> to be two different objects (both valid, and of all )!!
>
> How is it possible for eval to act in a different content?
>
> I've tracked it further to a very mindboggling situation.
> Going back to the top of this particular process, there's another
eval:
>
> eval("sub _us_code_$::V{US_CODE_COUNTER}(\$) { my (\$this) = \@_; $val
> };");
> eval("\@val = _us_code_$::V{US_CODE_COUNTER}(\$this)");
>
> the $val which makes up the _us_code_* function is:
> "my $f = new_object("custom:faq/faq","faq"); $f->cset();"
>
> Now I've tracked it down with the debugger, and where it all starts
> getting confused is when $f->cset() is called.
> $f is the object I'd expect it to be, but once it gets inside
> cset() it changes and becomes a different object! That is it becomes
> the $this of the top-most eval.
>
> cset is:
>
> sub cset($) {
>         my ($this) = @_;
>         if (!$this->configuration_is_loaded()) { # load default
> configuration
>                 $this->configuration_load($this->get("name"));
>         }
> }
>
> Then within the function at the top of this message, the object that
is
> passed as $this is the wrong one, BUT when it is assigned to $trace4
> is the right one, and the eval'd is the wrong one - I'm really lost.
>
> CLUE TO IT ALL (for those of you who can figure it out):
> if I change $this to another name in cset, ie:
> sub cset($) {
>       my($o) = @_;
>       ....
> }
>
> then the $o object is the correct one!!!!!!!!!!!!!
>
> There seems to be some namespace confusion going on, and for the life
> of me I cannot figure it out (of course I could change all the $this
to
> something else for the functions called by the top-most eval, but
> that's like leaving a time-bomb alone by stepping sideways for the
> moment...).
>
> Anyone who's able to help please let me know what you think!
>
> thanks!
> dani
>


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


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

Date: Thu, 04 Nov 1999 16:27:05 GMT
From: "Reba Davis" <queen7@gte.net>
Subject: Help? What are Black Squares?
Message-Id: <ttiU3.263$_Y3.7442@dfiatx1-snr1.gtei.net>

Hi,

Can someone tell me which key on the keyboard is used to display the
"black" squares when one is looking at a CGI script when using Notepad.

There have been times when I wanted to edit a script, but I don't know where
the black squares are coming from.  They seem to appear between each piece
of variable information for example.

reba
queen7@gte.net

--





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

Date: 04 Nov 1999 11:54:00 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: Help? What are Black Squares?
Message-Id: <kushfj2ci53.fsf@strange.bu.edu>

"Reba Davis" <queen7@gte.net> writes:
> Can someone tell me which key on the keyboard is used to display the
> "black" squares when one is looking at a CGI script when using Notepad.
> 
> There have been times when I wanted to edit a script, but I don't
> know where the black squares are coming from.  They seem to appear
> between each piece of variable information for example.

I think they are newlines. Like when I write an HTML document
in Unix, then view the source, there are a bunch of black boxes
appearing in Windows where the newlines are and it is all one
big line of text. The way to fix it is never use Windows and
start a unabomber campaign against those who do.

(that, or convert the text-file format, but that's *so* boring...)

-- 
"I'm going to have fun telling you about this absurdity, because I
find it delightful." --Richard Feynman


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

Date: Thu, 04 Nov 1999 14:54:00 GMT
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: Hiding Perl Scripts?
Message-Id: <Pine.LNX.3.96.991104095329.17620F-100000@uboat.berghold.net>

Hide from who? Web users or local users?    Wrapper scripts come to mind
for local users....


-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Peter L. Berghold                        Peter@Berghold.Net
"Linux renders ships                     http://www.berghold.net
 NT renders ships useless...."           ICQ# 11455958



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

Date: Thu, 4 Nov 1999 08:29:30 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How can I connect a net unit?
Message-Id: <Pine.GSO.4.10.9911040828390.29670-100000@user2.teleport.com>

On Thu, 4 Nov 1999, Jes=FAs Iglesias wrote:

> I have a NT server and I wanna do a Perl Script to connect a net unit
> in a W95 PC (and keep it connected in next sessions).

It sounds as if you want to use some protocol over a socket connection.
Maybe there's a module on CPAN for the protocol you'd like. Good luck!

--=20
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 4 Nov 1999 16:22:51 GMT
From: lee.lindley@bigfoot.com
Subject: Re: How can I set reg. expresion to anchor at the end of a string?
Message-Id: <7vsbsr$jcu$1@rguxd.viasystems.com>

Neko <tgy@chocobo.org> wrote:
:>>:>    my @a = /(?!^)....|.+?(?=(?:....)*\z)/gs;

:>The first match will match the second alternative, which searches the entire
:>string of N characters.  However, the second and subsequent matches will each
:>only need to search the next 4 characters to match the first alternative, for
:>a total of between N and (N - 4) characters.  So that's (2 * N - 4) or just
:>(2 * N), which is linear.

:>Hope I got that right.  Just in case though:

Ahh.  I see it now.  Thanks.  So the trick is to just get the first
one right and then the rest are straightforward.  Hmm.  I also saw
what Abigail was doing.  I think, yes, this may be even simpler:

my $f = length($_) % 4;
my @x = /^.{$f}|.{4}/g;

Hee, Hee.  You guys do all the work to figure it out and I just waltz
in and steal your ideas.  Cool.  :-)


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Thu, 04 Nov 1999 14:10:48 GMT
From: skeeta@gmx.net
Subject: how sort an array?
Message-Id: <7vs455$ogn$1@nnrp1.deja.com>

Hello,

I have a problem with sorting an array.

I have a file, in which all the data is stored like this:

SoftwareName|downloadaddress|description|rating|other
some|www.download.com|another cool thing|3|nothing
Winzip|www.winzip.com|bla bla bla|5|something
Winamp|www.winamp.com|this is cool|1|nothing

Now I want to sort this file by rating. This can be a value between
zero and 5. So I want the file to look like this:

Winzip|www.winzip.com|bla bla bla|5|something
some|www.download.com|another cool thing|3|nothing
Winamp|www.winamp.com|this is cool|1|nothing

The software with the best rating at first, the software with the worst
rating at the end.

So, how can I do this????

I hope anyone here can help me. Thank you very much...

PS: Please mail your solution to skeeta@muenster.de. Thanks a lot.

Skeeta.


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


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

Date: Thu, 4 Nov 1999 06:58:34 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: how sort an array?
Message-Id: <MPG.128b3ef2ce2412af989843@nntp1.ba.best.com>

skeeta@gmx.net (skeeta@gmx.net) seems to say...
> I have a problem with sorting an array.
> 
> I have a file, in which all the data is stored like this:


perldoc -q sort.+anything

> PS: Please mail your solution to skeeta@muenster.de. Thanks a lot.

Sorry, My ISP doesn't provide outgoing email service.



-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Thu, 04 Nov 1999 07:00:48 -0800
From: Mark Bluemel <mark.bluemelNOmaSPAM@siemens.co.uk.invalid>
Subject: Re: how sort an array?
Message-Id: <1415c574.b25aeb86@usw-ex0101-001.remarq.com>

In article <7vs455$ogn$1@nnrp1.deja.com>, skeeta@gmx.net wrote:
> Hello,
> I have a problem with sorting an array.
> I have a file, in which all the data is stored like this:
> SoftwareName|downloadaddress|description|rating|other
> some|www.download.com|another cool thing|3|nothing
> Winzip|www.winzip.com|bla bla bla|5|something
> Winamp|www.winamp.com|this is cool|1|nothing
> Now I want to sort this file by rating.

Don't do it in Perl - use your operating system's "sort" command...


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Thu, 04 Nov 1999 15:35:57 GMT
From: Vincent Murphy <vincent.murphy@cybertrust.gte.com>
Subject: Re: how sort an array?
Message-Id: <xjg7ljyb76r.fsf@gamora.ndhm.gtegsc.com>

>>>>> "skeeta" == skeeta  <skeeta@gmx.net> writes:

    skeeta> Hello,
    skeeta> I have a problem with sorting an array.

    skeeta> I have a file, in which all the data is stored like this:

    skeeta> SoftwareName|downloadaddress|description|rating|other
    skeeta> some|www.download.com|another cool thing|3|nothing
    skeeta> Winzip|www.winzip.com|bla bla bla|5|something
    skeeta> Winamp|www.winamp.com|this is cool|1|nothing

    skeeta> Now I want to sort this file by rating. This can be a value between
    skeeta> zero and 5. So I want the file to look like this:

    skeeta> Winzip|www.winzip.com|bla bla bla|5|something
    skeeta> some|www.download.com|another cool thing|3|nothing
    skeeta> Winamp|www.winamp.com|this is cool|1|nothing

    skeeta> The software with the best rating at first, the software with the worst
    skeeta> rating at the end.

    skeeta> So, how can I do this????

open(IN, "./weblist") || die;
my(@lines)=<IN>; close IN or die;

print map { $_->[0] }
      sort { $b->[4] <=> $a->[4] }
      map { [$_, split(/\|/)] } @lines;

    skeeta> I hope anyone here can help me. Thank you very much...

HTH


-Vinny


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

Date: Thu, 4 Nov 1999 07:57:28 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: how sort an array?
Message-Id: <MPG.128b4cc2163b69ae98a1a1@nntp.hpl.hp.com>

In article <7vs455$ogn$1@nnrp1.deja.com> on Thu, 04 Nov 1999 14:10:48 
GMT, skeeta@gmx.net <skeeta@gmx.net> says...
> I have a problem with sorting an array.

Others have had such problems in the past, which is why this is 
considered to be a Frequently Asked Question.  The answer can be found 
in perlfaq4: "How do I sort an array by (anything)?"

> PS: Please mail your solution to skeeta@muenster.de. Thanks a lot.

But that isn't the address you mailed from, and there is no 'Reply-To:' 
header.  Too bad!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 04 Nov 1999 15:56:41 GMT
From: blah1725@my-deja.com
Subject: Re: how sort an array?
Message-Id: <7vsabm$to5$1@nnrp1.deja.com>

You can do like this:

while (<>) {
  @fields = split(/\|/, $_);
  $lines{$field[3]} = $_;
}

for $f (sort keys %lines) {
  print $lines{$f};
}



In article <7vs455$ogn$1@nnrp1.deja.com>,
  skeeta@gmx.net wrote:
> Hello,
>
> I have a problem with sorting an array.
>
> I have a file, in which all the data is stored like this:
>
> SoftwareName|downloadaddress|description|rating|other
> some|www.download.com|another cool thing|3|nothing
> Winzip|www.winzip.com|bla bla bla|5|something
> Winamp|www.winamp.com|this is cool|1|nothing
>
> Now I want to sort this file by rating. This can be a value between
> zero and 5. So I want the file to look like this:
>
> Winzip|www.winzip.com|bla bla bla|5|something
> some|www.download.com|another cool thing|3|nothing
> Winamp|www.winamp.com|this is cool|1|nothing
>
> The software with the best rating at first, the software with the
worst
> rating at the end.
>
> So, how can I do this????
>
> I hope anyone here can help me. Thank you very much...
>
> PS: Please mail your solution to skeeta@muenster.de. Thanks a lot.
>
> Skeeta.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Thu, 4 Nov 1999 08:06:16 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: how sort an array?
Message-Id: <MPG.128b4ecdf14ace0c98a1a2@nntp.hpl.hp.com>

In article <1415c574.b25aeb86@usw-ex0101-001.remarq.com> on Thu, 04 Nov 
1999 07:00:48 -0800, Mark Bluemel 
<mark.bluemelNOmaSPAM@siemens.co.uk.invalid> says...
> In article <7vs455$ogn$1@nnrp1.deja.com>, skeeta@gmx.net wrote:
> > Hello,
> > I have a problem with sorting an array.
> > I have a file, in which all the data is stored like this:
> > SoftwareName|downloadaddress|description|rating|other
> > some|www.download.com|another cool thing|3|nothing
> > Winzip|www.winzip.com|bla bla bla|5|something
> > Winamp|www.winamp.com|this is cool|1|nothing
> > Now I want to sort this file by rating.
> 
> Don't do it in Perl - use your operating system's "sort" command...

Aarrrgh!

<Sound of months of effort on efficient Perl sorting hitting the ground>

http://www.hpl.hp.com/personal/Larry_Rosler/sort/

discusses when your answer is appropriate.  Hint:  Not often!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 04 Nov 1999 08:43:08 -0800
From: Mark Bluemel <mark.bluemelNOmaSPAM@siemens.co.uk.invalid>
Subject: Re: how sort an array?
Message-Id: <070dbf92.cd0ce3f7@usw-ex0101-001.remarq.com>

In article <MPG.128b4ecdf14ace0c98a1a2@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> wrote:
> In article <1415c574.b25aeb86@usw-ex0101-001.remarq.com> on Thu,
> 04 Nov
> 1999 07:00:48 -0800, Mark Bluemel
> <mark.bluemelNOmaSPAM@siemens.co.uk.invalid> says...
> > In article <7vs455$ogn$1@nnrp1.deja.com>, skeeta@gmx.net wrote:
> > > Hello,
> > > I have a problem with sorting an array.

Then he said (crucially in my view)

> > > I have a file, in which all the data is stored like this:

Note the magic word "file"...

> > > SoftwareName|downloadaddress|description|rating|other
> > > some|www.download.com|another cool thing|3|nothing
> > > Winzip|www.winzip.com|bla bla bla|5|something
> > > Winamp|www.winamp.com|this is cool|1|nothing
> > > Now I want to sort this file by rating.
> >

So I said

> > Don't do it in Perl - use your operating system's "sort"
> command...

To which Larry responded

> Aarrrgh!
> <Sound of months of effort on efficient Perl sorting hitting the
> ground>
> http://www.hpl.hp.com/personal/Larry_Rosler/sort/
> discusses when your answer is appropriate.  Hint:  Not often!

Yes, OK, but this may be one of of those infrequent times :-) I'm not
pre-judging the issue, but ...

I've scanned your paper and I didn't see any reference to benchmarking
against an OS sort utility, given that you already _have_ the data in a
flat file. Have you actually shown that it is more efficient to read an
unsorted file into an array and sort it using your technique, as
opposed to sorting the file and then reading it in?

--
Mark Bluemel


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Thu, 04 Nov 1999 16:41:14 GMT
From: BlastMaster <jhelgesen@my-deja.com>
Subject: Re: how sort an array?
Message-Id: <7vscv9$vqj$1@nnrp1.deja.com>

In article <7vsabm$to5$1@nnrp1.deja.com>,
  blah1725@my-deja.com wrote:
> You can do like this:
>
> while (<>) {
>   @fields = split(/\|/, $_);
>   $lines{$field[3]} = $_;
> }
>
> for $f (sort keys %lines) {
>   print $lines{$f};
> }
>

This assumes that the ratings are unique and don't exceed 10.  You also
get the header in the output.

how about

$_ = <>;
while ( <> ) {
     @fields = split /\|/;
     my $obj = { 'line' => $_, 'rating' => $field[3] };
     push @lines, $obj;
}

foreach $obj ( sort { $a->{'rating'} <=> $b->{'rating'} } @lines ) {
    print $obj->{'line'};
}


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


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

Date: 04 Nov 1999 08:57:33 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how sort an array?
Message-Id: <m1puxqtcsi.fsf@halfdome.holdit.com>

>>>>> "Vincent" == Vincent Murphy <vincent.murphy@cybertrust.gte.com> writes:

Vincent> open(IN, "./weblist") || die;
Vincent> my(@lines)=<IN>; close IN or die;

Vincent> print map { $_->[0] }
Vincent>       sort { $b->[4] <=> $a->[4] }
Vincent>       map { [$_, split(/\|/)] } @lines;

Slightly more optimized (to save the sound of all those scalars falling on
the floor:

print map { $_->[0] }
      sort { $b->[1] <=> $a->[1] }
      map { [$_, (split(/\|/, $_, 5)[4]] } @lines;

But the obscuration may not be worth it.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 04 Nov 1999 09:57:34 -0500
From: Joshua Daniel Edelstein <joshua@groundwaves.com>
Subject: HTML::Mason on NT
Message-Id: <38219EDD.6694A8C5@groundwaves.com>

Hello,

Does anybody know how to compile HTML::Mason on a Windows NT web server
running Apache?  The folks at http://masonhq.com say that they know it's
been done, but they have no idea how.  I know that I need a unified
perl+Apache+mod_perl installation batch, but where do I go from there?

Thanks,
Joshua



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

Date: Thu, 04 Nov 1999 15:21:04 GMT
From: not@home.com (Grim)
Subject: Is this a bug?
Message-Id: <3821a3dd.142875@news.alt.net>

When I run the following code:

$x = " 18.99";
print sprintf("%5d",$x*100);

it prints out 1898.  Is this a bug or am I missing something here?


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

Date: Thu, 04 Nov 1999 16:51:56 +0100
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Is this a bug?
Message-Id: <3821AB9C.B90DC5D4@ife.ee.ethz.ch>

Grim wrote:
> 
> When I run the following code:
> 
> $x = " 18.99";
> print sprintf("%5d",$x*100);
> 
> it prints out 1898.  Is this a bug or am I missing something here?

It's not a bug. 18.99 gets converted to a floating point number when you
multiply it. The result is a tiny little bit smaller than 1899, less
than e. If you print() it as a floating point number (with print or
printf "%f"), it is converted to 1899. If you remove the fractional part
(with int() or printf "%d"), it is converted to 1898

$x=18.99*100;
print "$x  ",int $x; 
printf "  %d %f %.f\n", $x, $x, $x;

1899  1898  1898 1899.000000 1899

If you need to do *exact* arithemtic, don't use normal floating point
numbers. Use integers.

- Alex


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

Date: Thu, 4 Nov 1999 08:18:58 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Is this a bug?
Message-Id: <MPG.128b51caf14eb64998a1a5@nntp.hpl.hp.com>

In article <3821a3dd.142875@news.alt.net> on Thu, 04 Nov 1999 15:21:04 
GMT, Grim <not@home.com> says...
> When I run the following code:
> 
> $x = " 18.99";
> print sprintf("%5d",$x*100);
> 
> it prints out 1898.  Is this a bug or am I missing something here?

You are missing an understanding of how floating-point numbers are 
represented internally.  To see what is wrong, replace your format with 
'%.20f'.

You can get the effect you want with format '%5.0f', which causes 
rounding instead of truncation.

BTW, 'printf' is the same as 'print sprintf'.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 04 Nov 1999 14:43:58 GMT
From: kenkhouri@my-deja.com
Subject: localtime object y2k compliant?
Message-Id: <7vs63e$q66$1@nnrp1.deja.com>

I am trying to find out if the perl localtime class is y2k compliant.  I
would like to assume that it is, however, the following code example
(from O'reilly:  Programming Perl) looks questionable.

If you know the answer, I would be interested in hearing it and also
where you might have learned it.  Although the O'reilly book
provides information on the class, it does not specify what
happens after 2000!  It's surprising to me that you should add
1900 to the year to get a 4 digit year.  Thanks!

-Ken

 use Time::localtime ;
 $tm = localtime ;

 $dt_str = sprintf("%04d%02d%02d",
        $tm->year+1900,
        ($tm->mon) + 1,
        ($tm->mday) - 1) ;


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


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

Date: Thu, 04 Nov 1999 14:53:07 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: localtime object y2k compliant?
Message-Id: <pudge-0411990953120001@192.168.0.77>

In article <7vs63e$q66$1@nnrp1.deja.com>, kenkhouri@my-deja.com wrote:

# I am trying to find out if the perl localtime class is y2k compliant.  I
# would like to assume that it is, however, the following code example
# (from O'reilly:  Programming Perl) looks questionable.
# 
# If you know the answer, I would be interested in hearing it and also
# where you might have learned it.  Although the O'reilly book
# provides information on the class, it does not specify what
# happens after 2000!

SO READ THE DOCS.


# It's surprising to me that you should add
# 1900 to the year to get a 4 digit year.  Thanks!

It wouldn't be if you had read the docs.

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


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

Date: 4 Nov 1999 15:09:30 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: localtime object y2k compliant?
Message-Id: <3821a1aa_2@newsread3.dircon.co.uk>

kenkhouri@my-deja.com wrote:
>                      It's surprising to me that you should add
> 1900 to the year to get a 4 digit year. 
> 

Why is that ?  It is clearly described in the documentation for localtime.

/J\
-- 
"If homo sapiens really were 'homo' sapiens is that why they're
extinct?" - Joey, Friends


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

Date: 4 Nov 1999 15:20:47 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: localtime object y2k compliant?
Message-Id: <7vs88f$guv$1@solti3.sdm.de>

In article <7vs63e$q66$1@nnrp1.deja.com>, kenkhouri@my-deja.com wrote:

> I am trying to find out if the perl localtime class is y2k compliant.  I
> would like to assume that it is, however, the following code example
> (from O'reilly:  Programming Perl) looks questionable.

> If you know the answer, I would be interested in hearing it and also
> where you might have learned it.  Although the O'reilly book

See "man perlfunc" or "perldoc perlfunc" (section about localtime).

> provides information on the class, it does not specify what
> happens after 2000!

The manual does. Read it.

> It's surprising to me that you should add
> 1900 to the year to get a 4 digit year.

Obviously you don't understand subtraction.
Please return to grammar school for an update. >;-)

> Thanks!
> -Ken

Best regards,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


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

Date: Thu, 04 Nov 1999 10:07:02 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: kenkhouri@my-deja.com
Subject: Re: localtime object y2k compliant?
Message-Id: <3821AF26.C3A77C16@mail.uca.edu>

[cc'd to k so he gets his answer promptly]

kenkhouri@my-deja.com wrote:
> 
> I am trying to find out if the perl localtime class is y2k compliant.  I
> would like to assume that it is, however, the following code example
> (from O'reilly:  Programming Perl) looks questionable.
> 
> If you know the answer, I would be interested in hearing it and also
> where you might have learned it.  Although the O'reilly book
> provides information on the class, it does not specify what
> happens after 2000!  It's surprising to me that you should add
> 1900 to the year to get a 4 digit year.  Thanks!
> 
> -Ken
> 
>  use Time::localtime ;
>  $tm = localtime ;
> 
>  $dt_str = sprintf("%04d%02d%02d",
>         $tm->year+1900,
>         ($tm->mon) + 1,
>         ($tm->mday) - 1) ;

Let's see, you sent this somewhere over an hour ago... I'm going to give
you an experiment to see if localtime is YMM-compliant (the teaching
gurus call this "active learning"). You have a nice small script there.
Set your computer's clock to, say, Feb 27, 2002. Run the script. Did it
work? That experiment took, oh, 45 seconds? Next time, please try
something like this before you waste an hour of your time, which I
assume is valuable.

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Thu, 04 Nov 1999 15:08:49 +0100
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Lost in Splitting.......
Message-Id: <38219371.21DE112@ife.ee.ethz.ch>

Matt King wrote:
> The first line looks like this:
>  ITEM 1/1   ITEM 2/2           DESCRIPTION
> This is not tab delmitated and the file has some 60000 lines in it so
> changing the format would be just to much work. I'm trying to read in and
> split the above like this:
> ...
>   foreach $line(@LINES) {
>   ($item1,$item2,$item3) = ($line =~  m{
>                  \s*
>                 (\S*(\s*)\S*)\s*
       for $item1 ^   ^ for $item2

>                 (\S*(\s*)\S*)\s*
>                 (.*)\s*}x);
 Takes all the rest ^  ^ does nothing
> ...
> print "($item1)($item2)($item3)\n";
> 
> The output looks like this:
> (ITEM 1/1)()( ITEM)

And this is not true
The output looks like: (ITEM 1/1)( )(ITEM 2/2)
the opening parens determine which supattern goes where. Just lose some
parens:
m/^\s*(\S*\s*\S*)\s*(\S*\s*\S*)\s*(.*)/; 

If you want to lose trailing spaces as your code seems to indicate, use 
nongreedy matching and anchor it at EOL

m/^\s*(\S*\s*\S*)\s*(\S*\s*\S*)\s*(.*?)\s*$/; 


- Alex


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

Date: Thu, 04 Nov 1999 11:18:54 -0500
From: Brad Langhost <bwlang@usa.net>
Subject: Re: Lost in Splitting.......
Message-Id: <3821B1EE.EFB23C96@usa.net>

you could try
  using split instead
($item1,$item2,$item3, $item4, $rest) = split (/\s+/, $line, 5);
which should  take the first 4 space delimited items
and put them into seperated variables
join the  variables 1 and 2, 3 and 4 on space to get  what you want

probably not the most graceful way but  should work.

brad


>
> What is wrong with this split? I have been trying different 'formats', but I
> can't find the one that will give me the output that looks like this, which
> is the one I need:
> (ITEM 1/1)(ITEM 2/2)(DESCRIPTION)
>



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

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


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