[12032] in Perl-Users-Digest
Perl-Users Digest, Issue: 5632 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 11 18:07:27 1999
Date: Tue, 11 May 99 15:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 11 May 1999 Volume: 8 Number: 5632
Today's topics:
[Fwd: my hands are tied] <gbartels@xli.com>
Re: [Fwd: my hands are tied] (Andrew Allen)
Re: Anyone willing to spare a shoulder ? <carol@herb4.freeserve.co.uk>
Re: array help needed (Tad McClellan)
Re: Can't Write to Files? <kperrier@blkbox.com>
Re: CONTRACT PERL PROGRAMMER <webmaster@chatbase.com>
Re: Databse connectivity (Alastair)
Re: FAQ 9.10: How do I redirect to another page? <webmaster@chatbase.com>
Re: File::Find non-functional when passing arguments to <rgoldber@eb.com>
GD/GIFgraph weirdness huichai@my-dejanews.com
HASH AND ARRAY bababozorg@aol.com
Re: Hello, good evening, and welcome! (Alastair)
HELP: FTP Part2 <mbarg@hotmail.com>
Re: HELP: FTP Part2 (Charles R. Thompson)
Re: HELP: FTP Part2 (Alastair)
HELP: FTP <mosher@hotmail.com>
Re: host table management (Alastair)
How can I create a socket server of non-blocking? <lt@linuxsvr.volcano.com>
Re: How process a file? (Alastair)
Re: ICMP packets: send & receive <ksv@gw.al.lg.ua>
Re: Link -> auto generated page (Alastair)
Re: Net::SMTP Problems. Help ! <oussov@mail.ru>
Re: neverendless loop in regexp (Charles DeRykus)
pattern matching - confused.... <arranp@datamail.co.nz>
Re: Perl Processes and Deamons. (Alastair)
Reading directories, entering directories, chaning file <agjemmes@extremeonline.com>
Re: Sorting is too slow for finding top N keys... <sb@sdm.de>
SRC - Educational input on my search routine request. (Charles R. Thompson)
Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Desig (Chris Nandor)
Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Desig <mkruse@rens.com>
Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Desig (Chris Nandor)
Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Desig (Benjamin Franz)
Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Desig (Charles R. Thompson)
Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Desig (Alastair)
Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Desig (Lee)
Re: This code just wont run. Any ideas? (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 May 1999 16:15:52 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: [Fwd: my hands are tied]
Message-Id: <37388FF8.18A1AF2C@xli.com>
This is a multi-part message in MIME format.
--------------01F161245D5F4DACB0575F8B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Greg Bartels wrote:
> this works:
> my $first; tie $first, 'stoplight', \$first, 4;
>
> sub TIESCALAR # in stoplight.pm looks like this
> {
> my ($class,$ref,$value) =@_;
> my $r_hash = {
> 'ref' => $ref,
> 'value'=>$value };
> return bless $r_hash, $class;
> }
>
> The problem is that
> my $first; tie $first, 'stoplight', \$first, 4;
> is about as ugly as you can get.
>
> is there anyway to write a subroutine that I could
> say something like:
> my $first = magic_routine(4);
> and it figures out the rest?
> i.e. $first is a scalar tied to 'stoplight' package, initialized to 4,
> and
> a reference to the scalar is stored in the object.
> something like:
>
> sub magic_routine
> {
> my($initial_value) = @_:
> my $scalar;
> tie $scalar, 'stoplight', \$signal, $initial_value;
> my $r_hash = {
> 'ref' => \$signal,
> 'value' => $value };
> return bless $r_hash, 'stoplight';
> }
>
> in yet other words, how can I write my own 'tie' routine?
>
> my_tie( my $first, 4);
>
> how does tie do its magic?
>
> gbartels@xli.com
--------------01F161245D5F4DACB0575F8B
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
X-Mozilla-Status2: 00000000
Message-ID: <373884E1.A8385FFE@xli.com>
Date: Tue, 11 May 1999 15:28:33 -0400
From: Greg Bartels <gbartels@xli.com>
X-Mailer: Mozilla 4.5 [en] (X11; I; SunOS 5.5.1 i86pc)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.lang.perl.moderated
Subject: my hands are tied
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
this works:
my $first; tie $first, 'stoplight', \$first, 4;
sub TIESCALAR # in stoplight.pm looks like this
{
my ($class,$ref,$value) =@_;
my $r_hash = {
'ref' => $ref,
'value'=>$value };
return bless $r_hash, $class;
}
The problem is that
my $first; tie $first, 'stoplight', \$first, 4;
is about as ugly as you can get.
is there anyway to write a subroutine that I could
say something like:
my $first = magic_routine(4);
and it figures out the rest?
i.e. $first is a scalar tied to 'stoplight' package, initialized to 4,
and
a reference to the scalar is stored in the object.
something like:
sub magic_routine
{
my($initial_value) = @_:
my $scalar;
tie $scalar, 'stoplight', \$signal, $initial_value;
my $r_hash = {
'ref' => \$signal,
'value' => $value };
return bless $r_hash, 'stoplight';
}
in yet other words, how can I write my own 'tie' routine?
my_tie( my $first, 4);
how does tie do its magic?
gbartels@xli.com
--------------01F161245D5F4DACB0575F8B--
------------------------------
Date: 11 May 1999 21:51:05 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: [Fwd: my hands are tied]
Message-Id: <7ha8o9$fe3$1@fcnews.fc.hp.com>
Greg Bartels (gbartels@xli.com) wrote:
: this works:
: my $first; tie $first, 'stoplight', \$first, 4;
: sub TIESCALAR # in stoplight.pm looks like this
: {
: my ($class,$ref,$value) =@_;
: my $r_hash = {
: 'ref' => $ref,
: 'value'=>$value };
: return bless $r_hash, $class;
: }
If your object needs a reference of what's tied to it, something's
amiss. It shouldn't care. Really. May want to rethink exactly what
you're doing. All a tied-to-package does is implement the "access
methods" of a tied variable. But it should stand on it's own, being
completely usable (if syntactically inconvenient) even if nobody ever
ties a variable to it.
: The problem is that
: my $first; tie $first, 'stoplight', \$first, 4;
: is about as ugly as you can get.
: is there anyway to write a subroutine that I could
: say something like:
: my $first = magic_routine(4);
Yes. Just write it:
sub magic_routine
{
my $tievar;
tie $tievar,'stoplight',\$tievar,@_;
return $tievar;
}
and if you want it in the package, it is probably a good candidate for
@EXPORT or @EXPORT_OK (see the Exporter docs).
Andrew
------------------------------
Date: Tue, 11 May 1999 21:03:16 +0100
From: "Carol Herbert" <carol@herb4.freeserve.co.uk>
Subject: Re: Anyone willing to spare a shoulder ?
Message-Id: <7ha2i7$6d$1@news4.svr.pol.co.uk>
I have tried 'z' and 'd'.
I have a feeling that Active Perl may not be working properly.
I have just tried a combination of ctrl, z and return - and the script
worked.
However, I have just spent 10 minutes trying to repeat the action - to no
avail.
I will therefore try re-installing Active Perl before I bother you all again
:)
Thanks
Stephen Warren wrote in message ...
>Carol Herbert <carol@herb4.freeserve.co.uk> wrote in message
>news:7ha1dc$v57$1@news4.svr.pol.co.uk...
>> Using Dos to check perl programmes : when entering a list of strings, the
>> command to finish on UNIX is CTRL+D. Other systems states CTRL+Z - but
>> neither of these work. Is there a different command for DOS ?
>
>Did you try typing CTRL-D, then return? Assuming that you mean entering a
>list of strings by typing...
>
>--
>Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
>mailto:swarren@techhouse.com http://www.techhouse.com/
>mailto:swarren@wwwdotorg.org http://www.wwwdotorg.org/
> MIME, S/MIME and HTML mail are acceptable
>
>
>
------------------------------
Date: Tue, 11 May 1999 10:53:11 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: array help needed
Message-Id: <n8g9h7.tdf.ln@magna.metronet.com>
xdream@my-dejanews.com wrote:
: Thanks for the url's and pointers - I will give them a read (or two).
: Upon further investigation, I see that I'm using a copy of "Learning
: Perl" from April 1994. The term "hash" isn't even in the index. The same
^^^^
They were called "associative arrays" back then.
: applies to "my" variables.
my() did not exist back then.
: Looks like I need to get a more up-to-date
: verion ASAP.
Yep.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 11 May 1999 15:05:10 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: Can't Write to Files?
Message-Id: <ysiyaive5jd.fsf@blkbox.com>
"Jerry Raynor" <jerryr001<NO-SPAM>@yahoo.com> writes:
>
> I continue to get the checksum for the else statement through the browser:
>
> /home/user1/public_html/files/customers.txt
> does not exist
>
> It never creates the file and if I create the file myself and run it I get
> the same thing files does not exist and yes it is pathed correctly, I went
> as far as doing a pwd to get the current directory and cutting and pasteing
> it into the script. I'm loosing my mind!!
First, your problem is a cgi one, not a perl one so this should be asked
in the cgi newsgroup comp.infosystems.www.authoring.cgi
Second, I would check the permissions of the file against the permissions that
the webserver is running under. Your problem may lie there.
Kent
------------------------------
Date: Tue, 11 May 1999 14:41:58 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: CONTRACT PERL PROGRAMMER
Message-Id: <3738A426.A9FEE230@chatbase.com>
> Experience/Skills:
>
> * CGI scripting (Perl/C)
YES!
> * Software Debugging
YES!
> * BSDi UNIX, Linux, FreeBSD or Sun operating systems
YES, YES, YES, YES to all!
> * system backups/maintenance scripts
That's wise.
> * ability to troubleshoot and solve problems creatively
YES! I'm *very* "creative".
> * self-motivated with a positive attitude
Damn! I'm out. (I need constant encouragement from my peers).
> * Reliable at completing projects in a timely manner
Or whatever you think is "timely" and promise your client I do the work
for. :-)
> Not Required, But Helpful
None of the above was required?
> * UNIX system administration
> * UNIX security
> * database programming/SQL
Yes to all. Too bad you SPAM, or you might have had some help.
--
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
The Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm: http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!
------------------------------
Date: Tue, 11 May 1999 21:52:27 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Databse connectivity
Message-Id: <slrn7jhd7e.5f.alastair@calliope.demon.co.uk>
PREETI KUMAR <preetikumar@rocketmail.com> wrote:
>I want to get ingo from browsers thru a form which needs to be stored in a
>database. How do I do it ?
A step at a time. Don't run before you can walk. Read the Perl docs and get a
good book on perl. Learn Perl. Then, when you get stuck on something specific,
come back and ask.
Good luck.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 11 May 1999 14:44:31 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: FAQ 9.10: How do I redirect to another page?
Message-Id: <3738A4BF.9B80EEA7@chatbase.com>
Henry Hartley wrote:
>
> I know this can be found elsewhere but since you are addressing the topic of
> redirection, how 'bout adding a sentence about targeting another frame (since
> this took me a while to figure out, even after reading references in the CGI
> FAQ). Something like:
>
> To target a particular frame in a frameset, include the "Window-target:" in the
> header.
>
> print "Location: http://www.domain.com/newpage\nWindow-target: <FrameName>\n\n";
>
> It's a little thing but those of us who don't know much about headers will find
> it useful.
Unless you use IE and not Netscape, and it doesn't work 1/2 the time.
--
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
The Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm: http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!
------------------------------
Date: Tue, 11 May 1999 17:01:42 -0500
From: RayG <rgoldber@eb.com>
Subject: Re: File::Find non-functional when passing arguments to &wanted
Message-Id: <Pine.GSO.3.96.990511165917.20638C-100000@cliff.eb.com>
> : Andrew Allen wrote:
>
> : sub foo { shift };
> : print \foo; # undef
> : -> SCALAR(0x13b1e0)
> : print \foo(3); # 3
> : -> SCALAR(0x13b1e0)
> : print \&foo(3); # 3
> : -> SCALAR(0x13b1e0)
> : print \&foo;
> : -> CODE(0xffc12238)
>
> : Well there's a bizarre exception alright. "&foo" is the only syntax that
> : returns a code ref, WITHOUT excuting the sub. The others all return a
> : reference to the value returned by the sub call.
you could also use *foo{CODE}
------------------------------
Date: Tue, 11 May 1999 19:56:21 GMT
From: huichai@my-dejanews.com
Subject: GD/GIFgraph weirdness
Message-Id: <7ha213$hrh$1@nnrp1.deja.com>
I have a script that is supposed to create a line graph
of some data, but it craps out with a division by 0
error. I traced the location of the error through the module
and it fails at line 1036 in GIFgraph::axestype::setup_legend().
there, it tries to $num/$s->{lg_cols}, and both of these values
are 0. Looking back, I see that $num is set to 0 in the beginning
of the function, and $s->{lg_cols} = _min($s->{lg_cols}, $num), which
makes it 0.
If there anyone who is familiar with the internals of GIFgraph who can
explain what is happening there, I would really REALLY appreciate it.
Thanks!!
Hui.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 11 May 1999 21:10:44 GMT
From: bababozorg@aol.com
Subject: HASH AND ARRAY
Message-Id: <7ha6cf$l9s$1@nnrp1.deja.com>
hi
can any one please tell me how to do this? :
i have a array like this:
@array = ("aaa","bbb","ccc");
i would like to add each element of this array az a key into a hash.
like this:
%hash = ("aaa","",
"bbb","",
"ccc","");
i tried this:
%hash = @array;
but it will be like this:
%hash = ("aaa",
"bbb","ccc");
it actualy brings the third one as a value of the second one.
please tell me how to do this :)
AND ALSO DOES ANY ONE KNOWS HOW TO SORT a HASH?
thanks
hamed
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 11 May 1999 21:42:41 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Hello, good evening, and welcome!
Message-Id: <slrn7jhcl3.5f.alastair@calliope.demon.co.uk>
Steve Laybourn <laughingotter@foxinternet.net> wrote:
>Hello, everyone!
> Be gentle with me, it's my first time...
> I am a PERL programmer with a problem...
> Basically, it involves using the Net::FTP module...
The best thing to do is always read the docs that come with the module - they're
installed on your hard disk. Try ;
perldoc Net::FTP
or
man Net::FTP
Then, take things one step at a time. If you know a file present on an FTP
server somewhere, use the example at the top of the manual to retrieve it i.e.
use Net::FTP;
$ftp = Net::FTP->new("some.host.name");
$ftp->login("anonymous","me@here.there");
$ftp->cwd("/pub");
$ftp->get("that.file");
$ftp->quit;
Once you're happy with this, try using 'put' to upload a file. Step by step.
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 11 May 1999 22:55:42 +0200
From: "mosher" <mbarg@hotmail.com>
Subject: HELP: FTP Part2
Message-Id: <7ha5gf$bvj$1@rztsun2.tu-harburg.de>
Hi,
could someone please send me an example about how to
upload a file to a ftp-server by using the ftp-package !
Many thanks !
mail to mbarg@hotmail.com please !
------------------------------
Date: Tue, 11 May 1999 21:20:17 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: HELP: FTP Part2
Message-Id: <MPG.11a26a708b6f5928989698@news>
In article <7ha5gf$bvj$1@rztsun2.tu-harburg.de>, mosher says...
> could someone please send me an example about how to
> upload a file to a ftp-server by using the ftp-package !
> Many thanks !
> mail to mbarg@hotmail.com please !
Sequels never are any good.
Quit multi-posting.
------------------------------
Date: Tue, 11 May 1999 21:33:05 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: HELP: FTP Part2
Message-Id: <slrn7jhc34.5f.alastair@calliope.demon.co.uk>
mosher <mbarg@hotmail.com> wrote:
>Hi,
>
>could someone please send me an example about how to
>upload a file to a ftp-server by using the ftp-package !
There's an example in the man page i.e.
man Net::FTP
or
perldoc Net::FTP
use Net::FTP;
$ftp = Net::FTP->new("some.host.name");
$ftp->login("anonymous","me@here.there");
$ftp->cwd("/pub");
$ftp->get("that.file");
$ftp->quit;
Change 'get' to 'put' and check for error conditions. Assuming this is the
'ftp-package' you're referring to.
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 11 May 1999 22:52:19 +0200
From: "mosher" <mosher@hotmail.com>
Subject: HELP: FTP
Message-Id: <7ha5a4$bsg$1@rztsun2.tu-harburg.de>
Hi,
could someone please send me an example about how to
upload a file to a ftp-server by using the ftp-package !
Many thanks !
------------------------------
Date: Tue, 11 May 1999 21:47:02 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: host table management
Message-Id: <slrn7jhct8.5f.alastair@calliope.demon.co.uk>
mjbower@my-dejanews.com <mjbower@my-dejanews.com> wrote:
>anyone seen a script to manage a host table ?
Never seen one, sorry.
>I'd like to use a html front end to add/delete/edit entries
>in the hosts table.
OK.
>any help is greatly appreciated
It's probably not that hard. Have a go! If you get stuck, ask something
specific.
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Mon, 10 May 1999 13:53:45 +0800
From: "lt" <lt@linuxsvr.volcano.com>
Subject: How can I create a socket server of non-blocking?
Message-Id: <373746a2.0@system.nari-china.com>
Hi,
I am a newbie of Perl, I found a socket server example in the book
Programming Perl, but I want to look for a program using non-blocking server
socket, I have tried fcntl() on the socket after binding and listening, but
when I call accept() the script died with "Resource temporarily unavailable"
message in $!. Is there any samples on this? Like a chat server something.
thanks,
------------------------------
Date: Tue, 11 May 1999 21:17:28 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: How process a file?
Message-Id: <slrn7jhb5r.5f.alastair@calliope.demon.co.uk>
Yang Chao <yangc@ra.comm.mot.com> wrote:
>This is a multi-part message in MIME format.
Please configure your 'news reader' and post plain text. This is not the web.
> open(FILE, "file.txt")
No. You're not even checking if your 'open' worked.
>yang chao is good.
Not yet. You need to practice some more.
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 11 May 1999 19:31:34 +0300
From: "Sergey V. Kolychev" <ksv@gw.al.lg.ua>
Subject: Re: ICMP packets: send & receive
Message-Id: <Pine.LNX.3.96.990511192954.8507B-100000@gw.al.lg.ua>
On Mon, 10 May 1999, Zekers wrote:
> I am testing a commercial program (Seagate Software's Nerve Center) that
> among other things, can receive and then take action on ICMP
> error packets. I need to create a program that will receive the initial
> ICMP request from NC and then send an ICMP error packet back to NC. This
> would be repeated for the thirty or so ICMP error packets. I haven't
> found a pm that handles the ICMP stuff. Is there such a thing? Is there
> a UDP pm that I can build an ICMP packet with? Any thoughts would be
> appreciated.
> Thanx, Zekers!
If your platform is unix-like then use Net::RawIP from
http://quake.skif.net/RawIP or CPAN
>
>
>
----------------------Alchevsk Linux User Group-----------------------
I don't call, I don't cry , I don't sorry.
All will gone like a white appletreeses's smoke... (S.Esenin)
http://www.ic.al.lg.ua/~ksv | e-mail: ksv@gw.al.lg.ua
PGP key & Geekcode: finger ksv@gw.al.lg.ua
------------------------------
Date: Tue, 11 May 1999 21:50:24 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Link -> auto generated page
Message-Id: <slrn7jhd3j.5f.alastair@calliope.demon.co.uk>
Andreas <andreas73@my-dejanews.com> wrote:
>Hi,
>I4d like the visitors at my homepage to click on a link - which then
>generates a page automatic with an image. Sort of thumbnail, without the
>nails, just links. The page that is generated should the contain an
>image that is related to the link. See what I mean?
I think so. Good luck! If you get stuck, you should come back and ask something
specific.
Best Wishes,
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: 12 May 1999 00:00:40 +0400
From: "Ilya Oussov" <oussov@mail.ru>
Subject: Re: Net::SMTP Problems. Help !
Message-Id: <01be9be8$c48326c0$54c82ed4@oussov.spb.cityline.ru>
> script, I get a couple of diff err msgs. These include:
>
> D:\Documents and Settings\stevenmc\My Documents\perl>mail.pl
> In string, @there now must be written as \@there at D:\Documents and
> Settings\st
Just do exactly what error message tells you about - replace all @ with \@
in your addresses in the script.
Perl of version 5 hardly tolerates these @'s, using it for special
purposes.
--
o-:^>___? Ilya Oussov <oussov\@mail.ru>
`~~c--^c'
------------------------------
Date: Tue, 11 May 1999 20:46:05 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: neverendless loop in regexp
Message-Id: <FBL5ot.D9p@news.boeing.com>
In article <373807F1.2447D263@nospam-correctnl.com>,
Henry <hvermeulen@nospam-correctnl.com> wrote:
>Hi to you all.
>I've got a bit of a problem with the following piece of code.
>It starts a loop while it should read about 500 lines from $ov.
>It does, only it starts over and over.
>
> ...
> while ($1 ne "<!--stop-->") {
> print "$1\n"; }
You'll loop if $1 doesn't equal the comparison string.
P.S. - All your curly braces badly need chiropractic alignment... :)
Doesn't something more like:
while ($1 ne "blah" ) {
bleh;
blah;
}
or, if you come from an impurer faith, even something like:
while ($1 ne "blah" )
{
bleh;
blah;
}
make you feel like much better about your posture...
Cheers,
--
Charles DeRykus
------------------------------
Date: Wed, 12 May 1999 09:51:47 +1200
From: Arran Price <arranp@datamail.co.nz>
Subject: pattern matching - confused....
Message-Id: <3738A673.52F1@datamail.co.nz>
Hi all,
Ok, Problem is this, I created a subroutine for one of my perl scripts
that locates a character and substitutes it. Now this worked (and still
works fine) apart from when the character I am changing from is a |
(pipe). Now I realised that a | could be used as match|this|orthis but I
got further confused as if I read the variable in from stdin as "\|" it
works correctly. If I I just set the variable it dosent work. Anyone
clue me in here? At current using | not \| tends to give me a pipe
character as every second character. I need the script to work for any
passed character.
Thanks in advance for any help.
The code follows:
#!/usr/local/bin/perl
$IFN="frog";
$OFN="frog2";
#uncomment these 2 lines to see when I hardcode the chars
#$CHAR_FROM="|";
#$CHAR_TO="!";
#comment out the next 4 lines when using the hardcoded
print"\nEnter from char : ";
chomp($CHAR_FROM=<STDIN>);
print"\nEnter to char : ";
chomp($CHAR_TO=<STDIN>);
open(IF,"$IFN") || die "Cant open $IFN.\n";
open(OF,">$OFN") || die "Cant open $OFN.\n";
my $MC=0;
while(<IF>)
{
if ($_=~/$CHAR_FROM/g)
{
s/$CHAR_FROM/$CHAR_TO/g;
++$MC;
}
print OF;
}
close IF || die "Cant close $IFN.\n";
close OF || die "Cant close $OFN.\n";
# Print conversion information.
print"\n$MC records Converted - Successful.\n";
Arran Price
arranp@datamail.co.nz
My opinions are my own and do not reflect those of my employer.
------------------------------
Date: Tue, 11 May 1999 21:45:11 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Perl Processes and Deamons.
Message-Id: <slrn7jhcpq.5f.alastair@calliope.demon.co.uk>
Ming <fungs@logica.com> wrote:
>Can anyone give me some pointers for writing Perl Deamons and Spawning child
>processes in Perl.
You could always fall back on looking at the perl docs.
perldoc perlipc
would be one place to start.
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 11 May 1999 22:10:14 +0200
From: "Asbjorn Gjemmestad" <agjemmes@extremeonline.com>
Subject: Reading directories, entering directories, chaning file permissions...
Message-Id: <_60_2.531$d31.4131@news1.online.no>
I am trying to create a script taht will do the following:
- Get a list of the directories in a given folder.
- Enter each of these directories, and chmod all files to 777 in each and
every directory.
I figure that the best way of doing this is through a telnet interface,
since you've got your own permissions instead of Perl's permissions like
through a html page. (don't you???)
Here's what I've come up with, but it doesn't seem to do the trick. Any help
whatsoever is greatly apprecciated.
thnx
Asbjorn
########## The script : ###########
# :'s and .'s are used as progress indocators
#one : is printed for each directory, and one . is printed for each file.
#!/usr/local/bin/perl -w
$dir = "/usr/sites/blitzkrieg.org/blitzkrieg/members";
use Benchmark;
$t0 = new Benchmark;
chdir ($dir) || die "Can't change directory!";
opendir(DIR, ".") || die "Can't open directory";
@files = readdir(DIR) || die "Can't read directory ";
closedir(DIR);
print "Processing : <br>";
@errors = "";
$processed = 0;
$dirs = 0;
$fnum = @files;
print "Files: $fnum";
foreach $file (@files) {
chomp ($file);
print ":";
opendir(D, $dir/$file) || die "Can't read directory 3";
@members = readdir(D);
closedir(D);
$dirs++;
foreach $member (@members) {
chomp($member);
chmod(0777, "$dir/$file/$member") || push(@errors, "$file/$member");
print ".";
$processed++;
}
}
if ($errors[0]) {
print "The following files returned errors:";
foreach $error (@errors) {
print "$error\n";
}
}
print "\n $processed files in $dirs directories processed! ";
$t1 = new Benchmark;
$td = timediff($t1, $t0);
print "Execution time:",timestr($td),"\n";
exit;
------------------------------
Date: 11 May 1999 21:45:10 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: Sorting is too slow for finding top N keys...
Message-Id: <7ha8d6$jig$1@solti3.sdm.de>
In article <7h24na$sfp$1@xenon.inbe.net>, Michel Dalle <michel.dalle@usa.net> wrote:
> I've had a funny experience with using sort. Can anyone tell
> me why perl sorts so slowly sometimes, depending on the
> values to be sorted ?
> Here's what happened : I have a hash with about 30.000 entries,
> I want to sort them by value and extract the top N elements.
> The hash contains about 500 different values, and the majority
> of values are all the same (=heavy-tailed distribution?).
> 1) the simple (obvious) way would be to let Perl do the job :
> @topn = (sort {$hash{$b} <=> $hash{$a}} keys %hash)[0..$n];
> This works fine for random values (a few seconds), but for the
> hash I have, it takes several minutes !!
> 2) since this was quite unacceptable, I ended up writing my own
> top N sort routine :
> [...]
> I also tried replacing the sort with pops, splices and unshifts, but it didn't
> really improve anything. Can anyone suggest other alternatives ?
You might want to try HeapSort instead of "sort" (which is really QuickSort,
internally, and which degrades to quadratic complexity if the elements
are mostly sorted already, as in your case).
You can find a Perl implementation of HeapSort in my module "Graph::Kruskal"
(which you can rip out and adapt to suit your specific needs). See my sig below
for URLs where you can download this module.
(Note: Let "N" be the number of elements in your array, and "n" the number
of topmost elements you're interested in. Then after the initialization
of the heap, simply perform the "heapify" loop "n" times instead of "N"
times. The first "n" elements in the array will then be the "n" greatest
(or smallest, depending wether you use "<=" or ">=" in the comparison
statements) elements from your list.)
This should be more efficient, because worst case behaviour of HeapSort
( O( n * ld(n) ) is much better than that of QuickSort ( O( n^2 ) ),
even though the proportionality constants are in favour of QuickSort
in average case, and also because you only need the "n" topmost elements
and thus you don't need to sort the remaining N-n elements as you would
with QuickSort.
Hope this helps!
Regards,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/
http://www.engelschall.com/u/sb/download/
http://www.perl.com/CPAN/authors/id/STBEY/
http://www.oreilly.de/catalog/perlmodger/bnp/
------------------------------
Date: Tue, 11 May 1999 21:26:04 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: SRC - Educational input on my search routine request.
Message-Id: <MPG.11a26bc85061d6b6989699@news>
Being somewhat limited to Modules due to version conflicts, I'm having to
custom write a few search routines for a site. In the process I'm
learning quite a few things and wondered if I could get some educational
feedback on a section of my script as it stands so far. This script was
originally a big flat blob of while loops, opendir, too many arrays, etc.
I have received many helpful opinions on various aspects of what I've
done so far, especially in regard to File::Find and the anonymous
subroutine. (I'm still a bit baffled, but maybe what I have presented is
valid?) Input is greatly appreciated.
#@keyword_list comes from a Form Input tag and
#is error checked before search is called.
#search must be as a sub in this design
&search('/drv1/web/sites/web6517e/', @keyword_list);
sub search{
my($path, @keyword) = @_;
find(
sub{
return unless ((/\.shtml.*$/) || (/cgi-bin/));
my ($curr_file) = $_;
my $found_words = "";
my $word_count = 0;
{
local $_;
($pagelines = read_file($curr_file)) =~ s/(\s+)(\n)/ /g;
foreach (@keyword){
$word_count = 0;
while ($pagelines =~ /$_/ig) {
$word_count++;
}
if ($word_count) {
$found_words .= "$_ $word_count times, ";
}
}
if ($found_words) {
print "$found_words $this_word_count in $curr_file<br>";
}
}
},$path);
}
I'm pretty sure I blew it with this line...
> ($pagelines = read_file($curr_file)) =~ s/(\s+)(\n)/ /g;
perhaps this doesn't evaluate as fast as an alternative?
Thanks for any insight,
CT
------------------------------
Date: Tue, 11 May 1999 20:02:25 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Design
Message-Id: <pudge-1105991602270001@192.168.0.77>
In article <Sa%Z2.20938$ny.1333283@typhoon-sf.snfc21.pbi.net>,
snowhare@long-lake.nihongo.org (Benjamin Franz) wrote:
# JavaScript has many problems in cross-platform compatibility, but it's
# by no means restricted to 'two valid uses'. For example, I use it in
# an application where I have 14 series of data that may need to be
# 'shifted' one place left or right for the user. The page the form
# is in is OVER 300 K net
And I can cut my Thanksgiving turkey with nothing but a pair of toothpicks.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Tue, 11 May 1999 15:10:00 -0700
From: "Matt Kruse" <mkruse@rens.com>
Subject: Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Design
Message-Id: <7ha307$d5i$1@ffx2nh3.news.uu.net>
Chris Nandor wrote in message ...
>It has nothing to do with HTML 2.0. Again, HTML, by definition, cannot
>define what something will look like, no matter what the version. HTML is
>a *device-independent* markup language.
I fully understand what HTML is capable of and what ut was designed for.
I suspect the majority of readers of this thread fit into the same
category. Don't insult our intelligence by assuming we're ignorant simply
because we disagree with you.
Matt Kruse
mkruse@rens.com
------------------------------
Date: Tue, 11 May 1999 20:34:55 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Design
Message-Id: <pudge-1105991634570001@192.168.0.77>
In article <7ha307$d5i$1@ffx2nh3.news.uu.net>, "Matt Kruse"
<mkruse@rens.com> wrote:
# Chris Nandor wrote in message ...
# >It has nothing to do with HTML 2.0. Again, HTML, by definition, cannot
# >define what something will look like, no matter what the version. HTML is
# >a *device-independent* markup language.
#
# I fully understand what HTML is capable of and what ut was designed for.
# I suspect the majority of readers of this thread fit into the same
# category. Don't insult our intelligence by assuming we're ignorant simply
# because we disagree with you.
If you know what HTML is, then you have no reason to disagree. If you
disagree, it is reasonable to assume it is because you don't know what
HTML is.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Tue, 11 May 1999 20:46:56 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Design
Message-Id: <4H0_2.20974$ny.1341561@typhoon-sf.snfc21.pbi.net>
In article <MPG.11a250cb6057b2bc989696@news>,
Charles R. Thompson <design@raincloud-studios.com> wrote:
>[This followup was posted to comp.lang.perl.misc and a copy was sent to
>the cited author.]
>
>In article <Sa%Z2.20938$ny.1333283@typhoon-sf.snfc21.pbi.net>, Benjamin
>Franz says...
>> This is like saying 'Perl only has two valid uses: Report generation
>> and data reduction'.
>
>no. It's exactly like saying trusting JavaScript to pre-supply your error
>checking is a totally nearsighted and dangerous concept. I am talking
>about compatibility and fallbacks here.
Unless I've totally lost my grip on the English language, your first
statement didn't qualify itself to the restricted problem of
error checking. You made a declaration of universal principle that
JavaScript can *ONLY* be validly used for error checking and rollovers.
>I said that you should *still* error check in your script which *no one*
>from this NG with an inkling of understanding would argue against.
Of course you do. Nor did I argue against it.
>> JavaScript has many problems in cross-platform compatibility, but it's
>> by no means restricted to 'two valid uses'. For example, I use it in
>> an application where I have 14 series of data that may need to be
>> 'shifted' one place left or right for the user.
>
>JavaScript *is* restricted due to cross-platform compatibility. As you
>very well point out above and below, you completely missed the following
>points from the threads...
>
>1) download time. Even with my blistering connection here, I wouldn't
>touch that bloated page.
Not asking you to. The page is a backend data entry page - the
general public is not even invited to the party.
>2) non-javascript users. My previous example illustrates that there
>should be fallbacks to any client side driven solution on the server. If
>you aren't doing that, you are opening your script's weaknesses
>(possibly security issues) and quite possibly ruining someone's visit to
>your site.
Restricted audience. The people using the page *WILL* be using a current
version of Netscape. Period. Again - *this is not a page for public access*.
>> The page the form
>> is in is OVER 300 K net (yes, its a monster. A matter of necessity
>> for its application.)
>
>What a waste. I hope you don't pay for your bandwidth usage.
Nope. I buy a data pipe. What I do with my pipe is my business.
>> Using CGI around the loop to shift the data
>> one place in the form fields takes an unreasonable amount of time.
>
>I would say it would take about forever + 1/2 since CGI can't do that in
>the first place. The *language* you script in does. I'll even up the ante
>by declaring that more than 10 people in the NG could match if not beat
>your 'shift code' times in Perl. Your solution doesn't really gain
>anything since the CGI bottleneck will effect whatever the heck you send
>it anyway.
You are playing semantic games. I _have_ written the shift code in Perl
before for a related application (this same application in another guise,
really). Whether written Perl, C, Ada, Java or God's Own Programming Language,
it forces the user to reload 300K of HTML to have the CGI script perform
the shift.
I'm not going to torture my users by making them unnecessarily reload a
300K page to do something I can use a JavaScript assist on their
end to do in a second or so. I save the generation and load time for 300K
of HTML. I don't consider that a minor win.
>> JavaScript does it in a second or so on request.
>
>Heh.. that's all great and wunnerful and all that, but what happens when
>a user without JavaScript hits your page?
Not an issue. As I said before, this is *NOT* a public accessible
page. I have complete control over the software being used to access
this.
>You have lost part of your visitors due to download time
>You have lost another part due to no fallbacks
I've lost nobody. This isn't a web page for surfers. This is part
of the backend support application for a publishing system. The
people here are *paid* to be here, they use the software *I*
specify to access it.
--
Benjamin Franz
"There are more things in heaven and earth, Horatio,
than are dreamt of in your philosophy."
------------------------------
Date: Tue, 11 May 1999 21:19:25 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Design
Message-Id: <MPG.11a26a2d14159ae8989697@news>
In article <4H0_2.20974$ny.1341561@typhoon-sf.snfc21.pbi.net>, Benjamin
Franz says...
> Unless I've totally lost my grip on the English language, your first
> statement didn't qualify itself to the restricted problem of
> error checking. You made a declaration of universal principle that
> JavaScript can *ONLY* be validly used for error checking and rollovers.
Preceded by IMO. In My Opinion as applied to compatibility issues which
is how this thread kicked off (and was later modified to reveal it's
true nature). Hardly a declaration of Universal Principle. besides...
> the general public is not even invited to the party.
> Restricted audience. The people using the page *WILL* be using
> *this is not a page for public access*.
> I have complete control over the software being used to access this.
> they use the software *I* specify to access it.
Why are you trying to make an argument for this when the core concept
originally presented clearly does not even apply to you in the first
place?
Besides, the thread now really isn't about what we're hashing over
anyway.
I've spammed enough.
--
CT
"Perl.. there I said it"
------------------------------
Date: Tue, 11 May 1999 21:23:54 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Design
Message-Id: <slrn7jhbhs.5f.alastair@calliope.demon.co.uk>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> +------------------------------------------------------+
> | Ten Tips toward *DIVERSITY COMPLIANCE* in Web Design |
> +------------------------------------------------------+
I agree with the sentiment wholeheartedly. However, considering the grief people
get around here for posting off-topic messages. I see precious little Perl
content in there.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Tue, 11 May 1999 16:33:53 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Ten Tips toward *DIVERSITY COMPLIANCE* in Web Design
Message-Id: <B35E0C71966869126@0.0.0.0>
In article <37387ff8@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
> "J|rgen Exner" <juex@my-dejanews.com> writes:
>:Somehow I fail to see the relation with Perl.
>:Do you mind to explain?
>
>It's in my followup -- a perl-based proxy to fix a lot
>of this totally evil crap.
May I suggest that it, and much else that is found in this ng, would more
properly belong in alt.fan.tom-c or comp.lang.perl.religion?
Lee
------------------------------
Date: Tue, 11 May 1999 11:08:14 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: This code just wont run. Any ideas?
Message-Id: <u4h9h7.tdf.ln@magna.metronet.com>
Roger Liu (rliu2@ford.com) wrote:
: This is a multi-part message in MIME format.
^^^^^^^^^^^
Please stop posting that.
It makes you look foolish.
Usenet is a plain text medium.
: > $to = "daniel.vesma@thewebtree.com";
: ^^^^^^^
: Change @ to \@
Change " to '
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5632
**************************************