[18922] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1117 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 12 09:05:36 2001

Date: Tue, 12 Jun 2001 06:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <992351110-v10-i1117@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 12 Jun 2001     Volume: 10 Number: 1117

Today's topics:
        Artificial code blocks (Maggie)
    Re: Artificial code blocks <buggs-clpm@splashground.de>
    Re: Function error <krahnj@acm.org>
    Re: Function error (Anno Siegel)
    Re: How to make a Perlscript Shareware? <bop@mypad.com>
    Re: newbie question (Anno Siegel)
    Re: newbie question <jddp@tid.es>
    Re: open two files for line processing concurrently??? <buggs-clpm@splashground.de>
    Re: open two files for line processing concurrently??? (Anno Siegel)
    Re: open two files for line processing concurrently??? (Bernard El-Hagin)
    Re: open two files for line processing concurrently??? (Anno Siegel)
    Re: open two files for line processing concurrently??? (Bernard El-Hagin)
    Re: open two files for line processing concurrently??? (Bernard El-Hagin)
    Re: open two files for line processing concurrently??? (Anno Siegel)
        printing from webpage <snefski@hotmail.com>
        Re:REGEX <philip@p6m7g8.student.umd.edu>
    Re: Script <a.v.a@home.nl>
        sorting a hash on part of its value? <m.grimshaw@salford.ac.uk>
    Re: sorting a hash on part of its value? <m.grimshaw@salford.ac.uk>
        Table/Cell formatting with CGI.pm <paanwa@hotmail.com>
    Re: Table/Cell formatting with CGI.pm <m.grimshaw@salford.ac.uk>
    Re: Table/Cell formatting with CGI.pm <paanwa@hotmail.com>
        What is ${'string'} ? Gordon.Haverland@gov.ab.ca
        Win32::OLE Question <keng@spinalfluid.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 Jun 2001 04:33:02 -0700
From: maggie_black@hotmail.com (Maggie)
Subject: Artificial code blocks
Message-Id: <5644c067.0106120333.63e43d59@posting.google.com>

Hello,



  I have a friend who writes code like this:



#!/usr/bin/perl -w

use strict;



{

  my $variable1;

  my $variable2;

}





{

  my $other_variable;

}



and so on.



In other words there's never any place in his code which is not a block. I think this

is bad style, but am unable to find convincing arguments against it. Could someone

either confirm my doubts about this style or prove me wrong and explain why this is

a good thing?



Thank you,

Maggie


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

Date: Tue, 12 Jun 2001 13:43:04 +0200
From: buggs <buggs-clpm@splashground.de>
Subject: Re: Artificial code blocks
Message-Id: <9g4vba$t89$04$1@news.t-online.com>

Maggie wrote:

> Hello,
> 
> 
> 
>   I have a friend who writes code like this:
> 
> 
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> 
> 
> {
> 
>   my $variable1;
> 
>   my $variable2;
> 
> }
> 
> 
> 
> 
> 
> {
> 
>   my $other_variable;
> 
> }
> 
> 
> 
> and so on.
> 
> 
> 
> In other words there's never any place in his code which is not a block. I
> think this
> 
> is bad style, but am unable to find convincing arguments against it. Could
> someone
> 
> either confirm my doubts about this style or prove me wrong and explain
> why this is
> 
> a good thing?
> 
> 
> 
> Thank you,
> 
> Maggie
> 

I know someone who uses two times the newlines than others.
Is that bad style?
;-)

Buggs


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

Date: Tue, 12 Jun 2001 10:41:24 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Function error
Message-Id: <3B25F1D4.953EF9C4@acm.org>

