[13959] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1369 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 13 18:08:49 1999

Date: Sat, 13 Nov 1999 15:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942534312-v9-i1369@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 13 Nov 1999     Volume: 9 Number: 1369

Today's topics:
    Re: Aack Auto-Responder... (Kragen Sitaker)
    Re: bad header (David Efflandt)
    Re: CHMOD for Net::FTP. Help, cool hackers ! (David Efflandt)
    Re: Filehandle Question (Thunderdust (TomH))
    Re: Help needed please, simple hash slice question! (Abigail)
    Re: Help with collecting -w information! (Kragen Sitaker)
    Re: How can I determine different "use" statements? (Matthew Bafford)
    Re: How can I vist a number of websites and email addys (Kragen Sitaker)
    Re: how to create a random id? (Kragen Sitaker)
    Re: how to parse dir recursively for files? (Kragen Sitaker)
    Re: Let me look a Win32-script on Perl (Michel Dalle)
    Re: Need help with arrays. (Kragen Sitaker)
    Re: Newbee needs some date functions . . . (Kragen Sitaker)
    Re: Newbee needs some date functions . . . <no@spam.com>
    Re: Newbee needs some date functions . . . (Kragen Sitaker)
    Re: Newbee needs some date functions . . . <no@spam.com>
    Re: Newbee needs some date functions . . . (Kragen Sitaker)
    Re: Newbie: Background Sounds (Michel Dalle)
    Re: output a binary file to browser from perl script <flavell@mail.cern.ch>
    Re: output a binary file to browser from perl script (Kragen Sitaker)
    Re: parsing UNIX mail spool files (Kragen Sitaker)
    Re: Perl and commonsense part 2 (Kragen Sitaker)
        regular expression riddle <reembar@netvision.net.il>
    Re: regular expression riddle (Bart Lateur)
    Re: regular expression riddle (Kragen Sitaker)
    Re: regular expression riddle <r28629@email.sps.mot.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 13 Nov 1999 20:44:26 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Aack Auto-Responder...
Message-Id: <K4kX3.7445$YI2.294532@typ11.nn.bcandid.com>

In article <coWW3.15396$Ph7.111503@insync>, Lee Sharp <lee@insync.net> wrote:
>Kragen Sitaker wrote in message
><2TMW3.461$YI2.26152@typ11.nn.bcandid.com>...
>|No.  Please don't post here unless you have a question (or an answer)
>|about programming in Perl.
>
>   Of all the groups I read, only the Perl folks will spend so much energy
>being completely unhelpful.  Assuming you have tried cpan, try
>http://www.technotrade.com/cgi/ http://www.cgi-resources.com/
>http://cgi.resourceindex.com/Programs_and_Scripts/Perl/
>http://www.perlarchive.com/index.shtml  Good luck.

Of all the groups I read, only comp.lang.perl.misc gets so many
off-topic posts.

At least one of those web sites -- www.cgi-resources.com -- appears to
be appallingly awful.  I haven't looked at the others.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 13 Nov 1999 20:16:28 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: bad header
Message-Id: <slrn82rhot.4n2.efflandt@efflandt.xnet.com>

On Sat, 13 Nov 1999 09:35:55 -0000, Chris
<chris@chrismail.connectfree.co.uk> wrote:
>I keep getting told Bad header=: http://blsoftpart.hypermart.net/sign_up.pl
>all the time even with corrections shown

Since all of your scripts 500 Error (die before printing anything), I
suspect you are making a common newbie blunder.  Doesn't hypermart or a
user there have a CGI FAQ?  If not, consult a cgi newsgroup.

Maybe you forgot to:
1. ftp upload scripts and text data in 'ASCII' mode (not binary).
2. type a closing quote or semicolon or other typo.
3. print a proper header (print header,start_html; using CGI.pm).
4. test an open() statement to see why it failed.

>--
>Chris
>chris@chrismail.connectfree.co.uk
>www.bl-soft.com/chrissite


-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: 13 Nov 1999 20:33:12 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: CHMOD for Net::FTP. Help, cool hackers !
Message-Id: <slrn82rio9.4n2.efflandt@efflandt.xnet.com>

