[17431] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4851 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 9 00:05:44 2000

Date: Wed, 8 Nov 2000 21:05:09 -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: <973746309-v9-i4851@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 8 Nov 2000     Volume: 9 Number: 4851

Today's topics:
    Re: Getting 500 Undefined subroutine &HTML::Entities::d <bwalton@rochester.rr.com>
    Re: help on improving code (pine2mutt-script ca 130 lin (Colin Watson)
    Re: help on improving code (pine2mutt-script ca 130 lin <jschauma@netmeister.org>
    Re: help on improving code (pine2mutt-script ca 130 lin (Tad McClellan)
    Re: help on improving code (pine2mutt-script ca 130 lin (Tad McClellan)
    Re: how do i ask for input? <elephant@squirrelgroup.com>
    Re: How would you delete the topmost line of a file? <wyzelli@yahoo.com>
    Re: I do not Understand Perl Formats <james@NOSPAM.demon.co.uk>
    Re: Net::Telnet & Net::Ping (Martien Verbruggen)
    Re: NT4 - How do I display the current userid? <bwalton@rochester.rr.com>
    Re: OOP and information hiding <james@NOSPAM.demon.co.uk>
    Re: Pushing a hash on to a stack... (Martien Verbruggen)
    Re: Pushing a hash on to a stack... (Christopher Burke)
    Re: Pushing a hash on to a stack... (Christopher Burke)
    Re: Pushing a hash on to a stack... (Christopher Burke)
    Re: Pushing a hash on to a stack... (Martien Verbruggen)
    Re: Q: Can't locate integer.pm in @INC <elephant@squirrelgroup.com>
    Re: Redirect a user by country ? <mtaylorlrim@my-deja.com>
    Re: Redirect a user by country ? <jeff@vpservices.com>
        Rename file in Perl triton89076@my-deja.com
    Re: Rename file in Perl <bwalton@rochester.rr.com>
        STDIN in child process <zenja@home.com>
    Re: this code uses cookies, but server still complains <elephant@squirrelgroup.com>
    Re: Use Eval to open file? <james@NOSPAM.demon.co.uk>
    Re: What's with taint???? (Mark-Jason Dominus)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 09 Nov 2000 03:26:55 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Getting 500 Undefined subroutine &HTML::Entities::decode_entities  called
Message-Id: <3A0A1A51.F120C103@rochester.rr.com>

theepan wrote:
> 
> Getting 500 Undefined subroutine &HTML::Entities::decode_entities called
> 
> I am using win98 & Appache & ActiveState Perl. I am getting this error!
> I Did was
> 
> #!Perl
> use LWP::Simple;
> use LWP::UserAgent;
> print "Content-type: text/html\n\n";
> 
>   $ua = new LWP::UserAgent;
>   $ua->agent("$0/0.1 " . $ua->agent);
>   $ua->agent("Mozilla/8.0");
>   $req = new HTTP::Request 'GET' => 'http://www.altavista.com';
>   $req->header('Accept' => 'text/html');
>   # send request
>   $res = $ua->request($req);
>   # check the outcome
>   if ($res->is_success) {
>      print $res->content;
>   } else {
>      print "Error: " . $res->status_line . "\n";
>   }
> 
> If Anyone Could give me a hand! It would be nice....
Hmmmmm...works fine on my setup:  Windoze 98 with WebSite 1.1.
-- 
Bob Walton


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

Date: 9 Nov 2000 03:07:48 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: help on improving code (pine2mutt-script ca 130 lines)
Message-Id: <8ud4e4$nrf$1@riva.ucam.org>

Tad McClellan <tadmc@metronet.com> wrote:
>On Wed, 08 Nov 2000 22:08:38 GMT, Jan Schaumann 
>   <jschauma@www.netmeister.org> wrote:
>>#declaration of variables used up here
>>my $PINE =  $ENV{HOME} . "/.addressbook";
>
>I think most people would use interpolation rather than
>concatenation for that:
>
>   my $PINE =  "$ENV{HOME}/.addressbook";

It's also probably best to use lower-case variable names; upper-case
ones are conventionally left for built-in Perl variables (like %ENV
there) and of course filehandles.

>>            /(.*?)\t(.*?)\t(.*?)$/;
[...]
>I don't see that non-greediness is needed either:
>
>   if ( /([^\t]*)\t([^\t]*)\t(.*)$/ ) {

I invariably find that form harder to read that the non-greedy form, and
it doesn't generalize easily to having more than one character between
the captures, since it requires the manual construction of the negations
of expressions (thus effectively duplicating effort). Is there a
compelling reason I'm missing why the greedy form should be used
instead?

-- 
Colin Watson                                     [cjw44@flatline.org.uk]
"Racism is generally the last refuge of the unimportant."


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

Date: Wed, 08 Nov 2000 22:23:34 -0500
From: "Jan Schaumann" <jschauma@netmeister.org>
Subject: Re: help on improving code (pine2mutt-script ca 130 lines)
Message-Id: <LKoO5.207$D_2.74714@news-east.usenetserver.com>

tadmc@metronet.com wrote:

> On Wed, 08 Nov 2000 22:08:38 GMT, Jan Schaumann 
>    <jschauma@www.netmeister.org> wrote:
>>
>>having just changed from pine to mutt I decided to write a little script
>>that converts the .addressbook into a mutt-alias-file. Here's what I
>>have come up with - it does the job, but I'd like to learn Perl in more
>>depths and would appreciate any feedback on how to improve the code, how
>>to make it more
>>"perlish" etc.
> 

[lots of helpful comments]

Thanks a lot!
I'll make the changes and am happy to say that I learned something ;-)

Thanks to cjw44 as well.

-Jan

-- 
Jan Schaumann <http://www.netmeister.org>

Microsoft's biggest and most dangerous  contribution to the software
industry may be the degree to which it has lowered user expectations.


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

Date: Wed, 8 Nov 2000 22:09:47 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help on improving code (pine2mutt-script ca 130 lines)
Message-Id: <slrn90k5br.ak3.tadmc@magna.metronet.com>

On Wed, 8 Nov 2000 19:27:33 -0500, I myself wrote:

>Never ever use the dollar-digit variables unless you have
>first tested to see if the match succeeded:

[snip]

>Probably best, would be to use a pattern match in list context:
>
>   ($nick, $name, $tmp) = /([^\t]*)\t([^\t]*)\t(.*)$/;


But you of course need to see if _that_ match succeeded too:

   die "line $. did not have 2 tab chars\n" 
      unless ($nick, $name, $tmp) = /([^\t]*)\t([^\t]*)\t(.*)$/;


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


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

Date: Wed, 8 Nov 2000 22:53:46 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help on improving code (pine2mutt-script ca 130 lines)
Message-Id: <slrn90k7ua.ao1.tadmc@magna.metronet.com>

On 9 Nov 2000 03:07:48 GMT, Colin Watson <cjw44@flatline.org.uk> wrote:
>Tad McClellan <tadmc@metronet.com> wrote:
>>On Wed, 08 Nov 2000 22:08:38 GMT, Jan Schaumann 
>>   <jschauma@www.netmeister.org> wrote:


>>>            /(.*?)\t(.*?)\t(.*?)$/;
>[...]
>>I don't see that non-greediness is needed either:
>>
>>   if ( /([^\t]*)\t([^\t]*)\t(.*)$/ ) {
>
>I invariably find that form harder to read that the non-greedy form, and
>it doesn't generalize easily to having more than one character between
>the captures, since it requires the manual construction of the negations
>of expressions (thus effectively duplicating effort). Is there a
>compelling reason I'm missing why the greedy form should be used
>instead?


No, there is an uncompelling reason.

Greedy was all there was when I learned Perl, so I'm used to it.

A semi-compelling reason is that the 3rd one is completely
unnecessary and slows down the match. I probably should 
have left the first two alone:

   /(.*?)\t(.*?)\t(.*)$/;



But now that I think about it, split() is probably the "best"
solution anyway:

   ($nick, $name, $tmp) = split(/\t/, $_, 3);

Dunno why I didn't just say that to begin with. I expect
split() to kick butt in benchmarks compared to a regex as well.


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


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

Date: Thu, 9 Nov 2000 14:15:07 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: how do i ask for input?
Message-Id: <MPG.1474c1c1271e080198988b@localhost>

EM wrote ..
>I am using activeperl on windows
>how do i ask for user input

there are a number of ways .. the simplest is to use angle brackets 
around STDIN .. take a look at the perlop section of the manual under 
"I/O Operators" for some examples

  perldoc perlop

>like say i make a program that ask for a password
>and i make a prompt "Please enter password:"
>how do i allow the user to put in his password and put it in $password

for specifics about password inputs .. take a look at the Perl FAQ by 
typing the following at the command prompt

  perldoc -q password

for more information on the perldoc utility type the following at the 
command prompt

  perldoc perldoc

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 9 Nov 2000 11:41:54 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How would you delete the topmost line of a file?
Message-Id: <aFnO5.25$4c.2913@vic.nntp.telstra.net>

<research@ev1.net> wrote in message news:8ucqlj$jpg$1@nnrp1.deja.com...
> As the subject reads, how would you remove the topmost line of a file?
>

open (IN,'testfile.txt') or die "Cant $!";
open (OUT, '>testfile.new') or die "Wont $!";
<IN>;
print OUT while <IN>;


BTW this is a FAQ

Wyzelli

--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;





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

Date: Thu, 9 Nov 2000 01:52:22 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: I do not Understand Perl Formats
Message-Id: <ant0901221cbfNdQ@oakseed.demon.co.uk>

In article <8uce9i$8jm$1@nnrp1.deja.com>,
<URL:mailto:john_s_brown@my-deja.com> wrote:
>
> I have read through Programming Perl (3rd edition) chapter number 7,
> which tells about Perl Formats. But still I don't understand even the
> basics.

The first time I looked at formats this dark and deeply suppressed
memory of programming in Fortran flashed before me, and I ran for my
life in the opposite direction in a cold sweat. The *might* be a good
reason to use formats, but I think the potential trauma of doing so
would strongly encourage me to try to think of another way.

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Thu, 09 Nov 2000 04:51:14 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Net::Telnet & Net::Ping
Message-Id: <slrn90kba4.7ck.mgjv@verbruggen.comdyn.com.au>

On Thu, 09 Nov 2000 01:37:36 GMT,
	nodo70@my-deja.com <nodo70@my-deja.com> wrote:
> Anyone know what is wrong with the script below if I just want to write
> to error log file if the hostname is not alive, cannot telnet to it, or
> user/password is incorrect and just keep on next hostname, not
> terminate the script at failing?  I try to run with the NT hostname
> which doesn't support telnet and it still die, not writing to error log
> file and move on next hostname as I expected it.  I also try to run
> with either user/password incorrect and it also die.  Any suggestion?
> Thanks in advance.

Woah.. take a deep breath. This stream of consciousness is really hard
to follow.

> my $user   = 'nodo';
> my $pass   = 'nodo00';
> my @host   = ('nodo-00','nodo-01','nodo-02');
> my $cmd    = 'vmstat 1 2';
> foreach (@host) {

It's better to use

foreach my $host (@host)

but I think you sort of half did that. You seem to be mixing $_ and
$host in this loop.

> my $ping   = Net::Ping->new("icmp",10);
> my $result = $ping->ping($_);
> if ($result) {
>     my $telnet = Net::Telnet->new(-host => $_,
>                                   -timeout => 30);
>     if ($telnet) {
>        if ($telnet->login($user, $pass)) {

Net::Telnet->login and Net::Telnet->new actually die on failure.

Didn't you see any error messages on your terminal when you ran this,
and tried to connect to your NT box? Or is that what you were saying?
If so, wrap it in an eval, or use errmode, as documented in the
Net::Telnet documentation.

And yes, I think this is a design flaw in Net::Telnet. By default, it
shouldn't do this. However, it is documented, so you should have read
about it.

my $telnet = Net::Telnet->new(-host => $_,
                              -timeout => 30,
							  -errmode => 'return');

or pick another one.

>     else {
>        writeErrorLog ("Cannot connect to $host: $!");

Global symbol "$host" requires explicit package name

writeErrorLog("Cannot connect to $_");

$! is meaningless here.

>     }
> }
> else {
>   writeErrorLog ("$host is not alive");

Global symbol "$host" requires explicit package name

> }
> }
> 
> sub writeErrorLog {
>     my ($str) = @_;
>     my ($errorLogFile) = "error.log";

my $str = shift;
my $errorLogFile = 'error.log';

> 
>     if (stat($errorLogFile)) {
>        open (ERRORLOG, ">>$errorLogFile") || die "Cannot append
> $errorLogFile to write\n";
>     }
>     else {
>        open (ERRORLOG, ">$errorLogFile") || die "Cannot open
> $errorLogFile to write\n";

Append mode will create the file
if it doesn't already exist. There is no need for this second attempt.
You only run the risk of clobbering valuable error logs.

open(ERRORLOG, ">>$errorLogFile") or
	die "Can't append to $errorLogFile: $!";

>     }
>     print ERRORLOG "$str\n\n";
>     close ERRORLOG;
> }

And I changed it to do udp pings, because I didn't feel like becoming
root to test this.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | What's another word for Thesaurus?
NSW, Australia                  | 


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

Date: Thu, 09 Nov 2000 03:51:21 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: NT4 - How do I display the current userid?
Message-Id: <3A0A200A.79A6119D@rochester.rr.com>

Bill Border wrote:
 ...
> I am running a Perl pgm that is invoked from a unix server (with
> the resource kit rsh nt daemon) and in order to get an ODBC
> Oracle application to work, I need to know what USERID it my
> task is running under.
> 
> The $> variable returns 0.     ??????
 ...
> Bill
Maybe you could parse it from the output of the "net config" DOS
command?
-- 
Bob Walton


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

Date: Thu, 9 Nov 2000 02:05:59 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: OOP and information hiding
Message-Id: <ant090259b49fNdQ@oakseed.demon.co.uk>

In article <8uct95$ujo$1@towncrier.cc.monash.edu.au>, Damian Conway
<URL:mailto:damian@cs.monash.edu.au> wrote:
>
> But if pressed, I think the Tie::Securehash module represents the
> closest thing to a "best practice" for most applications. That's why
> I've proposed most of its features as standard mechanisms in Perl 6.
> 
> I certainly think it's simple enough to warrant wider use.
>
[snip interesting explanation]

Fascinating, Damian, is all this discussed/explained in your book?
Can you remind me of the title, publisher, ISBN, etc.

> then you can release under 'fast' mode:
> 
>         use Tie::SecureHash 'mode';
> 
> and the performance hit disappears too.

Is that correct, or should it be use Tie::SecureHash 'fast'; ?

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Thu, 09 Nov 2000 02:22:59 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Pushing a hash on to a stack...
Message-Id: <slrn90k2k4.7ck.mgjv@verbruggen.comdyn.com.au>

On Thu, 09 Nov 2000 01:14:48 GMT,
	Christopher Burke <craznar@hotmail.com> wrote:
> jeff@yoak.com (Jeff Yoak) wrote in <8ucor40psu@news2.newsguy.com>:
> 
>>Look, you've said something that on the surface sounds silly.  Expert
>>people have pointed this out and even provided a lot of discussion and
>>even code on how you might solve your problem given what sounds like an
>>inane requirement.
>>
> 
> I asked a fairly simple question, which I knew had a difficult answer. I 
> posted a very small bit of code demonstrating what my problem was.
> 
> During the time which I had to rapidly defend myself against ever 
> increasing attacks - I slipped once in one message.
> 
> The original post is still a valid question, but I now know two things. 
> 
> 1. There is no answer of how to use 'push' to push a hash onto an array.

Yes, there is. Just no decent one given the restrictions you put on it
initially.

> 2. There is so many smart arse people on this newsgroup that once a newbie 
> comes along with a question they cannot answer - they start attacking the 
> newbie for having the hide to propose a question without an answer.

No. What people, and in particular I, objected to was an utterly silly
limitation in the possible solution set that your problem has. The
possible solutions that fit your description were all utterly and
hastily abandoned by people when they upgraded to Perl 5, now some 6
years ago. and there was a very good reason for that abandonment.

Every solution that doesn't require references, and that might fit
your problem once it gets specified a bit more precise, is going to be
utterly inefficient, ugly, and large, in code. A solution with
references requires only calls to builtin Perl operators.

People object to giving other people rubbish, garbage and bad advice.
Personal pride normally prevents that. If you ask for rubbish, you
better justify why you need the rubbish. I don't have any trouble
helping you out, as long as the result isn't crap (unless I
accidentally give you crap).

> To clarify - the 'push line can use references until the cows come home' 
> however the code that puts the elements into the hash CANNOT, and neither 
> can the code that extracts the elements at the end.

See my other post today, for a possible solution. I'm happy to extend
it a bit further for you, if it doesn't entirely meet your
requirements. But, really, you should have just phrased it this way to
start of with. It just shows how important it is to be precise, as
well as concise, in stating a problem. 

> push @fulldata, ???(%hash)???  # whatever references you want
> print $fulldata[0]{x};    # this line is fixed - prints 3
> print $fulldata[0]{y};    # this line is fixed - prints 4

If you want direct access to the members of one of those pushed
stacks, by index, then you need to modify the code I posted, and
remove the outer block braces around the push_hash and pop_hash code.
You'll get direct access to @HashStack in your code that way.

I just took your use of the word 'stack' literally, but maybe
shouldn't have done that. Again, it's unclear. You say 'stack', but
you mean 'array'.

If you had just stated that all you wanted was some code that hides
the use of references from the user, while pushing a hash or array
reference, this whole discussion wouldn't have existed. Anyway, here's
some changed code that allows you to do this more along the line of
what your example code looks like, than what I posted earlier.

#!/usr/local/bin/perl -wl
use strict;

sub push_hash (\@\%)
{
    my $aref = shift;
    my $href = shift;
    push @$aref, {%$href};
}

sub pop_hash (\@)
{
    my $aref = shift;
    my $href = pop @$aref;
    return %{$href};
}

# And for the usage:

my @stack;

my %hash = (foo => 1, bar => 2, baz => 3);
push_hash @stack, %hash;
$hash{banana} = 4;

print $stack[0]{foo};
print $stack[0]{baz};
# And to prove that there is a reference, no matter what you call it:
print $stack[0];

my %chash = pop_hash @stack;
while (my ($key, $value) = each %chash)
{
    print "$key, $value";
}

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.   | cynical. It's perfectly easy to be
NSW, Australia                  | cynical.


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

Date: Thu, 09 Nov 2000 04:26:44 GMT
From: craznar@hotmail.com (Christopher Burke)
Subject: Re: Pushing a hash on to a stack...
Message-Id: <8FE793864Craznar@24.192.1.17>

mgjv@tradingpost.com.au (Martien Verbruggen) wrote in 
<slrn90k13b.7ck.mgjv@verbruggen.comdyn.com.au>:

>So, what you are saying is that you're happy to use references, you
>just don't want them exposed to the users of your library?  Why didn't
>you just say that right away?
>

Thats not what I am saying .... it isn't a library I am writing...

However I am giving up on this whole joke .
-- 
---
/* Christopher Burke - Spam Mail to craznar@hotmail.com
|* www.craznar.com - International Internet Writing Experiment
\* Real mail to cburke(at)craznar(dot)com


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

Date: Thu, 09 Nov 2000 04:27:53 GMT
From: craznar@hotmail.com (Christopher Burke)
Subject: Re: Pushing a hash on to a stack...
Message-Id: <8FE79953FCraznar@24.192.1.17>

mgjv@tradingpost.com.au (Martien Verbruggen) wrote in 
<slrn90k1c3.7ck.mgjv@verbruggen.comdyn.com.au>:

>This is not C. It's Perl. It's not nitpicking, this is how Perl works.
>How other languages resolve and implement syntax similar to the above,
>has nothing to do with how Perl does it. Denying that there are
>references is just silly, because it prevents you from understanding
>what is going on, and how your stuff is stored.

Thats right - I will not bother this newsgroup anymore, after all there is 
no help for people new to Perl on experts are welcome here.
-- 
---
/* Christopher Burke - Spam Mail to craznar@hotmail.com
|* www.craznar.com - International Internet Writing Experiment
\* Real mail to cburke(at)craznar(dot)com


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

Date: Thu, 09 Nov 2000 04:31:24 GMT
From: craznar@hotmail.com (Christopher Burke)
Subject: Re: Pushing a hash on to a stack...
Message-Id: <8FE7954C6Craznar@24.192.1.17>

mgjv@tradingpost.com.au (Martien Verbruggen) wrote in 
<slrn90k2k4.7ck.mgjv@verbruggen.comdyn.com.au>:

>No. What people, and in particular I, objected to was an utterly silly
>limitation in the possible solution set that your problem has. The
>possible solutions that fit your description were all utterly and
>hastily abandoned by people when they upgraded to Perl 5, now some 6
>years ago. and there was a very good reason for that abandonment.
>
>

I asked a simple question - can you use push to push a hash onto an array, 
the example code I gave showed my existing solution.

Simple question - attacks, nitpicking and now an assumed answer that you 
cannot.

I didn't need a solution to a problem, I already had that. I needed an 
answer to a question. That is something the people here found difficult to 
do.

If someone asked 'how do I concatenate strings' and I responded 'why do you 
want to cancatenate string' and 'use arrays not strings' etc. Thats what 
happened here.

I have learnt that this is an elite group and others are not welcome - I 
shall try to respect that and not bother you with any more questions.

-- 
---
/* Christopher Burke - Spam Mail to craznar@hotmail.com
|* www.craznar.com - International Internet Writing Experiment
\* Real mail to cburke(at)craznar(dot)com


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

Date: Thu, 09 Nov 2000 04:59:17 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Pushing a hash on to a stack...
Message-Id: <slrn90kbp9.7ck.mgjv@verbruggen.comdyn.com.au>

On Thu, 09 Nov 2000 04:31:24 GMT,
	Christopher Burke <craznar@hotmail.com> wrote:
> mgjv@tradingpost.com.au (Martien Verbruggen) wrote in 
><slrn90k2k4.7ck.mgjv@verbruggen.comdyn.com.au>:
> 
>>No. What people, and in particular I, objected to was an utterly silly
>>limitation in the possible solution set that your problem has. The
>>possible solutions that fit your description were all utterly and
>>hastily abandoned by people when they upgraded to Perl 5, now some 6
>>years ago. and there was a very good reason for that abandonment.
>>
>>
> 
> I asked a simple question - can you use push to push a hash onto an array, 
> the example code I gave showed my existing solution.

No, it didn't. It showed what you _wanted_, not a solution.

> Simple question - attacks, nitpicking and now an assumed answer that you 
> cannot.

Not true. I have in fact submitted several solutions to what your
problem was. If those weren't applicable, then you should specify your
problem better. You never specified what you wanted correctly. If none
of the suggestions given by all the people in this thread came
anywhere close to what you wanted, then it's YOUR problem, not ours. 

> I didn't need a solution to a problem, I already had that. I needed an 

You didn't have a solution. I haven't seen one. Many people asked how
you were doing this magical thing of pushing hashes on stacks without
references, and you did not show us a single one.

> answer to a question. That is something the people here found difficult to 
> do.

The length of this thread refutes your words. People attempted to
answer your question, it's just that your question contained no sense.
People have attempted to educate you, it's just that you do not want
to be educated. If you are new to Perl, why do you refuse to learn
about it? If you don't want to learn about Perl, why do you use it,
and why are you here?

You make no sense, and that confuses people.

> If someone asked 'how do I concatenate strings' and I responded 'why do you 
> want to cancatenate string' and 'use arrays not strings' etc. Thats what 
> happened here.

If people asked "How do I concatenate strings? Oh! You can't use
quotes or the .!", then they would meet the same resistance. If people
asked the question you posed, and didn't put idiotic restrictions on
it, they would get the correct answer.

It wasn't the question that was the problem, it was your restriction
of not using references. 

> I have learnt that this is an elite group and others are not welcome - I 
> shall try to respect that and not bother you with any more questions.

You're ungrateful, and unreasonable. And very childish, too. But if
you want to go off, and sulk in a corner, that's fine by me. Usenet
can be hard on the ego, especially if you're of a stubborn nature.
Some people never get over that.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | values of Beta will give rise to dom!
NSW, Australia                  | 


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

Date: Thu, 9 Nov 2000 13:41:22 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Q: Can't locate integer.pm in @INC
Message-Id: <MPG.1474b9e232ebe9a9989889@localhost>

jonasroden@my-deja.com wrote ..
>I've installed perl using MSV C++ to C:\perl on an
>w2000 system
>Installation:
>
>VCVARS32.BAT
>#from the win32 direktory
>nmake
>nmake test
>nmake install
>
>I've uppdated the PATH with
>c:\perl\bin;c:\perl\bin\MSWin32-x86
>
>My problem is that I cant use any modules, for
>example integer.
>use integer;
>
>I get the error "Can't locate integer.pm in @INC".
>If @INC is printed using
>print join("\n",@INC);
>
>I get the result
>..\lib\i386-win32
>..\lib
>.
>
>Is there anything I've forgotten?

don't know .. one point - you could try (and IMHO you should) installing 
the ActiveState installation of Perl .. which has binary install 
packages available that handle all this stuff for you

my @INC contains explicit paths to all the lib directories .. those 
relative paths look weird - and will probably be relative to where the 
script is executed from - not where Perl is located

if you need to stay with this Perl installation then you can add 
explicit paths to your @INC by including them in an environment variable 
called PERL5LIB

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 09 Nov 2000 02:18:52 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: Redirect a user by country ?
Message-Id: <8ud1i7$pef$1@nnrp1.deja.com>

In article <3A09FC33.4D6183D2@vpservices.com>,
  Jeff Zucker <jeff@vpservices.com> wrote:
> Mark wrote:
> >
>
> language != country
>
> If my preferred language is English, do I live U.S., England,
Australia
> ...
>
> If my preferred language is French, do I live in France, Canada,
Senegal
> ...
>
> If my preferred language is Spanish ...
>
> To know the answer, you'd have to ask me, then believe what I tell
you.

I suppose I was assuming that Erik was intending to simply redirect in
order to provide pages in different languages....if the intent is to
provide different content based on the country then yes...you do it
differently. Use Environment variables and get the host name (assuming
host name lookups are enables on the web server). Parse it to determine
the country, if it indeed contained a clue as to the country...then a
simple print "Location:..." statement would do.

Mark

--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


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


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

Date: Wed, 08 Nov 2000 18:39:18 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Redirect a user by country ?
Message-Id: <3A0A0E56.104363DB@vpservices.com>

Mark wrote:
> 
 .....if the intent is to
> provide different content based on the country then yes...you do it
> differently. Use Environment variables and get the host name (assuming
> host name lookups are enables on the web server).

Nope.  As others in this thread have pointed out, there is no reliable
mthoed of determining country from hostname even where hostname is
avaialble.  The only way is to ask the user.

-- 
Jeff


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

Date: Thu, 09 Nov 2000 02:53:04 GMT
From: triton89076@my-deja.com
Subject: Rename file in Perl
Message-Id: <8ud3ie$r32$1@nnrp1.deja.com>

Greetings,

Appreciate if anyone could help me to solve the following problem :

I'm supposed to do a rename (move) of file from a directory to another
but when I run the perl script in both cron job or from the shell the
file did not seemed to be moved completely (the file still remains in
the source directory undeleted while it was already copied over to the
target directory).

Did I miss out some important setting or Perl script did not understand
what I'm doing? Please help.

Here's how the script looks :

($dropBox = source directory,$dataDir = target directory, @file = list
of files to move)

print "Moving [$c] files...\n";
      for ($i=0; $i<$c; $i++)
      {
         $origFile = "$dropBox/$file[$i]";
         $newFile = "$dataDir/$file[$i]";
		 @gzipCmd = ("/usr/local/bin/gzip", "-9f", $newFile);

         if (rename($origFile, $newFile) == 0)
         {
            $errMsg = "Could not move [$origFile]";
            &exitError();
         }
  		 system(@gzipCmd);
      }


Thanks and regards,
triton89076


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


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

Date: Thu, 09 Nov 2000 04:02:07 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Rename file in Perl
Message-Id: <3A0A2290.4BD01DE7@rochester.rr.com>

triton89076@my-deja.com wrote:
 ...
> I'm supposed to do a rename (move) of file from a directory to another
> but when I run the perl script in both cron job or from the shell the
> file did not seemed to be moved completely (the file still remains in
> the source directory undeleted while it was already copied over to the
> target directory).
> 
> Did I miss out some important setting or Perl script did not understand
> what I'm doing? Please help.
> 
> Here's how the script looks :
> 
> ($dropBox = source directory,$dataDir = target directory, @file = list
> of files to move)
> 
> print "Moving [$c] files...\n";
>       for ($i=0; $i<$c; $i++)
>       {
>          $origFile = "$dropBox/$file[$i]";
>          $newFile = "$dataDir/$file[$i]";
>                  @gzipCmd = ("/usr/local/bin/gzip", "-9f", $newFile);
> 
>          if (rename($origFile, $newFile) == 0)
>          {
>             $errMsg = "Could not move [$origFile]";
>             &exitError();
>          }
>                  system(@gzipCmd);
>       }
 ...
> triton89076
 ...
Hmmmm...you wouldn't happen to be renaming across filesystems, would
you?  The docs (perldoc -f rename) state that rename probably can't do
that on most systems, even if mv can.  You could copy and delete.
-- 
Bob Walton


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

Date: Thu, 09 Nov 2000 04:43:57 GMT
From: "Zenja Ivkovic" <zenja@home.com>
Subject: STDIN in child process
Message-Id: <hYpO5.6345$IE2.217510@news1.sshe1.sk.home.com>

I am trying to make a simple chat program.  The problem I come into (I
think) is that doing something like "$foo = <STDIN>" will wait for input and
let the user type but it doesn't seem to ever end.

Here is the code snippet:

# Split program into two processes
die "Unable to create child process: $!\n" unless defined($kidpid = fork());

# Determine if this is the original or child process
if($kidpid) {
 # Original process carries on here
 while($running eq "yes") {
  ($ready) = IO::Select->select($readable, undef, undef, undef);
  foreach $s (@$ready) {
   if($s == $listener) {
    # New connection
    $new_sock = $listener->accept;
    $readable->add($new_sock) if $new_sock;
    print "[Connection accepted]\n";
    print $s "Connected\n";
   } else {
    # Allready established
    $sline = <$s>;
    if(defined $sline) {
     if($sline eq "`\n") {
      beeper();
     } else {
      print "> $sline";
     }
    } else {
     # Connection lost
     $readable->remove($s);
     $s->close;
     print "[Dropped connection to client]\n";
    }
   }
  }
 }
 kill("TERM", $kidpid);
} else {
 # This is the child
 while($running eq "yes") {
  print "1 ";  # Debugging
  $kline = <STDIN>;
  print "2 ";  # Debigging
  chomp $kline;
  if($kline eq "/connect") {
   Connect();
  } elsif($kline eq "/quit") {
   $shutdown = "yes";
  } elsif($kline eq "/beep") {
   if($client_socket) { print $client_socket "`\n"; }
  } elsif($kline eq "/mode") {
   Mode();
  }
 }
 print "[Client going down]\n";
}

As you can see first I fork() and let the original process do the server
part and the child process the client part.  The server part works fine, but
the client part doesn't seem to do anything other then just hang and receive
input.  The first line in the client part (the else in the big if), the
"print '1 ';" doesn't even get executed, it won't print the 1 or 2.  When I
comment the $kline = <STDIN>; line it prints out the 1 and 2 and loops
correctly.

Some help on making this ask for input properly would be appreciated.





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

Date: Thu, 9 Nov 2000 14:01:25 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: this code uses cookies, but server still complains
Message-Id: <MPG.1474be8c698cfe8798988a@localhost>

jawanth@att.net wrote ..
>I use the HTTP methods to set and load cookies(Netscape) before I send
>the request using the get method.
>The server still complains that my browser does not accept cookies.
>Why is this so and what can I do to make this work ?
>
>#### code cliver looks like this......
>
>$cookiejar= HTTP::Cookies::Netscape->new(  file => "C:/Program\
>Files/Netscape/Users/default/cookies.txt", autosave => 1 );
>
>$cookiejar->load("C:/Program\
>Files/Netscape/Users/default/cookies.txt");
>
>############  initailaize cookie-jar ####################
>############  Piggybacking on cookies created by Netscape during login
>############  sequence.
>
>###########  print debug satement #############################
>print $cookiejar->as_string(1);
>
>############  cookie jar is now loaded and initialized ########
>
>$request=HTTP::Request->new(GET => "$url_string");
>
>##########  add cookie header so that server wont complain, hopefully
>
>$cookiejar->add_cookie_header($request);
>
>######### Now get the content by going over the net...
>
>$response= $ua->request($request);
>$html_source=$response->content;

the code on the server might be determining your cookie-ness by other 
means .. such as a little browser sniffing .. you might try setting the 
HTTP_USER_AGENT header to mimic a cookied browser

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 9 Nov 2000 02:40:47 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Use Eval to open file?
Message-Id: <ant090247d07fNdQ@oakseed.demon.co.uk>

In article <3A09CD76.AD078BAC@webimpact.com>, Don Vaillancourt
<URL:mailto:donv@webimpact.com> wrote:
>
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>

Yuck. Please post plain text, not HTML.

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Thu, 09 Nov 2000 04:47:20 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: What's with taint????
Message-Id: <3a0a2c58.43fe$25a@news.op.net>
Keywords: differentiate, fiducial, society, transmogrify


In article <kppuk6dnkb.fsf@dagon.conectiva>,
Jorge Godoy  <godoy@conectiva.com> wrote:
>delete $ENV{'PATH'};
>
>It might help.

It doesn't.

-- 
@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: 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 4851
**************************************


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