[18020] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 180 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 31 03:05:36 2001

Date: Wed, 31 Jan 2001 00: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: <980928312-v10-i180@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 31 Jan 2001     Volume: 10 Number: 180

Today's topics:
    Re: 'apply' function in perl? (Mark Jason Dominus)
    Re: 'apply' function in perl? (Damian Conway)
    Re: <>, tie *STDIN or *ARGV <johnlin@chttl.com.tw>
    Re: <>, tie *STDIN or *ARGV <johnlin@chttl.com.tw>
    Re: accessing name of variable (=?iso-8859-1?Q?J=F6rg?= Ziefle)
    Re: code review request <shutupsteve@aNwOdSaPnAgM.com>
    Re: copy construct reference to anonymous scalar <johnlin@chttl.com.tw>
        differences in DB_File files accross systems <news@#nospam#althepal.com>
    Re: differences in DB_File files accross systems (Rob - Rock13.com)
        Do threads really work? <raphael@iscusa.com>
        exists news reply grabber? [somewhat OT] (=?iso-8859-1?Q?J=F6rg?= Ziefle)
        Freelancer wanted for quickie <webdev@ihatrading.com>
    Re: How to send back 2 or more gif, if only one cgi cal <david@kasey.umkc.edu>
        Include bug in HTML::Template 2.2 <james@NOSPAM.demon.co.uk>
    Re: making a mail reciving script (Rafael Garcia-Suarez)
    Re: Newbie question dtbaker_dejanews@my-deja.com
    Re: printing array of hashes <peter.sundstrom@eds.com>
    Re: printing array of hashes <motivusNO@SPAMhotmail.com>
    Re: Printing to a device, not a local port? - How 'bout <karlt@pine-grove.com>
        Proc::Background <chahn@peregrine.com>
    Re: pushing hash onto an array (Gwyn Judd)
    Re: pushing hash onto an array (Gwyn Judd)
    Re: qr and backreferences (Gwyn Judd)
    Re: qr and backreferences <joe+usenet@sunstarsys.com>
    Re: Question on appending to file dtbaker_dejanews@my-deja.com
        Referencing module functions query. <phillips@central.murdoch.edu.au>
        Security based on REMOTE_ADDR <m_ario@my-deja.com>
    Re: Security based on REMOTE_ADDR <wyzelli@yahoo.com>
    Re: Security based on REMOTE_ADDR <bop@mypad.com>
    Re: Security based on REMOTE_ADDR <tore@extend.no>
    Re: Security based on REMOTE_ADDR <godzilla@stomp.stomp.tokyo>
    Re: simple hash question. <tore@extend.no>
    Re: substituting "@" with regexp <todda@xmission.com>
        Unresponsive file handles.. <ayoungtechie@my-deja.com>
    Re: Unresponsive file handles.. <webmaster@jargonnetengineer.cjb.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 31 Jan 2001 06:03:59 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: 'apply' function in perl?
Message-Id: <3a77aacf.6ef4$2a8@news.op.net>

In article <pc7y9vs1z15.fsf@panix2.panix.com>,
Lewis Perin  <perin@panix.com> wrote:
>Might it not be nice to have a curried version without locals:
>> Now you can call 
>> 
>>         reduce { $a + $b } 0, (1,4,2,8,5,7);
>
>seduce { $_[0] + $_[1] } 0 , (1,4,2,8,5,7);


Sure, but I don't see what the benefit is.  { $a + $b } is easier to
read and to type than { $_[0] + $_[1] }.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 31 Jan 2001 07:03:28 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: 'apply' function in perl?
Message-Id: <958dc0$oo3$1@towncrier.cc.monash.edu.au>

mjd@plover.com (Mark Jason Dominus) writes:

>>seduce { $_[0] + $_[1] } 0 , (1,4,2,8,5,7);

>Sure, but I don't see what the benefit is.  { $a + $b } is easier to
>read and to type than { $_[0] + $_[1] }.

But not as easy as:

	seduce ^a + ^b, 0, (1,4,2,8,5,7);

and certainly not as general as:

	deduce ^a * ^b - ^c, 0, (1,4,2,8,5,7);

See: 
	http://dev.perl.org/rfc/23.html
	http://dev.perl.org/rfc/76.html
	Function::HigherOrder (RSN!)

Damian


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

Date: Wed, 31 Jan 2001 10:51:40 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: <>, tie *STDIN or *ARGV
Message-Id: <957un0$8gr@netnews.hinet.net>

"Rick Delaney" write
>   BEGIN { tie *ARGV, 'A' unless -t }

Oh, great!!!  Now I learned the "-t".

Strangely, it doesn't work, although it makes sense.

