[15520] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2930 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 3 03:05:29 2000

Date: Wed, 3 May 2000 00: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: <957337510-v9-i2930@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 3 May 2000     Volume: 9 Number: 2930

Today's topics:
    Re: [IMPORTANT] Content-type to download an image! <charles.henry@engineer2k.com>
    Re: bourne 'dot' or csh 'source behavior (Stuart Hutchison)
    Re: Can anyone recommend a good book (Tad McClellan)
    Re: Clear and then Reuse a package name space richard_chen@my-deja.com
    Re: DB_File Question <bwalton@rochester.rr.com>
    Re: DB_File Question stevenm@blackwater-pacific.com
    Re: Help with substitution operator. <krasi77@yahoo.com>
    Re: Help with substitution operator. (Craig Berry)
    Re: Help with substitution operator. (Tad McClellan)
        installing perl5.6.0 on sunos 5.3 problem <citecdjc@citec.qld.gov.au>
    Re: making croak _not_ act like confess (Charles DeRykus)
    Re: Order of evaluation (Was: Re: regex) <lr@hpl.hp.com>
        Perl & CGI Script Resource <web-botNOweSPAM@cgiextremes.com.invalid>
    Re: Perl CGI Script Crashes on Win2K but not at Command <KidRockYou@yahoo.com>
    Re: Perl CGI Script Crashes on Win2K but not at Command (Sam Holden)
        Permission denied on a read write file under Win98 <vulcan_c2@hotmail.com>
    Re: Puzzled - Please help. (Tad McClellan)
    Re: References and hashes <bmb@ginger.libs.uga.edu>
    Re: Regular Expression and HTML tags <Tbone@pimpdaddy.com>
        Reload a text file? <kamri@nortelnetworks.com>
    Re: Reload a text file? <jeff@vpservices.com>
    Re: resizing an image (Eric Bohlman)
        return value of bare subroutine in list/scalar context <lancon@mail.ce.utexas.edu>
    Re: return value of bare subroutine in list/scalar cont <rootbeer@redcat.com>
        searching file and performance (Mats Larsson)
    Re: setting an array in a Struct? <lr@hpl.hp.com>
        sort() <s0218327@unix1.cc.ysu.edu>
    Re: Thanks Craig. (Craig Berry)
    Re: toggling read-only flag for files in win32 <oliver@rutherfurd.net>
    Re: Unicode in Perl 5.6 - broken? <blape@grey-net.com>
    Re: Unicode in Perl 5.6 - broken? <bertilow@hem.passagen.se>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 3 May 2000 03:08:47 +0200
From: "Charles Henry" <charles.henry@engineer2k.com>
Subject: Re: [IMPORTANT] Content-type to download an image!
Message-Id: <8enukc$4o0$1@news3.isdnet.net>

> > code will prevent most people from hotlinking my logo
>             ^^^^^^^^^^^^^^^^^^^
>
> So, in spite of your original claim, you now admit that you cannot
> "force" it.

damn




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

Date: Tue, 2 May 2000 20:47:26 -0600
From: shutchis@incentre.net (Stuart Hutchison)
Subject: Re: bourne 'dot' or csh 'source behavior
Message-Id: <MPG.13794128f89d88c5989680@news.newsfeeds.com>

In article <x7itwwy2o9.fsf@home.sysarch.com>, uri@sysarch.com says...
> >>>>> "ANM" == Andrew N McGuire <andrew.mcguire@walgreens.com> writes:
> 
> 
>   ANM> my $config = "/path/to/some/config/file";
>   ANM> %ENV = ();
>   ANM> my @shenv = `sh -c ". $config; /usr/bin/env"`;
>   ANM> chomp @shenv;
>   ANM> %ENV = map { split /=/ } @shenv;
> 
> not a bad solution. do you really want this to set the entire ENV
> including stuff set before the perl script started and stuff set by perl?
> if not, then set another hash first %SH_ENV the way you do with %ENV and
> then you can decide whether those values override the existing %ENV or
> not.
> 
> shell overrides:
> 
> %ENV = ( %ENV, %SH_ENV ) ;
> 
> or
> 
> @ENV{ keys %SH_ENV } = values %SH_ENV ;
> 
> %ENV overrides:
> 
> %ENV = ( %SH_ENV, %ENV ) ;
> 
> uri
> 
> 
Excellent! Thank you all. Not too blatent, I hope.

regards,
Stuart Hutchison
shutchis@incentre.net
(Apologies for the address change; far easier to post from here.)


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Tue, 2 May 2000 19:20:46 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can anyone recommend a good book
Message-Id: <slrn8guome.64s.tadmc@magna.metronet.com>

On Tue, 02 May 2000 22:22:30 GMT, Jon S. <jonceramic@nospammiesno.earthlink.net> wrote:

>The O'Reilly Perl books get you started great and teach
              ^^^^^^^^^^
>you Perl great, but for this newbie, they are a little short on
>specifics for web use.


Because they are *Perl* books, not web books.

Get a book about the web if you want to read stuff about the web  :-)

Perl is not the web. The web is not Perl. 

Perl was getting work done before the CGI even existed.


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


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

Date: Wed, 03 May 2000 02:09:36 GMT
From: richard_chen@my-deja.com
Subject: Re: Clear and then Reuse a package name space
Message-Id: <8eo1om$idg$1@nnrp1.deja.com>

