[6260] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 882 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 2 09:07:13 1997

Date: Sun, 2 Feb 97 06:00:42 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 2 Feb 1997     Volume: 7 Number: 882

Today's topics:
     5.004's new srand() default seed <roderick@gate.net>
     Re: Best locking method for NFS - buffered IO safe? (Silvio Picano)
     Re: CGI SCRIPT / PERL Setup and Executing of scripts (Johan Neven)
     Choosing Good Subject Lines [Periodic Posting] (Dean Roehrich)
     Re: Creation time and date of file (Petr Prikryl)
     Re: Grabbing Html via perl from the web <felicity@eclectic.kluge.net>
     help with mail form (Matt)
     Re: Need help with permissions (Petr Prikryl)
     Need help with variable manipulation <ez045864@peseta.ucdavis.edu>
     Re: Need help with variable manipulation (Nathan V. Patwardhan)
     parsing problem? (Greg Hassan)
     pattern matching of sorts <ez045864@peseta.ucdavis.edu>
     Re: pattern matching of sorts <merlyn@stonehenge.com>
     Re: pattern matching of sorts <aas@bergen.sn.no>
     perl and signal handling question <cam@chch.planet.org.nz>
     Re: Reading numbers from file.. (Dave Thomas)
     regex eats newline? (Frans Postma)
     sorting multidimensional arrays in perl? (Apple-O)
     Re: Time of day questions (I R A Aggie)
     Re: Time/Date (Abigail)
     Tk: Automatic Multiple Selection in Listboxes (Dana & Jennifer Edwards)
     unitialized variables?? (Ted Pedersen)
     why does this regexp eat a newline?? (Frans Postma)
     Re: Xemacs: Spell checking a buffer and comments (Reinhold J. Gerharz)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 1 Feb 1997 23:56:08 -0500
From: Roderick Schertler <roderick@gate.net>
Subject: 5.004's new srand() default seed
Message-Id: <pzbua3g64m.fsf_-_@eeyore.ibcinc.com>

On Wed, 22 Jan 1997 23:09:05 GMT, ca@pobox.com (Apple Spider) said:
> 
>>     srand (time ^ $$);	# Seed rand()
> 
> Hey folks. Time to bring srand up to the 20th century. The *correct*
> version is:
>
> 	srand (time() ^ ($$ + ($$ << 15)));

Quite right, but thankfully this won't be necessary in 5.004.  In the
new release srand() will use a good seed by default.  The seed it uses
isn't the venerable formula you list, though, it's basically

    if (vms)
        _ckvmssts(sys$gettim(when));
        seed = when[0] ^ when[1];
    elsif (has gettimeofday)
        gettimeofday(&when,(struct timezone *) 0);
        seed = when.tv_sec ^ when.tv_usec;
    else
        time(&seed);

    seed ^= ( (  269 * (U32)getpid())
             ^ (26107 * (U32)&when)
             ^ (73819 * (U32)stack_sp));

I'm not sure who wrote the new code.  If any of the mathematically
inclined in the audience want to comment on this seed, and in particular
if it's better than the form listed above, it would be welcomed.  I
called for comments about which was better on the perl5-porters list but
nobody piped up, so I assumed that the current implementation is
superior and documented it as such.  It's not too late to change it
before the release if that's not the case, though.

-- 
Roderick Schertler
roderick@gate.net


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

Date: 2 Feb 1997 03:04:59 GMT
From: spicano@ptdcs2.intel.com (Silvio Picano)
Subject: Re: Best locking method for NFS - buffered IO safe?
Message-Id: <5d108r$289@ptdcs5.ra.intel.com>

Jason,

I too would be much *interested* in a solaris 5.5 solution.


Joel,

I had a similar problem close to a month ago; my routines for sunos-4.1 &
aix-3.5.2 work fine (separate & together); the sunos-5.5.1 execution did
not like this mixed nfs environment though.

I tried the non-buffered code you mention, but it still failed (i.e., in
a very tight loop, the solaris system periodically saw a 0-byte file). I 
finally worked in a hack that has yet to fail on these mixed os'es. It 
slows down the critical section (~ 0.25 secs), but it does seem to fix 
my problem.