My experiment shows "-t ARGV" has better discrimination than "-t":

C:\>perl -e "<>; print -t" hello.txt
1
C:\>perl -e "<>; print -t"
1
C:\>perl -e "<>; print -t ARGV" hello.txt

C:\>perl -e "<>; print -t ARGV"
1

But, as a matter of fact, neither
BEGIN { tie *ARGV, 'A' unless -t }
nor
BEGIN { tie *ARGV, 'A' unless -t ARGV }
will work.

I guess either
the -t checking in the BEGIN block is too early
or
Win32 is the problem.

John Lin

P.S.  The  "unless @ARGV"  works.  Thanks.





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

Date: Wed, 31 Jan 2001 13:58:37 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: <>, tie *STDIN or *ARGV
Message-Id: <9589lh$lrr@netnews.hinet.net>

Nobull wrote:

> Note: tieing ARGV cannot replace the sematics of the special function
> of eof().  (eof()) is, perversely, actually different from (eof) and
> there's no way I know that you can alter the semantics of (eof()).

I know what you mean:
-------------------------------------------------------
package A;

sub TIEHANDLE { print "tie called\n"; bless \(my $num = 0) }

sub READLINE {
    my $num = shift;
    $$num++ < 4? "line $$num\n": undef;
}

sub EOF {
    my $num = shift;
    return $$num % 2;
}

BEGIN { tie *ARGV,'A' unless @ARGV }

package main;

while(<>) {
    print;
    print "***** EOF *****\n" if eof;
    print "**** EOF () ****\n" if eof();
}

The result you want is:

tie called
line 1
***** EOF *****
line 2
line 3
***** EOF *****
line 4
**** EOF () ****

But the actual result is:

tie called
line 1
***** EOF *****
**** EOF () ****
line 2
line 3
***** EOF *****
**** EOF () ****
line 4

Well, maybe we can ask next version of perl to callback
sub EOF with one more argument to indicate eof or eof().
Otherwise this can be considered as a bug, right?

John Lin





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

Date: 31 Jan 2001 03:37:39 GMT
From: gt4556a@acmez.gatech.edu (=?iso-8859-1?Q?J=F6rg?= Ziefle)
Subject: Re: accessing name of variable
Message-Id: <slrn97f243.hh0.gt4556a@acmez.gatech.edu>

On Tue, 30 Jan 2001 02:50:58 GMT, Rick Delaney <rick.delaney@home.com> wrote:

>> Is it possible (with globs, ...) to directly access the name of a
>> variable?  For instance, when I have a scalar named $foo, the operation
>> would give me the string 'foo', that is, the name of $foo stringified.

>Have you tried 
>
>   print *foo;

That's not quite functional: Imagine I have an array or a hash of refs of other
variables.  Now I want to access the name of each variable which is held in the
array/hash.

Sample (scalarref to scalar):
=============================

$variable = 'data';

$scalarref = \$variable;
print *variable;	# prints *main::variable
print *$variable;	# prints *main::data

What I want is either *main::variable (without knowing the name of the
variable, that is, but just using the scalarref in the example) or just
variable.

Jörg Ziefle


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

Date: Wed, 31 Jan 2001 03:17:57 GMT
From: "Stephen Deken" <shutupsteve@aNwOdSaPnAgM.com>
Subject: Re: code review request
Message-Id: <EtLd6.86365$lV5.1736896@news2.giganews.com>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

> A snippet from a potential off-site form action
> accessing your cgi script:

Well, it's not a CGI script, but the point is still valid - a bad entry in
the database could cause problems.  I've patched the code to use
Email::Valid to check the address and ensure a valid email address (at
least, an email address which conforms to RFC 822).

Thanks,

--sjd;




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

Date: Wed, 31 Jan 2001 11:20:29 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: copy construct reference to anonymous scalar
Message-Id: <9580d0$ak9@netnews.hinet.net>

"Martien Verbruggen"
> John Lin wrote:
> >
> > my $scalar_hard_ref = \$scalar;
> > my $scalar_copy_ref = ????????    # this is my question
>
> Out of curiosity, what are you going to use this for?

: p  No... I am just learning Perl.  I like to learn in a comparative way.

For example, when I learned "->", I would think of "how it applies on
array, hash, sub, scalar, filehandle, array slice... etc.":

$ref->[$i];    # for array
$ref->{key};    # for hash
$ref->(@param);    # for sub

but we don't have

$ref->???    # for scalar
$ref->???    # for filehandle

Having  $ref->[$i]  and  $ref->{key}  why Perl doesn't have

$ref->[1,2,3];    # looks better than  @{$ref}[1,2,3];
$ref->{'name','address','email'};    # @{$ref}{'name','address','email'};