One example is making legacy cgi scripts to work under modperl.
There you can use Apache::Registry to wrap you cgi script
as another package and this gets cached by apache server
and used many times.

Since each invocation of the script will involve completely
different variables in a given specified package name space,
it is absolutely essential to clear and then reuse the name space.
Otherwise, one request's data will get used by the next request.

We have a lot of cgi scripts which fill up data in a dynamically
generated package and then use that in template files.
Since we are talking about not doing too much rewriting of
the cgi scripts, the motivation of this question is clear.

Sorry I did not give enough motivation for this. But I think
this should be feasible in perl, given that it is such
a mature language. The question is not how to do it another way,
but if there is a way to do it head on.

Thanks for responding.

Richard


In article
<Pine.GSO.4.10.10005021631461.13677-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On Tue, 2 May 2000 richard_chen@my-deja.com wrote:
>
> > in some cases a perl process may have to reuse the same package name
> > space many times.
>
> Can you give an example of this? Perhaps there is a better way to do
> whatever you're trying to do. In fact, I'm almost completely certain
that
> there is. :-)
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>
>


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


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

Date: Wed, 03 May 2000 02:19:29 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: DB_File Question
Message-Id: <390F8BC0.5C8D6CD1@rochester.rr.com>

spurcell wrote:
> 
 ...