The system:
  1. a file that contains the unique/update-able info.
  2. an empty file acting as a shadow lock.

The simplified algorithm:
  1. all hosts attempt fcntl on the shadow file-handle.
  2. the winner opens/updates/closes the unique/update-able file
     using stdio functions; open, print, close...
  3. the winner releases the lock on the shadow file.

The solaris fix:
  Between steps 1. & 2., I inserted a dummy "cp" command (e.g.,
    "cp <unique-file> <old-unique-file>"
  which seems to refresh the file. Now the unique-file was its
  last written value, not a zero-byte file. I used it to protect a
  counter file.

I can't post the code; this was the only fix I could make reliable;
I tested it over several hours of tight looping on these 3 systems
simultaneously. Add in the shadow-lock file with a fcntl() retry 
loop, then try w/ & w/o the intermediate "cp".

Good luck.
Silvio


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

Date: Sun, 02 Feb 1997 10:52:50 GMT
From: Johan.Neven@ping.be (Johan Neven)
Subject: Re: CGI SCRIPT / PERL Setup and Executing of scripts
Message-Id: <32f4713c.1139271@news.ping.be>

On 31 Jan 1997 02:09:04 GMT, "Darrell LaRock" <rockhead@camalott.com>
wrote:

>I am learning scripts and forms currently.  Now I am following a tutorial
>and it doesnt cover the problem I ran into.

Try making your script executable with following command:
	chmod a+x testform.cgi
on your local directory on the ISP server. You need an FTP who
enables your to execute this command (WS_FTP).

Good luck!



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

Date: 2 Feb 1997 03:01:33 GMT
From: roehrich@cray.com (Dean Roehrich)
Subject: Choosing Good Subject Lines [Periodic Posting]
Message-Id: <subjects_854852491@cray.com>

NAME
     subject_lines - Choosing Good Subject Lines

DESCRIPTION
     The quality of your article's subject line will dictate the
     quality of the responses you receive.  Choose your subject
     lines wisely.

GOOD SUBJECT LINES
     These subject lines indicate exactly what the article will
     be about and are therefore quality subject lines.

             Putting Commas in a number
             Can I print "~" (tilde) in a format?
             Assigning to an @array and undefined value.
             Printing/calling date/time using unix gmtime
             How to install individual modules like CGI-Lite?
             getpwnam() & Solaris's /etc/shadow file


BAD SUBJECT LINES
     These subject lines say nothing about the content in the
     article.

             Where do I start???!! :-(
             How hard would this job be?
             Can YOU solve this simple problem?!
             Testing.
             04]?
             Simple split question

     These subject lines use negative-flash words.  See the
     section on NEGATIVE-FLASH WORDS.

             Perl newbie with cgi script problem
             Newbie needs help
             Total Beginner Reqs. Help - Please.
             Simple split question
             Can YOU solve this simple problem?!


NO SUBJECT LINE
     Many of the people who give high-quality responses will tend
     to ignore posts which have no subject line at all.

NEGATIVE-FLASH WORDS
     The following words are guaranteed to make large numbers of
     people deliberately ignore your article.  I call these
     negative-flash words.

     beginner  Many people ignore articles which have these words
               in their subject lines.

     emergency News propagation is too slow.  By the time anyone
               gets to read it your condition has probably been
               upgraded to catastrophic.  By the time you get
               their response you'll be dead.  Don't waste other
               people's time with this stuff.

     expert    See guru.

     girl      The people who can give you the highest-quality
               responses probably aren't in the mood for this
               sort of trolling.

     guru      The truth is that it's probably a non-guru
               question.  Most gurus will ignore any article that
               has this word in its subject line.

     help      It sounds like you've given up, or, more likely,
               haven't tried.  Omit this word and the rest of
               your subject line will probably be a high-quality
               attention-getter.

     newbie    See beginner.

     novice    See beginner.

     please    Don't beg.  It's a turn-off.

     question  It's too obvious, and probably answered in the
               manpages or the FAQ.

     sex       See girl.

     simple    This word should tell you something--that you need
               to look at the manpages a little harder.  Don't
               waste other people's time with this stuff.

     stupid    It's just plain derogatory.  People don't like to
               waste their time on things that are stupid.  Hint:
               don't tell them it's stupid, and you will get a
               higher-quality response.

     urgent    See emergency.

     woman     See girl.

NEGATIVE-FLASH EFFECTS
     The following effects, like the above list of negative-flash
     words, are guaranteed to make large numbers of people
     deliberately ignore your article.

     ALL CAPITALS
               Do not use all capital letters in your subject
               line.  Many people find the effect annoying or
               equate it with newcomers.  In either case they
               will ignore the posting.  Hint: There's nothing
               wrong with being a newcomer--we all were at one
               time--just don't advertise it.

     Multiple bangs!!!!!
               Multiple bangs (exclamation points) and multiple
               question marks come across as either over-zealous
               or literarily ignorant, and both effects tend to
               chase away the people who can give the highest-
               quality responses.

BAD, BARELY
     This brings us to the next category of subject lines:  Those
     which are bad but could be good with only a slight
     adjustment.

             HELP: Perl 5.002, SunOS 5.5, gcc 2.7.2, dynamic loading
             HELP: Converting text to binary


GRINCH
     Dean Roehrich,  July 26, 1996.



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

Date: 2 Feb 1997 12:55:52 GMT
From: prikryl@dcse.fee.vutbr.cz (Petr Prikryl)
Subject: Re: Creation time and date of file
Message-Id: <5d22so$ip@boco.fee.vutbr.cz>

Parmeshta Jain (jain@bcstec.ca.boeing.com) wrote:
>I need to be able to print out the creation time and date of a file in
>the following format.  Can someone help me with this?
>The format is:
>24 JAN 1997 AT 00:02:10 AM

I would recommend stat() and localtime() functions. The stat() function
takes the name of the file and returns also time of the creation; however,
usage of "time of modification" is more useful, in my opinion (also
returned by stat()). The time is in seconds from 1 Jan 1970. You can
pass this to localtime() to convert it to year, day, month, hour, minute, 
sec... (basicaly the numbers). Then it is quite easy to convert the 
numbers into strings like JAN, etc.

Petr

--
Petr Prikryl (prikryl@dcse.fee.vutbr.cz)   http://www.fee.vutbr.cz/~prikryl/
TU of Brno, Dept. of Computer Sci. & Engineering;     tel. +42-(0)5-7275 218


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

Date: 30 Jan 1997 20:39:26 GMT
From: Theo Van Dinter <felicity@eclectic.kluge.net>
Subject: Re: Grabbing Html via perl from the web
Message-Id: <5cr0tu$f6v$2@bigboote.WPI.EDU>

-----BEGIN PGP SIGNED MESSAGE-----

Nathan V. Patwardhan <nvp@shore.net> wrote:
> : Yeah simple right? Just wondering before I reinvent the wheel,  has
> : someone- somewhere done this before.  If not *any* suggestions on how to
> : do this?

I wrote a program called GetURL (see http://www.kluge.net/NES/) to do this
for me.

 ---------------------------------------------------------------------------
 Theo Van Dinter			www: http://www.kluge.net/~felicity/
 (Vice)President WPI Lens and Lights	      Active Member in SocComm Films
 Member of WPI ACM			      AME for the Masque C-Term Show

             Everywhere is walking distance if you have the time.
 ---------------------------------------------------------------------------

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQB1AwUBMvEG/m46V+hEhqEhAQFTSQL/YPPkRc6/S5xGUpxtfnq8RwoBOKMAZ2hp
U4e/kQvMoqhz/cyPwHzWPb/JO/y5rQ3ntAT2D7woST2Gxk9e86nxuhVAbO2ihg6J
qyBgTNRTCnNRtS2H2Gh2coxpViWJOBM8
=8/GP
-----END PGP SIGNATURE-----


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

Date: Thu, 30 Jan 1997 06:01:00 GMT
From: matt@apc.net (Matt)
Subject: help with mail form
Message-Id: <32f1390e.8753436@news.apc.net>


on my home page i would like to put a simple mail form...
however, my server wont let me access the CGI-BIN
im trying to do this : 

<FORM METHOD="POST" ACTION="mailto:me@me.net">

everytime i click on the button i get a email window up..... can
anyone help?


matt@apc.net


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

Date: 2 Feb 1997 12:44:19 GMT
From: prikryl@dcse.fee.vutbr.cz (Petr Prikryl)
Subject: Re: Need help with permissions
Message-Id: <5d2273$ip@boco.fee.vutbr.cz>

D. M. Johnson (ez045864@peseta.ucdavis.edu) wrote:
>On 24 Jan 1997, Nathan V. Patwardhan wrote:
>> : If I have the userid and groupid, how can I find out if they have
>> : rwx permissions on a file, say the passwd file?
>> perl -e 'if(-W "/etc/passwd") {print "yes\n"} else {print "no\n"}'
>> The above will output no if the user is unable to write the file.

>As I understand it this will work only for the user running the script.
>If I am trying to test for another user, say my boss, and he is in the
>group, this test will not work.
>I know how to test if the user is the owner, but am still having trouble
>if they are in the group.

As Mike Stok wrote, you should use stat() function for the file.
You can obtain all the info associated with the file. See perlfunc(1)
manual page:

  ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
   $atime, $mtime, $ctime, $blksize, $blocks) = stat($filename);

You are interested in $mode, $uid, and $gid. The following code is 
a fragment from my simplified ls() function:

        my $ms;    # mode as a string

        if    ($mode & 0x8000) { $ms = '-' }   # file
        elsif ($mode & 0x4000) { $ms = 'd' }   # directory
        else                   { $ms = '?' }   # pipe, special,...

        $ms .= ($mode & 00400) ? 'r' : '-';    # user rights
        $ms .= ($mode & 00200) ? 'w' : '-';
        $ms .= ($mode & 00100) ? 'x' : '-';

        $ms .= ($mode & 00040) ? 'r' : '-';    # group rights
        $ms .= ($mode & 00020) ? 'w' : '-';
        $ms .= ($mode & 00010) ? 'x' : '-';

        $ms .= ($mode & 00004) ? 'r' : '-';    # rights for others
        $ms .= ($mode & 00002) ? 'w' : '-';
        $ms .= ($mode & 00001) ? 'x' : '-';

        print $fh "$ms $size $year-$mon-$mday $hour:$min $entry\n";

where $year, $mon, ... are generated by localtime($mtime). If $uid is 
equal to the person's uid, then user rights are applied, else if 
$gid is equal to the person's gid, then group rights are applied. Otherwise
the rights for others are applied. If you know uid and gid of any person,
you can find his/her access rights to the file. Every person has one 
primary gid assigned when she/he logs in. One can change it do different
gid from the list of groups of which he/she is the member. Deciding what
gid will be used by the user is another problem.

Petr

--
Petr Prikryl (prikryl@dcse.fee.vutbr.cz)   http://www.fee.vutbr.cz/~prikryl/
TU of Brno, Dept. of Computer Sci. & Engineering;     tel. +42-(0)5-7275 218


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

Date: Sat, 1 Feb 1997 20:30:26 -0800
From: "D. M. Johnson" <ez045864@peseta.ucdavis.edu>
Subject: Need help with variable manipulation
Message-Id: <Pine.GSO.3.95.970201202732.26868A-100000@bullwinkle.ucdavis.edu>

Hi all.  Two questions:

1) If $name = randal, how can I reverse this.  I need to get
   $name = ladnar (Assuming I don't know how many characters are
   in the name.)