The OP "copy construction" question is raised in the same situation.

John Lin





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

Date: Wed, 31 Jan 2001 05:13:22 GMT
From: Alex Hart <news@#nospam#althepal.com>
Subject: differences in DB_File files accross systems
Message-Id: <S9Nd6.559$6w3.205255@typhoon2.ba-dsg.net>

Is the format of the DB_File output dependent on the system?

I want to transfer some databases created with DB_File from one system
to another and I can't read them on the new system. I can create new
ones though.

Have they changed the format of the output?

Is there any way I can successfully transfer these files?

--

- Alex Hart



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

Date: 31 Jan 2001 05:52:19 GMT
From: rob_13@excite.com (Rob - Rock13.com)
Subject: Re: differences in DB_File files accross systems
Message-Id: <903A1369rock13com@207.91.5.10>

Alex Hart <news@#nospam#althepal.com>:

>Is the format of the DB_File output dependent on the system?
>I want to transfer some databases created with DB_File from one
>system to another and I can't read them on the new system. I can
>create new ones though.

Sorry for a rather clueless response but, did you transfer them as 
binary? If not then they could break.
-- 

Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/


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

Date: Tue, 30 Jan 2001 19:25:16 -0800
From: Raphael <raphael@iscusa.com>
Subject: Do threads really work?
Message-Id: <3A77859C.3ADE611D@iscusa.com>

If you can point me to an answer to this question that is great, but I have reviewed the Perl FAQ, search the Perl and CPAN web sites and have not been able to find the current status of Perl threads. I need to learn the exact status in order to decide what approach to take for a major development effort..

Let me start by providing some background information:

I am a member of the team which develops SupportWizard (http://www.supportwizard.com), a 100% Perl web based application that provides web based customer support/trouble ticketing/dynamic FAQs etc.

We began development long before Perl threads became available and at present SupportWizard uses multiple continuously processes that communicate with the webserver via FastCGI.

Now we are deciding on the architecture of the next generation product and want to reduce memory usage.

The alternatives are 

1) Using multiple Perl threads instead of processes.

2) Implementing in some language such as C++ which supports shared object libraries
   (basically, we would stuff 99% of the code into the library)

3) Implementing in some language such as Java (or Python?) which supports threads.

4) Telling our customers to buy lots of memory (well, it work for Oracle..) .

We would like to stay with Perl, but get conflicting answers about whether Perl threads are really usable. Here is my current understand. I would be very grateful for any corrections/clarifications:

Perl threads work, but

a) You are limited to a small number (12 ?) threads under NT and a larger number (?) under Linux.

b) Most of the CPAN modules are not thread safe

c) Some essential modules such as ::CGI and ::MySQL DBI are not thread safe

d) It takes a lot of work to make a module thread safe (about 75% as much as writing it from scratch)

e) There are still a few known bugs in the basic Perl thread implementation.

f) There is no central location/URL/newsgroup you can go to that is focussed on Perl threads.

g) Threads will only become fully functional in Perl 6.

Thanks for your feedback.

Raphael



-- 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Raphael                    	Mail:   raphael@iscusa.com
Integral Solutions Corp.       	Voice:  408 859 6389
http://www.supportwizard.com	FAX:    650 745 1209


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

Date: 31 Jan 2001 05:24:14 GMT
From: gt4556a@acmex.gatech.edu (=?iso-8859-1?Q?J=F6rg?= Ziefle)
Subject: exists news reply grabber? [somewhat OT]
Message-Id: <slrn97f8bu.gfb.gt4556a@acmex.gatech.edu>

Before I roll my own script:

Question:
=========
Does anybody know of a (Perl) program that checks the news (e.g. running from
CRON) and automatically delivers replies to one's own news articles?

Background:
===========
For example, if I write 10 Articles to 7 different news groups, it is
quite difficult (even with scoring) to read all the answers to them.
Or, if I know that I won't be able to read news a lot or post to a group
which I normally don't read and just want to have answers to urgent
questions, such a program would come handy.

Jörg Ziefle

P.s.: Yes, I know of the "Mail-Copies-To:" header. :)


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

Date: Wed, 31 Jan 2001 08:04:06 -0000
From: "Rhidian Jones" <webdev@ihatrading.com>
Subject: Freelancer wanted for quickie
Message-Id: <0EPd6.9303$Gn6.42370@news11-gui.server.ntli.net>

We are building a flatfile database of fixed events that will change rarely.
The databased is managed from a perl generated web gui and served via perl
generated web pages.
We need the ability for the administrator to set a date range from the admin
screen which will then show a screen populated with the values from the
usual database. These will then be modified and within the specified date
range will be displayed to public users through our serving mechanism.

