[15902] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3315 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 10 21:05:31 2000

Date: Sat, 10 Jun 2000 18:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960685509-v9-i3315@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 10 Jun 2000     Volume: 9 Number: 3315

Today's topics:
        ActivePerl on PWS dammit32@my-deja.com
    Re: ActivePerl on PWS <rootbeer@redcat.com>
    Re: ActivePerl on PWS <flavell@mail.cern.ch>
    Re: ANSI Perl: No Way !!! <dan@tuatha.sidhe.org>
    Re: Encrypting / decrypting. <bmb@ginger.libs.uga.edu>
    Re: Encrypting / decrypting. <bmb@ginger.libs.uga.edu>
    Re: excluding certain domains in e-mails <brondsem@my-deja.com>
    Re: Extracting hash elements based on an array <rootbeer@redcat.com>
    Re: Extracting hash elements based on an array (Philip Taylor)
    Re: Extracting hash elements based on an array <rootbeer@redcat.com>
    Re: Help a newbie, do a good deed.  Mail question.... (Colin Watson)
    Re: Hiding / Setting the text in the URL location bar o <bmb@ginger.libs.uga.edu>
    Re: How to pick up shell variable from perl ? (Peter McMorran)
        modifying/updating CSV fields <mcdonabNO@SPAMyahoo.com>
    Re: now this is strange... (jason)
    Re: obfuscated but useful magic() - for your perlish am <gisle@ActiveState.com>
    Re: obfuscated but useful magic() - for your perlish am <sweeheng@usa.net>
    Re: please help <helza@planet.nl>
    Re: please help <rootbeer@redcat.com>
        RE:Routing users by username & password <flavell@mail.cern.ch>
    Re: Routing users by username & password <rootbeer@redcat.com>
        Shebang line -- What exactly does Perl do? (daniel mcgrath)
    Re: Shebang line -- What exactly does Perl do? <rootbeer@redcat.com>
    Re: Shebang line -- What exactly does Perl do? <abe@ztreet.demon.nl>
    Re: split using varible length white spaces as field se siva_ayyar@my-deja.com
    Re: split using varible length white spaces as field se <billy@arnis-bsl.com>
        textfile reading template <jagman98@home.com>
    Re: textfile reading template <rootbeer@redcat.com>
    Re: Time-Date Question ?? (Peter J Scott)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 10 Jun 2000 23:10:48 GMT
From: dammit32@my-deja.com
Subject: ActivePerl on PWS
Message-Id: <8huhtg$f55$1@nnrp1.deja.com>

I have access to an Unix server with Perl but I like to write and test
my scripts offline on my Windows 98 PC. Problem is, the ActivePerl
documentation only tells you how to set it up for IIS and isn't
specific concerning Personal Web Server (PWS). I have PWS4 and if
anyone could help me I'd greatly appreciate it.

Thanks,
Brian


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


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

Date: Sat, 10 Jun 2000 17:08:46 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: ActivePerl on PWS
Message-Id: <Pine.GSO.4.10.10006101707350.10286-100000@user2.teleport.com>

On Sat, 10 Jun 2000 dammit32@my-deja.com wrote:

> From: dammit32@my-deja.com

What a username! :-)

> I have access to an Unix server with Perl but I like to write and test
> my scripts offline on my Windows 98 PC. Problem is, the ActivePerl
> documentation only tells you how to set it up for IIS and isn't
> specific concerning Personal Web Server (PWS). I have PWS4 and if
> anyone could help me I'd greatly appreciate it.

If you're testing your programs offline, you shouldn't need a server at
all. But if you must set up your server, you probably want to search for
the docs, FAQs, and newsgroups about setting up webservers in general and
your server in particular. Cheers!

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



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

Date: Sun, 11 Jun 2000 01:46:44 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: ActivePerl on PWS
Message-Id: <Pine.GHP.4.21.0006110142030.22953-100000@hpplus03.cern.ch>

On Sat, 10 Jun 2000 dammit32@my-deja.com wrote:

> I have access to an Unix server with Perl but I like to write and test
> my scripts offline on my Windows 98 PC. Problem is, the ActivePerl
> documentation only tells you how to set it up for IIS and isn't
> specific concerning Personal Web Server (PWS). I have PWS4 and if
> anyone could help me I'd greatly appreciate it.

The consensus seems to be that the best way to come to terms with
PWS is to use something else.

If you want to develop a transferrable skill, then choose Win32 Apache
(this was my choice).

If you want something simple, then find out from the
c.i.w.servers.ms-windows group what the feeling is (I wouldn't presume
to advise).  This is only indirectly a Perl language question.




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