2) I need to spell check a word.  If I store "dog" into $word, how
   can I spell check $word?

Thanks.

D.J.



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

Date: 2 Feb 1997 06:13:00 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Need help with variable manipulation
Message-Id: <5d1b9c$ffg@fridge-nf0.shore.net>

D. M. Johnson (ez045864@peseta.ucdavis.edu) wrote:

: 1) If $name = randal, how can I reverse this.  I need to get
:    $name = ladnar (Assuming I don't know how many characters are
:    in the name.)

$name = 'randal';
$newname = reverse($name);
print $newname,"\n";

: 2) I need to spell check a word.  If I store "dog" into $word, how
:    can I spell check $word?

There's a ton of ways to do this: 
(1) if your system has webster installed you can do:

$webster = '/usr/local/bin/webster';
open(SPELLME, "$webster 2>&1 |");
@output = <SPELLME>;
close(SPELLME);

foreach $response (@output) {
   print $response,"\n";
}

(2) You might create a "lexicon" of words, which is a file containing 
a number of words, and compare your entry against the list of words.

Ex:

$spell = '/path/lexicon.txt';
print ("Enter a word: ");
chop($word = <STDIN>);

open(LEX, "$spell")
    || die("Hey: $!\n");	
@correct = <LEX>;
close(LEX);