>     # we need to open the portfolio hash and deal with it.
>     tie (%SN, 'DB_File', "$lbPortfolio/$jobid", O-RDWR, 0777)
O_RDWR--------------------------------------------^^^^^^
>         or &squawk("Problems opening the lbPortfolio jobhash to remove the
> single entry from the deletion.");
 ...
> Scott
-- 
Bob Walton


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

Date: Wed, 03 May 2000 06:48:13 GMT
From: stevenm@blackwater-pacific.com
Subject: Re: DB_File Question
Message-Id: <NYPP4.15$2c1.23709@bcandid.telisphere.com>

In article <390f431c$0$1864@wodc7nh1.news.uu.net>, "spurcell"
 <skpurcell@hotmail.com> wrote:
> Hello,
> I have the code below, which opens a DB_File., and then I quickly print out
> its contents. Which is good and works. But then I add a new key and val, and
> reprint it out, but I never seen my new entry?


   tie (%SN, 'DB_File', "$lbPortfolio/$jobid", O-RDWR, 0777)

One thing mentioned by another poster: O-RDWR is not correct, 
though I wonder if that's the whole problem....

You wind up with a tied hash %SN, 
then you do:   $SN{'scott'} = 'perl5';

Ok so far.

Then you print the key/values of $LB????

I'm at a loss (based on the code snippet you posted) why %LB should reflect
any changes made to %SN....

Steve
 .  




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

Date: Wed, 03 May 2000 01:30:04 GMT
From: Krasimir Christozov <krasi77@yahoo.com>
Subject: Re: Help with substitution operator.
Message-Id: <sgv08si11g2160@corp.supernews.com>

1,000 is interpreted as a string value, converted to a number and then 
added. And any string that contains a character which is not a digit or 
dot is evaluated as 0 when being converted to a number.

try

$data_line =~ s/,//;

if you want to remove the ","'s.

Dan Burch wrote:
> 
> This is probably an easy one, but I'm new to Perl and I'm having a hard
> time figuring this. I have a txt file with line that contain QTY SOLD
> and then space delimited fields with monthly totals that I can split on.
> The problem is commas in numbers over 1000 like 1,000.  If I just try to
> add up the fields it works for numbers under 1000, but gives a zero
> value for numbers with the comma.  This is what I'm trying:
> 
>         elsif (  "$data_line[1]" =~ /QTY SOLD/  )
>         {
> 
> 
>          local $year_total = ($data_line[2] +$data_line[3]
> +$data_line[4] +$data_line[5] +$data_line[6] +$data_line[7]
> +$data_line[8] );
> 
>                 print DATA_OUT "$year_total,";
>         }
> 
> I tried :
> 
>   foreach $data_line ( @data_line )
> {
>     $data_line = s/,//;
> }
> 
> ahead of getting the total but that doesn't seem to work.
> 
> Any Suggestions would be greatly appreciated.
> 
> Best Regards
> Dan Burch
> 
> 


--
Posted via CNET Help.com
http://www.help.com/


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

Date: Wed, 03 May 2000 03:43:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help with substitution operator.
Message-Id: <sgv82d751g2162@corp.supernews.com>

Krasimir Christozov (krasi77@yahoo.com) wrote:
: 1,000 is interpreted as a string value, converted to a number and then 
: added. And any string that contains a character which is not a digit or 
: dot is evaluated as 0 when being converted to a number.

Minor quibble:  'e' (upper or lower case) can also appear, as can '-' and
'+', in certain defined positions. 

: $data_line =~ s/,//;
: 
: if you want to remove the ","'s.

That will only remove the first comma encountered.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "The road of Excess leads to the Palace
      of Wisdom" - William Blake


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

Date: Tue, 2 May 2000 23:32:03 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with substitution operator.
Message-Id: <slrn8gv7dj.6dc.tadmc@magna.metronet.com>

[ Please put your comments *following* the quoted text that you
  are commenting on.

  Please do not quote .sigs

  Please see     news.announce.newusers

  Jeopardectomy performed
]


On Wed, 03 May 2000 01:30:04 GMT, Krasimir Christozov <krasi77@yahoo.com> wrote:
>Dan Burch wrote:
>> 
>> The problem is commas in numbers over 1000 like 1,000.

>> I tried :
>> 
>>   foreach $data_line ( @data_line )
>> {
>>     $data_line = s/,//;
                  ^
                  ^ you have the wrong operator there


>. And any string that contains a character which is not a digit or 
>dot is evaluated as 0 when being converted to a number.


No it isn't. 

I wonder where you even got such a "rule", as it is not
very close to the real rule at all...

Here are 5 (including "1,000") that follow your description,
yet do NOT evaluate to zero when used as a number:


----------------------------
#!/usr/bin/perl -w
use strict;

foreach ( '1,000', qw/ +3.14159 9abc 1.7e10 1.7e10foo/ ) {
   print "string: $_\n";

   print 'number: ', $_ + 0, "\n";
   print "\n";
}
----------------------------


The rule is:

   leading whitespaces are skipped

   perl collects as many chars that "look like" part of
   a number as it can, _those_ chars are converted to a number

   it ignores the rest of the string when it gets to a char
   that doesn't "look like" part of a number. perl will
   warn (-w) you about these ignored chars if you ask it to,
   and all Perl programmers worth their salt ask it to.


Maybe you were thinking of something like $_ = 'abc',
which, following the rules above, is zero when used
as a number?


>try
>
>$data_line =~ s/,//;
>
>if you want to remove the ","'s.


And when you get to 1,000,000, try:

   $data_line =~ s/,//;
   $data_line =~ s/,//;

??

Better make that:

   $data_line =~ s/,//g;


No! We are not looking for a string or a pattern there,
we are looking for a character, so tr/// should be used
instead:

   $data_line =~ tr/,//d;


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


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

Date: Wed, 03 May 2000 11:36:09 +1000
From: Damian Carvolth <citecdjc@citec.qld.gov.au>
Subject: installing perl5.6.0 on sunos 5.3 problem
Message-Id: <390F8289.20E02BE6@citec.qld.gov.au>

Before anyone flames me:

I've had a poke about the perl websites I know of (CPAN, www.perl....)
read FAQ's etc I could find etc. If this is a FAQ or the answer is
archived an pointer to the appropriate spot would be most appreciated.

If this is the wrong place to post this then I apologise and could
someone point me to the right place.

Finally could any followups be sent to my email address (and news
optionally as you please) as my news server flushes every 2 days..:( and
I don't want to miss your valuable advice.

I'm trying to put 5.6 on an older sun server and having problems. Make
breaks with the error below.

I need 5.004 or later to run egd. The machine is an important one and I
have to be careful not to break anything so can't overwrite the older
perls on it. Thus one of the non standard elements of the installation
is putting the whole box and dice into a particular subdirectory. I
don't think this is the problem though, looks to me like it's choking on
the C libraries ?

I'm happy to plead my ignorance of perl (although I'm learning it
gradually) and am having a bit of a struggle with implementing it on
this machine.

Thoughts ?

Thanks in advance. Error output follows :

          CCCMD =  cc -DPERL_CORE -c -I/usr/local/include -O
rm -f libperl.a
/usr/ccs/bin/ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o
regcomp.o dump.o util.o mg.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o
pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o
universal.o xsutils.o globals.o perlio.o perlapi.o
cc   -o miniperl \
    miniperlmain.o opmini.o libperl.a
Undefined                       first referenced
 symbol                             in file
log                                 libperl.a(pp.o)
pow                                 libperl.a(pp.o)
sqrt                                libperl.a(pp.o)
floor                               libperl.a(pp.o)
fmod                                libperl.a(pp.o)
atan2                               libperl.a(pp.o)
exp                                 libperl.a(pp.o)
sin                                 libperl.a(pp.o)
cos                                 libperl.a(pp.o)
ld: fatal: Symbol referencing errors. No output written to miniperl
make: *** [miniperl] Error 1?


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

Date: Wed, 3 May 2000 01:35:17 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: making croak _not_ act like confess
Message-Id: <Ftyn2t.DC@news.boeing.com>

In article <390F106D.A47743DB@mail.ce.utexas.edu>,
Donald Lancon  <lancon@mail.ce.utexas.edu> wrote:
>In Perl, the Carp module gives you a way of making croak() behave like
>confess():
>
>  perl -MCarp=verbose script.pl
>
>or (for example):
>
>  use Carp qw(:DEFAULT verbose);
>
>or by including "MCarp=verbose" in the PERL5OPT environment variable
>(see Carp documentation).
>
>Somehow, on my Perl (ActivePerl 5.6.0, build 613, on Win NT 4.0) this
>behavior is enabled by default:
>
>  C:\>perl -e "use Carp; sub a{confess 'foo'} &a;"
>  foo at -e line 1
>          main::a called at -e line 1
>  
>  C:\>perl -e "use Carp; sub a{croak 'foo'} &a;"
>  foo at -e line 1
>          main::a called at -e line 1
>
>But I want croak() to behave like croak()!
>
>...
>So what's the obvious thing I'm not seeing here?
>

The docs look misleading to me here too. Carp 
walks the call stack looking for a package 
different from the current one. Then there's 
a punt and full trace if a different package 
isn't found. From Carp.pm:

    "un-oh! It looks like we crawled all
     the way up the stack and never found 
     a candiate package. Oh well, let's call
     longmess to generate a full stack trace."

So, something like:

   perl -MCarp <<END
      package Foo; 
      sub a { Carp::croak 'foo' };
      package main; Foo::a;
   END

does the "right thing".

If, this is a buglet rather than feature, I
believe a pseudo import like the verbose
flag, say "prune", could easily fix the
problem. 

--
Charles DeRykus


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

Date: Tue, 2 May 2000 13:22:58 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Order of evaluation (Was: Re: regex)
Message-Id: <MPG.1378d8fe42a5e79298a9cb@nntp.hpl.hp.com>

In article <8el1q4$bg6@mercury.adc.com> on 1 May 2000 22:51:48 GMT, 
Brand Hilton <bhilton@tsg.adc.com> says...
> In article <MPG.1374a95e311095a998a9b5@nntp.hpl.hp.com>,
> Larry Rosler  <lr@hpl.hp.com> wrote:
> >In C, the order of evaluation of the operands of a binary operator is 
> >explicitly unspecified for most operators.  Left-to-right evaluation is 
> >guaranteed for only a few binary operators, as in Perl:  && || and 
> >comma.
> >
> >Perl should document either that the order of evaluation of the operands 
> >of a binary operator is in general unspecified, or it should document 
> >that it is left-to-right.  In the absence of either specification, 
> >assertions such as yours are suspect.
> 
> Does the Camel count?  There's a nice operator precedence table
> (including associativity) on page 76.

The table constitutes the section SYNOPSIS at the beginning of perlop.

But as has been discussed in this thread, associativity seems to 
determine order of evaluation only to a limited degree; some have said 
not at all.

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


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

Date: Tue, 02 May 2000 21:26:11 -0700
From: sfinlay <web-botNOweSPAM@cgiextremes.com.invalid>
Subject: Perl & CGI Script Resource
Message-Id: <088286c0.6572a754@usw-ex0105-035.remarq.com>

Hello,

I am working on building a resource for Perl/Cgi Scripts.  You
can check out the resource currently at
http://www.cgiextremes.com.

It currently has over 2,000 scripts.
Additionally, if you are a perl programmer and have a script
you'd like to submit, please add it for review.

Thanks,

SF
http://www.cgiextremes.com

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



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

Date: Wed, 03 May 2000 06:04:51 GMT
From: "John" <KidRockYou@yahoo.com>
Subject: Re: Perl CGI Script Crashes on Win2K but not at Command
Message-Id: <7kPP4.21938$g4.569694@newsread2.prod.itd.earthlink.net>

Obviously people think I've taken no acts of my own to fix this problem.
For the last 4 days I've spent about 15 hours a day trying to get DBI and
ODBC to work correctly.  I'm amazed that people don't seem to understand
that perl.exe is started by the OS and comes to a screeming halt so fast the
OS doesn't even Identify the crashing program only to call it unknown.
Other CGI scripts run fine from the browser that don't use ODBC.  The DBI
test script works great.  So please explain to me why none of the ODBC work
from the browser, and everything works from the command prompt?

I have the know how to get things done, I wouldn't be in this news group
asking people for help if I wasn't exasperated with my problem.

Instead of pointing me to idiot lists and telling me that I'll get my
problem solved there (which after reading was no better off), I would just
like someone to tell me why, or if they have similar problems.

Here are my error messages in detail if that helps.

Unknown has generated errors and will be closed by windows.  You will need
to restart the program. An error log is being created.

Event Type: Error
Event Source: Perflib
Event Category: None
Event ID: 1000
Date:  5/2/2000
Time:  7:33:55 PM
User:  N/A
Computer: ENTERPRISE
Description:
Access to performance data was denied to IUSR_ENTERPRISE as attempted from
C:\WINNT\System32\drwtsn32.exe

If anyone is willing to offer me some kind of real help, I would very much
indeed be in bebt to them.

John




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

Date: 3 May 2000 06:16:46 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl CGI Script Crashes on Win2K but not at Command
Message-Id: <slrn8gvh2e.p0t.sholden@pgrad.cs.usyd.edu.au>

On Wed, 03 May 2000 06:04:51 GMT, John <KidRockYou@yahoo.com> wrote:
>Obviously people think I've taken no acts of my own to fix this problem.
>For the last 4 days I've spent about 15 hours a day trying to get DBI and
>ODBC to work correctly.  I'm amazed that people don't seem to understand
>that perl.exe is started by the OS and comes to a screeming halt so fast the
>OS doesn't even Identify the crashing program only to call it unknown.
>Other CGI scripts run fine from the browser that don't use ODBC.  The DBI
>test script works great.  So please explain to me why none of the ODBC work
>from the browser, and everything works from the command prompt?

Becasue the command prompt and the CGI script run in different environments
and as different users.

>
>I have the know how to get things done, I wouldn't be in this news group
>asking people for help if I wasn't exasperated with my problem.

Reading any old guide to CGI authoring should cover this.

>
>Instead of pointing me to idiot lists and telling me that I'll get my
>problem solved there (which after reading was no better off), I would just
>like someone to tell me why, or if they have similar problems.
>
>Here are my error messages in detail if that helps.
>
>Unknown has generated errors and will be closed by windows.  You will need
>to restart the program. An error log is being created.
>
>Event Type: Error
>Event Source: Perflib
>Event Category: None
>Event ID: 1000
>Date:  5/2/2000
>Time:  7:33:55 PM
>User:  N/A
>Computer: ENTERPRISE
>Description:
>Access to performance data was denied to IUSR_ENTERPRISE as attempted from
>C:\WINNT\System32\drwtsn32.exe

You have permission to access the ODBC source, the user the CGI script is
running as doesn't. A stated in the error message above. Give IUSR_ENTERPRISE
permission or ask somewhere where they discuss winNT for how to make a
CGI script run as a specific user.


-- 
Sam

I explicitly give people the freedom not to use Perl, just as God gives
people the freedom to go to the devil if they so choose.
	--Larry Wall


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

Date: Wed, 03 May 2000 05:46:09 GMT
From: vulcan_c2 <vulcan_c2@hotmail.com>
Subject: Permission denied on a read write file under Win98
Message-Id: <8eoeev$vvh$1@nnrp1.deja.com>

I am a bit frustrated here, I am not sure what I am doing wrong.  I am
trying to open a file with ">" which is supposed to truncate the file.
It doesn't seem to work however as I keep gettig the following error:

Permission denied at probcalc.pl line 42.

Line 42 is my open command.  The file already exists.  If I specify a
new file name it works fine.  The only attrib set high on the file is
A.  Here is where the code is, I am going to bed and hopefully some
other night owl will have an answer or it will come to me in a dream...

# Print out results
if ($#ARGV == 2) {
	chmod (0666, $ARGV[2]);
	$fn = safe_filename($ARGV[2]);
	open (resultset, ">$fn") || die $!;
	$hdlOutput = "resultset";
} else {
	$hdlOutput = "STDOUT";
}
foreach $key (sort by_number (keys (%resultHash))) {
	print $hdlOutput "$key\t$resultHash{$key}\n";
}
close($hdlOutput);

sub safe_filename {
	local $_  = shift;
	s#^([^.\\])#.\\$1#;
	$_ .= "\0";
	return $_;
}

Thanks, --Peter


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


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

Date: Tue, 2 May 2000 22:58:41 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Puzzled - Please help.
Message-Id: <slrn8gv5f1.6dc.tadmc@magna.metronet.com>

On Wed, 03 May 2000 00:44:10 GMT, Bob Cunningham <sparky@alt-usage-english.org> wrote:
>On Tue, 2 May 2000 15:32:00 -0400, tadmc@metronet.com (Tad McClellan)
>said:
>
>>[I said:]

>I gather that some distributions of Perl include something called
>'manpages'.  


Just as "grep" means "do a word search", "man pages" mean
"the standard documentation".

Unix has the "man" command to look stuff up.

Windows has "help" for that (I guess).

Perl has it's own that works (I guess again) on both, perldoc.


>That seems not to be true of the Windows distribution of
>Active Perl.


'Cause it runs on Windows and Windows doesn't have
the "man" command.


>   To find out where the configuration has installed the 
>   manpages, type:
>
>       perl -V:man.dir
>
>When you type that at the DOS command line, you get:
>
>   man1dir=''
>   man3dir=''


That seems accurate.

There _are no_ man page directories on Windows  :-)


>So much for manpages under Windows.


But you are not missing anything with regards to Perl, as
the man pages for Perl on Unix are the *.pod files
translated into the form that the "man" command wants
(with the 'pod2man' program that ships with perl).

On Windows they probably use 'pod2html' instead.

Same content.


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


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

Date: Tue, 2 May 2000 23:27:29 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: References and hashes
Message-Id: <Pine.A41.4.10.10005022306030.12760-100000@ginger.libs.uga.edu>

On Tue, 2 May 2000, rbbdsb wrote:

> Thanks a bunch to all who responded.
>   One last question:  I hate to be dense (and yes I'm RTFMing the Perl
> Cookbook but I'm a newbie and floundering).  I am still having trouble.
> Keys obviously pulls the name field, but values appears to pull a hash
> address.  What I need to do is iterate through the rec hash for each $name
> and then each $key and use the $val as the key for yet another array.  Whew!
> Should I be looking at Tie::RefHash as part of the solution?
> 
> TIA,
> Russ

I suspect you need to read `man perlref` or `perldoc perlref`.

Lines 23 and 29 below are pertinent to your question if I'm
understanding you correctly.  You say, "key for yet another array",
which I take to mean, "another hash".

--
Brad

     1  #!/usr/local/bin/perl
     2  use strict;
     3
     4  my %rec = (
     5    brad => {
     6      brass => 'front',
     7      chrome => 'back',
     8      },
     9    soho => {
    10      nose => 'wet',
    11      tail => 'wag',
    12      },
    13    );
    14
    15  my %another = (
    16      front => 'wood',
    17      back  => 'glass',
    18      wet   => 'healthy',
    19      wag   => 'happy',
    20      );
    21
    22  foreach my $key1 ( sort keys %rec ) {
    23    foreach my $key2 ( sort keys %{$rec{$key1}} ) {
    24
    25      print join( ", ",
    26          $key1,
    27          $key2,
    28          $rec{$key1}{$key2},
    29          $another{ $rec{$key1}{$key2} } ),
    30          "\n";
    31
    32    }  # foreach key2
    33  }  # foreach key1


Output:

brad, brass, front, wood
brad, chrome, back, glass
soho, nose, wet, healthy
soho, tail, wag, happy





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

Date: 3 May 2000 06:53:52 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: Regular Expression and HTML tags
Message-Id: <8eoie0$tl6$1@news.enteract.com>

ilya@math.ohio-state.edu writes:
>> It's not possible to parse HTML with simple regular expressions; use
>> HTML::Parser or another module instead.
>
>Depends on how simple is "simple".

Once again I will mention REX, a regular expression which may be
found on the web by searching for the terms "shallow parse" and
"XML". Maybe it is not "simple", but it's excellent for a task
like stripping tags, and is at least an order of magnitude
faster than HTML::Parser.



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

Date: Wed, 03 May 2000 14:35:56 +1000
From: "Amri, Kuross [WOLL:4009-I:EXCH]" <kamri@nortelnetworks.com>
Subject: Reload a text file?
Message-Id: <390FACAC.97C3E361@nortelnetworks.com>

G'day,
	
	I was wondering if there is some way of making a text file reload
automatically every time it is brought up to be viewed on the browser.
Similar to the Meta refresh tag but not.

Thanks
Kuross A


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

Date: Tue, 02 May 2000 22:26:24 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Reload a text file?
Message-Id: <390FB880.85C1DA67@vpservices.com>

"Amri, Kuross [WOLL:4009-I:EXCH]" wrote:
> 
>         I was wondering if there is some way of making a text file reload
> automatically every time it is brought up to be viewed on the browser.
> Similar to the Meta refresh tag but not.

Browser ... refresh tag .. reload ...  Those are all concepts that have
to do with CGI and none of them have to do with Perl.  Please visit a
CGI related newsgroup and find out whether what you want to do is
possible and/or advisable and what information needs to be sent to a
browser to accomplish it.  The specifics of what to send have to do with
the CGI and HTTP protocols, the capabilities of webservers and browsers,
and nothing at all to do with Perl syntax or capablities (which is the
subject matter of this newsgroup).  I suggest you look for words like
pragma, and no-cache, and header, and content-type.  I also suggest you
find out as much as you can about caching and how it impacts which
choices are available to a server and a browser.  Good luck!

-- 
Jeff


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

Date: 3 May 2000 07:01:04 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: resizing an image
Message-Id: <8eoirg$4ml$1@slb7.atl.mindspring.net>

johnand@my-deja.com wrote:
: Yikes!  You should NOT do this; having the browser resize images slows
: down the browser's page rendering and totally wastes bandwidth.

Not to mention that most browsers do an absolutely horrible job of 
rescaling images.



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

Date: Tue, 02 May 2000 20:52:38 -0500
From: Donald Lancon <lancon@mail.ce.utexas.edu>
Subject: return value of bare subroutine in list/scalar context
Message-Id: <390F8666.AA589FC2@mail.ce.utexas.edu>

Here's something I noticed about using bare subroutines (that is,
subroutines with no statements in their definition) in list vs. scalar
context.

BTW, the specific Perl I'm using is ActivePerl 5.005 and 5.6.0 for Win32
(NT 4.0), but I'd assume this behavior is consistent across all versions
and flavors of Perl.

First, some results that weren't surprising to me (these are one-liners
on the command line, each followed by its output; the numbers to the
left are only for reference, of course):