Date: Sat, 10 Jun 2000 23:51:13 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <RvA05.110150$hT2.432156@news1.rdc1.ct.home.com>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> John from PUNY wrote:

> (snipped with an attitude)

>> LR: people should devote their attention to firming up the semantics
>> and making sure that the implementation conforms to those semantics,
>> rather than the other way around
>  
>> ME: No more swiss-army-chainsaw, :`(

> Perl is dead and has been for years. The release of
> Perl 5.x began the intonement of Perl's Death Knell.

Cool! Larry Wall killed perl! I shall have to tell him that.

You do realize that Larry was responsible for perl 5, the same way as he
was for perl 4, perl 3, perl 2, perl 1, and perl 0, right?

> Early on, Perl 4 was written for real programmers
> who love a challenge and love to truly program.

No it wasn't. Perl was never intended for 'real programmers', Gojira. It
was written by and for Larry, and the fact that it was useful to other
people's always been a nice side benefit. 

> Our
> Perl 5, is the end product of a molestation and rape
> of Mother Perl 4.

Actually, it's the end product of the abuse of perl 0, if you want to take
this to its logical extreme. Perl 4 was never a stopping point--it was
just one incarnation of the language Larry is still in the process of
creating. All of the stuff that was in version 4 (and 3, and 2, and 1...)
is still in there. Some of it's a darned sight faster now too.

> This grandiose nature is a direct reflection of
> in-house battles of egos by self-proclaimed elitists
> of Perl, supported by a staff of one-hundred monkeys.
> This primate cabal, supposedly in charge of Perl,
> amounts to nothing more than a Good Ol' Boys Club
> populated by little boys looking to masturbate their
> egos at the expense of purist programmers who don't
> give a Scarlett O'Hara damn about ego satiation.

No, actually, that's not the case. I don't think anyone's ever proclaimed
themselves one of the elites of perl, and we really only have one ego of
any size. We certainly aren't doing it for some ego-stroke--it's far too
much work for that. There are much easier ways to get a good ego stroke
than patching perl.

> Those of us who are still purist programmers expend
> a lot of effort compensating for all those bugs and
> glitches inherent to Perl 5.

Such as? perlbug comes with every copy of perl, Gojira. If you've found
bugs, report the things and they'll get fixed.

> Most annoying of all,
> we purist programmers are put into a position of
> having to write code which fools Perl 5 into doing what
> we want, not what some maxed out zoom sissified geek
> decided we should do with our programs and insist,
> use strict.

You'll note that use strict is off by default. Perl 5, by default, behaves
identically to perl 4, with a few well-documented exceptions. (The
biggest being that perl 5 lacks perl 4's buffer overrun problems)

But why are you writing code in perl anyway, Gojira? The whole language is
amazingly far from the hardware, and by many measures (including the ones
you use) bloated and slow. I think you'll find your system comes with an
assembler--you'll get much tigher and faster code out of that.

> Perl 5 is a big fat slow gas guzzling high
> operating expense Mercedes Benz driven by
> Pee Wee while listening to ever so gag me
> with a spoon boring half watt background
> elevator music, with a Family Bible size
> owner's manual written in ancient Oriental
> caligraphy residing within its glove box,
> a glove box with a lid which won't stay shut.

> Perl 4 is a sleek five-hundred horsepower
> classic Corvette Mako Shark which snorts
> and rips up asphalt while spitting fire
> out its tailpipes, driven by a James Dean
> fashion Rebel Without A Cause listening to
> Steppenwolf at an equal five-hundred watts
> of rock and roll power. Mako Sharks have
> no glove box for an owner's manual. Drivers
> of Perl 4 know how to tune for neck snapping
> wild performance.

Wow, impressive comparison! Not true, alas, but impressive nonetheless.

If you're worried about speed, why on *earth* are you writing code in
perl? Your best bet's probably assembly, followed closely by Fortran.
Perl's damn slow in comparison to both of those.

				Dan


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

Date: Sat, 10 Jun 2000 20:40:13 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Encrypting / decrypting.
Message-Id: <Pine.A41.4.21.0006102039540.12492-100000@ginger.libs.uga.edu>

On Fri, 9 Jun 2000, Drew Simonis wrote:

> "Godzilla!" wrote:
> 
> > I bite.
> > 
> > Kira
> 
> 
> Wow!  The first true words from this one.  
> 
> You sure do.

Dentures.

-- 
Brad



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

Date: Sat, 10 Jun 2000 20:45:05 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Encrypting / decrypting.
Message-Id: <Pine.A41.4.21.0006102042530.12492-100000@ginger.libs.uga.edu>

On Sat, 10 Jun 2000, Ben Kennedy wrote:

> If me trying to open up an honest dialog about the nature of your posts is
> 'trolling and harassing', then you have a strange definition of those words.

The troll doesn't bother with rational thought.

> Why don't you respond to my post again and actually read it and consider its
> points.  Or, send me a message directly, which is probably best for this
> group.  I am not accusing you of anything, I (and most people) just want to
> discuss the issue since there is clearly a 'situation' and we should all at
> least be able to agree that its bad.

The troll doesn't want to discuss any issue except trollself.

-- 
Brad



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

Date: Sun, 11 Jun 2000 00:20:44 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: excluding certain domains in e-mails
Message-Id: <8hum0k$hnh$1@nnrp1.deja.com>

  Z-man <dzapped@theramp.net> wrote:
> Hi all,
> I have a registration script that requires an e-mail address what i'd
> like to do is exclude certain domains from registering i.e.
> someone@hotmail .com  is this possable and if so how currently the
> e-mail part reads this
> &error("missing email address") if (!$in{'email'});
>  &error("invalid email address") if ($in{'email'} !~ /\@/);

Use the same logic as the check for @
if ($in{'email'} !~ /\@/ || $in{'email'} !~ /anytextyouwant/);
|| means or


> any help appreciated
>
> Denis
>
>


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


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

Date: Sat, 10 Jun 2000 15:13:38 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Extracting hash elements based on an array
Message-Id: <Pine.GSO.4.10.10006101508480.10286-100000@user2.teleport.com>

On Sat, 10 Jun 2000, Philip Taylor wrote:

> >> I want to pull elements from the player hash based on the list of
> >> player_codes in the array.
> >
> >It sounds as if you want a slice:
> >
> >    my @elements = @player{ @fields };

> Am I correct in thinking the '@' on @player above is the slice
> operator which allows you to specify the content of the slice on the
> %player hash using the @fields array?

Well, it's not an operator. It's part of the syntax meaning "a group of
items".

> I'm not clear on what needs to go in the braces in place of @fields?
> Does @fields act on the key or the value of the hash?

Inside the braces is a list expression whose value is the list of indices.
If the list is qw/ code name age / , then the resulting value from the
slice is the same as ($player{code}, $player{name}, $player{age}) .

Cheers!

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



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

Date: Sat, 10 Jun 2000 23:55:09 GMT
From: phil.taylor@bigfoot.com (Philip Taylor)
Subject: Re: Extracting hash elements based on an array
Message-Id: <3942d3d7.57431026@news.demon.co.uk>

On Sat, 10 Jun 2000 15:13:38 -0700, Tom Phoenix <rootbeer@redcat.com>
wrote:

>Inside the braces is a list expression whose value is the list of indices.
>If the list is qw/ code name age / , then the resulting value from the
>slice is the same as ($player{code}, $player{name}, $player{age}) .

I understand slices now (I think), but iy doesn't solve my problem
completely. The test program below does not produce any o/p because my
available list of indices (@playerCodes) are not keys to the
PlayerList hash.

my (@playerCodes, %playerList, @result, %player1, %player2, %player3,
%player4, %player5, %player6);

$playerCodes[0] = "001";
$playerCodes[1] = "003";

$player1{'code'} = "001";
$player1{'name'} = "player1";
$player2{'code'} = "002";
$player2{'name'} = "player2";
$player3{'code'} = "003";
$player3{'name'} = "player3";
$player4{'code'} = "004";
$player4{'name'} = "player4";
$player5{'code'} = "005";
$player5{'name'} = "player5";
$player6{'code'} = "006";
$player6{'name'} = "player6";

$playerList{'player1'} = \%player1;
$playerList{'player2'} = \%player2;
$playerList{'player3'} = \%player3;
$playerList{'player4'} = \%player4;
$playerList{'player5'} = \%player5;
$playerList{'player6'} = \%player6;

@result = @playerList{@playerCodes};

foreach (@result) {
	print "$_\n";
}


cheers

Phil


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

Date: Sat, 10 Jun 2000 17:26:25 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Extracting hash elements based on an array
Message-Id: <Pine.GSO.4.10.10006101724070.10286-100000@user2.teleport.com>

On Sat, 10 Jun 2000, Philip Taylor wrote:

> I understand slices now (I think), but iy doesn't solve my problem
> completely. The test program below does not produce any o/p because my
> available list of indices (@playerCodes) are not keys to the
> PlayerList hash.

I think you're going to want to make an index hash which lets you look up
a "playerCode" and get a reference to the (anonymous?) hash which has
that one's information. Then you might be able to use a slice, or perhaps
map().

See the perldsc manpage (and related ones) for more information on using
anonymous hashes like this. Good luck with it!

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



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

Date: 10 Jun 2000 22:47:05 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: Help a newbie, do a good deed.  Mail question....
Message-Id: <8hugh9$q2i$1@riva.ucam.org>

Ranyart Olias <dilcher@cueva.com> wrote:
>I am trying to find a small snippet of code that can parse a text file,
>(which happens to be a mail message body), and can extract the
>plain text out (and discard any attachments, html, etc.).

Have a look at the MIME-tools modules, available from CPAN
(http://www.perl.com/CPAN-local/authors/Eryq/MIME-tools-5.209.tar.gz).
If you take the first example in the readme file next to that on CPAN,
or in the documentation for the MIME::Tools module, and tweak it a bit,
you should be able to produce something pretty close to what you want.

-- 
Colin Watson                                     [cjw44@flatline.org.uk]
"Oh Danny Boy, the pipes, the pipes are calling,
 From glen to glen, and down the mountainside ..."


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

Date: Sat, 10 Jun 2000 21:03:20 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Hiding / Setting the text in the URL location bar of browser - how ?
Message-Id: <Pine.A41.4.21.0006102055100.12492-100000@ginger.libs.uga.edu>

On Sat, 10 Jun 2000 bluecraft@hushmail.com wrote:
> Can anyone tell me how to define the URL text in the location bar. If
> for example I have a web form that sends input to a CGI, when it
> returns it show the fields and data that were sent into the CGI, like:
> 
> http://www.mydomain.com/cgi-bin/search.pl?name=fred&password=1234
> 
> I want it on return to only show like:
> 
> http://www.mydomain.com/access
> 
> I remember a guy I knew (who got me into cgi years ago!) doing this
> because he did not lik the 'messy' locations that showed up, now I want
> to do the same - anyone have any thoughts of how to achieve this (apart
> from using frames ... he didn't).

I had need to do this and the frames solution wasn't a solution.
This may or may not be pertinent to your situation.

The URL that I did not want to show contained:

    ... sessionid=0 ...

which, when reloaded, started a new session (software implemented
session).

The URL that I did want to show contained:

    ... sessionid=01-010101-010101 ...

which, when reloaded, did not start a new session.

My solution was to use LWP to retrieve the contents of the
"sessionid=0" page, tease out the actual sessionid and then relocate to

"Location: http://url.com?sessionid=01-010101-010101\n\n"

etc.

You might find this helpful.

-- 
Brad



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

Date: Sun, 11 Jun 2000 00:36:04 GMT
From: mcmorran@visi.net (Peter McMorran)
Subject: Re: How to pick up shell variable from perl ?
Message-Id: <3942deef$1$zpzbeena$mr2ice@news.visi.net>

In <MPG.13ac5057c2f719b0989719@news>, on 06/10/00 
   at 03:16 AM, elephant@squirrelgroup.com (jason) said:

>Andy writes ..
>>I am running a web page with perl script on a unix system.  The page
>>is expected to run for different applicaiton purpose whcih depents on
>>a shell environment variable.  The shell environment vairable is set
>>when the web server is started on a particular environment for an
>>application environment.
>> I wish to pick up the shell environment variable from my perl when it
>>is called from the client's browser to know what application I should
>>go.
>>
>>Can someone give me a help on what I should be looking for from the
>>perl to get the shell environment vairables at the instance.
>>
>>I already tried the %ENV{} which does not seem contains anyting for
>>the shell.

>doesn't contain anything ? .. then you're probably using it
>incorrectly  ... show some code

Or you're looking for shell variables, not environment variables.

The environment is something that each process passes to its
children. It is not specifically related to the shell, though
shells access their environment, and pass it to their children.
The shell sets environment variables by export (sh) or setenv
(csh). Other shell variables are not accessible to the child
processes.

In your case, the environment variable is set when the web server
is started, so it should be present in perl scripts invoked by
the server. Have you tried dumping the contents of %ENV? Sorting
the keys helps since they come out in random order.

Cheers,
Peter

-- 
-----------------------------------------------------------
mcmorran@visi.net (Peter McMorran)
-----------------------------------------------------------



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

Date: Sat, 10 Jun 2000 17:32:49 -0700
From: "Brian McDonald" <mcdonabNO@SPAMyahoo.com>
Subject: modifying/updating CSV fields
Message-Id: <8humna$iq5$1@nntp9.atl.mindspring.net>

(thanks to lauren and tad for their previous advice on my earlier post)

Hi.

I have a text file that contains many records that look like this:

jovovich,milla,,,,,1974,,model, singer and actress

where the last field is marked by the 8th comma.

What I would like to do is double quote all the string values in the record.
For example,

"jovovich","milla","","","","","1974","","model, singer and actress"

I have written the following code to do the job. The only problem is that I
don't know how to get the updated fields back into an object that I can then
write to another output file.

require Text::CSV_XS;

$fieldnum = 9;

# create a new csv object
my $csv = Text::CSV_XS->new;
 ...
while (<TXTIN>) {
  $line = $_;
  if ($line ne "") {  # this is a record
    chomp;
    if ($csv->parse($line)) {  # this record is valid
      # count this record
      ++$rec_count;
      # get fields of this record
      my @field = $csv->fields;
      # init field_count var
      my $field_count = 0;
      for $column (@field) {
        # count this field
        ++$field_count;
        # put double quotea around string
        $column = "" . $column . "";
      }
      # check field count
      if ($field_count ne $fieldnum) {
        print "Record number: " . $rec_count . " has only " . $field_count .
" fields.\n";
      } else {
         # write the updated record to output file
        ########################
         #### here's where i'm stuck!
      }
    } else {  # this record is invalid
       my $err = $csv->error_input;
       print "parse() failed on argument: ", $err, "\n";
    }
} # end while stmt

I've pored over the Text::CSV_XS documentation... but I can't seem to
understand how to do this.

Any ideas?

Brian




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

Date: Sat, 10 Jun 2000 22:58:13 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: now this is strange...
Message-Id: <MPG.13ad6536a328055e98971e@news>

Raphael Pirker writes ..
>I have quite a few variables that need to be defined:
>
>$autoresp_state       = $FORM{autoresp_state};
>$autoresp_from        = $FORM{autoresp_from};
>$autoresp_spam        = $FORM{autoresp_spam};
>$admin_state          = $FORM{admin_state};
>$admin_from           = $FORM{admin_from};
>$admin_sort           = $FORM{admin_sort};
>$results_message      = $FORM{results_message};
>$results_template     = $FORM{results_template};
>$results_cartoon      = $FORM{results_cartoon};
>$results_results      = $FORM{results_results};
>$results_link_text    = $FORM{results_link_text};
>$results_link_url     = $FORM{results_link_url};

if you used the CGI module instead of whatever is creating this %FORM 
hash (is it cgi_lib ?) then you could use the import_names() function 
which imports all the CGI form variables into a given namespace

  use CGI 'import_names'; import_names('Q');

  $Q::autoresp_state;  #etc

'Q' is the default namespace btw .. BUT .. all those variables that 
you've got listed on the right above are scalars as well and can be used 
anywhere (god it makes me nervous using absolutes in here :) that a 
normal scalar can be used

Disclaimer: where I say 'anywhere' above I really am only thinking about 
interpolation situations such as double-quoted strings and regexes .. 
although I can't think of any situation where they behave differently - 
there may be

>Could anyone point me into the right direction? (please feel free to
>underestimate my IQ... :-)

something that a lot more posters here should invite .. well said

what you're missing is called a symbolic reference .. but 'use strict' 
will not let you use it anyway .. and hashes are a far better 
alternative .. as is the CGI::import_names() function

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 11 Jun 2000 01:32:13 +0200
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: obfuscated but useful magic() - for your perlish amusement
Message-Id: <m33dml9koy.fsf@eik.g.aas.no>

"Tim" <tcuffel@exactis.com> writes:

> Gisle Aas wrote in message ...
> 
> >  sub magic{+{map{my$m=substr gmtime 25e5*$_,4,3;$m,$_,$_,$m}1..12}->{$_[0]}}
> 
> 
> Shaving a char...
> 
>    sub magic{+{map{(my$m=substr gmtime 25e5*$_,4,3),$_,$_,$m}1..12}->{$_[0]}}

Did you test it?  That does not seem to work for me.  This is another
way of getting rid of a char...

  sub magic{+{map{my$m=substr gmtime$_*25e5,4,3;$m,$_,$_,$m}1..12}->{$_[0]}}

-- 
Gisle Aas


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

Date: Sun, 11 Jun 2000 07:55:31 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: obfuscated but useful magic() - for your perlish amusement
Message-Id: <8huk6c$1nl$1@violet.singnet.com.sg>

> >                                back to the working table. :o)
>
> Once I can take but twice ... I think you mean drawing board ;-}

well, i have no drawing board at home... but thanks for the correction. :o)
if i was looking for an excuse, i would say i "cut-and-pasted". but i
didn't.




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

Date: Sun, 11 Jun 2000 00:41:43 +0200
From: "Helza" <helza@planet.nl>
Subject: Re: please help
Message-Id: <8hujdu$5lsl6$1@reader2.wxs.nl>

Yes it returned 0, but as you'll see if you ping it, this server is up.
so it should be returning a 1 :) not a 0

Craig Berry <cberry@cinenet.net> wrote in message
news:sk2es6v7h5120@corp.supernews.com...
> Helza (helza@planet.nl) wrote:
> : ohyeah part of code i forgot I tryed the Net::Ping
> :
> : ------
> : #!/usr/bin/perl
> :
> : use Net::Ping;
> :
> : $host = "130.89.225.137";
> : $p = Net::Ping->new();
> : $retval = $p->ping($host,5);
> : $p->close();
> :
> : print "Content-type: text/html\n\n";
> : print "Retval value is: $retval";
> : -------
> : but everything i wrote below the $p->close();
> : doesn't seem to be executed :(
>
> Just ran that very code here (perl 5.005, Solaris 2.6) and all was well
> (returned 0, by the way).
>
> --
>    |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
>  --*--  "You live in Los Angeles, and you are going to Reseda; we are
>    |   all in some way or another going to Reseda someday, to die."
>                - Soul Coughing




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

Date: Sat, 10 Jun 2000 17:15:04 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: please help
Message-Id: <Pine.GSO.4.10.10006101712351.10286-100000@user2.teleport.com>

On Sun, 11 Jun 2000, Helza wrote:

> Yes it returned 0, but as you'll see if you ping it, this server is up.

Maybe I'm missing something, but I think you're mixing two different kinds
of pings. One (from the ping program, running as a privileged user) shows
you that the machine is alive. But the other (from Net::Ping, running as
an ordinary user, and doing a udp ping to the echo port) is failing. Could
it be that there's no echo service on that machine's udp port? If so, that
method would be correct to fail. 

Cheers!

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



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

Date: Sun, 11 Jun 2000 00:30:53 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: RE:Routing users by username & password
Message-Id: <Pine.GHP.4.21.0006110016190.3434-100000@hpplus03.cern.ch>

On Sat, 10 Jun 2000 msorense@my-deja.com wrote:

> Dear Perl Gurus:

Oh dear.  Alarm bells are tinkling.

> I am trying to implement a password script 

There's a lot of it about...

> on my site (Apache server)

The Apache server happily implements basic authentication for you.
No scripts required, and certainly no Perl gurus need to be engineered
into such a system...

> that simply directs the user to a protected page based on their username
> and password.  The protected page may contain further links to other
> protected pages that the user should be able to freely retrieve (i.e.
> should only have to enter username and password once). 

This is the normal arrangement, after all.

>  I don't think
> the htaccess per-directory authorization scheme works because it only
> protects directories, it does not route a particular user to a
> particular page.

You are misinformed.  Check your server documentation, specifically
in regard to the use of <Files...> and <FilesMatch...> brackets.
 
> Hopefully someone can give me the general strategy behind such a script.

Sure:  the general strategy is "don't"   ;-)

>   My current script tries to use chmod to change the permissions of the
> requested file ($request), send the URL corresponding to that file
> ($target), and then reset the permissions.

I'm sorry to have to tell you that you are totally at sea, attempting
to solve a problem that doesn't exist by using totally inappropriate
technology.

> For some reason I can't understand, chmod does not work when the script
> is called over the net, 

That's the least of your worries.

This is sad, because you've obviously invested a deal of effort in
designing this misguided scheme before seeking assistance (and in the
wrong place, as it happens).  I can't make out whether I ought to stop
there, or carry in into the details and try to show what's wrong.

Trouble is, if I try to do that latter, there's almost nothing that's
on-topic for this group, so I'm set to be ruled out of order for that
too.

> it only works when called from a shell. 

keywords: unix directory permissions, effective userid of web server.

But your scheme is misconceived.  Think what happens when ten people
are accessing the page concurrently, what should the filemode be?

> 1. Is there a generally accepted method to route users with a valid
> username and password to a protected page based on their username and
> password?

Do you mean that each user gets the same page?  then the answer's yes.

Each user gets a different page?  then the answer's yes too, but you
need extra machinery (e.g mod_rewrite) to select the page.

Basic authentication, the very thing that you abandoned prematurely.

good luck, don't take it too hard.  (But don't ask for gurus: you
don't need them yet, these are quite normal web server techniques).




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

Date: Sat, 10 Jun 2000 15:30:40 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Routing users by username & password
Message-Id: <Pine.GSO.4.10.10006101514360.10286-100000@user2.teleport.com>

On Sat, 10 Jun 2000 msorense@my-deja.com wrote:

> Subject: RE:Routing users by username & password

Please don't start your subject line with "re:" unless it's a follow-up,
like this one. It makes your message look like you're responding to
someone else's request.

> I am trying to implement a password script on my site (Apache server)
> that simply directs the user to a protected page based on their
> username and password.  The protected page may contain further links
> to other protected pages that the user should be able to freely
> retrieve (i.e. should only have to enter username and password once).  
> I don't think the htaccess per-directory authorization scheme works
> because it only protects directories, it does not route a particular
> user to a particular page.

You should be able to use the REMOTE_USER environment variable to do do
any redirection you want after authentication (which is normally triggered
by a .htaccess file). Of course, if you want that target page to be
password protected, use your server's authentication mechanism.

> My current script tries to use chmod to change the permissions of the
> requested file ($request),

That's probably the wrong strategy. If Fred has just been authenticated,
wouldn't Barney now be able to access the newly-chmod'ed page?

> send the URL corresponding to that file ($target), and then reset the
> permissions.

It's getting worse: Now the remote user has several seconds (presumably)
to fetch the page. If they don't get it in time, they're mad at you. If
they do get it, though, anyone who shares their caching proxy also gets
it. So, if one AOL user sees your page, they all can.

>   chmod 0755, $request;
>   print redirect(-uri => $target);
>   chmod 0700, $request;

You're changing the mode back (probably) before your webserver passes on
your redirect message. Way too fast. Besides, you probably don't want the
webserver process to have the authority to change the permissions on your
important files.

> For some reason I can't understand, chmod does not work when the script
> is called over the net, it only works when called from a shell.

Because your admin knows that you probably don't want the webserver
process to have the authority to change the permissions on your important
files. :-)

> My script also sends an encrypted cookie to the

Of course, many browsers don't support cookies, don't have them enabled,
or are connected via proxies which filter out cookies - so you may not get
that to work with everyone.

> 1. Is there a generally accepted method to route users with a valid
> username and password to a protected page based on their username and
> password?  If so what is it?

Use the REMOTE_USER to send them to whatever page you want, but if you
want that page to be password-protected, you'll want to use your server's
authentication mechanism.

> 2.  Can I use htaccess in conjunction with such a scheme?

You'll probably have to, unless you want to work a lot harder!

> 3.  Why doesn't my call to chmod work when called over the net?

Because your webserver process is running as another user-id than you are.

Since this would all be the same if you were programming in C or any other
language, it's not really a Perl question. Perhaps you want to search for
the docs, FAQs, and newsgroups about programming for the web. Reading
comp.infosystems.www.authoring.cgi would be a good place to start.

Cheers!

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



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

Date: Sat, 10 Jun 2000 22:59:55 GMT
From: dmcg6174@yahoo.com (daniel mcgrath)
Subject: Shebang line -- What exactly does Perl do?
Message-Id: <3942c0fd.23001907@news.liii.com>

Hello, I may be learning Perl and I don't know the exact deal with the
shebang line.  I had originally thought that Perl just treated it as a
regular comment and that it was there only so that you could run the
program on UNIX as "program.pl" and didn't need to type "perl" in
front.  But I see that at least on my implementation, this isn't so.
A program beginning with "#!/usr/bin/perl -w" will give warning
messages even if I don't type "-w" on the command line.  But then, I
use a Windows system, so of course there's no such thing as
"/usr/bin".

So, what exactly happens with the shebang line?

I will probably have more to ask.

daniel


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

Date: Sat, 10 Jun 2000 16:11:24 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Shebang line -- What exactly does Perl do?
Message-Id: <Pine.GSO.4.10.10006101609050.10286-100000@user2.teleport.com>

On Sat, 10 Jun 2000, daniel mcgrath wrote:

> So, what exactly happens with the shebang line?

On systems which support it, it can tell the system to start perl. But I
think you want to know what happens after perl sees it.

perl looks for the word "perl" on that line. If it's a shebang-line
without that string, perl starts that program for you. 

If it did find "perl", it looks for command-line switches, and tries to
use those, as you discovered.

Is that what you needed, or is there something more?

Cheers!

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



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

Date: Sun, 11 Jun 2000 02:33:10 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Shebang line -- What exactly does Perl do?
Message-Id: <5um5ksgehgudk43nuo0e9c1jgpt0286sub@4ax.com>

On Sat, 10 Jun 2000 22:59:55 GMT, dmcg6174@yahoo.com (daniel mcgrath)
wrote:

> Hello, I may be learning Perl and I don't know the exact deal with the
> shebang line.
 ...
> A program beginning with "#!/usr/bin/perl -w" will give warning
> messages even if I don't type "-w" on the command line.  But then, I
> use a Windows system, so of course there's no such thing as
> "/usr/bin".
On mine there is, just tell ActivePerl Installer you want perl installed
in c:\usr (instead of c:\Perl)

> So, what exactly happens with the shebang line?
To add to Tom Phoenix's response, if you have perl installed, you can
read the large set docs that comes with perl either in a web browser
(start->programs->ActivePerl->documentation) or with a command-line
program called 'perldoc'
Your question will be answered by typing:

	perldoc perlrun

> I will probably have more to ask.
You're welcome to, but be sure to read (at least) the perlfaqX documents
before you do.

-- 
Good luck,
Abe


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

Date: Sat, 10 Jun 2000 22:23:26 GMT
From: siva_ayyar@my-deja.com
Subject: Re: split using varible length white spaces as field separators
Message-Id: <8huf4j$dg6$1@nnrp1.deja.com>




@array = split(/\s+/, $line);

In article <8htfdn$ogd$1@nnrp1.deja.com>,
  Larry James <ljames@apollo3.com> wrote:
>      Can someone advise me how to break up a line using split (or any
> other routine) where the separations maybe an inconsistent number of
> white spaces.  It there was one space of course it would be:
>
>           @array = split(/ /,$line);
>
>      Thanks in advance for any suggestions or comments.
>
>                                    -- L. James
>
> --
> ---------------------------
> Larry James
> ljames@apollo3.com
> http://www.apollo3.com/~ljames
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Sun, 11 Jun 2000 00:18:52 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: split using varible length white spaces as field separators
Message-Id: <8hult3$hls$1@nnrp1.deja.com>

In article <8htfdn$ogd$1@nnrp1.deja.com>,
  Larry James <ljames@apollo3.com> wrote:
>      Can someone advise me how to break up a line using split (or any
> other routine) where the separations maybe an inconsistent number of
> white spaces.  It there was one space of course it would be:
>
>           @array = split(/ /,$line);
>
>

@array = split ' ', $line;

or maybe (task dependent)

@array = split /\s+/, $line;

Please consult your local 'perldoc -f split'
or http://www.cpan.org/doc/manual/html/pod/perlfunc/split.html
for more details.

Hope this helps.
Ilja.


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


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

Date: Sat, 10 Jun 2000 22:06:30 GMT
From: Manny <jagman98@home.com>
Subject: textfile reading template
Message-Id: <3942BBEE.7C17013@home.com>

Needs to read huge text file in series of records.  Folliwing text file:

test.txt

field1         : value1
field2         : value2
field3         : value3

field1         : 1
field2         : 2
field3         : 3
=============

I needs to read in
$value1,$value2,$value3  as record 1. and write it to other text file.
example:

test.out
value1,value2,value3
1,2,3
and so on.

Thanks in advance!



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

Date: Sat, 10 Jun 2000 15:33:38 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: textfile reading template
Message-Id: <Pine.GSO.4.10.10006101532240.10286-100000@user2.teleport.com>

On Sat, 10 Jun 2000, Manny wrote:

> Needs to read huge text file in series of records.

Have you tried using Perl? It's good at this sort of thing. Perhaps you
need a good book for beginners; many folks around here recommend "Learning
Perl" from O'Reilly. Cheers!

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



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

Date: Sat, 10 Jun 2000 22:35:26 GMT
From: peter@PSDT.com (Peter J Scott)
Subject: Re: Time-Date Question ??
Message-Id: <Ooz05.12762$F9.398177@news1.gvcl1.bc.home.com>

In article <MPG.13ac164917ef974698ab5c@nntp.hpl.hp.com>,
 Larry Rosler <lr@hpl.hp.com> writes:
>Golfers might prefer 'A2'x5 (saves four strokes :-).
>
>But the superiority of unpack over a set of substrs is quite clear.

I assume you are talking about golf scores, not performance?

use Benchmark;
$line = <DATA>;
timethese (1000000,
  { 
    'regex' => q{
      my ($year, $m, $d, $h, $min)
         = ($line =~ /(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/);
    },
    'substr' => q{
      my ($year, $m, $d, $h, $min)
         = (substr($line, 0, 2),
	    substr($line, 2, 2),
	    substr($line, 4, 2),
	    substr($line, 6, 2),
	    substr($line, 8, 2),
	    substr($line, 10, 2));
    },
    'unpack' => q{
      my ($year, $m, $d, $h, $min)
         = unpack "A2"x5, $line;
    }
  });
__END__
0006091338

Benchmark: timing 1000000 iterations of regex, substr, unpack...
     regex: 44 wallclock secs (43.93 usr +  0.01 sys = 43.94 CPU) @ 22758.31/s (n=1000000)
    substr: 20 wallclock secs (19.76 usr +  0.00 sys = 19.76 CPU) @ 50607.29/s (n=1000000)
    unpack: 38 wallclock secs (37.53 usr +  0.00 sys = 37.53 CPU) @ 26645.35/s (n=1000000)

-- 
Peter Scott


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

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


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