To clarify, we already have most elements. We just need the date range
routines.


Current thinking here is:


- new flatfile generated containing standard data but with changes. Writes
details of the date range to a text file.

- Page serving system checks text file. If todays date is within the date
range, data is served from the date-range specific (override) database.
Otherwise, data is served from the regular database.

The way I've written it makes it sound complicated, but it should be quite
easy if you're good at manipulating dates in perl.

Budget is US $100.
Written purchase order available.
Payment by credit card/pay-pals or any other convenient method.
Right person can expect plenty of freelance work in the future

Rhidian Jones
webdev@ihatrading.com





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

Date: Fri, 26 Jan 2001 17:19:24 -0600
From: "David L. Nicol" <david@kasey.umkc.edu>
To: johngros@Spam.bigpond.net.au
Subject: Re: How to send back 2 or more gif, if only one cgi call?
Message-Id: <3A7205FC.ECA6A056@kasey.umkc.edu>

John Boy Walton wrote:
> 
> Claude, I think the only way to do such a thing would be to paste the two
> gifs together and send them as one.
> The actual script is beyond me. Maybe someone else could give some ideas on
> perl modules that might do the job.


Write both pictures to static files visible from the static file
area, then return an html page that refers to them in <img> tags.


-- 
                      David Nicol 816.235.1187 dnicol@cstp.umkc.edu
                            Five seconds of light is a lot of data.


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

Date: Wed, 31 Jan 2001 04:29:21 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Include bug in HTML::Template 2.2
Message-Id: <ant3104210b0fNdQ@oakseed.demon.co.uk>

I think I've found a bug in HTML::Template but I'll pass it by you
guys first as a sanity check. I noticed it in version 2.0 but I've
just downloaded 2.2 from CPAN and the alleged bug's still there.

I have the output of one template pass which I am using to create a
new template object via the scalarref option to new, like this:

$newtemplate = HTML::Template->new( scalarref => \$tempoutput,
                                    die_on_bad_params => 0,
                                  );

This works fine unless the string in $tempoutput uses a TMPL_INCLUDE tag
to include another file, in which case my program gives the following errors:

Use of uninitialized value at /PerlSiteLib:/HTML/Template.pm line 2095.
Modification of non-creatable array value attempted, subscript -1 at /PerlSiteLib:/HTML/Template.pm line 1419.

I took a look at line 2095 and I saw this:

    my @path = split('/', $options->{filepath});

After a bit of fiddling around I've discovered I can work around the
problem by calling new() with the parameter pair: filepath => '.'

I don't understand why filepath => '.' fixes it, or why it should be
necessary, after all "filepath" is an undocumented option and I'd
really rather not have to use it. I had a look at the similar option
called "path" the use of which does NOT fix the problem in the way one
would expect.

I have double checked that the syntax of the templates I am using are
correct, and that the file named in the TMPL_INCLUDE is present in the
correct place. Please could someone tell me if I'm doing something
fundamentally wrong, or whether this is a genuine bug in
HTML::Template. Thank you.

-- 
James Taylor <james (at) oakseed demon co uk>
Based in Hammersmith, London, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Wed, 31 Jan 2001 07:59:06 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: making a mail reciving script
Message-Id: <slrn97fhfg.69o.rgarciasuarez@rafael.kazibao.net>

flash wrote in comp.lang.perl.misc:
> i need to copy /var/spool/mail/smash
> to my directory
> then i need to seperate differant enteries   how would i do this?
> does anyone have experiance doing this?

If using Perl is not an absolute requirement, have you considered
procmail? That's a powerful mail processor. Maybe it's already installed
on your machine.

BTW, comp.lang.perl is a dead group. Don't post to it.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 31 Jan 2001 04:50:25 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Newbie question
Message-Id: <9585if$hbu$1@nnrp1.deja.com>

In article <9572mh$hn4$1@nnrp1.deja.com>,
  asparak@my-deja.com wrote:

> the simplest method or sorting/mapping the column of data, so that
each
> entry only appears once, when I generate the OPTION values.
--------------

do a little reading about "hash" and/or "associative array".
Also, next time you post, try using a more descriptive subject.

D


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 15:33:06 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: printing array of hashes
Message-Id: <957th3$ga2$1@hermes.nz.eds.com>


"Jürgen Exner" <juex@deja.com> wrote in message
news:3a77648b$1@news.microsoft.com...
> "B McDonald" <motivusNO@SPAMhotmail.com> wrote in message
> news:H2Jd6.78402$Wq1.33716117@nnrp5-w.sbc.net...
> [...]
> > I've seen plenty of examples about sorting on one of the hash keys, but
> how
> > about just maintaining the order of the keys as entered in a array of
> > hashes?
>
> By its very definition a hash does not have an order (well, there is an
> implementation-defined order but that is pretty much useless for all
> practical purposes).
> Therefore it cannot preserve any order.
>
> If you want an order, then you must use an array (or pointer lists or
> whatever).

