[13574] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 984 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 4 18:07:24 1999

Date: Mon, 4 Oct 1999 15:05:17 -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: <939074716-v9-i984@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 4 Oct 1999     Volume: 9 Number: 984

Today's topics:
    Re: Bug with localtime() in Perl 5.004 and 5.005 (Clinton Pierce)
    Re: Bug with localtime() in Perl 5.004 and 5.005 <sariq@texas.net>
    Re: Bug with localtime() in Perl 5.004 and 5.005 (Clinton Pierce)
    Re: Can I have a subroutine return a hash? (Larry Rosler)
        Conversion ASCII flat file into Excel spreadsheet file <Vorname.Name@pcm.bosch.de>
    Re: Conversion ASCII flat file into Excel spreadsheet f (Michel Dalle)
    Re: Conversion ASCII flat file into Excel spreadsheet f <mck@iag.net>
        converting to Linux from NT but need a hand. <kangas@anlon.com>
    Re: Editing Perl scripts with emacs <aqumsieh@matrox.com>
        Getting variable contents from other files arahkay@my-deja.com
    Re: Help! I'm having big trouble searching my database (Clinton Pierce)
    Re: Input/output from programs <gellyfish@gellyfish.com>
    Re: Loading code at run-time <gellyfish@gellyfish.com>
        mod_perl type handler? <dnichols@fhcrc.org>
        Net::SMTP <nigh_postal@my-deja.com>
    Re: Newbie: Chomp and Case Conversion on Input (Michael W. Fleming)
        Perl macros for vi <ken.chesak@dhs.state.tx.us>
        Perl on OS/2, can't run it (peter karlsson)
        previous link <ICEMOUNTAIN@prodigy.net>
    Re: Processing a comma delimited file <aqumsieh@matrox.com>
    Re: References <aqumsieh@matrox.com>
    Re: RegEx for html->plain text <aqumsieh@matrox.com>
        Setuid Question <dbohl@sgi.com>
    Re: Simple newbie problem... jon@osfn.org
    Re: Simple newbie problem... <aqumsieh@matrox.com>
    Re: sort routine - can it ignore numeric values? (Larry Rosler)
    Re: sort routine - can it ignore numeric values? <makkulka@cisco.com>
    Re: sort routine - can it ignore numeric values? <uri@sysarch.com>
    Re: Test this please (Clinton Pierce)
    Re: Test this please <laurensmith@sprynet.com>
    Re: Test this please (Michel Dalle)
        What's the quickest way to read a file <debot@xs4all.nl>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 04 Oct 1999 20:20:45 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Bug with localtime() in Perl 5.004 and 5.005
Message-Id: <37ff0461.196430231@news.ford.com>