foreach $entry (@correct) {
   chop($entry); ### remove trailing \n so matching won't get hosed
   if($word eq $entry) { 
     print("Word spelled correctly.\n"); ### found
     $correct = 1; ### we'll set a flag because of fail-cases
   } 
}

if($correct != 1) { ### fail-case: word not found.
  print("Word not found or misspelled.\n");
}

(3) Import you lexicon into a database, like Oracle, and query
    responses against your database.

(4) If you system has ispell, you can do something similar to example #1.

HTH!

--
N Patwardhan
nvp@shore.net
[news:alt.fan.jwz]


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

Date: 2 Feb 1997 12:31:09 GMT
From: gwhassan@cs.buffalo.edu (Greg Hassan)
Subject: parsing problem?
Message-Id: <5d21ed$cl6@nntp.Stanford.EDU>

heyas,

I ftp a few .tgz files in ascii by mistake, now i cant
unzip them because it says incorrect gzip format.
The bad thing is that I can no longer ftp these files
correctly as they have been deleted on the other server.

Does anyone have a script that will fix these files so that
I can uncompress/untar them?

i tried to just remove all the control M's with perl -pi -e 's/\cM...
but that didnt seem to help at all.  I imagine this is because
there are control M's that are supposed to be in the .tgz file
that i am removing. 