You can use the Tie::IxHash
http://search.cpan.org/search?mode=module&query=IXhash




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

Date: Tue, 30 Jan 2001 20:14:51 -0800
From: "B McDonald" <motivusNO@SPAMhotmail.com>
Subject: Re: printing array of hashes
Message-Id: <bkMd6.78473$Wq1.33766711@nnrp5-w.sbc.net>


"Peter Sundstrom" <peter.sundstrom@eds.com> wrote in message
news:957th3$ga2$1@hermes.nz.eds.com...
>
> "Jürgen Exner" <juex@deja.com> wrote in message
> news:3a77648b$1@news.microsoft.com...
> >
> > By its very definition a hash does not have an order (well, there is an
> > implementation-defined order but that is pretty much useless for all
> > practical purposes).
> > Therefore it cannot preserve any order.
> >
> > If you want an order, then you must use an array (or pointer lists or
> > whatever).
>
> You can use the Tie::IxHash
> http://search.cpan.org/search?mode=module&query=IXhash
>

Thank you for the tip, Peter. This might be a naive question, but what is
the computational penalty of using such a module? I am wondering if it is
too expensive for my application.

Brian




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

Date: Wed, 31 Jan 2001 02:49:26 GMT
From: "Karl Thompson" <karlt@pine-grove.com>
Subject: Re: Printing to a device, not a local port? - How 'bout 'Default' printer?
Message-Id: <W2Ld6.198459$w35.35028222@news1.rdc1.nj.home.com>

Thank you. I thought that I had tried that and it didn't work. But it did
today (though at a different site).

Actually, rather than specify a particular printer, do you know how I would
open the default Windows' printer?

Thanks,
Karl


"Chris W" <chrisw@dynamite.com.au> wrote in message
news:auqd6.42$rP4.2177@news0.optus.net.au...
> "Chris W" <chrisw@dynamite.com.au> wrote in message
> news:Drqd6.40$rP4.2085@news0.optus.net.au...
> [snip]
> > open(PRINTER, '> file://server/laserjet') || die;
>
> Pardon Outlook Express' braindead munging of my file name.
> You need to remove the file: bit that it added  (leaving slash slash
server
> slash laserjet)
>
>




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

Date: Tue, 30 Jan 2001 18:36:59 -0800
From: "Christopher Hahn" <chahn@peregrine.com>
Subject: Proc::Background
Message-Id: <957tqq$54s$1@dfw-ixnews3.ix.netcom.com>

Hello,

I am facing the age-old problem of having my Perl-Tk
interface appear locked up because my read from a pipe is
blocking.

This is to say:
=================================
open(BPIPE, "command_name |");
while (<BPIPE>) {
LogMessage "LINE:$_\n";
$HMain->update();
}
=================================
Because I only see the call to update() every
time output becomes available from the pipe, the interface
appears to be frozen, for example it will not repaint
itself when uncovered.