[poster cc'd in e-mail]

On Mon, 04 Oct 1999 15:17:36 -0400, Robert Rothenberg
<rrothenberg@fsnt.gis.sunysb.edu> wrote:
>The localtime() function is not computing dates correctly.
>Run the code below and you get the folling glitch:
> [stuff omitted]
>Notice that October 31 is printed out twice (month is 0..11 in
>Perl).
>
>Or if this is not a bug but a "feature" please explain it to me.

Feature, not a bug.

>$seconds_per_day = 86400;

WRONG WRONG WRONG WRONG.

Not all days (locally adjusted) have 86400 seconds in them!  Specifically,
in most places in the United States (and Canada) days have either +3600 or
-3600 seconds twice a year.  This is due to an effect which I like to call
"Daylight Savings Time".  You can use that term as well, if you like.

>$epoch_time = timelocal(0, 0, 0, $day, $month, $year);
>
>do {
>    ($sec, $min, $hour, $mday, $mon, $year) = localtime($epoch_time);
>    $epoch_time += $seconds_per_day;
>    print $mon, "\t", $mday, "\t", $year, "\t", $epoch_time, "\n";
>} while ($mon<11);

This is silly, you're mixing GMT and localtime, you're headed for trouble.

Also, you print out your computed $mon, $mday, etc.. with the adjusted
$epoch_time.  This is misleading for debugging.  Let's re-write this:

>do {
>    ($sec, $min, $hour, $mday, $mon, $year) = localtime($epoch_time);
>    print $mon, "\t", $mday, "\t", $year, "\t", $epoch_time, "\t", 
>       scalar(localtime($epoch_time)), "\t", scalar(gmtime($epoch_time)), 
>	"\n";
>    $epoch_time += $seconds_per_day;
>} while ($mon<11);

Now check out a sample of output (wrapped for Usenet):

9       30      99      941256000       Sat Oct 30 00:00:00 1999
				        Sat Oct 30 04:00:00 1999
9       31      99      941342400       Sun Oct 31 00:00:00 1999
				        Sun Oct 31 04:00:00 1999
9       31      99      941428800       Sun Oct 31 23:00:00 1999
				        Mon Nov  1 04:00:00 1999
10      1       99      941515200       Mon Nov  1 23:00:00 1999
				        Tue Nov  2 04:00:00 1999

Notice that the gmtime() column (the bottom one) progresses quite nicely
from the 30th to the 2nd...without skipping or repeating anything.  The
localtime() column jumps BACKWARDS relative to gmtime...probably a
daylight savings time adjustment takes place there (and localtime() knows
that).  


Watch closely:

(Midnight)+(3600 seconds)-(DST adjustment for autumn)=11pm THE SAME DAY.



By the same token, if I adjust your little test into the year 2000, this
happens in late March/April:

2       31      100     954478800       Fri Mar 31 00:00:00 2000       
					Fri Mar 31 05:00:00 2000
3       1       100     954565200       Sat Apr  1 00:00:00 2000
				        Sat Apr  1 05:00:00 2000
3       2       100     954651600       Sun Apr  2 00:00:00 2000
				        Sun Apr  2 05:00:00 2000
3       3       100     954738000       Mon Apr  3 01:00:00 2000
				        Mon Apr  3 05:00:00 2000

Notice that April 3rd (happy birthday to me!) is now an hour out of kilter
again with respect to March 31st-April 2nd?  (Since I've got the time
knocked forward to 5am, the GMT-4 doesn't play into it anymore...)


Good luck!  And quit computing time by hand, there's nice modules to do
that for you.
-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Mon, 04 Oct 1999 15:24:56 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Bug with localtime() in Perl 5.004 and 5.005
Message-Id: <37F90D18.24A631B1@texas.net>

Robert Rothenberg wrote:
> 
> The localtime() function is not computing dates correctly.
> Run the code below and you get the folling glitch:
> 
>   9     30      99      941342400
>   9     31      99      941428800
>   9     31      99      941515200
>   10    1       99      941601600
>   10    2       99      941688000
> 
> Notice that October 31 is printed out twice (month is 0..11 in
> Perl).
> 
> Or if this is not a bug but a "feature" please explain it to me.

Of course it's a feature.

Before you make a fool out of yourself (again), try to test your code a
bit more thoroughly.  Keep in mind that there are alot of very
high-level professionals using Perl, and this type of bug would be
virtually impossible.

For starters, try changing the hour field in your timelocal call to
something around midday.

- Tom


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

Date: Mon, 04 Oct 1999 20:24:02 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Bug with localtime() in Perl 5.004 and 5.005
Message-Id: <38000cac.198553174@news.ford.com>

On Mon, 04 Oct 1999 20:20:45 GMT, cpierce1@ford.com (Clinton Pierce)
wrote:
>(Midnight)+(3600 seconds)-(DST adjustment for autumn)=11pm THE SAME DAY.

s/3600/86400/

-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Mon, 4 Oct 1999 13:13:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Can I have a subroutine return a hash?
Message-Id: <MPG.1262aa54ec0c74c398a032@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <4t7K3.27$BD3.1872@typhoon.nyu.edu> on Mon, 04 Oct 1999 
19:45:04 GMT, Ruben Safir <ruben@llinderman.dental.nyu.edu> says...

[Rearranged to resemble normal human discourse -- question before 
answer]

> In article <37CCA3A2.C5832276@ix.netcom.com>,
> 	gremlin <gremlin_NO_SPAM_@ix.netcom.com> writes:
> > I would like to call a subroutine and have that routine open up a file,
> > add data to a hash, and return the new hash to the calling routine.  I
> > have everything working except getting the data back to the caller!  Can
> > anyone show me the declaration; call; sub. return statement that will
> > make all this work?

> No

WRONG!!!  Of course you can return a hash.  It is flattened into a key 
=> value list, which you can put together by assignment to a hash.

> But you can return a hash reference.

That is another way to do it, which may indeed be more efficient, but 
that isn't what was requested.

Maybe you should have read perlsub before you answered so dogmatically.  
Here is the beginning of its second paragraph:

The Perl model for function call and return values is simple: all 
functions are passed as parameters one single flat list of scalars, and 
all functions likewise return to their caller one single flat list of 
scalars. Any arrays or hashes in these call and return lists will 
collapse, losing their identities--but you may always use pass-by-
reference instead to avoid this. 

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


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

Date: 4 Oct 1999 16:15:35 GMT
From: "Vorname Name" <Vorname.Name@pcm.bosch.de>
Subject: Conversion ASCII flat file into Excel spreadsheet file
Message-Id: <01bf0e83$1da4d6b0$480e7891@be14p072>

Hello Win32 wizards,

coming from Unix I haven't so far given much care to
Windoze applications and the file formats Mightgosoft
is using.
Unfortunately, I am forced to rely on NT and was
asked to convert output from an Oracle Server which
is run on HP-UX into MS's proprietary Excel format.

Having no knowledge of the Excel format whatsoever
but feeling quite comfortable with Perl I thought this
would be an easy task for a Perl script.
So I scoured through CPAN's Win32 modules in
hope to find something appropriate, but anything
that comes closest to my understanding was the
Win32::OLE module.
But being unfamiliar with OLE this scared me off a bit.

I am convinced that there already exist loads of
file format conversion scripts that can do the job.

Has anyone a hint?

Regards
Ralph


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

Date: 4 Oct 1999 20:45:15 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Conversion ASCII flat file into Excel spreadsheet file
Message-Id: <7tb3kr$15k$1@xenon.inbe.net>

Vorname.Name@pcm.bosch.de (Vorname Name) wrote in 
<01bf0e83$1da4d6b0$480e7891@be14p072>:
>Hello Win32 wizards,
>
>coming from Unix I haven't so far given much care to
>Windoze applications and the file formats Mightgosoft
>is using.
>Unfortunately, I am forced to rely on NT and was
>asked to convert output from an Oracle Server which
>is run on HP-UX into MS's proprietary Excel format.

You could CSV format (or any other 'basic' format like
pipe-separated, or fixed-length, etc.). Excel can then
import your format directly...

This will be much quicker than trying to use OLE (or
the gobbledygook format that Excel uses internally).

Michel.


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

Date: Mon, 04 Oct 1999 17:05:02 -0400
From: Matt <mck@iag.net>
Subject: Re: Conversion ASCII flat file into Excel spreadsheet file
Message-Id: <JRb5N46gMtSqvcT3wzlad0xwv=ON@4ax.com>

On 4 Oct 1999 20:45:15 GMT, michel.dalle@usa.net (Michel Dalle) wrote:

>Vorname.Name@pcm.bosch.de (Vorname Name) wrote in 
><01bf0e83$1da4d6b0$480e7891@be14p072>:
>>Hello Win32 wizards,
>>
>>coming from Unix I haven't so far given much care to
>>Windoze applications and the file formats Mightgosoft
>>is using.
>>Unfortunately, I am forced to rely on NT and was
>>asked to convert output from an Oracle Server which
>>is run on HP-UX into MS's proprietary Excel format.
>
>You could CSV format (or any other 'basic' format like
>pipe-separated, or fixed-length, etc.). Excel can then
>import your format directly...
>
>This will be much quicker than trying to use OLE (or
>the gobbledygook format that Excel uses internally).
>
>Michel.

Agreed, CSV (quote-comma delimited) is your best bet. Additionally,
installing Excel on a PC causes the association for .CSV files to be
set to Excel. 



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

Date: Mon, 04 Oct 1999 16:53:33 -0500
From: Kangas <kangas@anlon.com>
Subject: converting to Linux from NT but need a hand.
Message-Id: <37F921DD.9623F361@anlon.com>

I have MySQL running, KMySQL running, perl running. But I want to
install the DBD::MySQL so that I can use perl to connect to my database
When I run through the `perl Makefile.PL` for the msq module it asks me
for the mysql.h file location in the 'include' subdirectory of my MySQL
installation.

I have used the search too for mysql.h and *sql*h to find it but it is
NOT on my machine. How can i get around this? Thanks.

--
Michael Kangas
kangas@anlon.com




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

Date: Mon, 4 Oct 1999 10:31:27 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Editing Perl scripts with emacs
Message-Id: <x3y905jrydc.fsf@tigre.matrox.com>


Eric Rountree <rountree@cs.queensu.ca> writes:

> I use emacs to edit my perl scripts, and I really like the automatic
> indentation feature. Unfortunately, the perl mode of my emacs does not
> deal well with constructs like the following:
> 
>      ${coursesByCourseId{$course}}[4]
> 
> The curly braces around the variable names seem to mess up the
> automatic indentation.

My emacs deals with those just fine.

> Is there a way to fix this?

I would suggest downloading the latest cperl-mode. Get it from

http://www.cpan.org/modules/by-authors/Ilya_Zakharevich/cperl-mode/

--Ala



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

Date: Mon, 04 Oct 1999 20:34:36 GMT
From: arahkay@my-deja.com
Subject: Getting variable contents from other files
Message-Id: <7tb30r$jgr$1@nnrp1.deja.com>

Help!

I want to use the contents of certain assigned
variables in my perl program.

For example,

If I have a .kayrc file (written in perl) that
assigns $NODE_DIR = "/home/karah";
How do I grap the value of $NODE_DIR for the file
kay.pl.

I thought maybe a use statement would be appropriate,
instead of doing an open, reading contents into an
array and then doing a grep.



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


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

Date: Mon, 04 Oct 1999 19:44:41 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Help! I'm having big trouble searching my database
Message-Id: <37fe0279.195942069@news.ford.com>

[poster cc'd in e-mail]

On Mon, 04 Oct 1999 19:06:53 GMT, sleepernyc@my-deja.com wrote:
>Might anyone be willing to look at this code and offer suggestions?
>check out www.tasteofbrooklyn.com/tob/cgi-bin/dbman/main3.html

There is no code here, only a stupid web page.  You want is to look at
your HTML or something? 

Begone!  Next time show us some Perl we can look at.




-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: 4 Oct 1999 19:47:51 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Input/output from programs
Message-Id: <7tb097$av1$1@gellyfish.btinternet.com>

On Mon, 04 Oct 1999 09:46:17 -0700 Paul Walker wrote:
> In article
> <Pine.GSO.4.10.9910040721590.14462-100000@crusoe.crusoe.net>, Jeff
> Pinyan <jeffp@crusoe.net> wrote:
> 
>>   use IPC::Open2;
>>   open2(\*READ, \*WRITE, "program", "arg1", "arg2") or
>>     die "can't run program: $!";
>>   print WRITE "...\n";
>>   chomp($ans = <READ>);
> [snip]
> 
> Looks promising, anyway. :-) Doesn't quite work just yet, but I'll see
> if I can get our IT department to install a newer version of perl first
> (we're still using 5.001, for some reason).
> 

Yes I would definitely do that - not only does 5.001 not have IPC::Open2
as far as I can recall but also has bugs that have subsequently been fixed.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: 4 Oct 1999 19:33:11 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Loading code at run-time
Message-Id: <7tavdn$auu$1@gellyfish.btinternet.com>

On Mon, 04 Oct 1999 18:15:04 GMT Channing wrote:
> 
> Jonathan Stowe wrote:
>> 
>> Robert Young <tekwiz@home.com> wrote:
>> > I am interested in knowing the technique for loading new code at runtime.
>> > Specifically, the port to SCO UNIX that I have does not have many of the
>> > very nice modules that are included in the resource kit (not in the source
>> > code either), such as the DateCalc and the DateManip modules.
>> >
<snip>
>> 
>> Sorry I'm not quite sure what you mean - I use SCO at work and have built
>> perl and installed several modules - what specific problems are you having ?
>> 
> 
> If I may ask.  
> Which SCO (and version) and what Perl version ?

OpenServer 5.0.5a
Development system 5.1.1a
RSS505 - recommended service patches
OSS499a - Important patch for dynamic linker bug in ln

Perl 5.005.03

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>


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

Date: Mon, 04 Oct 1999 20:53:37 +0000
From: Douglas Nichols <dnichols@fhcrc.org>
Subject: mod_perl type handler?
Message-Id: <37F913D1.B36F094E@fhcrc.org>

I have compiled apache 1.3.9 and mod_perl 1.21 & httpd -l
gives:
Compiled-in modules:
  http_core.c
  mod_env.c
  mod_log_config.c
  mod_mime.c
  mod_negotiation.c
  mod_status.c
  mod_include.c
  mod_autoindex.c
  mod_dir.c
  mod_cgi.c
  mod_asis.c
  mod_imap.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_access.c
  mod_auth.c
  mod_setenvif.c
  mod_perl.c

So when I try to crank  this succker up I get 

Starting httpd: 
Syntax error on line 324 of /etc/httpd/conf/httpd.conf:
Invalid command 'PerlTypeHandler', perhaps mis-spelled or defined by a
module not included in the server configuration
                                                           [FAILED]

The lines that I use look like this:

PerlModule Apache::Roaming
<location /roaming>
        PerlHandler Apache::Roaming->handler
        PerlTypeHandler Apache::Roaming->handler_type
        AuthType Basic
        AuthName "Roaming User"
        AuthUserFile /etc/httpd/users
        require valid-user
        PerlSetVar BaseDir /home/httpd/html/roaming
</Location>

So Does anyone have an idea what I am forgetting? seems to look good the
mod_perl loaded Apache-Roaming in installed in the correct places...,
/usr/lib/perl5/site_perl/Apache/Roaming.pm and some other files.

Thanks for you help!
-- 
Cheers, dn

Douglas Nichols                              dnichols@fhcrc.org
---------------------------------------------------------------
National Wilms Tumor Study Group                   206.667.4283
Seattle, WA


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

Date: Mon, 04 Oct 1999 20:49:56 GMT
From: nigh_postal <nigh_postal@my-deja.com>
Subject: Net::SMTP
Message-Id: <7tb3tf$k3h$1@nnrp1.deja.com>

I'm trying to write a bulk email program using the Net::SMTP module and
I'm running into some problems.  I've showed my code to various people,
and they all say it looks right.  What I need help with is determining
what my be causing it to fail.  I've posted the code below.  Assume
that @email_addr contains the list of emails to send to.

For obvious reasons, I've replace the mail server address with a bogus
one.

    $smtp = Net::SMTP->new('mailserver');
    $smtp->mail('foo');
    $smtp->to(@email_addr);
    $smtp->data();
    $smtp->datasend("From: $email_from\n");
    $smtp->datasend("Date: $email_date\n");
    $smtp->datasend("To: Blah\n");
    $smtp->datasend("Subject: $email_subject\n\n");
    $smtp->datasend("$TxtToSend\n\n");
    $smtp->dataend();
    $smtp->quit;

Now the thing is, I am on this list about 1/4 of the way up (about 130
on the list), and everytime the cgi runs I get the email.  But we are
getting complaints that some aren't recieving it.  So somewhere along
the line the process is failing.  I've tried sending it in chunks of 50
and even 20 but still no luck.  If anybody knows why this code might
not be working, please let me know.

-Cody


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


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

Date: Mon, 04 Oct 1999 14:09:48 -0700
From: mfleming@csub.edu (Michael W. Fleming)
Subject: Re: Newbie: Chomp and Case Conversion on Input
Message-Id: <mfleming-0410991409480001@cserv51.csubak.edu>

In article <MPG.12629add13dcb82e98a030@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:

>You're welcome.  Now I have to wonder why anyone cares about piling 
>several operations into one statement.  Does Cal State Bakersfield 
>charge exorbitant rates per semicolon?

Only $.01 per 100, but they add up :).

Call it economy, call it perverse logic, call it my version of PerlThink
laziness--if I have a semi-standard way of treating my input, it's easier
to remember one line.

Michael

-- 
Michael W. Fleming, Network Analyst, California State University
Voice/mail:(661)664-2118 (24hrs)  Fax:(661)664-2099 (24hrs)
Disclaimer: I directly represent only myself and my family;
            indirectly, I represent God and all His creation.


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

Date: Mon, 4 Oct 1999 15:23:37 -0500
From: "Ken Chesak" <ken.chesak@dhs.state.tx.us>
Subject: Perl macros for vi
Message-Id: <7tb2g0$qp4$1@news.tdh.state.tx.us>

Where can I get Perl macros for vi?

 I tried the following link in Perl FAQ  and it is not valid.
http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc,

Thanks




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

Date: 4 Oct 1999 23:34:10 +0100
From: pk@mds.mdh.se (peter karlsson)
Subject: Perl on OS/2, can't run it
Message-Id: <slrn7vi7ai.d35.pk@dat95pkn.campus.mdh.se>

Hi!

First of all, I'm sorry if this is the wrong place to post, but I couldn't
find any other...

I downloaded Perl 5.005_53 for OS/2 from www.perl.com, but can't get it to
run correctly. I used the GUI installer, and it finished correctly (except
that I skipped installing its sh.exe, since I already had a sh.exe pointing
to bash.exe in that directory).

However, after the required reboot, I can't get it to run. It answers almost
everything I do with "Malformed PERLLIB_PREFIX". It is set to
"E:/APP/PERLLIB/LIB", which is where I installed it. I had it set to
"E:\APP\PERLLIB\LIB" (which was what the installation program set it to),
but since that didn't work, I switched the slashes, to no avail.

Does anyone know about this? I would appreciate any help!

-- 
\\//
peter - who has recently became a Perl addict.

Please Cc: replies to me, as I don't know how long my news server keeps
messages in this group.


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

Date: Mon, 4 Oct 1999 17:51:26 -0400
From: <ICEMOUNTAIN@prodigy.net>
Subject: previous link
Message-Id: <7tb7uj$2bnc$1@newssvr04-int.news.prodigy.com>

I made a script to display a camaro gallery. Everything works perfectly
except the previous link, It is there but It is always there even when there
isn't anything before it to see.
Here is the script:

$max = 4;
$last = $FORM{'num'} + $max;
$next = $last + 1;
$prev = $FORM{'num'} - $max;

open(TEXT,"gallerydata.txt");
@info = <TEXT>;
close(TEXT);

$searchstr_year = "$FORM{'year'}";
$searchstr_model = "$FORM{'model'}";


if($last < $#info) {
 for($i=$FORM{'num'}; $i<=$last; $i++) {
  ($year,$model,$numb,$width,$lwidth,$lheight,$desc,$align) = split(/\|/,
@info[$i]);
 if (($year eq $searchstr_year) || ( $model eq $searchstr_model ))
        {
     print "<tr><td align=center>\n";
  print "<a
href=http://www.3gc.net/cgi-bin/scripts/backup/gallerytest.cgi?action=desc&m
odel=$model&year=$year&numb=$numb><img
src=/gallery/$model{$FORM{'model'}}/images/$year$numb\small.jpg border=0
width=$width height=150 alt=\"Click for larger image and
description\"></a>\n";
  print "</td></tr><tr><td align=center><a
href=http://www.3gc.net/cgi-bin/scripts/backup/gallerytest.cgi?action=desc&m
odel=$model&year=$year&numb=$numb>19$year $FORM{'model'}</a></td></tr>\n";
        }
 }
 print "</table><br><img src=\"/images/blank.jpg\" width=\"1\"
height=\"10\"><br>\n";
 if (($FORM{'num'} < $#info) && ($prev < $#info)) {
 print "<a
href=\"gallerytest.cgi?action=$FORM{'action'}\&model=$FORM{'model'}\&num=$pr
ev\">Previous</a>\&nbsp;\&nbsp;\&nbsp;\n";
 }
 if ($last < $#info) {
 print "<a
href=\"gallerytest.cgi?action=find_model\&model=$FORM{'model'}\&num=$next\">
Next</a>\n";
 }
}




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

Date: Mon, 4 Oct 1999 11:49:42 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Processing a comma delimited file
Message-Id: <x3yhfk76s89.fsf@tigre.matrox.com>


ebohlman@netcom.com (Eric Bohlman) writes:

> What you really want to do is use a hash keyed by the field titles.  You 
> can set it up very easily by using hash slices:
> 
>  while (<DB>) {
>      my @fields{@vars} = parse_csv($_);

The above will generate a compile-time error:

	Can't declare hash slice in my at - line x, near "} ="

You have to actually do it in two steps:

	my %fields;
	@fields{@vars} = parse_csv($_);

I made this error multiple times in the past. But, I was never able to
guess why this error is necessary. Why shouldn't I be able to declare
a hash slice in my()? Anybody with a good reason?

--Ala



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

Date: Mon, 4 Oct 1999 10:58:20 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: References
Message-Id: <x3y7ll3rx4k.fsf@tigre.matrox.com>


perl@bjclark.com (Brian) writes:

[snip]

>    $html =~ s!\$(\w+)!${$1}!g;

[snip]

> The program above is supposed to substitute the values for the scalars
> $subject and $sigline in the program into two of the form input
> values. In other words, it's just recalling previous user settings
> when the page is loaded.

The little snippet above is actually identical to what the perlfaq4
suggests. Good.

> When I test the syntax using perl -c it tells me 'syntax OK.', but
> when I run the program it returns:
> 
>   Can't use string ("subject") as a SCALAR ref while "strict refs"
>   in use at ref-example.pl line 20.
> 
> I'm pleading for any input that may help me to understand the
> referencing, or lack thereof, that is happening in the particular
> piece of code above.

The reference is being done in the substitution part of the
regexp. You match a '$' character, followed by a word, and then you
try to use that word as a variable name. This is called symbolic
referencing, and its use is generally discouraged (due to reasons you
know very well by now :-).

The strict pragma doesn't allow you to use symbolic references. It
says so in the 'strict' docs:

     strict refs
           This generates a runtime error if you use symbolic
           references (see the perlref manpage).

So, you have two solutions.

1) You can disable the strict refs pragma in a certain limited scope,
where you apply your substitution. Something like:

	{
		no strict 'refs';
		$html =~ s!\$(\w+)!${$1}!g;
	}

2) you could create a hash of the variables you will match in your
regexp. So, for example, instead of defining a variable:

	$subject = 'bla';

you would define a hash with a key 'subject' and value 'bla'.

	my %hash;
	$hash{subject} = 'bla';

And to perform the substitution, you would do:

	$html =~ s!\$(\w+)!$hash{$1}!g;

I would choose the second solution.

HTH,
--Ala



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

Date: Sun, 3 Oct 1999 19:34:20 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: RegEx for html->plain text
Message-Id: <x3yvh8ovx2l.fsf@tigre.matrox.com>


sam@samredman.com writes:

> I am new to Deja so I didn't realize that this had nothing to do with
> Python assuming that if I linked from Python.org it had to be "on
> subject".  So, sorry about the posts, I will attempt to find a similar
> Python forum.

No Wait. Perhaps fate is trying to tell you something here ;)

Try out Perl. You won't regret it.

--Ala



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

Date: Mon, 04 Oct 1999 15:32:47 -0500
From: Dale Bohl <dbohl@sgi.com>
Subject: Setuid Question
Message-Id: <37F90EEF.2944C4A1@sgi.com>


  Does anyone know how to use Perl to
traverse a file tree to find all setuid root
executables on UNIX?
-- 

Thanks,
Dale

Dale Bohl
SGI Information Services
Engineering Building
1050 Lowater Road
Chippewa Falls, WI 54729-1445
dbohl@sgi.com
(715)-726-8406


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

Date: Mon, 04 Oct 1999 20:58:52 GMT
From: jon@osfn.org
Subject: Re: Simple newbie problem...
Message-Id: <gy8K3.7200$L4.532037@typ12.nn.bcandid.com>

Jonathan Stowe <gellyfish@gellyfish.com> wrote:
:On Fri, 01 Oct 1999 23:39:42 GMT jon@osfn.org wrote:
:> Hi,
:> 
:> I need to replace one string with an other in multiple .html documents
:> 

:I had also forgotten that Tom Christiansen posted a program quite recently
:here that would do exactly this - I'm sure you will be able to find it on


perl -pi -e's/x/y/i;' *.html

is exactly what I needed (didn't occur to me to check runtime
switches). Forgiveness please for not crediting the author of a
preceding post who recommended this one liner...

-- 
Email: jon@osfn.org			Web:
       jdp@efn.org			http://users.ids.net/~tuan/


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

Date: Mon, 4 Oct 1999 10:25:58 -0400 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Simple newbie problem...
Message-Id: <x3ybtafrymi.fsf@tigre.matrox.com>


moseley@best.com (Bill Moseley) writes:
> jon@osfn.org (jon@osfn.org) seems to say...

[snip]

> > how do I now edit these files (I want the changed file to have the
> > original name??
> 
> Check out the -I switch.  Program Perl has an example (lookup -I in the 
> index) or perldoc perlrun and look at the -I examples.

I think perhaps you meant the '-i' switch. Perl is case sensitive, you
know :)

--Ala



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

Date: Mon, 4 Oct 1999 13:08:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sort routine - can it ignore numeric values?
Message-Id: <MPG.1262a902d73c7c4998a031@nntp.hpl.hp.com>

In article <37F8FD6A.707A872A@1185design.com> on Mon, 04 Oct 1999 
12:18:04 -0700, mikej <mikej@1185design.com> says...
> I have a list of names and corresponding ID numbers in an array that
> goes something like this:
> 
> 0    Rossi, Valentino
> 1    Abe, Norick
> 2    Okada, Tadayuki
> ..................on and on until..............
> 5089    Roberts, Kenny
> 
> My dilemma is that I want to sort this list alphabetically by the last
> names while ignoring any and all the numbers in front. Putting the
> numbers in back of the name is unfortunately not an option. Is this
> possible using the sort routine and if so can someone give me an
> example?

perlfaq4: "How do I sort an array by (anything)?"

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


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

Date: Mon, 04 Oct 1999 13:12:34 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: sort routine - can it ignore numeric values?
Message-Id: <37F90A31.A6FB725B@cisco.com>

{ mikej wrote:

> My dilemma is that I want to sort this list alphabetically by the last
> names while ignoring any and all the numbers in front. Putting the
> numbers in back of the name is unfortunately not an option. Is this
> possible using the sort routine and if so can someone give me an
> example?

my @data = <DATA>;
@data = sort  map { (split (/\s+/, $_))[1] }  @data ;
print  join  "\n", @data ;
exit ;

__DATA__
0    Rossi, Valentino
1    Abe, Norick
99l  Kulkarni, Makarand
2    Okada, Tadayuki
5089 Roberts, Kenny
22 Landau, Dominic




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

Date: 04 Oct 1999 17:06:03 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: sort routine - can it ignore numeric values?
Message-Id: <x7emfau98k.fsf@home.sysarch.com>

>>>>> "MK" == Makarand Kulkarni <makkulka@cisco.com> writes:

  MK> my @data = <DATA>;
  MK> @data = sort  map { (split (/\s+/, $_))[1] }  @data ;
  MK> print  join  "\n", @data ;
  MK> exit ;

  MK> __DATA__
  MK> 0    Rossi, Valentino
  MK> 1    Abe, Norick
  MK> 99l  Kulkarni, Makarand
  MK> 2    Okada, Tadayuki
  MK> 5089 Roberts, Kenny
  MK> 22 Landau, Dominic

that generates this:

Abe,
Kulkarni,
Landau,
Okada,
Roberts,
Rossi,

not too useful for the original poster as it loses the first names as
well as the numbers. please try again and come up with a better
answer. larry's reply of a perlfaq is more appropriate.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Mon, 04 Oct 1999 19:35:05 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Test this please
Message-Id: <37fbfe28.194836950@news.ford.com>

On Mon, 04 Oct 1999 20:20:29 +0100, Danny Verkade <webmaster@mybegin.com>
wrote:
>I've created a CGI/Perl program and hope that you can test it. The
>program will retrieve the latest headlines and displays them in my own
>format. Can you please tell me what you think about it?? Is anything
>wrong with it, do you see mistakes?

}> test code
I see no code here

}> look url
There is no url here

}> look newbie
newbie is wearing a stupid grin and a nametag which
    reads "webmaster", written in crayon, on a napkin, 
    and pinned upside down to his 
    "I'm with Stupid" t-shirt.

}> club newbie
What should I club newbie with?

}> club newbie with cluestick
newbie dies a horrible death, with multiple contusions,
    lacerations, and broken bones.  Whimpering pitifully,
    his last words are "So, did you see mistakes?"