On Sat, 13 Nov 1999 16:02:15 GMT, MetaWizard <mwiz@mail.ru> wrote:
>
>The VirtualAvenue(www.virtualave.net) freehosting server enable
>entrance to your account only via FTP. To change mode of files in my
>directories I am writing "chmod 0666 test.txt"(for examle).
>So I need realization of this method to make this procedure from Perl-
>script. But Net::FTP doesn't enable it. I ask everybody who may help me!

CGI runs as you on virtualave.net, so 666 or 777 permission is totally
unnecessary (and totally insecure) regardless of what any script
instructions say.  In fact you do not have to set any permissions there
because .cgi and .pl is automatically run as CGI without doing anything.

But if you want to hide a CGI data file from web access, but still access
it from a CGI script, you could do a:

$ftp->site("chmod 600 test.txt");

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Sat, 13 Nov 1999 19:27:37 GMT
From: beans@bedford.net (Thunderdust (TomH))
Subject: Re: Filehandle Question
Message-Id: <382db844.11196588@news.bedford.net>





My point was that in either case STDOUT as a bareword, or the value of
the scalar $s is nothing more than the name of the filehandle. There's
no such thing as a "FILEHANDLE variable".

On 12 Nov 1999 02:29:53 GMT, sholden@pgrad.cs.usyd.edu.au (Sam Holden)
wrote:

>On Fri, 12 Nov 1999 01:31:14 GMT, Thunderdust (TomH) <beans@bedford.net> wrote:
>>
>>What's a "filehandle variable"? 
>>
>>Try this, is the filehandle variable STDOUT, or $s?
>>
>>#################### 
>>print STDOUT "Hello ";
>>
>>$s = "STDOUT";
>>print $s "World\n";
>>##################3
>
>STDOUT is the filehandle variable.
>$s is a symbolic reference. 
>
>Do you think that $s is a sub in this code as well?:
>
>sub foo {print "Hello\n";}
>$s = 'foo';
>$foo();
>
>use strict and you won't go down such evil paths.
>
>Filehandles not having a symbol out the front means you can get them mixed
>up with directory handles as in:
>
>open(A,'>/tmp/test') || die "something is wrong: $!";
>opendir(A, '/etc') || die "I hope this isn't a unix...: $!";
>print A readdir A;
>closedir A;
>close A;
>
>But that's the way it is...
>
>-- 
>Sam
>
>Just don't create a file called -rf.  :-)
>	--Larry Wall