So, what I want to do is fork off a child in which to run the
command and log the output, with the parent calling update
every second or two.

 ..but I am using AS Perl 5.6 on windows 2000 :-( !!!

Stealing from the fork example from the Camel book i try:
========================================
use Errno qw(EAGAIN);
use POSIX ":sys_wait_h";
my $pid;
my $chld;
FORK: {
if ($pid = fork) {
#parent process
do {
$chld = waitpid(-1,&WNOHANG);
$HMain->update();
sleep 2;
} unless $chld == -1;
} elsif (defined $pid) {
open(BPIPE, "msdev sc.dsw /MAKE \"$i - ALL\" |");
while (<BPIPE>) {
LogMessage "LINE: " . <BPIPE> . "\n";
$HMain->update();
}
} else {
die "Could not fork: $!\n";
}
}
========================================
Here the do-until of the first claus is intended (sic) to update
the interface every 2 seconds until the child process dies.
(This is what I need!!!)

BUT this produced an access exception and crashed the Perl-Tk app.

So....what is the recommended method (on win32!) for waiting
and updating an interface while a long running command runs.
Pardon the long-windedness, but TIA for any ideas.....

Christopher









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

Date: Wed, 31 Jan 2001 04:23:00 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: pushing hash onto an array
Message-Id: <slrn97f4p4.5tg.tjla@thislove.dyndns.org>

I was shocked! How could Gopi Sundaram <gopalan@cs.sc.edu>
say such a terrible thing:
>On Tue, 30 Jan 2001, B McDonald wrote:
>
>> for my $datum ( keys %$href ) {    # error occurs here!!!
>
>I've used %{$href} with success in the past.

Even when there was no variable called $href? Interesting behaviour.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
 ...[Linux's] capacity to talk via any medium except smoke signals.
-Dr. Greg Wettstein, Roger Maris Cancer Center


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

Date: Wed, 31 Jan 2001 04:26:21 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: pushing hash onto an array
Message-Id: <slrn97f4vd.5tg.tjla@thislove.dyndns.org>

I was shocked! How could Hardy Merrill <hmerrill@my-deja.com>
say such a terrible thing:
>In article <HvGd6.78382$Wq1.33682216@nnrp5-w.sbc.net>,
>  "B McDonald" <motivusNO@SPAMhotmail.com> wrote:
>>
>> Hi. I get the following error
>>
>> "Can't use string ("title") as a HASH ref while "strict refs" in use
>at
>> txt2xml.pl..."
>>
>> as related to the following code snippets...
>>
>>     %long_titles = ( line_num => $line_cnt,
>>                             doc_id => $doc_id,
>>                             begin_num => $control_ids{begin_num},
>>                             end_num => $control_ids{end_num},
>>                             title => $csv_record{title},
>
>The only thing I can see is that "title" is both a string key into the
>%csv_record hash, and a key to the %long_titles hash.  Try naming it
>something else so the two don't collide - just a guess.

Better not to guess. Giving no information is better than giving
patently wrong information as you did here.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Talk sense to a fool and he calls you foolish.
		-- Euripides


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

Date: Wed, 31 Jan 2001 04:45:59 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: qr and backreferences
Message-Id: <slrn97f647.5tg.tjla@thislove.dyndns.org>

I was shocked! How could Joseph Gottman <joegottman@worldnet.att.net>
say such a terrible thing:
>
>   I just realized that there is a problem with the interaction between the
>qr() operator and backreferences.  Consider the following code
>
>my $repeat = qr((.)\1); #Look for repeated characters.
>
>If this pattern is later interpolated into a longer regular expression that
>also contains capturing parens, then the \1 refers to the first pair of
>capturing parentheses in the larger regular expression.  Thus
>
>print ('abb' =~ /(.)$repeat/) ? 'true' :  'false'; #Prints false.
>print ('aba' =~ /(.)$repeat/) ? 'true' : 'false'; #Prints true.
>
>Is there any way to define $repeat so that it finds repeated characters even
>when interpolated into a longer regular expression?

How about:

my $repeat =
qr(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy|zz)i;

There Must Be A Better Way However? (TMBABWH?)

By the way your print lines are wrong I think. The parentheses should go
around the whole ?: expression.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Wilderness begins in the human mind.


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

Date: 31 Jan 2001 00:26:08 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: qr and backreferences
Message-Id: <m34ryg9tsf.fsf@mumonkan.sunstarsys.com>

"Joseph Gottman" <joegottman@worldnet.att.net> writes:

>    I just realized that there is a problem with the interaction between the
> qr() operator and backreferences.  Consider the following code
> 
> my $repeat = qr((.)\1); #Look for repeated characters.
> 
> If this pattern is later interpolated into a longer regular expression that
> also contains capturing parens, then the \1 refers to the first pair of
> capturing parentheses in the larger regular expression.  Thus
> 
> print ('abb' =~ /(.)$repeat/) ? 'true' :  'false'; #Prints false.
> print ('aba' =~ /(.)$repeat/) ? 'true' : 'false'; #Prints true.
> 
> Is there any way to define $repeat so that it finds repeated characters even
> when interpolated into a longer regular expression?
> 
5.6 has something new that might help here.  Try this instead:

        my $repeat = qr/(.)(??{$+})/;

HTH
-- 
Joe Schaefer


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

Date: Wed, 31 Jan 2001 04:47:35 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Question on appending to file
Message-Id: <9585d6$h1p$1@nnrp1.deja.com>

In article <956n4u$608$1@nnrp1.deja.com>,
  igotlooks.com <rbfitzpa@my-deja.com> wrote:
> You might want to add the 'close(FILE)' lines if you want it to work,
> but I agree - this is probably the quickest/easiest solution.
>
>  for(<*>) {
>    open(FILE,"<$_");
>    <FILE>;
>    if(!defined(<FILE>)) {
>        close(FILE);
>        open(FILE, ">>$_");
>        print FILE "";
>    }
>    close(FILE);
>  }
>
--------------
with this one you might get in memory trouble if any of the files are
VERY big, or you have LOTS of files in the directory. If neither is
expected to be huge, then slurping should be fine. You might want to use
a tight loop that just increments a counter and zips thru the file a
line at a time rather than slurping in the entire contents. If the
counter is one, then add you bogus line.

But I agree that the program READING the file should be fixed rather
than this workaround if possible.

D


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 14:26:38 +0800
From: Trevor Phillips <phillips@central.murdoch.edu.au>
Subject: Referencing module functions query.
Message-Id: <3A77B01E.568DC6E4@central.murdoch.edu.au>

I'm trying to figure out how to call a subroutine in a Perl module, where the
name of the routine is arbitary and stored as a string in a scalar.

eg; If I have a variable bink which has the value bill ($bink = "bill"), such
that I want to call subroutine bill using bink in module Fred, how would I do
it??

More to the point, how do I do it elegantly? ^_^
One way I've nutted out is like this:
  eval "Fred->$bink"
But that doesn't seem to be very efficient (using eval & all), and gets more
complex when you want to pass args to $bink...

Any ideas??

-- 
 . Trevor Phillips             -           http://jurai.murdoch.edu.au/ . 
: CWIS Systems Administrator     -           T.Phillips@murdoch.edu.au : 
| IT Services                       -               Murdoch University | 
 >------------------- Member of the #SAS# & #CFC# --------------------<
| On nights such as this, evil deeds are done. And good deeds, of     /
| course. But mostly evil, on the whole.                             /
 \      -- (Terry Pratchett, Wyrd Sisters)                          /


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

Date: Wed, 31 Jan 2001 02:44:53 GMT
From: Mario <m_ario@my-deja.com>
Subject: Security based on REMOTE_ADDR
Message-Id: <957u73$b59$1@nnrp1.deja.com>

Is there a way for the user to make an http request with an ip
different from the real one?

--
Mario
diab.litoATusa.net


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 12:32:38 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Security based on REMOTE_ADDR
Message-Id: <K5Ld6.11$GN5.4905@vic.nntp.telstra.net>

"Mario" <m_ario@my-deja.com> wrote in message
news:957u73$b59$1@nnrp1.deja.com...
> Is there a way for the user to make an http request with an ip
> different from the real one?
>

Via a proxy?

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";





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

Date: Wed, 31 Jan 2001 03:48:48 GMT
From: "flash" <bop@mypad.com>
Subject: Re: Security based on REMOTE_ADDR
Message-Id: <AWLd6.33272$HI.238079@news22.bellglobal.com>

i dont recomend this by itself.

what i do recomend is
remote_addr and remote_user
(check for proper ip then check for a good username etc..)

"Mario" <m_ario@my-deja.com> wrote in message
news:957u73$b59$1@nnrp1.deja.com...
> Is there a way for the user to make an http request with an ip
> different from the real one?
>
> --
> Mario
> diab.litoATusa.net
>
>
> Sent via Deja.com
> http://www.deja.com/




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

Date: Wed, 31 Jan 2001 06:23:58 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: Security based on REMOTE_ADDR
Message-Id: <MPG.14e1bfdcd2363482989877@news.online.no>

In article <957u73$b59$1@nnrp1.deja.com>, m_ario@my-deja.com says...
> Is there a way for the user to make an http request with an ip
> different from the real one?

Yes.


-- 
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/


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

Date: Tue, 30 Jan 2001 22:17:44 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Security based on REMOTE_ADDR
Message-Id: <3A77AE08.90CDDF6A@stomp.stomp.tokyo>

Mario wrote:
 
> Is there a way for the user to make an http request 
> with an ip different from the real one?


No, this is not possible. Every IP Address is quite
real; it must be to communicate across our internet.
Trick on security is deciding which IP Addresses
represent trouble or potential trouble. 

Connecting through a proxy will mask an 'orginating' 
IP Address for roughly thirty to forty percent of 
transactions. Most are unaware there are myriad ways
to pull a true IP Address through a proxy by orthodox
means and some less than orthodox means. Some are 
unaware most proxies today are transparent in nature,
including most 'firewall' type proxies which are
basically an expensive joke; a joke on the buyer.
Pulling internal IP addresses through a firewall
is most often child's play.

I've enjoy good luck blocking over ninety-nine percent
of all proxies with a small array, a quick loop and,
oh, I dunno, have to look, maybe a dozen lines of code.

A problem comes about with servers which do not provide
a host name for a transaction; might be a proxy, might
not be. It is usually prudent to block all servers which
do not provide a hostname. Without a hostname, you have
no way of attaining an email address for a nameless server,
at least not without a lot of research effort. For some
nameless servers, it is impossible to find a hostname;
you have no adminstrative contact. In most cases, a server
which doesn't provide a hostname, is trouble. It is a
deliberate act of concealment.

There are some social implications associated with servers.
Although this seems a bit of technological bigotry, often
people using America Online and Web TV, represent a great
potential for trouble, usually not deliberately. These users
often don't have 'internet savvy' like most. If they did,
these people would not be using AOL and Web TV for servers.
Frequently, these people cause problems simply by blunder.

So you see, security based on an IP address is risky business.
However, it is the only business in town. If you want tight
security, related to IP Addresses, block all proxies, block
nameless servers and closely watch those on AOL and Web TV.

Another precautionary measure is to establish sting pages
on your site. People looking to cause problems, in almost
all cases, are blithering idiots who cannot resist bait.
Trap them, log IP Addresses and block them. I have quite
a collection of IP Addresses of people like this, people
not smart enough to realize what is truly happening, a
few are regulars of this newsgroup. Surprising, yes?

In closing, pay attention to who is doing what at your
site, block proxies, block nameless servers and for
Goodness Sake, put a leash on AOL and Web TV yahoos.

Remember this, when you block an IP Address, you block
anyone and everyone using that IP Address, guilty,
innocent, or just plain stupid.


Godzilla!


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

Date: Wed, 31 Jan 2001 06:19:27 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: simple hash question.
Message-Id: <MPG.14e1beca841b4dc7989876@news.online.no>

In article <956uv6$dq1$1@nnrp1.deja.com>, msalerno@my-deja.com says...
> I have an array of passwords that I want to convert to a hash so
> there are no duplicates.

Heh. :)  I had the same problem a long time ago, and when looking on my 
code again, I don't think it's the best solution I have.  Or?

---
my @array = qw( pw1 pw2 pw3 pw2 );
my %hash;
%hash = map { $_ => $_ } @array;
---

Anyway.  The '$_ => $_' doesn't look good to, but as far as I can see, 
this piece of code works;

---
foreach my $key (keys %hash) {
	print "$key\n";
}
---

 ...which outputs all the elements in the array, except the last (which 
is a duplicate of the second element).

Hmm. :)


-- 
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/


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

Date: Tue, 30 Jan 2001 23:40:05 -0700
From: Todd Ahlstrom <todda@xmission.com>
Subject: Re: substituting "@" with regexp
Message-Id: <3A77B345.E23E643B@xmission.com>

yes, I downloaded it, I have now seen the light.  : )


Todd

Eli the Bearded wrote:

> In comp.lang.perl.misc, Todd Ahlstrom  <todda@xmission.com> wrote:
> > I take it back, I thought all the hex was being converted, but I threw
> > this line in
> > to see what would happen:
> > $form{email}=~s/%40/\@/;
> > and it fixed the problem.
>
> It fixed the problem you saw, but still leaves you with problems.
>
> Use the CGI module.
>
> Elijah
> ------
> don't trust yourself to write a replacement if you haven't read the RFCs



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

Date: Wed, 31 Jan 2001 05:49:47 GMT
From: Jargon / Network Engineer <ayoungtechie@my-deja.com>
Subject: Unresponsive file handles..
Message-Id: <95891q$k0l$1@nnrp1.deja.com>

Just wondering about a little problem I'm having writing a fairly large
piece of Perl art.

I need to open a file to read through its data to find the correct
data, but the compiler keeps spitting "Read on closed filehandle"
errors at me. Here's an example of the code that is supposedly reading
from a closed filehandle:

sub readBoxInfo {
	open( BOXINFO, $MachineInfoDB );

	while( <BOXINFO> ) {
		my( $VariablePair ) = $_;
		chomp( $VariablePair );
		( my( $Name ), my( $Value ) ) = split( / /,
$VariablePair );
		$MachineInfo{$Name} = $Value;
	}

	close( BOXINFO );
}

The while( <BOXINFO> ) { is getting the error, because, supposedly, the
filehandle isn't open - even though I've coded it so that it is.

Any thoughts on how I could fix this error would be greatly appreciated.

--
"Jargon, I'm never leaving the Fridge again, do you hear me?"
- Sosh, Level_9


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 31 Jan 2001 06:06:44 GMT
From: Jargon / Network Engineer <webmaster@jargonnetengineer.cjb.net>
Subject: Re: Unresponsive file handles..
Message-Id: <958a1i$kja$1@nnrp1.deja.com>

Okay, now I feel like a complete idiot. Never mind this thread - I went
back and put some files into place and the error went away.. One of the
first things every hacker should learn - make sure all the files are
there. Wow. I'm so stupid!

Sorry about the bother, everybody!

--
"Jargon, I'm never leaving the Fridge again, do you hear me?"
- Sosh, Level_9


Sent via Deja.com
http://www.deja.com/


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

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 V10 Issue 180
**************************************


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