i know with a text file you can just search and replace removing
all the control M's, but become binaries once you gzip.

Any thoughts would be helpful,

Greg


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

Date: Sat, 1 Feb 1997 21:20:14 -0800
From: "D. M. Johnson" <ez045864@peseta.ucdavis.edu>
Subject: pattern matching of sorts
Message-Id: <Pine.GSO.3.95.970201211812.26868B-100000@bullwinkle.ucdavis.edu>

I need to take a scalar variable and determine how many alphanumeric
characters and non-alphanumeric characters it contains.  I have tried a
for loop but that resulted in an infinite loop.  Any help would be greatly
appreciated.  Thanks.

D.J.



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

Date: 01 Feb 1997 22:43:34 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "D. M. Johnson" <ez045864@peseta.ucdavis.edu>
Subject: Re: pattern matching of sorts
Message-Id: <8cpvyj9309.fsf@gadget.cscaper.com>

>>>>> "D" == D M Johnson <ez045864@peseta.ucdavis.edu> writes:

D> I need to take a scalar variable and determine how many alphanumeric
D> characters and non-alphanumeric characters it contains.  I have tried a
D> for loop but that resulted in an infinite loop.  Any help would be greatly
D> appreciated.  Thanks.

	$_ = "Some string with alphabetic chars!";
	$alpha_count = tr/A-Za-z//;
	$non_alpha_count = tr/A-Za-z//c;

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 576 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 02 Feb 1997 12:47:32 +0100
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: pattern matching of sorts
Message-Id: <hhgjvv38r.fsf@bergen.sn.no>

Randal Schwartz <merlyn@stonehenge.com> writes:

> D> I need to take a scalar variable and determine how many alphanumeric
> D> characters and non-alphanumeric characters it contains.  I have tried a
> D> for loop but that resulted in an infinite loop.  Any help would be greatly
> D> appreciated.  Thanks.
> 
> 	$_ = "Some string with alphabetic chars!";
> 	$alpha_count = tr/A-Za-z//;
> 	$non_alpha_count = tr/A-Za-z//c;

Randal's solution does not work well with locales.  This one might be
better for some:

  @a = /([^\W\d_])/g;
  $alpha_count = @a;
  $non_alpha_count = length($_) - $alpha_count;

-- 
Gisle Aas <aas@sn.no>


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

Date: Fri, 31 Jan 1997 17:32:30 +1300
From: Cameron Hart <cam@chch.planet.org.nz>
Subject: perl and signal handling question
Message-Id: <32F175DE.6639CEAB@chch.planet.org.nz>

Hi there,