Juan Delgado Díaz-Pache wrote:
> 
> Hi,
> 
> Can anyone tell me if this function is correct?
> 
> sub import {
>     shift;
>     my $mask = ${^WARNING_BITS} ;
>     if (vec($mask, $Offsets{'all'}, 1)) {
>         $mask |= $Bits{'all'} ;
>         $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1);
>     }
>     ${^WARNING_BITS} = $mask | bits(@_ ? @_ : 'all') ;
> }
> 
> Does {^ this make sense?, or could it be a transference problem. I don't

No, it doesn't make sense, ^ is a binary operator.



John
-- 
use Perl;
program
fulfillment


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

Date: 12 Jun 2001 10:59:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Function error
Message-Id: <9g4sn2$cdm$5@mamenchi.zrz.TU-Berlin.DE>

According to John W. Krahn <krahnj@acm.org>:
> Juan Delgado Díaz-Pache wrote:
> > 
> > Hi,
> > 
> > Can anyone tell me if this function is correct?
> > 
> > sub import {
> >     shift;
> >     my $mask = ${^WARNING_BITS} ;
> >     if (vec($mask, $Offsets{'all'}, 1)) {
> >         $mask |= $Bits{'all'} ;
> >         $mask |= $DeadBits{'all'} if vec($mask, $Offsets{'all'}+1, 1);
> >     }
> >     ${^WARNING_BITS} = $mask | bits(@_ ? @_ : 'all') ;
> > }
> > 
> > Does {^ this make sense?, or could it be a transference problem. I don't
> 
> No, it doesn't make sense, ^ is a binary operator.

With current Perls, ${^WARNING_BITS} is a legit variable.  It used
to be a syntax error (before 5.6.0, afaik).

Anno


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

Date: Tue, 12 Jun 2001 08:08:45 -0400
From: "flash" <bop@mypad.com>
Subject: Re: How to make a Perlscript Shareware?
Message-Id: <WAnV6.3572$mK6.350707@news20.bellglobal.com>

I just wrote a script that encrypts the data.
And then decrypts to a temporary location, and runs the program, and deletes
it. (decrypted version)

Then you would probally perlcc that script, so no one can change it.

--
#--*--*--*--*--*--*--*--*--*--*--#
#            The hypermart faq.            #
#       http://www.hmdc.f2s.com       #
#--*--*--*--*--*--*--*--*--*--*--#

"Tom Klinger" <admin@the-piper.net> wrote in message
news:3b25e7e3$1@news.i-one.at...
> Hi!
>
> Maybe my idea differs from the base intention of perl that code is free.
> From my point of view why not earn money with your code when it is used by
a
> company which makes finally money using your script while you have to
> develope all that code?
>
> Now, I want to go to develope 2 different versions of my software, one
> so-called lite version with less features and options than the second
> version, a so-called pro version with all enhancements.
>
> My problem now is how to secure the code so that for example a pro version
> will expire for example after 30 days or only runs if is already licensed?
> I know that there are too many gurus out there who can modify the code,
> sure.
> But why not give it a try?
>
> So my question now is if someone can give me a tip how to handle this or
> maybe he can tell me the way how they're securing their code or methods to
> purchase a software. Any information would be great.
>
> Thanks in advance and for your time reading my written crap. ;)
>
> Tom
>
>




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

Date: 12 Jun 2001 10:41:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: newbie question
Message-Id: <9g4rk6$cdm$3@mamenchi.zrz.TU-Berlin.DE>

According to Juan Delgado Díaz-Pache  <jddp@tid.es>:

We are not making much progress, are we?  For one, you top-posted
again.

> Here you have your error:

Thank you very much.  The syntax error was clear from the beginning.

I have now asked you *twice* to rename the offending warnings.pl and
try without it.  I'm not asking again.

Anno

[snip]


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

Date: Tue, 12 Jun 2001 13:46:54 +0200
From: Juan Delgado =?iso-8859-1?Q?D=EDaz=2DPache?= <jddp@tid.es>
Subject: Re: newbie question
Message-Id: <3B26012D.E9D24133@tid.es>

The post before this one included the error resulting of the execution
of my script with the warnings.pm renamed. As you can see, the error was
still there, but in a different way, it couldn't find the file
(warnings.pm). Now i have uninstalled 5.6.1 and installed 5.00503 which
is the one that came with the product. The error has dissapeared.

Thanks
Juan

Anno Siegel wrote:

> According to Juan Delgado Díaz-Pache  <jddp@tid.es>:
>
> We are not making much progress, are we?  For one, you top-posted
> again.
>
> > Here you have your error:
>
> Thank you very much.  The syntax error was clear from the beginning.
>
> I have now asked you *twice* to rename the offending warnings.pl and
> try without it.  I'm not asking again.
>
> Anno
>
> [snip]



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

Date: Tue, 12 Jun 2001 12:05:18 +0200
From: buggs <buggs-clpm@splashground.de>
Subject: Re: open two files for line processing concurrently???
Message-Id: <9g4pk0$ith$01$1@news.t-online.com>

Bernard El-Hagin wrote:

> On Tue, 12 Jun 2001 11:48:54 +0200, buggs <buggs-clpm@splashground.de>
> wrote:
>>Anno Siegel wrote:
>>
>>
>>> The line input operator <> has no particular relationship with $_.
>>> Only in the special case "while ( <$f> ) { ..." is the result
>>> automatically assigned to $_, but you can change that:
>>> "while ( $line = <$f> ) { ...".  If you want to process two files
>>> side by side, you can use a while loop like this:
>>> 
>>>     while ( $line1 = <$f1> or $line2 = <$f2> ) { ...
>>
>>That will process the second file after the first file.
> 
> I think Anno meant:
> 
> while ( $line1 = <$f1> and $line2 = <$f2> )

Guess so, and it shows what the OP wanted to know.
But that will end the loop when either file one or two ends,
I don't like that somehow ...

Buggs


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

Date: 12 Jun 2001 10:16:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: open two files for line processing concurrently???
Message-Id: <9g4q6q$cdm$1@mamenchi.zrz.TU-Berlin.DE>

According to buggs  <buggs-clpm@splashground.de>:
> Anno Siegel wrote:
> 
> 
> > The line input operator <> has no particular relationship with $_.
> > Only in the special case "while ( <$f> ) { ..." is the result
> > automatically assigned to $_, but you can change that:
> > "while ( $line = <$f> ) { ...".  If you want to process two files
> > side by side, you can use a while loop like this:
> > 
> >     while ( $line1 = <$f1> or $line2 = <$f2> ) { ...
> 
> That will process the second file after the first file.

Oh, right, it's short-circuiting.  Apologies.

This will work:

    until ( eof $f1 and eof $f2 ) {
        my $line1 = <$f1>;
        my $line2 = <$f2>;
        ...

Anno


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

Date: Tue, 12 Jun 2001 10:23:47 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: open two files for line processing concurrently???
Message-Id: <slrn9ibqm0.k93.bernard.el-hagin@gdndev25.lido-tech>

On Tue, 12 Jun 2001 12:05:18 +0200, buggs <buggs-clpm@splashground.de> wrote:
>Bernard El-Hagin wrote:
>
>> On Tue, 12 Jun 2001 11:48:54 +0200, buggs <buggs-clpm@splashground.de>
>> wrote:
>>>Anno Siegel wrote:
>>>
>>>
>>>> The line input operator <> has no particular relationship with $_.
>>>> Only in the special case "while ( <$f> ) { ..." is the result
>>>> automatically assigned to $_, but you can change that:
>>>> "while ( $line = <$f> ) { ...".  If you want to process two files
>>>> side by side, you can use a while loop like this:
>>>> 
>>>>     while ( $line1 = <$f1> or $line2 = <$f2> ) { ...
>>>
>>>That will process the second file after the first file.
>> 
>> I think Anno meant:
>> 
>> while ( $line1 = <$f1> and $line2 = <$f2> )
>
>Guess so, and it shows what the OP wanted to know.
>But that will end the loop when either file one or two ends,
>I don't like that somehow ...

Well yes, but the OP wanted to compare line x in one file with
line x in the other file. If one of the files is shorter there
is no point in continuing the while loop.

Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'


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

Date: 12 Jun 2001 10:26:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: open two files for line processing concurrently???
Message-Id: <9g4qof$cdm$2@mamenchi.zrz.TU-Berlin.DE>

According to Bernard El-Hagin <bernard.el-hagin@lido-tech.net>:
> On Tue, 12 Jun 2001 11:48:54 +0200, buggs <buggs-clpm@splashground.de> wrote:
> >Anno Siegel wrote:
> >
> >
> >> The line input operator <> has no particular relationship with $_.
> >> Only in the special case "while ( <$f> ) { ..." is the result
> >> automatically assigned to $_, but you can change that:
> >> "while ( $line = <$f> ) { ...".  If you want to process two files
> >> side by side, you can use a while loop like this:
> >> 
> >>     while ( $line1 = <$f1> or $line2 = <$f2> ) { ...
> >
> >That will process the second file after the first file.
> 
> I think Anno meant:
> 
> while ( $line1 = <$f1> and $line2 = <$f2> )

No, I did mean to process both files to the end.  Checking for eof
in the loop condition (while reading inside the loop) is one way to
do it.

Anno


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

Date: Tue, 12 Jun 2001 10:41:30 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: open two files for line processing concurrently???
Message-Id: <slrn9ibrn6.k93.bernard.el-hagin@gdndev25.lido-tech>

On 12 Jun 2001 10:26:23 GMT, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
wrote:
>According to Bernard El-Hagin <bernard.el-hagin@lido-tech.net>:
>> On Tue, 12 Jun 2001 11:48:54 +0200, buggs <buggs-clpm@splashground.de> wrote:
>> >Anno Siegel wrote:
>> >
>> >
>> >> The line input operator <> has no particular relationship with $_.
>> >> Only in the special case "while ( <$f> ) { ..." is the result
>> >> automatically assigned to $_, but you can change that:
>> >> "while ( $line = <$f> ) { ...".  If you want to process two files
>> >> side by side, you can use a while loop like this:
>> >> 
>> >>     while ( $line1 = <$f1> or $line2 = <$f2> ) { ...
>> >
>> >That will process the second file after the first file.
>> 
>> I think Anno meant:
>> 
>> while ( $line1 = <$f1> and $line2 = <$f2> )
>
>No, I did mean to process both files to the end.

But if one of the files has less lines than the other what's the point
of processing both to the end?

Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'


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

Date: Tue, 12 Jun 2001 10:43:22 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: open two files for line processing concurrently???
Message-Id: <slrn9ibrqm.k93.bernard.el-hagin@gdndev25.lido-tech>

On Tue, 12 Jun 2001 10:41:30 +0000 (UTC), Bernard El-Hagin
<bernard.el-hagin@lido-tech.net> wrote:
>On 12 Jun 2001 10:26:23 GMT, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
>wrote:
>>According to Bernard El-Hagin <bernard.el-hagin@lido-tech.net>:
>>> On Tue, 12 Jun 2001 11:48:54 +0200, buggs <buggs-clpm@splashground.de> wrote:
>>> >Anno Siegel wrote:
>>> >
>>> >
>>> >> The line input operator <> has no particular relationship with $_.
>>> >> Only in the special case "while ( <$f> ) { ..." is the result
>>> >> automatically assigned to $_, but you can change that:
>>> >> "while ( $line = <$f> ) { ...".  If you want to process two files
>>> >> side by side, you can use a while loop like this:
>>> >> 
>>> >>     while ( $line1 = <$f1> or $line2 = <$f2> ) { ...
>>> >
>>> >That will process the second file after the first file.
>>> 
>>> I think Anno meant:
>>> 
>>> while ( $line1 = <$f1> and $line2 = <$f2> )
>>
>>No, I did mean to process both files to the end.
>
>But if one of the files has less lines than the other what's the point
>of processing both to the end?

Jesus! Never mind. Misread the OP.

Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'


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

Date: 12 Jun 2001 10:53:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: open two files for line processing concurrently???
Message-Id: <9g4sas$cdm$4@mamenchi.zrz.TU-Berlin.DE>

According to Bernard El-Hagin <bernard.el-hagin@lido-tech.net>:
> On 12 Jun 2001 10:26:23 GMT, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
> wrote:
> >According to Bernard El-Hagin <bernard.el-hagin@lido-tech.net>:
> >> On Tue, 12 Jun 2001 11:48:54 +0200, buggs <buggs-clpm@splashground.de> wrote:
> >> >Anno Siegel wrote:
> >> >
> >> >
> >> >> The line input operator <> has no particular relationship with $_.
> >> >> Only in the special case "while ( <$f> ) { ..." is the result
> >> >> automatically assigned to $_, but you can change that:
> >> >> "while ( $line = <$f> ) { ...".  If you want to process two files
> >> >> side by side, you can use a while loop like this:
> >> >> 
> >> >>     while ( $line1 = <$f1> or $line2 = <$f2> ) { ...
> >> >
> >> >That will process the second file after the first file.
> >> 
> >> I think Anno meant:
> >> 
> >> while ( $line1 = <$f1> and $line2 = <$f2> )
> >
> >No, I did mean to process both files to the end.
> 
> But if one of the files has less lines than the other what's the point
> of processing both to the end?

That would depend on the circumstances.  We don't know much about
the OP's purpose, so it may or may not make sense to look at the
rest of the longer file.

Actually, looking back at the original posting it seems that he/she
doesn't really want side-by-side processing:

    "...but if I need to open two files for processing, for example,
    if line N in file 1 not equal to line 1 in file 2, then compare
    with line 2 in file2"

This looks a bit like an attempt at a diff-like program, which would
need a quite different approach.

Anno


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

Date: Tue, 12 Jun 2001 14:16:31 +0200
From: S.E.Franke <snefski@hotmail.com>
Subject: printing from webpage
Message-Id: <MPG.1590268b4fc20e8d989684@news.cistron.nl>

Hi,

I'm making a webpage that shows something in a template. I want to print 
the same data on the users printer.

How can I do this?
i know I can use javascript, but then some ugly headers are printed......

Anyone an idea???
Sven


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

Date: 12 Jun 2001 12:49:22 GMT
From: "Philip M. Gollucci" <philip@p6m7g8.student.umd.edu>
Subject: Re:REGEX
Message-Id: <9g534i$4pg$1@hecate.umd.edu>

Thanks so much for the help, I will try both of the suggestions.  Unfortunately,
I can't use any module for this that I didn't write myself.

Philip 

*****************************************************************************
Philip M. Gollucci (p6m7g8)
Web-site    : http://www.p6m7g8.com
	    : http://test.p6m7g8.com
	    : http://database.p6m7g8.com

E-mail      : gollucci@wam.umd.edu 
	      philip@p6m7g8.com 

Phone       : 301.249.6261 (Home)
	      301.314.3118 (College Fall, Winter, Spring)
	      301.314.3445 (College Summer)
*****************************************************************************



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

Date: Tue, 12 Jun 2001 10:29:51 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: Script
Message-Id: <3B25C76D.DECAB51B@home.nl>

out Juanjo wrote:

> Hi!
>
> I'm trying to find a script that don't allow to write a certain character
> in any of the form fields, displaying an alert message.
>
> Thanks in advance.
>
> Juanjo

If you want to check that at the time of typing, then you will probably
need a javascript.
Else you can do it with : if ($field =~ /%/){.... ;}



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

Date: Tue, 12 Jun 2001 13:09:26 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: sorting a hash on part of its value?
Message-Id: <3B260676.81BC867F@salford.ac.uk>

Hi all,

I have what I suspect is a highly inefficient algorithm (due to the
number of loops I have) for sorting a hash based on _part_ of its value
string.  (perldoc -q sort only demonstrates how to sort a hash on all of
its value string.)  What I have works but is slow.  I would appreciate
any help in making the alogorithm more efficient/quicker.

The value string of my DB_File db is delimited by '¬' and among other
data, contains the UNIX time of when a user last logged on (using a
bulletin board I've written).

A further complication is that this UNIX time may be the same across
different key : value pairs (if people happen to have logged on in the
same second).

Additionally, I need to keep the rest of the hash value tied to its UNIX
time so that I can display, for example, who it was who logged in at
that time.

example:

key : status¬email¬numposts¬UNIX time¬etc.¬etc.¬etc. although my actual
UNIX time is in index 10.

I need to sort the hash on UNIX time which may be the same as another
UNIX time in another key : value pair.

Here's the code I'm using:

        foreach $key(keys %USER)
        {
                @string = split(/¬/, $USER{$key});
                if($string[10] ne 'null')
                {
                        push(@time, $string[10]);
                }
                else
                {
                        push(@reprobates, $key); # these will be
displayed last - order unimportant.
                }
        }
        @time = reverse sort {$a <=> $b} @time; # to get last login time
first.
# highly inefficient sort algorithm - needs sorting ;) some time
        foreach(@time)
        {
                $time = $_;
                @names = keys %USER;	# keys are the names of users which
will be $profile'ised
                BACK2: foreach(@names)
                {
                        $name = $_;
                        foreach(@done)
                        {
                                next BACK2 if($name eq $_);     #
already done this one
                        }
                        @string = split(/¬/, $USER{$name});
# doesn't matter if $time happens to be from another @string (another
key:value pair)
# as it's simply the login time and if 2 people happen to have logged in
at the same time, who cares
# which is displayed first.
                        if($string[10] eq $time)
                        {
# check for spaces in usernames
                                $profile = $name;
                                if($profile =~ / /)
                                {
                                        $profile =~ s/ /%20/g;
                                }
                                push(@done, $name);
                                last; 
                        }
                }
                $time = q_time_of_post($time); # pulled from an external
module - simply formats $time
						# into readable format
                print "<LI><A
HREF=\"register.cgi?view=$profile\">$name</A>,
                        last seen: $time";
        }


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

Date: Tue, 12 Jun 2001 13:15:53 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: sorting a hash on part of its value?
Message-Id: <3B2607F9.24A2E123@salford.ac.uk>

P.S. long lines with comments have been wrapped in the post above - it's
not like this in the script....

Mark Grimshaw wrote:
> 
> Hi all,
> 
> I have what I suspect is a highly inefficient algorithm (due to the
> number of loops I have) for sorting a hash based on _part_ of its value
> string.  (perldoc -q sort only demonstrates how to sort a hash on all of
> its value string.)  What I have works but is slow.  I would appreciate
> any help in making the alogorithm more efficient/quicker.
> 
> The value string of my DB_File db is delimited by '¬' and among other
> data, contains the UNIX time of when a user last logged on (using a
> bulletin board I've written).
> 
> A further complication is that this UNIX time may be the same across
> different key : value pairs (if people happen to have logged on in the
> same second).
> 
> Additionally, I need to keep the rest of the hash value tied to its UNIX
> time so that I can display, for example, who it was who logged in at
> that time.
> 
> example:
> 
> key : status¬email¬numposts¬UNIX time¬etc.¬etc.¬etc. although my actual
> UNIX time is in index 10.
> 
> I need to sort the hash on UNIX time which may be the same as another
> UNIX time in another key : value pair.
> 
> Here's the code I'm using:
> 
>         foreach $key(keys %USER)
>         {
>                 @string = split(/¬/, $USER{$key});
>                 if($string[10] ne 'null')
>                 {
>                         push(@time, $string[10]);
>                 }
>                 else
>                 {
>                         push(@reprobates, $key); # these will be
> displayed last - order unimportant.
>                 }
>         }
>         @time = reverse sort {$a <=> $b} @time; # to get last login time
> first.
> # highly inefficient sort algorithm - needs sorting ;) some time
>         foreach(@time)
>         {
>                 $time = $_;
>                 @names = keys %USER;    # keys are the names of users which
> will be $profile'ised
>                 BACK2: foreach(@names)
>                 {
>                         $name = $_;
>                         foreach(@done)
>                         {
>                                 next BACK2 if($name eq $_);     #
> already done this one
>                         }
>                         @string = split(/¬/, $USER{$name});
> # doesn't matter if $time happens to be from another @string (another
> key:value pair)
> # as it's simply the login time and if 2 people happen to have logged in
> at the same time, who cares
> # which is displayed first.
>                         if($string[10] eq $time)
>                         {
> # check for spaces in usernames
>                                 $profile = $name;
>                                 if($profile =~ / /)
>                                 {
>                                         $profile =~ s/ /%20/g;
>                                 }
>                                 push(@done, $name);
>                                 last;
>                         }
>                 }
>                 $time = q_time_of_post($time); # pulled from an external
> module - simply formats $time
>                                                 # into readable format
>                 print "<LI><A
> HREF=\"register.cgi?view=$profile\">$name</A>,
>                         last seen: $time";
>         }


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

Date: Tue, 12 Jun 2001 07:58:33 -0400
From: "PaAnWa" <paanwa@hotmail.com>
Subject: Table/Cell formatting with CGI.pm
Message-Id: <tic0vaalbb53ca@corp.supernews.com>

The main problem I am still having is getting the correct formatting for
placing a param('') variable inside a cell -- it seems that no matter what I
do the code does not work.

Here is what I am trying to accomplish:

print "<td><input type='textbox'
name='Contact_FirstName'value=",param('Contact_FirstName'),"></td>";

Why do I need this?  I am making a form that submits to itself and checks to
see if all fields are completed; if not, an error appears beside the field
needing attention while keeping the data passed in the other fields.

Thanks for your help.

PAW




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

Date: Tue, 12 Jun 2001 13:12:28 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: Table/Cell formatting with CGI.pm
Message-Id: <3B26072C.8A6D7F8B@salford.ac.uk>



PaAnWa wrote:
> 
> The main problem I am still having is getting the correct formatting for
> placing a param('') variable inside a cell -- it seems that no matter what I
> do the code does not work.
> 
> Here is what I am trying to accomplish:
> 
> print "<td><input type='textbox'
> name='Contact_FirstName'value=",param('Contact_FirstName'),"></td>";
> 
> Why do I need this?  I am making a form that submits to itself and checks to
> see if all fields are completed; if not, an error appears beside the field
> needing attention while keeping the data passed in the other fields.
> 
> Thanks for your help.
> 
> PAW

hmm - are you sure it's 'textbox' and not 'textarea'?  If the latter,
then try something like:

print "<TD><TEXTAREA
NAME=\"Contact_FirstName\">param('Contact_FirstName')</TEXTAREA></TD>";


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

Date: Tue, 12 Jun 2001 08:32:33 -0400
From: "PaAnWa" <paanwa@hotmail.com>
Subject: Re: Table/Cell formatting with CGI.pm
Message-Id: <tic2v6rjvcu361@corp.supernews.com>

Hi Mark,

Sorry I was not clear in my post.  I am looking for modify what I have into
CGI.pm formatting.  Here is what I have:

print "<td><input type='textbox'
name='Contact_FirstName'value=",param('Contact_FirstName'),"></td>";

Thanks!

PAW




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

Date: Tue, 12 Jun 2001 12:58:15 GMT
From: Gordon.Haverland@gov.ab.ca
Subject: What is ${'string'} ?
Message-Id: <3b26116d.340959040@news.gov.ab.ca>

As the subject field says, what is ${'some_string'} ?

Would their be any reason why someone would use this, instead of any
other variable, when their is only 1 unique string used in the entire
program.

Thanks,
Gord



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

Date: Tue, 12 Jun 2001 18:18:12 +0800
From: "keng" <keng@spinalfluid.com>
Subject: Win32::OLE Question
Message-Id: <9g4q7k$j81$1@violet.singnet.com.sg>

hi all,
was wondering if anyone can explain this to me.
i want to open excel application under win98 but just cannot get it to work.
however i can open word application instead.
i am using office 2000 on win98
pls help
thanks

my script as below

use Win32::OLE;
#can work
$ex = Win32::OLE->new('Word.Application') or die "oops\n";
$ex->{Visible}=1;

#cannot work
#$ex = Win32::OLE->new('Excel.Application') or die "oops\n";
#$ex->{Visible}=1;

--
regards
isaac




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1117
***************************************


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