Schnoodlewinks-constantly leveling up warrior
Fluffy_the_Fly-lvl.7 warrior (x2-don't ask!)
Flame-QFG5 Paladin


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

Date: 13 Nov 1999 16:45:30 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Help needed please, simple hash slice question!
Message-Id: <slrn82rqmt.lmh.abigail@alexandra.delanet.com>

Max (mholland@bestweb.net) wrote on MMCCLXV September MCMXCIII in
<URL:news:mholland-1211992156290001@dialin-13.nanuet.bestweb.net>:
;; #Help needed with following script, please!
;; #Using MacPerl, Learn Perl in 21 days, Chapter 8, Slices
;; #Why doesn't my slice subset include the keys 'red' and 'green'
;; #with their corresponding values? All I get are their values.
;; 
;; %hash=('blue',10,'red',20,'green',5);
;; %hashslice=@hash{'red','green'};
;; 
;; foreach $x (keys %hashslice) {
;;       print "Key: $x,  Value: $hashslice{$x}\n"; } 
;; 
;; #Result: "Key: 20,  Value: 5"
;; #What am I doing wrong? Many, many thanks!!! Max


@hash {'red','green'} is the same as ($hash {red}, $hash {green}), 
which is in this case (20, 5). Assign that to %hashslice, and you
end up with a hash that has one entry, a key of 20, with 5 as its
value.

What you are looking for is:

    @hashslice {'red', 'green'} = @hash {'red', 'green'};

Or, to not repeat indices:

    @colours = qw /red green/;
    @hashslice {@colours} = @hash {@colours};


Abigail
-- 
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
          for (??;(??)x??;??)
              {??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Sat, 13 Nov 1999 22:55:42 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Help with collecting -w information!
Message-Id: <O%lX3.7826$YI2.314321@typ11.nn.bcandid.com>

In article <slrn82ntmj.iv.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>>$cmd = `perl -w $file`;
>
>   I would suggest `perl -cw $file` rather than running just
>   any old program, it might do Something Bad...

tmp.x:
#!/usr/bin/perl -w
use strict;
BEGIN { print "I 0wn y0u\n"; }

perl -cw tmp.x 
prints:
tmp.x syntax OK
I 0wn y0u

Perhaps -cw is not sufficient.

Oh, and if $file is -e 'BEGIN { print "I 0wn y0u\n" }`, -c isn't going
to help much there, either.

Conclusion: for security, this script is equivalent to putting PERL.EXE
in your cgi-bin dir.

>>print "Content-type: text/html\n\n";
>                           ^^^^
>
>   Backticks do not return HTML. You shouldn't lie to the browser
>   like that...

They may or may not return HTML, depending on what the program they
spawn outputs.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 19:30:13 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: How can I determine different "use" statements?
Message-Id: <slrn82rdqj.1e9.*@dragons.duesouth.net>

'How can I determine different "use" statements?' posted by hookman
<hookman@cwnet.com>, on Sat, 13 Nov 1999 09:45:34 -0800 from the
'who-cares-if-it-is-ontopic' dept: 
: I use this:
: 
: sub BEGIN {
:    if(condition){
:       use 'module1.pm';
:       use 'module2.pm';
:    }else{
:       use 'module3.pm';
:       use 'module4.pm';
:    }
: }
: 
: BEGIN gets called when the script first starts...

Did you try it?

$ echo 'print STDERR "1\n";1' > mod1.pm 
$ echo 'print STDERR "2\n";1' > mod2.pm
$ perl -e 'BEGIN{if(0){use mod1;} else {use mod2;}}'
1
2
$

Look up 'use' in the manpages.  You'll find it behaves as if it's in its
own BEGIN block (which is run at compile time).

HTH,

--Matthew


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

Date: Sat, 13 Nov 1999 19:41:18 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How can I vist a number of websites and email addys
Message-Id: <y9jX3.7249$YI2.285805@typ11.nn.bcandid.com>

In article <80ijmr$pem$1@nnrp1.deja.com>,  <tony_123@my-deja.com> wrote:
>How can I write a script that given a web site address, will go to that
>site and extract all email addresses from that page.  I want to know
>what modules would help in doing this,  is there already a script out
>there that does this, those sort of things.

Why?

Where do you live?  I would like to discuss this with you in person.
With some rope and some slivers of bamboo, and possibly a baseball bat.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 20:48:13 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: how to create a random id?
Message-Id: <h8kX3.7454$YI2.295120@typ11.nn.bcandid.com>

In article <IeVW3.867$YI2.73083@typ11.nn.bcandid.com>,
Kragen Sitaker <kragen@dnaco.net> wrote:
>my @chars = ('a'..'z', 0..9);    #UNTESTED
>join '', map { $chars[randgenerator @chars] } 1..20;  #UNTESTED

I got a private response from Fabian on this one; I think they should
probably post their response (including its further questions) here, so
that other people can help to answer it.


-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 20:01:55 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: how to parse dir recursively for files?
Message-Id: <TsjX3.7334$YI2.287542@typ11.nn.bcandid.com>

In article <382c8999.159086824@news.pajo.com>,
Kazz Asher <kazz@ashernet.net> wrote:
>>This is bad advice.
>
>Kragen, perhaps you should take your medication. 90% of your posts are
>merely to be an asshole. Refrain - is your keyword of the day.

Sorry you thought I was just being an asshole.  I was trying to warn
anyone who read the two-level-deep recursion solution that it was a bad
solution, and that they would be better off with one of the other
solutions posted in the thread.

I appreciate your concern for me, but maybe it's predicated on a
misunderstanding of my post?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 20:59:00 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Let me look a Win32-script on Perl
Message-Id: <80kjgd$b4r$2@nickel.uunet.be>

In article <80k38v$ncq$1@nnrp1.deja.com>, MetaWizard <microwizard@my-deja.com> wrote:
>Tell me were can I find a Win32-script on Perl.
>I downloaded Win32::GUI but cannot make with it nothing usefull!
>Give me something interesting and EASY TO INSTALL !

Hmmm, have you tried Win32::Process::KillProcess() ?

Try shooting any process until your PC doesn't work anymore,
then reboot and start again... Sounds like a nice one to me :-)

Michel.


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

Date: Sat, 13 Nov 1999 22:49:56 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Need help with arrays.
Message-Id: <oWlX3.7778$YI2.313325@typ11.nn.bcandid.com>

In article <000b8d9b.77acc8a7@usw-ex0101-004.remarq.com>,
John Iyezack  <snapperhead_420NOsnSPAM@hotmail.com.invalid> wrote:
>I have this array filled with numbers.  I need to be able to go through
>the array an take out all of the duplicate entrys and place them into
>another array.
>
>array 1:
>1 1 2 2 3 1 2 2 1 2 5 3 4 2 1 3 9 8 
>Array 2 would only have all the number listed once.
>1 2 3 5 9 8

	@array2 = keys %{{map{$_,1}@array1}};

This could be considered unnecessarily obfuscated.  It's barely shorter than
	{my%x;@array2 = grep !$x{$_}++,@array1}
and 
	{my$x;@x{@array1}=();@array2 = keys %x}
from the FAQ entry, which could both also be considered needlessly
obfuscated.  The FAQ entries, though, might be shortenable in some
circumstances, while my solution isn't, except for the whitespace they
all share.  So depending on the Golf course, I might lose.

I think the clearest way to do it, though, is:
	{
		my %hash;
		my $val;
		foreach $val (@array1) {
			$hash{$val} = 1;
		}
		@array2 = keys %hash;
	}

Any C++er who knows enough of Perl to know a hash from an array can
understand that.  No refs, maps, slices, $_s, or greps.  I'm not sure
the trickiness of any of the one-line solutions is really justified.

To me, though,
	my %hash = map {$_ => 1} @array1;
	@array2 = keys %hash;
seems almost as clear as the foreach solution to the novice, and
perhaps a little clearer to the regular Perl user.  What do you think?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 19:48:23 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Newbee needs some date functions . . .
Message-Id: <bgjX3.7288$YI2.286596@typ11.nn.bcandid.com>

In article <80kcm7$q3n$1@supernews.com>, Simon Brook <no@spam.com> wrote:
>Recently turned to PERL (2 weeks) for web programming and luving it. However
>being an Microsoft programmer (sorry) I am used to there being a function
>for everything - e.g. DateDiff() etc etc.
>
>Trying to do various things with dates, namely work out someones age (like
>Andrej) and some other slightly more complicated calculations . . . .
>
>I found (to my delight) DateCalc.pm on my Win32 installation of PERL, and
>these worked brilliantly (including the awesome decode_date!!) ;-) . . .
>however my ISP (demon - UK) doesn't have these modules installed, and when I
>tried to use date:datecalc, it told me that dynamic linking was not aloud on
>the server.