1. C:\>perl -e "sub a {shift}; $q = &a('bar'); print $q;"
   bar

2. C:\>perl -e "sub a {}; $q = &a('bar'); print $q;"
   

In the first example, the subroutine returns its (scalar) input, as
expected.  In the second, the bare subroutine returns nothing, as
expected (I did, anyway).

But then:

3. C:\>perl -e "sub a {}; @q = &a('bar'); print @q;"
   bar

4. C:\>perl -e "sub a {}; push @q, &a('bar'); print @q;"
   bar

5. C:\>perl -e "sub a {}; print &a('bar');"
   bar

6. C:\>perl -e "sub a {};($q) = &a('bar'); print $q"
   bar

So I was wrong!  A bare subroutine _does_ return something -- its input
-- but only in list context.

Just to check:

7. C:\> perl -e "sub a {}; @q = scalar &a('bar'); print @q;"
   

Yep.  Nothing.

Well... actually, not quite nothing.  You can check that @q in the last
example has one element, but its value is the null string.

So the bare subroutines in #2 and #7 (in scalar context) appear to be
returning a "false" value, while the others (in list context) are
returning their input.

Why?

-- 
Donald Lancon


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

Date: Tue, 2 May 2000 20:45:34 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: return value of bare subroutine in list/scalar context
Message-Id: <Pine.GSO.4.10.10005022038210.13677-100000@user2.teleport.com>