I have some queries about IPC.  I am writing a perl script that one day
will run continuously reading input data,  processing it,  and writing
to a log file.  Every now and then I want to rotate the log file.  I
figure,  send it a kill -HUP signal to close and reopen the log file. 
Here's where the fun begins.  I have some code say

sub reopen {
 ...
}

$SIG{'HUP'} = 'reopen';

also in the subroutine that writes to the logs the signal HUP is ignored
so I don't reopen in the middle of a write.  Now what is going to happen
when I receive a signal?  Will my program keep going where it was rudely
interupted after handling the signal?  Or is it not quite that simple?

thanks,

Cam


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

Date: 2 Feb 1997 04:17:04 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Reading numbers from file..
Message-Id: <slrn5f855i.a2g.dave@fast.thomases.com>

On 1 Feb 1997 21:18:47 GMT, Juha Hartikainen ia201 <jhartika@orion.pspt.fi> wrote:
> I have a huge database which is on my own format. It haves strings, which 
> are easy to read with Perl. It haves also MANY floating point numbers. 
> How can I read these Intel double numbers and convert 'em to string??
> double is 8 bytes long floating point number.

The 'unpack' function will do what you want, _assuming_ that the native
floating point format on the box you're using is the same as in your file.
The 'd' template specifier to unpack will extract a double precision float
from a string.

Regards

Dave


-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Sun, 02 Feb 1997 13:41:00 GMT
From: F.Postma@inter.NL.net (Frans Postma)
Subject: regex eats newline?
Message-Id: <32f3a29f.8399347@news.Nl.net>

Hi there,

I got a script which parses a standard mail-message header and
extracts some components of it. Among other things it determines the
subject (Subject: line).

Problems arise when the subject is empty or only filled with spaces.
Example as short as I could:

#!perl
$x='Subject:
To: bla@abla
Date: Sat 01-02-1997';
$x=~s/Subject:\s*([^\n]*?)\s*\n/Subject: $1\n/im;
print $x;
__END__

Output of this is:
Subject: To bla@abla
Date: Sat 01-02-1997

Question: why does the regexp on $x eat the line on the Subject line?
$1 should be empty in the s//m in this case but for some reason it
grabs the next line too, which it shouldn't 'cos I specificly exclude
newlines (\n)....

I now do this in two steps (extract subject first and strip the
leading and trailing whitespace later) but that really shouldn't be
nessecary....

Any ideas?

Frans Postma
	(fpostma@inter.nl.net)


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

Date: 1 Feb 1997 23:28:28 -0500
From: appleo@raven.cybercomm.net (Apple-O)
Subject: sorting multidimensional arrays in perl?
Message-Id: <5d155c$83i@raven.cybercomm.net>

Does perl support multidimensional arrays? 
(if so, can someone post a simple example of how to use 
and sort them under different keys?)

Or are they emulated using parallel one-dim arrays? 
(if this is the case, how do you sort?)

Many thanks in advance. 



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

Date: Fri, 31 Jan 1997 09:36:38 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Time of day questions
Message-Id: <fl_aggie-ya023180003101970936380001@news.fsu.edu>

In article <32F18098.4F15@iadfw.net>, Wayne Kube <wkube@iadfw.net> wrote:

[posted && cc'd]

+ Is there a Perl (or other method?) script that could be
+ used to access the England time from either server and return that value
+ to the index page being displayed on the user's screen?

One way to do it would be to access the time returned by the gmtime()
function, which returns GMT. Does England have more than one time zone?
You may need to tweek for Daylight Savings Time, tho.

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

James

-- 
Consulting Minster for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Sun, 2 Feb 1997 05:18:24 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Time/Date
Message-Id: <E4yMqo.CAL@nonexistent.com>

On Thu, 30 Jan 1997 13:31:18 +0100, Wouter de Boer wrote in comp.lang.perl.misc:
++ Hello,
++ 
++ Are there Perl functions to change the time and the date ?? I can only
++ find the possibility to obtain the date/time with the command:
++ 
++ ($..- $..) = localtime(time);
++ 
++ Can I use the same command to change the date/time ?? 

Well... you can do this:

#!/usr/local/bin/perl -w
 
use strict;
 
print scalar localtime, "\n";
sleep 5;
print scalar localtime, "\n";

__END__
Sun Feb  2 00:16:50 1997
Sun Feb  2 00:16:55 1997


++ Are there fucntions to change the Time Zone in Perl ??

$ENV {TZ} = "EST";


Abigail



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

Date: Sun, 02 Feb 1997 04:36:30 GMT
From: edwardsfv@mindspring.com (Dana & Jennifer Edwards)
Subject: Tk: Automatic Multiple Selection in Listboxes
Message-Id: <5d15o4$v9c@camel0.mindspring.com>

I'm trying to select multiple entries of a Listbox in Tk using the
following algorithm:
foreach(@array) {
	if (/some_pattern/) {
		select item from Listbox;
	}
}

Here is some sample code I've tried.  Tk complains that "-state" is an
unknown option for a listbox:
foreach(@array) {
	if (/some_pattern/) {
		$listbox_widget -> insert('end',$_); 
		# Somehow I'd like to configure the item just inserted as "selected"
		# and not the entire listbox as follows (which is illegal anyhow) 
		$listbox_widget -> configure(-state => 'selected');
	}
}

The selection type is set to 'multiple' during the creation of the
listbox widget.  If anyone can help me, I would really appreciate it!

Thank you,
Dana+E





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

Date: 2 Feb 1997 12:38:25 GMT
From: pedersen@seas.smu.edu (Ted Pedersen)
Subject: unitialized variables??
Message-Id: <5d21s1$j5b@giant.seas.smu.edu>


I have some fairly simple perl code that runs "without incident" on one
system - but when I move it over to another system I find that it
generates massive numbers of unitialized variable messages. The code still
produces the desired outbut but it generates all these warnings in the
process. 

I don't change anything in the perl code and the version of perl running
on both systems is the same. I am using the -w option by the way. Anybody
experience something similar and have any ideas why this happens? 

Thanks,
Ted

---
* Ted Pedersen                     pedersen@seas.smu.edu              * 
*                                  http://www.seas.smu.edu/~pedersen/ *
* Department of Computer Science and Engineering,                     *
* Southern Methodist University, Dallas, TX 75275      (214) 768-3712 *



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

Date: Sun, 02 Feb 1997 13:45:01 GMT
From: F.Postma@inter.NL.net (Frans Postma)
Subject: why does this regexp eat a newline??
Message-Id: <32f49a2b.15352344@news.Nl.net>

Hi there,

I got a script which parses a standard mail-message header and
extracts some components of it. Among other things it determines the
subject (Subject: line).

Problems arise when the subject is empty or only filled with spaces.
Example as short as I could:

#!perl
$x='Subject:
To: bla@abla
Date: Sat 01-02-1997';
$x=~s/Subject:\s*([^\n]*?)\s*\n/Subject: $1\n/im;
print $x;
__END__

Output of this is:
Subject: To bla@abla
Date: Sat 01-02-1997

Question: why does the regexp on $x eat the line on the Subject line?
$1 should be empty in the s//m in this case but for some reason it
grabs the next line too, which it shouldn't 'cos I specificly exclude
newlines (\n)....

I now do this in two steps (extract subject first and strip the
leading and trailing whitespace later) but that really shouldn't be
nessecary....

Any ideas?

Frans Postma
	(fpostma@inter.nl.net)


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

Date: Sun, 02 Feb 1997 04:58:08 GMT
From: rgerharz@erols.com (Reinhold J. Gerharz)
Subject: Re: Xemacs: Spell checking a buffer and comments
Message-Id: <32f41e2e.14813540@news.erols.com>

I guess my original reply got lost:

Mike Campbell <mcampbel@tvmaster.turner.com> wrote:

>rgerharz@erols.com (Reinhold J. Gerharz) writes:
>
>> Originally posted in comp.emacs.xemacs, but no reply:
>
>Which is where this question belongs, BTW.
>
>> I tried to spell check a perl script and it failed to find a
>> misspelled word within a comment. If this is deliberate, is there a
>> way to force it to check comments?
>
>This has nothing to do with perl.

So no one in this news group knows anything about or uses Xemacs? And
the Perl mode developers for Xemacs never monitor this group?
Extraordinary!


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

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 V7 Issue 882
*************************************

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