Dynamic linking, eh?  What was the error, exactly?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 20:14:24 -0000
From: "Simon Brook" <no@spam.com>
Subject: Re: Newbee needs some date functions . . .
Message-Id: <80kgci$e3f$1@supernews.com>

Oops, I think you spotted something that I misquoted, the full error was as
follows (using their own sort of debugger which routes STDERR to STDOUT)

Can't load module Date::DateCalc, dynamic loading not available in this
perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the Date::DateCalc module statically linked into
it.)
 at Date/DateCalc.pm line 28
BEGIN failed--compilation aborted ...



Kragen Sitaker <kragen@dnaco.net> wrote in message
news:bgjX3.7288$YI2.286596@typ11.nn.bcandid.com...
> In article <80kcm7$q3n$1@supernews.com>, Simon Brook <no@spam.com> wrote:
> >Recently turned to PERL (2 weeks) for web programming and luving it.
However
> >being an Microsoft programmer (sorry) I am used to there being a function
> >for everything - e.g. DateDiff() etc etc.
> >
> >Trying to do various things with dates, namely work out someones age
(like
> >Andrej) and some other slightly more complicated calculations . . . .
> >
> >I found (to my delight) DateCalc.pm on my Win32 installation of PERL, and
> >these worked brilliantly (including the awesome decode_date!!) ;-) . . .
> >however my ISP (demon - UK) doesn't have these modules installed, and
when I
> >tried to use date:datecalc, it told me that dynamic linking was not aloud
on
> >the server.
>
> Dynamic linking, eh?  What was the error, exactly?
> --
> <kragen@pobox.com>       Kragen Sitaker
<http://www.pobox.com/~kragen/>
> The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
> <URL:http://www.pobox.com/~kragen/bubble.html>




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