-- 
Clinton A. Pierce       "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org        Miracles."  -- Miracle Max, The Princess Bride
http://www.geeksalad.org


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

Date: Mon, 4 Oct 1999 13:12:01 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Test this please
Message-Id: <7tb1n8$vtf$1@brokaw.wa.com>


Danny Verkade wrote in message <37F91578.474B3F61@mybegin.com>...
>
>Makarand Kulkarni wrote:
>
>> [ Danny Verkade wrote:
>>
>> > Can you please tell me what you think about it?? Is anything
>> > wrong with it, do you see mistakes?
>>
>> I don't see any code.
>
>Well, of course you don't see any code. [something something]
HAHAHAHAHAHAHA...  haaa...

Lauren
--
Mmm.. Black box testing...




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

Date: 4 Oct 1999 20:29:37 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Test this please
Message-Id: <7tb2nh$t5m$1@xenon.inbe.net>

webmaster@mybegin.com (Danny Verkade) wrote in
<37F915A1.31335ACB@mybegin.com>: 
>Abigail wrote:
>
>> Danny Verkade (webmaster@mybegin.com) wrote on MMCCXXV September
>> MCMXCIII in <URL:news:37F8FDFC.71FEBE1E@mybegin.com>:
>> $$
>> $$ I've created a CGI/Perl program and hope that you can test it. The
>> $$ program will retrieve the latest headlines and displays them in my
>> own $$ format. Can you please tell me what you think about it?? Is
>> anything $$ wrong with it, do you see mistakes?
>>
>> I think it's perfect. Nice and quiet.
>
>Great, any reccomentations.?

Well, what about posting the URL you're referring to ? (*)
That would be a big improvement (I think).

But post it in comp.infosystems.www.authoring.cgi, please !


Michel.
(*) unless the URL is your homepage, of course, in which case
I would recommend that you place your test-CGIs somewhere else :)


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

Date: Tue, 05 Oct 1999 00:00:01 +0200
From: Frank de Bot <debot@xs4all.nl>
Subject: What's the quickest way to read a file
Message-Id: <37F92360.8621DD4@xs4all.nl>

What is the quickest way to read a file of about 2800 Kb? I want to read
as fast as possible (and every ms is one too much for a script to me).
Currently I have benchmark times from over 0.35 Cpu on the script. I bet
this can be much faster. I know a few methods to load a file, but I let
you say it which your fasted method is. Maybe it's one I never saw
before.

thanks,

Frank de Bot




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

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


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