On Tue, 2 May 2000, Donald Lancon wrote:

> So the bare subroutines in #2 and #7 (in scalar context) appear to be
> returning a "false" value, while the others (in list context) are
> returning their input.
> 
> Why?

It's a bug. I'd guess that the sub's code is accidentally leaving the
parameter list on the stack in some cases. But it's just a guess.

If you file a bug report, I'm sure it'll be fixed soon. But it's a pretty
low priority bug!

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



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

Date: 3 May 2000 07:01:50 GMT
From: mats-larsson@iname.com (Mats Larsson)
Subject: searching file and performance
Message-Id: <8eoisu$nm5$1@u30075.rsv.rsv.se>

I am browsing some huge files to find a specific line. When this line is 
located I like to print a number of lines starting with the line just before 
the current one. What would be the best way of doing this? 
The obvious way would be to always keep a copy of the previous line but is 
there some other solution to this?

Tia
Mats



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

Date: Tue, 2 May 2000 17:55:49 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: setting an array in a Struct?
Message-Id: <MPG.137918f5d42d5bd298a9d1@nntp.hpl.hp.com>

In article <8enrip$bpj$1@nnrp1.deja.com> on Wed, 03 May 2000 00:24:08 
GMT, Crypto-Boy <crypto_boy@my-deja.com> says...

 ...