Date: Sat, 13 Nov 1999 20:26:13 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Newbee needs some date functions . . .
Message-Id: <FPjX3.7413$YI2.292242@typ11.nn.bcandid.com>

In article <80kgci$e3f$1@supernews.com>, Simon Brook <no@spam.com> wrote:
>Oops, I think you spotted something that I misquoted, the full error was as
>follows (using their own sort of debugger which routes STDERR to STDOUT)
>
>Can't load module Date::DateCalc, dynamic loading not available in this
>perl.
>  (You may need to build a new perl executable which either supports
>  dynamic loading or has the Date::DateCalc module statically linked into
>it.)
> at Date/DateCalc.pm line 28
>BEGIN failed--compilation aborted ...

No, I think your analysis was correct.  Evidently Date::DateCalc has
parts written in C and your Perl doesn't support dynamic loading.  I
was just hoping you were wrong and there would be an easy solution.

There are some other modules that might help, but I don't know if they
have parts written in C or not.

If you have the space, by the way, building Perl might not be too bad;
it took me only about 20 minutes, including time to find and read the
INSTALL file.  Your machine is likely slower.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 21:01:03 -0000
From: "Simon Brook" <no@spam.com>
Subject: Re: Newbee needs some date functions . . .
Message-Id: <80kj41$ope$1@supernews.com>


Kragen Sitaker <kragen@dnaco.net> wrote in message
news:FPjX3.7413$YI2.292242@typ11.nn.bcandid.com...
>
> No, I think your analysis was correct.  Evidently Date::DateCalc has
> parts written in C and your Perl doesn't support dynamic loading.  I
> was just hoping you were wrong and there would be an easy solution.
>
> There are some other modules that might help, but I don't know if they
> have parts written in C or not.
>
> If you have the space, by the way, building Perl might not be too bad;
> it took me only about 20 minutes, including time to find and read the
> INSTALL file.  Your machine is likely slower.

But doesn't the build get details from the local environment, i.e. my
computer (running win32 perl), when what I want it to get is the details
from the ISP's server?

VERY NEW to this so I don't really know what I am talking about - but I
really appreciate you helping me out - these news groups are really great,
If only I had found out about them earlier (my ISP and web host is bloody
useless, but unfortunately the decision to move is not mine)





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

Date: Sat, 13 Nov 1999 21:10:18 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Newbee needs some date functions . . .
Message-Id: <_skX3.7492$YI2.298001@typ11.nn.bcandid.com>

In article <80kj41$ope$1@supernews.com>, Simon Brook <no@spam.com> wrote:
>Kragen Sitaker <kragen@dnaco.net> wrote in message
>news:FPjX3.7413$YI2.292242@typ11.nn.bcandid.com...
>> If you have the space, by the way, building Perl might not be too bad;
>> it took me only about 20 minutes, including time to find and read the
>> INSTALL file.  Your machine is likely slower.
>
>But doesn't the build get details from the local environment, i.e. my
>computer (running win32 perl), when what I want it to get is the details
>from the ISP's server?

Right -- I'd assumed you'd build perl on the ISP's server.

>VERY NEW to this so I don't really know what I am talking about - but I
>really appreciate you helping me out - these news groups are really great,
>If only I had found out about them earlier (my ISP and web host is bloody
>useless, but unfortunately the decision to move is not mine)

I hope we can help you :)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 20:51:50 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Newbie: Background Sounds
Message-Id: <80kj30$b4r$1@nickel.uunet.be>

In article <O5hX3.106$16.13398@news.flash.net>, "Andy (IL)" <akoszyk@flash.net> wrote:
>This should be easy for you all!
[snip]

I'm afraid there is already enough background noise in this newsgroup...

Michel.


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

Date: Sat, 13 Nov 1999 20:36:51 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: output a binary file to browser from perl script
Message-Id: <Pine.HPP.3.95a.991113202823.21249I-100000@hpplus01.cern.ch>

On Sat, 13 Nov 1999, Kragen Sitaker wrote:

> In article <slrn82q36c.1q2.efflandt@efflandt.xnet.com>,
> David Efflandt <efflandt@xnet.com> wrote:

> >Why in chunks?  [...]

> This won't work well if $file is 200MB and you only have 32MB of
> virtual memory -- or, more reasonably, if $file is 5MB, your virtual
> memory is 64MB, and you have 20 people trying to download the file at
> once.

right

> Also, it chops the data up into one-line chunks; for some data this
> will be very small. 

If you know that the file is small enough to fit in memory, how about
an undefined $/ ?

But in general, clearly you're right to read it in chunks of a size that
you know you can handle.

Good points.  Trust me to pick on the nits and miss the big picture.

thanks



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

Date: Sat, 13 Nov 1999 19:53:49 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: output a binary file to browser from perl script
Message-Id: <hljX3.7303$YI2.287300@typ11.nn.bcandid.com>

In article <Pine.HPP.3.95a.991113202823.21249I-100000@hpplus01.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>On Sat, 13 Nov 1999, Kragen Sitaker wrote:
>> Also, it chops the data up into one-line chunks; for some data this
>> will be very small. 
>
>If you know that the file is small enough to fit in memory, how about
>an undefined $/ ?
>
>But in general, clearly you're right to read it in chunks of a size that
>you know you can handle.

If you know the file is small enough to fit in memory, you can simply
supply how much memory you want to use as an argument to read().  This
will be equivalent to undefining $/ for the cases when you're right,
and will still work when you're wrong.  And I don't think it's really
any more difficult: {local $/; $x = <FILE>; print $x} for one case, and
while (read FILE, $x, 131072) {print $x} for the other.

I typically undefine $/ only when reading files in chunks makes my code
more complicated -- e.g. maintaining regular expression state across
chunk boundaries.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 19:25:08 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: parsing UNIX mail spool files
Message-Id: <oWiX3.7134$YI2.283358@typ11.nn.bcandid.com>

In article <cxj9042xsur.fsf@acs5.bu.edu>, Dave Bakhash  <cadet@bu.edu> wrote:
>Does Perl V have a good library for parsing UNIX mail spool files?  What is it
>called?

Yes; look in the module list on CPAN, search for Mail.  (I assume you
mean Perl 5.)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 21:03:47 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Perl and commonsense part 2
Message-Id: <TmkX3.7481$YI2.297175@typ11.nn.bcandid.com>

In article <80eljm$s0m$1@nnrp1.deja.com>,  <ajmayo@my-deja.com> wrote:
>Regarding the use of map, I frankly have to admit I haven't the
>faintest idea how this works, and reading over the documentation
>for 'map' I am not terribly enlightened, but I will persevere.

There are many thing in Perl that were like that for me.  map happened
not to be one of them.

map simply transforms an input list into an output list according to a
specification of what each element of the input list should turn into.

So map { 'f', 'g' } 1, 2, 'dwarf', \$_ returns 'f', 'g', 'f', 'g', 'f', 'g',
'f', 'g'.  There are four elements in the input list, and each becomes
'f', 'g'.

I occasionally use map this way, where I simply ignore the input list
-- e.g. map { 1 + int rand 6 } 1..10 gives me ten random integers from 1
to 6.  Usually, though, I use the input list.