> Ok, Ok, I should have written "use Class::Struct;" in my post.  Geeezzz.
> And I did read the Class:Struct documentation, which doesn't mention
> using the (weird to me) @{} notation, or any kind of entire-array
> assignment (just one element at a time assignment).
> 
> So you (Mr. Rosler) are saying that @{$Family->members} is the array
> referred to by the reference that the getter method returns?  I guess
> that makes sense.  I found examples of @{} usage in POD/perlref, but I
> still don't understand.  Where is a good reference on this @{} stuff?

perldoc perlreftut

 ...

Use Rule 1

If $aref contains a reference to an array, then you can put {$aref} 
anywhere you would normally put the name of an array. For example, 
@{$aref} instead of @array.

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


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

Date: Tue, 2 May 2000 21:57:30 -0400
From: NagaPutih <s0218327@unix1.cc.ysu.edu>
Subject: sort()
Message-Id: <Pine.A41.4.20.0005022133340.21628-100000@unix1.cc.ysu.edu>


can anyone tell me what sort algorithm is used
on sort() in perl?

what is perl interpreted into? if i have the
following statement, what would it be interpreted
into?

@out=sort(@string_list);

that's all...and thank's!



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

Date: Wed, 03 May 2000 03:47:49 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Thanks Craig.
Message-Id: <sgv8b5i81g220@corp.supernews.com>