The block inside { } is evaluated (as you see above) once for each
member of the input list.  When it is evaluated, $_ is temporarily
bound to that member.  So map { $_ * $_ } 1..10 returns a list of the
squares of the first ten numbers.

An idiom I use frequently to turn a list (usually an array) into a hash
is %hash = map { $_ => 1 } (list).  This is useful because it is
clearer to write a test for membership in the set of the keys of a hash
than in the set of members of an array, and because it eliminates
duplicates.

>    %hash = map { getkey($_) => $_ } @array;

So if @array contains 1, 2, 3, this map will return getkey(1) => 1,
getkey(2) => 2, getkey(3) => 3.  So you can look up any member of
@array in the hash by the value returned by getkey.


-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 20:30:14 +0200
From: Re'em Bar <reembar@netvision.net.il>
Subject: regular expression riddle
Message-Id: <382DAE36.E0174516@netvision.net.il>


I want to change any word so it begins with CAPS
the little rabbit => The Little Rabbit
hope it's not in the FAQ too...

also, excuse my ignorance, but is there a way to pass more then one
array to a subroutine, not into the @_?
-- 
Re'em
http://snark.co.il


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

Date: Sat, 13 Nov 1999 19:28:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regular expression riddle
Message-Id: <382fbb18.619993@news.skynet.be>

Re'em Bar wrote:

> want to change any word so it begins with CAPS
>the little rabbit => The Little Rabbit
>hope it's not in the FAQ too...

I wouldn't be surprised if it was. The general term for it is
"titlecase".

	$_ = 'the LITTLE rabbit';
	s/(\w+)/\u\L$1/g;
	print;

-- 
	Bart.


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

Date: Sat, 13 Nov 1999 19:43:42 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: regular expression riddle
Message-Id: <ObjX3.7261$YI2.286246@typ11.nn.bcandid.com>

In article <382DAE36.E0174516@netvision.net.il>,
Re'em Bar  <reembar@netvision.net.il> wrote:
>I want to change any word so it begins with CAPS
>the little rabbit => The Little Rabbit
>hope it's not in the FAQ too...

perldoc -q capital
=head1 Found in /usr/local/lib/perl5/5.00503/pod/perlfaq4.pod

=head2 How do I capitalize all the words on one line?

To make the first letter of each word upper case:

        $line =~ s/\b(\w)/\U$1/g;

This has the strange effect of turning "C<don't do it>" into "C<Don'T
Do It>".  Sometimes you might want this, instead (Suggested by Brian
Foy):

    $string =~ s/ (
                 (^\w)    #at the beginning of the line
                   |      # or
                 (\s\w)   #preceded by whitespace
                   )
                /\U$1/xg;
    $string =~ /([\w']+)/\u\L$1/g;

To make the whole line upper case:

        $line = uc($line);

To force each word to be lower case, with the first letter upper case:

        $line =~ s/(\w+)/\u\L$1/g;

You can (and probably should) enable locale awareness of those
characters by placing a C<use locale> pragma in your program.
See L<perllocale> for endless details on locales.

This is sometimes referred to as putting something into "title
case", but that's not quite accurate.  Consdier the proper
capitalization of the movie I<Dr. Strangelove or: How I Learned to
Stop Worrying and Love the Bomb>, for example.


>also, excuse my ignorance, but is there a way to pass more then one
>array to a subroutine, not into the @_?

By reference.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Sat, 13 Nov 1999 00:36:18 -0600
From: TK Soh <r28629@email.sps.mot.com>
Subject: Re: regular expression riddle
Message-Id: <382D06E2.6F232F11@email.sps.mot.com>

Re'em Bar wrote:
> 
> I want to change any word so it begins with CAPS
> the little rabbit => The Little Rabbit
> hope it's not in the FAQ too...

unfortunately it is:

perldoc -q capital

> also, excuse my ignorance, but is there a way to pass more then one
> array to a subroutine, not into the @_?

try passing them by reference. Having said, they still go into @_

BTW, try not to ask more than one Q in a single post.
 
-TK


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

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


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