Dan Burch (dburch@teleport.com) wrote:
: Very good.

Glad I could help out.

: > :          local $year_total = ($data_line[2] +$data_line[3]
: > : +$data_line[4] +$data_line[5] +$data_line[6] +$data_line[7]
: > : +$data_line[8] );
: >
: > There are easier ways to write that, such as
: >
: >   $year_total = 0;
: >   $year_total += $_ foreach @data_line[2..8];
: 
: This is great.  Now I can add variables [$x..$y] and make the code reusable.

As you get experienced with programming, you'll develop an aversion to
writing code in which you type the same thing over and over with a small,
patterned variation.  Doing things over and over with simple changes is
what *computers* are for, not people. :)  Any time you catch yourself
doing it, odds are there's an easier, more extensible way to approach the
problem.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "The road of Excess leads to the Palace
      of Wisdom" - William Blake


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

Date: Tue, 2 May 2000 21:09:58 -0400
From: "Oliver Rutherfurd" <oliver@rutherfurd.net>
Subject: Re: toggling read-only flag for files in win32
Message-Id: <8enuec$11n$1@bob.news.rcn.net>

Thanks!  chmod did the trick.

-Ollie

"Jon Ericson" <Jonathan.L.Ericson@jpl.nasa.gov> wrote in message
news:390E28EE.C0B97C00@jpl.nasa.gov...
> Ollie Rutherfurd wrote:
> > I've written a little script to replicate a directory tree, but the
> > File:Copy function 'copy' fails when the destination files already exist
and
> > are read-only.  I've got permission to change this flag, but can this be
> > done programatically using perl (so I can incorporate it into the
script)?
> >
> > BTW, I'm using 5.6 on NT 4.0.
>
> The ActiveState FAQS (http://www.activestate.com/ActivePerl/docs)
> discuss this question.  chmod does the best it can under DOS's limited
> file attribute scheme.
>
> Jon
> --
> Knowledge is that which remains when what is
> learned is forgotten. - Mr. King




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

Date: Wed, 03 May 2000 03:08:50 GMT
From: Bryon Lape <blape@grey-net.com>
Subject: Re: Unicode in Perl 5.6 - broken?
Message-Id: <390F970C.8E9F4C8F@grey-net.com>

Uh...when did Windoze 98 start supporting Unicode?

Bertilo Wennergren wrote:

> I just started experimentng with the new Unicode features
> of Perl 5.6 using the ActiveState Perl 5.6 in a Windows 98
> environment. I found some serious problems. Either my
> understanding of a few things is severly broken, or else
> Perl 5.6 is.
>
> My main problem concerns upper/lower case translation.
> Things just don't behave in an understandable way, and
> some things seem seriously broken.
>
> To summarize the problems I've met I concocted the following
> CGI-script. The result is meant to be read with at browser
> that can deal with UTF-8, and that can show the necessary
> glyphs for characters from Latin-1 Supplement and Latin
> Extended A.
>
> The code uses UTF-8 and won't make much sense if your
> reader can't interpret UTF-8.
>
> -------------------------------------------------------
>
> #!/usr/bin/perl
>
> use strict;
> use utf8;
>
> my ($string, $upper_string1, $upper_string2);
>
> $string = "abc ABC åäö ÅÄÖ ĉĝĥĵŝŭ ĈĜĤĴŜŬ";
>
> $upper_string1 = $string;
> $upper_string1 =~ s/(\w)/\U$1\E/g;
>
> $upper_string2 = $string;
> $upper_string2 = uc($upper_string2);
>
> my ($read_string, $upper_read_string1, $upper_read_string2);
>
> # THE FILE "read_string.txt" SHOULD CONTAIN THE SAME
> # LINE OF CHARACTERS AS "$string" ABOVE - ENCODED IN UTF-8.
> open(READ,"read_string.txt");
> $read_string = <READ>;
> close READ;
>
> $upper_read_string1 = $read_string;
> $upper_read_string1 =~ s/(\w)/\U$1\E/g;
>
> $upper_read_string2 = $read_string;
> $upper_read_string2 = uc($upper_read_string2);
>
> print qq(Content-type: text/html; charset=utf-8\n\n);
>
> print qq(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n);
> print qq(    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n);
> print qq(<html xmlns="http://www.w3.org/1999/xhtml">\n);
> print qq(<head>\n);
> print qq(<title>Test</title>\n);
> print qq(</head>\n);
> print qq(<body>\n);
>
> print qq(<p>STRING: $string</p\n>);
> print qq(<p>UPPERCASED STRING 1:  $upper_string1</p>\n);
> print qq(<p>UPPERCASED STRING 2:  $upper_string2</p>\n);
>
> print qq(<p>READ STRING: $read_string</p\n>);
> print qq(<p>UPPERCASED READ STRING 1:  $upper_read_string1</p>\n);
> print qq(<p>UPPERCASED READ STRING 2:  $upper_read_string2</p>\n);
>
> print qq(</body>\n);
> print qq(</html>\n);
>
> -------------------------------------------------------
>
> If you manage to get this code to work in a CGI environment,
> you'll see that the uppercasing of the string turns out in
> several different ways, and that it is correct in only half of the
> time. The "\U" method works only for the string that is read from
> a file. The "uc()" method works only for the other string (declared
> in the perl code.
>
> This is what I get in my broser:
>
> -------------------------------------------------------
>
> STRING: abc ABC åäö ÅÄÖ ĉĝĥĵŝŭ ĈĜĤĴŜŬ
>
> UPPERCASED STRING 1: AFC ABC åÄ1ö 01Ä01 ĉĜ1ĥĴ1ŝŬ1 Ĉ01Ĥ01Ŝ01
>
> UPPERCASED STRING 2: ABC ABC ÅÄÖ ÅÄÖ ĈĜĤĴŜŬ ĈĜĤĴŜŬ
>
> READ STRING: abc ABC åäö ÅÄÖ ĉĝĥĵŝŭ ĈĜĤĴŜŬ
>
> UPPERCASED READ STRING 1: ABC ABC ÅÄÖ ÅÄÖ ĈĜĤĴŜŬ ĈĜĤĴŜŬ
>
> UPPERCASED READ STRING 2: ABC ABC åäö ÅÄÖ ĉĝĥĵŝŭ ĈĜĤĴŜŬ
>
> -------------------------------------------------------
>
> The second line is particulary horrible. Note that "b" is
> uppercased to "F"! What is going on here?
>
> If the line "use utf8" is removed things look a bit less broken at
> first glance, but actually uppercasing of non-ASCII characters
> doesn't work at all without the utf8 pragma.
>
> Is it me or is it perl?
>
> My Perl version says:
>
>   This is perl, v5.6.0 built for MSWin32-x86-multi-thread
>   (with 1 registered patch, see perl -V for more detail)
>
>   Copyright 1987-2000, Larry Wall
>
>   Binary build 613 provided by ActiveState Tool Corp.
>   http://www.ActiveState.com
>   Built 12:36:25 Mar 24 2000
>
> --
> #####################################################################
>                          Bertilo Wennergren
>                  <http://purl.oclc.org/net/bertilo>
>                      <bertilow@hem.passagen.se>
> #####################################################################



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

Date: Wed, 3 May 2000 07:30:24 +0200
From: "Bertilo Wennergren" <bertilow@hem.passagen.se>
Subject: Re: Unicode in Perl 5.6 - broken?
Message-Id: <8eodcv$9dfor$1@fu-berlin.de>


"Bryon Lape":

> Uh...when did Windoze 98 start supporting Unicode?

From day one, or even earlier (since Windows 95 supported it too).
Not as fully as Windows NT/2000, but nevertheless is does support 
Unicode. MSIE 4/5 has full Unicode support under Windows 95/98,
as does many other programs.

-- 
#####################################################################
                         Bertilo Wennergren
                 <http://purl.oclc.org/net/bertilo>
                     <bertilow@hem.passagen.se>
#####################################################################




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

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


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