[16371] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3783 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 24 06:05:27 2000

Date: Mon, 24 Jul 2000 03:05:13 -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: <964433113-v9-i3783@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 24 Jul 2000     Volume: 9 Number: 3783

Today's topics:
    Re: ATTENTION PERL MEATHEADS (David H. Adler)
    Re: CGI.pm Cookies and images together (David Efflandt)
    Re: Check string for a certain format (Anno Siegel)
    Re: convert file permissions; octal-->stat (Natanael)
    Re: dos command in perl script (Homer Simpson)
        Empty PerlTOC.ps generated by perl-5.6.0/pod/roffitall <honchi_ng@my-deja.com>
        file extension <danielxx@bart.nl>
    Re: How to delete a record in a text data file? (Villy Kruse)
    Re: How to loop like this - for(a000 ... x999) ??? (Craig Berry)
    Re: How to loop like this - for(a000 ... x999) ??? <thoren@southern-division.com>
    Re: login help (Abigail)
    Re: login help (David Efflandt)
    Re: LWP UserAgent yaacovs@my-deja.com
        Need questions for Perl quiz <daniel@blackomega.com>
        Newbie "Learning Perl"  help <unknown-one@home.com>
    Re: password unix with crypt (Villy Kruse)
    Re: Perl 5.* (Gwyn Judd)
        Perl and Microsoft Personal Web Server - help <info@kulturystyka.com.pl>
    Re: perl v. tcl <bart.lateur@skynet.be>
    Re: redirection fails (Bernard El-Hagin)
        replacing any character except for spaces... <laf@gameonline.co.uk>
    Re: replacing any character except for spaces... (Bernard El-Hagin)
    Re: replacing any character except for spaces... (Abigail)
    Re: replacing any character except for spaces... <laf@gameonline.co.uk>
    Re: replacing any character except for spaces... (Tim Hammerquist)
    Re: Setting $/ from variable - accepting meta character kjeldahl@hotmail.com
        tutorials socket <haggi@tappe.net>
    Re: tutorials socket <bart.lateur@skynet.be>
        When will use the flock? <chaptera@hotmail.com>
    Re: Why won't  "use strict;"  work? <godzilla@stomp.stomp.tokyo>
    Re: Why won't  "use strict;"  work? (Abigail)
    Re: Why won't  "use strict;"  work? (BUCK NAKED1)
    Re: Why won't  "use strict;"  work? <bart.lateur@skynet.be>
    Re: Why won't  "use strict;"  work? <godzilla@stomp.stomp.tokyo>
    Re: Writing to a file error : Pt 2 <colin_larcombe@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 24 Jul 2000 05:18:54 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: ATTENTION PERL MEATHEADS
Message-Id: <slrn8nnkdu.je8.dha@panix6.panix.com>

On Fri, 21 Jul 2000 14:09:51 -0400, Drew Simonis <care227@attglobal.net> wrote:
>I have found the Cookbook to contain alot of careless errors.
>Nothing that anyone with even a small bit of experience using
>Perl modules wouldn't be able to overcome, but to a newbie
>they would be very frustrating, even more so since the books 
>examples are advertised as working as it to accomplish the 
>described tasks.

Admittedly, the first printing of the Ram had a lot of errors.
Nevertheless, the authors have been very good about keeping large
reams of errata where they can be accessed to deal with that
particular shortcoming:
http://www.oreilly.com/catalog/cookbook/errata/

Enjoy. :-)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
There's more than one way to skin a cat, and I happen to know that's
factually true.	  - Mayor Wilkins


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

Date: Mon, 24 Jul 2000 06:53:01 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: CGI.pm Cookies and images together
Message-Id: <slrn8nnpt5.8gj.efflandt@efflandt.xnet.com>

On Sun, 23 Jul 2000 18:46:50 +0100, Jerry Pank <Connected@btinternet.com> wrote:
>In article <slrn8njpca.2pa.efflandt@efflandt.xnet.com>, David Efflandt
><efflandt@xnet.com> writes
>>On Sat, 22 Jul 2000 15:08:30 +0100, Jerry Pank <Connected@btinternet.com> wrote:
>>>I am trying to use CGI.pm to return an image *and* drop a cookie at the
>>>same time and am nearly there, but not quite!
>>>
>>>eg:
>>>
>>>Calling document:
>>>
>>>..<body><img src='cookie.pl height='10' width='20'>..
>>>
>>>CGI part of script 
>>>
>>>sub return_img {
>>>   my $image  = &get_image;
>>>   my $cookie = &test_data;   
>>>   print header('-type' => 'image/gif',
>>>                '-cookie' => $cookie),
>>>                  $image;
>>>}
>>>
>>>The above returns the image, but only drops the cookie once the image
>>>source is viewed from the browser.  Not quite what I want!
>>
>>What are you attempting to read the cookie with.  You certainly could not
>>read it from the same page that has the <img src> tag, because the cookie
>>does not exist until after that <img src> is loaded.  But if you set the
>>path correctly in the cookie, any subsequent page should have it.
>>
>
>I have not even tried to read the cookie because I don't get the browser
>`leaving a cookie` warning unless I actually try to right click and read
>the source of the image. 
>-- j :wq

I thought maybe a cookie set in an img src was ignored, but it works
properly in Linux Netscape.  One problem is that images are cached, even
if generated by CGI, so your image is NOT refreshed on reload.  You either
need to hit shift-reload when testing, or have an expires header that
expires the same as the cookie.  Then image and cookie will be refreshed
if the page is reloaded after the cookie expires (or expire the image
'now' so it always reloads):

#!/usr/bin/perl -w
use CGI qw/:standard/;
my $cookie = cookie(	-name=>'Favorite',
			-value=>'Chocolate Chip',
			-expires=>'+30s',
			-path=>'/');
$image = '../img/apache_pb.gif';
$len = -s $image;
print header(-type=>'image/gif',-Content_length=>$len,
-expires=>'now',-cookie=>$cookie);
open(IMG,"$image") || die "Can't open $image: $!";
print <IMG>;
close IMG;

You might need a binmode or 2 in there if running on a Win server.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: 24 Jul 2000 08:06:55 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Check string for a certain format
Message-Id: <8lgtev$ujr$1@lublin.zrz.tu-berlin.de>

Jakob Schmidt  <sumus@aut.dk> wrote in comp.lang.perl.misc:
>"Colin Larcombe" <colin_larcombe@hotmail.com> writes:
>
>> However where do I find out about perlre or use
>> .
>> 
>>         perldoc perlre              perldoc -f length
>
>If I understand correctly you don't know how to read the docs?
>
>In MacPerl use the helpmenu to start the docs reader (the name escapes me -
>probably something with "pod" in it) you can find the perlre page and
>others in the menus or you can get them using the Lookup... menu item.

It's called "shuck".  Not that you need to know that to use it.

Anno


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

Date: Mon, 24 Jul 2000 07:28:04 GMT
From: natNOOSPAM@bethelite.net (Natanael)
Subject: Re: convert file permissions; octal-->stat
Message-Id: <397bee88.33887768@news1.c2i.net>

On Mon, 17 Jul 2000 15:51:27 GMT, ogiven@vertex.ucls.uchicago.edu
wrote:

>i know a bit shift sequence to convert file perms from the stat format
>to octal (@modelist = (($mode&0700)>>6, ($mode&0070), ($mode&0007));),
>but i don't know how to do the opposite: convert a file perm from octal
>to the stat representation.........

I guess your line should look like:

@modelist = (($mode&0700)>>6, ($mode&0070)>>3, ($mode&0007));

to reverse it the line looks like:

$mode = ($modelist[0]<<6) | ($modelist[0]<<3) | ($modelist[0])

the '|' operator is bitwise OR. you can use + as well, but I prefer |
in bit operations like this.



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

Date: 24 Jul 2000 05:54:45 GMT
From: homer.simpson@springfield.nul (Homer Simpson)
Subject: Re: dos command in perl script
Message-Id: <8lgln5$blt$0@216.39.130.117>

In article <clre5.3855$Uo6.198664@bgtnsc07-news.ops.worldnet.att.net>, "suj_h" <suj_h@yahoo.com> wrote:
>Could someone show me how I can run a command like "dir /on /a-d /b
>*.txt > list" from within a perl script? This is nt4 perl.
>Thanks
>
>
qx works for me to run commands...
On NT you might need to use cmd.exe /? to find out the parameters for dir 
(which is internal to cmd.exe)


I use the following to run NT's ping.exe command, send one packet (-n1) on 
a server. 


@PING=qx(ping -n 1 $SERVER_NAME) or die "\n\nFailed to run PING.EXE" ;


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

Date: Mon, 24 Jul 2000 04:23:27 GMT
From: Hon-Chi Ng <honchi_ng@my-deja.com>
Subject: Empty PerlTOC.ps generated by perl-5.6.0/pod/roffitall
Message-Id: <8lggbt$u8d$1@nnrp1.deja.com>

Hi

After I ran perl-5.6.0/pod/roffitall, the PerlDoc.ps came out fine, but
the PerlTOC.ps is empty except the title "Perl Table of Contents" on the
top.

  perl-5.6.0/pod % ./roffitall -groff
  roffitall: running groff -man -rC1 -rD1 -rF1 >./PerlDoc.ps
2>./PerlTOC.ps.raw
  roffitall: parsing TOC
  roffitall: running groff -man ./PerlTOC.tmp.man >./PerlTOC.ps
  roffitall: running groff -man -rC1 -rD1 >./PerlDoc.ps
2>./PerlTOC.ps.raw
  roffitall: leaving you with ./PerlDoc.ps and ./PerlTOC.ps

BTW, I'm using groff 1.16 and I'm sure it works fine.

Then, I commented out the "rm -f $tmp/PerlTOC.tmp.man
$tmp/PerlTOC.$ext.raw" line in perl-5.6.0/pod/roffitall, and re-run it
again.  Here are the contents in both intermediate/temporary files.

  % cat PerlTOC.tmp.man
  .de NP
  '.sp 0.8i
  .tl ''- % -''
  'bp
  'sp 0.5i
  .tl ''\fB\s+2Perl Table of Contents\s0\fR''
  'sp 0.3i
  ..
  .wh -1i NP
  .af % i
  .sp 0.5i
  .tl ''\fB\s+5Perl Table of Contents\s0\fR''
  .sp 0.5i
  .nf
  .na

  % cat /tmp/honching/PerlTOC.ps.raw
  /local/perl_5.6.0/man/man3/IPC::Msg.3:179: missing closing delimiter
  /local/perl_5.6.0/man/man3/IPC::Semaphore.3:185: missing closing
delimiter

It looks like some syntax errors in both "man/man3/IPC::Msg.3" and
"man/man3/IPC::Semaphore.3".  But, when I checked PerlDoc.ps, both pages
were fine (on page 1332 and 1336 respectively).

Could it be some bugs in the pod version of both files, or pod2man
itself?  If so, how can I fix it?

Thanks.  Any help is appreciated.

Regards
Hon-Chi


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


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

Date: Mon, 24 Jul 2000 09:03:42 GMT
From: "Daniel van den Oord" <danielxx@bart.nl>
Subject: file extension
Message-Id: <ODTe5.1858$Gd1.22529@Typhoon.bART.nl>

I made a simpel script to view a directory list with an index and security
so it can't get out of that directory !!
http://195.38.226.149/cgi-bin/filer.pl
though I want to know how I can read the extension or chop the rest of and
put it seperately !! I'm now using a way that if it isn't a directory it's a
mp3 (But this is not always the case I tried to chop of everything before a
' . ' but the error then is that some files are haveing a ' . ' in their
title !!!.. Is there a way to do this ??
The file content below:
----------------------------------------------------------------------------
----------

use CGI qw(:standard);
use strict;

my $direct = param("direct");
my
($dir,@entries,$entry3,@entries2,$description,$link,$namefile,$entry,$time,$
size);
my $number = 0;
my $number2 = 0;
my $gluedir = "d:/mp3/$direct";

opendir DH, $gluedir || die "Can't open: $!";
 my @entries = readdir DH;
closedir DH;

opendir DH, "d:/mp3" || die "Can't open: $!";
 my @entries2 = readdir DH;
closedir DH;

($dir) = split(/\//,$direct);
if ($dir eq "..") {$gluedir="d:/mp3";$direct="";}
if ($direct eq $dir) { $dir="";}

print "Content-type: text/html\n\n";
print "<html><head><title>MP3 Directory Filer</title></head><body><div
align='center'><center><table border='0' width='100%' cellspacing='0'
cellpadding='0'><tr><td width='100%'><p align='center'>";

foreach my $entry2 (map "d:/mp3/$_",
tries2){ 
 $entry3 = $entries2[$number2++];
 if ($entry3 eq ".") {}
 elsif ($entry3 eq "..") {}
 elsif ($entry3 eq "filer.pl") {}
 else {print "<a href='http://195.38.226.149/cgi-bin/filer.pl?direct=$entry3'>$entry3</a>-";}
}
print "</p><tr><td width='100%'><table border='1' width='100%' cellspacing='0' cellpadding='0' bordercolor='#000000'><tr> <td bgcolor='#0000FF' align='center'><font color='#FFFFFF'><b>Filename</b></font></td><td bgcolor='#0000FF' align='center'><font color='#FFFFFF'><b>Size</b></font></td><td bgcolor='#0000FF' align='center'><font color='#FFFFFF'><b>Date</b></font></td><td bgcolor='#0000F
F' align='center'><font
color='#FFFFFF'><b>Description</b></font></td></tr>";

foreach my $entry (map "$gluedir/$_",
tries){ 
 lstat $entry;
 my $time = scalar localtime((stat(_))[9]);
 if ($time =~ /^(\w+) (\w+)\s+(\d+) (\d+:\d+):\d+ (\d+)$/) {
        if ($3 < 10)  { $_ = "0" }
        else   { $_ = ""; }
        $time = "$_$3-$2-$5 $4";
 }
 $namefile = $entries[$number++];
 my $size = -s _;
 if ( -d $entry ) {
  $link = "<a href='http://195.38.226.149/cgi-bin/filer.pl?direct=$direct/$namefile'>";
      if ($namefile eq ".")  {
   $link ="<a href='http://195.38.226.149/cgi-bin/filer.pl?direct=$direct'>";
  }
  if ($namefile eq "..")  {
   $link ="<a href='http://195.38.226.149/cgi-bin/filer.pl?direct=$dir'>";
      }
   print <<HTML;
   <tr><td>$link<font color="red">$namefile</td><td>-</td><td>$time</td><td>directory</td></tr>
HTML
 }
 elsif ($namefile eq "filer.pl") {}
 else { 
     print <<HTML;
 <tr><td><a href="http://195.38.226.149/mp3/$direct/$namefile"><font color="blue">$namefile</td><td>$size</td><td>$time</td><td>mp3</td></tr>
HTML
 }
}
print "</table></td></tr></table></center></div>";





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

Date: 24 Jul 2000 09:16:39 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: How to delete a record in a text data file?
Message-Id: <slrn8no2bm.rfl.vek@pharmnl.ohout.pharmapartners.nl>

On Fri, 21 Jul 2000 19:28:03 +0200,
          Alan J. Flavell <flavell@mail.cern.ch> wrote:

>
>Who told you that the dataset was small enough to read it all into
>memory?  I'll give you a 1.8GByte dataset to try it out on, OK?
>
>


Did you grow up with IBM mainframes where files are called datasets? ;-)



Villy



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

Date: Mon, 24 Jul 2000 06:44:45 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to loop like this - for(a000 ... x999) ???
Message-Id: <snnpetgjjjt41@corp.supernews.com>

Thoren Johne (thoren@southern-division.com) wrote:
: rhys <rhys.tucker@dtn.ntl.com> wrote in message
: news:397AE1F5.B7F65F63@dtn.ntl.com...
: > I'm trying to produce numbers in this sort of format [a-z]\d{3}. I've
: > tried all sorts of notation to achieve this, even printf, without
: > success as yet. There must be a straightforward way to do it.
: 
: for my $char ( 'a'..'z' ) {
:     printf "%s%03u\n", $char, $_ for 0..999;
: }

For goodness' sake, has everyone forgotten autoincrement magic???

  for (my $key = 'a000'; $key le 'b999'; $key++) {
    print "$key\n";
  }

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Turning and turning in the widening gyre
   |   The falcon cannot hear the falconer." - Yeats, "The Second Coming"


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

Date: Mon, 24 Jul 2000 09:18:16 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: How to loop like this - for(a000 ... x999) ???
Message-Id: <8lgqkc$ik5$15$1@news.t-online.com>

Craig Berry <cberry@cinenet.net> wrote in message
news:snnpetgjjjt41@corp.supernews.com...
> Thoren Johne (thoren@southern-division.com) wrote:
> : rhys <rhys.tucker@dtn.ntl.com> wrote in message
> : news:397AE1F5.B7F65F63@dtn.ntl.com...
> : > I'm trying to produce numbers in this sort of format [a-z]\d{3}. I've
> : > tried all sorts of notation to achieve this, even printf, without
> : > success as yet. There must be a straightforward way to do it.
> :
> : for my $char ( 'a'..'z' ) {
> :     printf "%s%03u\n", $char, $_ for 0..999;
> : }
>
> For goodness' sake, has everyone forgotten autoincrement magic???

uhm... no, but i`d like to show how to deal that with printf ;)

>   for (my $key = 'a000'; $key le 'b999'; $key++) {
>     print "$key\n";
>   }

personaly, i would prefer

print "$_\n" for 'a000'..'z999'

gruß
thoren
8#X

--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com




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

Date: 24 Jul 2000 00:30:48 EDT
From: abigail@foad.org (Abigail)
Subject: Re: login help
Message-Id: <slrn8nnhjk.vcg.abigail@alexandra.foad.org>

han (lihock@pc.jaring.my) wrote on MMDXIX September MCMXCIII in
<URL:news:8lga9m$q7f$1@news6.jaring.my>:
<> Hi everyone...
<> i have a problem in doing the login form
<> what i need to do is
<> first i have a login screen
<> then after i enter the correct username and password...
<> my authorisation become true......
<> if my authorisation become true then i can access to the restricted pages..
<> but now i cant pass the variable(authorisation) to every page so that the
<> restricted pages that visited can indicated that my authorissation is true..
<> it is something like Session in asp but since i'm very new and fresh in cgi
<> and perl
<> so i dont know how to code them
<> so anyone out there can help me or giving me some code to refer?


You don't have a Perl problem.

Goodbye.



Abigail
-- 
New email address: abigail@foad.org


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

Date: Mon, 24 Jul 2000 07:14:00 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: login help
Message-Id: <slrn8nnr4g.8gj.efflandt@efflandt.xnet.com>

On Mon, 24 Jul 2000 10:39:25 +0800, han <lihock@pc.jaring.my> wrote:
>Hi everyone...
>i have a problem in doing the login form...

This is not Perl specific.  CGI methods are not that secure and require
either all CGI generated forms with hidden fields or cookies using some
sort of handler on the server.

Your best bet is to read the docs about authentication using your
webserver.  For apache you would go to http://www.apache.org/ and lookup
the 'require' directive and related links there.  Then if you have any
questions, look for a newsgroup about your webserver (#.www.servers.unix
or *.iis).

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Mon, 24 Jul 2000 06:22:33 GMT
From: yaacovs@my-deja.com
Subject: Re: LWP UserAgent
Message-Id: <8lgnb8$2r7$1@nnrp1.deja.com>

In article <8lf38v$4cjhm$1@ID-10059.news.cis.dfn.de>,
  decklin+usenet@red-bean.com (Decklin Foster) wrote:
> yaacovs@my-deja.com <yaacovs@my-deja.com> writes:
>
> > All I get is the main frame, without the wanted page.
>
> So request the page you want, instead of the page containing the
> frameset.
>
> --
> There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
> are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)
>

Thank you.

The problem is that I am using a tool which runs through a list of
URL's from our DB and it has to follow the redirections and search for
a certain text on the page.  When using a browser which supports
frames, I have no problems =(


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


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

Date: Mon, 24 Jul 2000 10:56:35 +0100
From: "Daniel Foster" <daniel@blackomega.com>
Subject: Need questions for Perl quiz
Message-Id: <8lh3si$fa2$1@news6.svr.pol.co.uk>

I'm compiling a quiz on Perl to test people's knowledge.  The
questions need to be multiple choice, with 4 or 5 answers, like this
one...

If an anonymous subroutine is created with "$coderef = sub {print
"Hello world\n";};" then how should it be called?
1. &coderef;
2. $coderef->call;
3. &{$coderef};
4. anoncall($coderef);

The other answers are clearly made up, with only one correct answer
(even though there are clearly multiple ways of doing anything).

If you could take a moment to write just one or two questions I'd be
most grateful.

---
<car>::=b<rev>m
<rev>::=r|r<rev>

Daniel Foster - daniel@blackomega.com







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

Date: Mon, 24 Jul 2000 05:13:42 GMT
From: "The Unknown" <unknown-one@home.com>
Subject: Newbie "Learning Perl"  help
Message-Id: <agQe5.48936$fR2.447019@news1.rdc1.mi.home.com>

Am using ActivePerl 5.22 and Windows 98 SE.

I must be missing something because I don't understand why this:

print "Type strings here:\n";
@a = <STDIN>;     # here I just typed "one two three"
print @a;                 # I also remembered to use
                               # CTRL-Z to indicate the eof

gives this:

two
three

instead of this:

one
two
three

If I hit enter before typing "one", then the program will
print "one two three" on different lines like it is supposed to.
Is it not reading "one" as part of the array?  And if not, why?
Am I missing something about the chomp function?
This is out of O'Reilly's "Learning Perl" chpt. 3, exercise1,
without the reverse function.

TIA




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

Date: 24 Jul 2000 09:27:52 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: password unix with crypt
Message-Id: <slrn8no30o.rfl.vek@pharmnl.ohout.pharmapartners.nl>

On Fri, 21 Jul 2000 16:28:51 -0500, Dale Bohl <dbohl@sgi.com> wrote:
>melet@my-deja.com wrote:
>> 
>> hello,
>> 
>> How retrieve the unix password with the function crypt.
>> I know thaat you lust find the encrypted password in shadow
>> or /password and apply crypt with the password not encrypted.
>> 
>> But, i am not ok!
>> 
>> thanks , fred
>> 
>> Sent via Deja.com http://www.deja.com/
>> Before you buy.
>
>Try this.
>
>
>#!/usr/bin/perl -w
>use strict;
>
>my $pwd = (getpwuid($<))[1];
>my $salt = substr($pwd, 0, 2);
>
>system "stty -echo";
>print "\nEnter Your Password: ";
>chop(my $word = <STDIN>);
>print "\n";
>system "stty echo";
>
>if (crypt($word, $salt) ne $pwd) {
>   die "Sorry...That is NOT your Password.\n";
>} else {
>   print "That IS your correct Password.\n";
>}
>



Also try this:

perldoc -f crypt


It is actualy not strictly necessary to extract the first two
characters to get the salt.  Specifying the password directly
as the salt paramter would do as well.  Other than that the 
example is almost identical to the example from the perldoc -f crypt
page.



Villy


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

Date: Mon, 24 Jul 2000 05:57:28 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl 5.*
Message-Id: <slrn8nnmm5.9on.tjla@thislove.dyndns.org>

I was shocked! How could Abigail <abigail@foad.org>
say such a terrible thing:
>Colin Keith (ckeith@clara.net) wrote on MMDXVIII September MCMXCIII in
><URL:news:mWEe5.11$DT4.1237384@nnrp2.clara.net>:
>&& In article <397afb96$0$6098@reader2>, "Roderik Hamers" <Dwarf3@casema.net> wrote:
>&& >Does someone know where a can download a Perl complitation program?
>&& 
>&& Er.. Do you mean a program to produce stand alone executables from perl 
>&& scripts, or a program that executes scripts?
>
>No, no, no. He surely means a program that given an incomplete program
>completes the program.

Nope. Merriam Webster and ispell both suggest "complication" as the
nearest match. What he wants is Godzilla!

>Doesn't Emacs have a keyboard macro for that?

God help us if it does.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
DELIBERATION

n. The act of examining one's bread to determine which side it is buttered
on.


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

Date: Mon, 24 Jul 2000 07:05:02 GMT
From: "Bitter" <info@kulturystyka.com.pl>
Subject: Perl and Microsoft Personal Web Server - help
Message-Id: <yURe5.37429$pD2.774232@news.tpnet.pl>

Is here somebody used Perl with Microsoft PWS ???
I need help :-(
please answer on priv:

mailto:info@kulturystyka.com.pl?subject=perl

Greetings Bitter




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

Date: Mon, 24 Jul 2000 08:21:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl v. tcl
Message-Id: <utunnsk0n4e0ec7k594sieqtj5vlb4ingc@4ax.com>

J.M. Ivler wrote:

>Then I was forced to learn Pascal and C and disliked both

>When I moved to *nix I
>learned shell, awk, etc and looked for a decent scripting language. I was
>offered Perl and Tcl. Of the two Perl is more C-like and Tcl is
>lisp-ish. Three guesses on what I chose. :-)

Gee... I, too, dislike Pascal and C a lot.

But yet, I love Perl.

Don't let Perl's superficial similarities with C fool you. Perl has none
of the features I hate about C.

-- 
	Bart.


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

Date: Mon, 24 Jul 2000 09:30:25 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: redirection fails
Message-Id: <slrn8no2sp.61h.bernard.el-hagin@gdndev25.lido-tech>

haggi@work <haggi@tappe.net> wrote:

>Hi,
>
>I'm trying to redirect a output in perl.
>
>system("ls -l > outputfile");
>
>I'm working with perl5.005 for cygwin. Windows NT.
>
>redirection in the shell works.

OK. Thanks for the info. Keep us posted.

Bernard
--
perl -le 'open(JustAnotherPerlHacker,"")or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: Mon, 24 Jul 2000 09:32:53 +0100
From: "Neil Lathwood" <laf@gameonline.co.uk>
Subject: replacing any character except for spaces...
Message-Id: <964427882.17285.0.nnrp-14.c246f129@news.demon.co.uk>

Hi Folks,

I am trying to do a search throughout a scalar variable that replaces every
occurrence of any character except spaces. Below is an example of what I
want to do:

$data = "1 2 3 4 5 6 7 8 9 0";

I then want to replace all characters except the spaces with a hyperlink
containing the replaced character I.e:

print "$data"; would print <a href=1>1</a> <a href=2>2</a> ,etc.....

many thanks in advance.

Neil




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

Date: Mon, 24 Jul 2000 09:43:35 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: replacing any character except for spaces...
Message-Id: <slrn8no3lf.61h.bernard.el-hagin@gdndev25.lido-tech>

On Mon, 24 Jul 2000 09:32:53 +0100, Neil Lathwood <laf@gameonline.co.uk>
wrote:
>Hi Folks,
>
>I am trying to do a search throughout a scalar variable that replaces every
>occurrence of any character except spaces. Below is an example of what I
>want to do:
>
>$data = "1 2 3 4 5 6 7 8 9 0";
>
>I then want to replace all characters except the spaces with a hyperlink
>containing the replaced character I.e:
>
>print "$data"; would print <a href=1>1</a> <a href=2>2</a> ,etc.....

Read...

perldoc perlre
perldoc perlop (specifically s/PATTERN/REPLACEMENT/egimosx)

 ...and try to come up with a solution. If you can't solve the problem
post your attempt and someone will certainly help you.

Bernard
--
perl -le 'open(JustAnotherPerlHacker,"")or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: 24 Jul 2000 05:40:14 EDT
From: abigail@foad.org (Abigail)
Subject: Re: replacing any character except for spaces...
Message-Id: <slrn8no3np.vcg.abigail@alexandra.foad.org>

Neil Lathwood (laf@gameonline.co.uk) wrote on MMDXIX September MCMXCIII
in <URL:news:964427882.17285.0.nnrp-14.c246f129@news.demon.co.uk>:
'' Hi Folks,
'' 
'' I am trying to do a search throughout a scalar variable that replaces every
'' occurrence of any character except spaces. Below is an example of what I
'' want to do:
'' 
'' $data = "1 2 3 4 5 6 7 8 9 0";
'' 
'' I then want to replace all characters except the spaces with a hyperlink
'' containing the replaced character I.e:
'' 
'' print "$data"; would print <a href=1>1</a> <a href=2>2</a> ,etc.....


So.... what have you done so far?


Abigail
-- 
New email address: abigail@foad.org


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

Date: Mon, 24 Jul 2000 10:42:30 +0100
From: "Neil Lathwood" <laf@gameonline.co.uk>
Subject: Re: replacing any character except for spaces...
Message-Id: <964432057.20106.0.nnrp-14.c246f129@news.demon.co.uk>

> Read...
>
> perldoc perlre
> perldoc perlop (specifically s/PATTERN/REPLACEMENT/egimosx)
>
> ...and try to come up with a solution. If you can't solve the problem
> post your attempt and someone will certainly help you.
>
Ok thanks, the reason i didn't supply any code that i have tried is that it
really doesn't work so i know i am not even close to finding the answer. I
will give the perldoc a try.

Many thanks Bernard.

Neil




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

Date: Mon, 24 Jul 2000 09:44:02 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: replacing any character except for spaces...
Message-Id: <slrn8no4fu.55s.tim@degree.ath.cx>

On Mon, 24 Jul 2000 10:42:30 +0100, Neil Lathwood <laf@gameonline.co.uk> wrote:
>> Read...
>>
>> perldoc perlre
>> perldoc perlop (specifically s/PATTERN/REPLACEMENT/egimosx)
>>
>> ...and try to come up with a solution. If you can't solve the problem
>> post your attempt and someone will certainly help you.
>>
>Ok thanks, the reason i didn't supply any code that i have tried is that it
>really doesn't work so i know i am not even close to finding the answer. I
>will give the perldoc a try.

Posting your attempt DOES help us to understand what you're trying to do
better than most explanations, but it does two other things:

1) It allows us to see where you're going astray, so that we might lead
you back to the correct path rather than just handing the answer to you.

2) It proves you at least tried before you asked. =)

>
>Many thanks Bernard.
>
>Neil

-- 
-Tim Hammerquist <timmy@cpan.org>

Emacs is a nice OS - but it lacks a good text editor.
That's why I am using Vim.  --Anonymous


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

Date: Mon, 24 Jul 2000 08:03:43 GMT
From: kjeldahl@hotmail.com
Subject: Re: Setting $/ from variable - accepting meta characters
Message-Id: <8lgt8t$7il$1@nnrp1.deja.com>

In article <j2omns4l6mblceuh4d700ro21hmhptog9q@4ax.com>,
  Bart Lateur <bart.lateur@skynet.be> wrote:
> kjeldahl@hotmail.com wrote:
>
> >I have an input field, where I want to accept meta characters such as
\n
> >and \t, but also normal characters. If I type the "\n" string in my
> >input field, how can I assign the interpolated value of that string
to
> >$/?
>
> 	%replace =( 'n' => "\n", 't' => "\t", # ...
> 	);
> 	s/\\(.)/$replace{$1} || $1/ge;

Now see if you are able to come up with a hash that include all the
metacharacter that perl accepts (including \000, \x00 etc..)? ;-)

Anyway, thanks for the answers. It seems the eval stuff suggested gets
the job done without compromising security.

Marius


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


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

Date: Mon, 24 Jul 2000 09:09:35 +0200
From: "haggi@work" <haggi@tappe.net>
Subject: tutorials socket
Message-Id: <397BEBAF.5B567886@tappe.net>


Hi,

does anyone know a source for example scripts for a connection via sockets?
tutorials, books?

haggi 

-- 

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

	haggi
	www.haggi.de
	haggi@haggi.de

	haggi`s visual effects & animation

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


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

Date: Mon, 24 Jul 2000 08:32:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: tutorials socket
Message-Id: <0bvnns499hrcq4jvi82c351c2qc1f73if9@4ax.com>

haggi@work wrote:

>does anyone know a source for example scripts for a connection via sockets?
>tutorials, books?

I've searched for this, too. There ahrdly seems to be any (tutorial
style) documentation available.

There's the "BSD sockets: quick and dirty primer" at
<http://world.std.com/~jimf/papers/sockets/sockets.html>. There is the
socket chapter in Dave Marshall's C tutorial,
<http://www.cs.cf.ac.uk/Dave/C/node28.html>.

And a few useful general "Unix system programming" links pages:

	<http://www-users.cs.umn.edu/~bentlema/unix/>
	<http://www.cs.buffalo.edu/~milun/unix.programming.html>

-- 
	Bart.


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

Date: Mon, 24 Jul 2000 15:22:24 +0800
From: Tom <chaptera@hotmail.com>
Subject: When will use the flock?
Message-Id: <397BEEB0.3F379B4E@hotmail.com>

Dear all,

I saw a lot of example from the web <-- free of source code!
I find that most of the people will not using the flock when some
data necessary to write on the file.

Is it possible?

The application like a guestbook, forum. They didn't take care
with the file sharing? Is it safe?

I tried to write 2 small programs for writing data into the same file.
Then run it at the same time nearly.
The later submitted program will automatically waiting the other one.
The platform is UNIX!

Thanks

---
Tom




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

Date: Sun, 23 Jul 2000 21:31:54 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <397BC6BA.58618425@stomp.stomp.tokyo>

BUCK NAKED1 wrote:
 
> The codes below seem to work fine, but when I insert "use strict;" they
> quit working. Why? Also: do I have the flocking done correctly now? 

(snipped)

Instead of asking about your file lock problem, why not
research your 'use Fcntl' and subsequent syntax for file
locking.  There is a good chance you will learn quite a 
bit about your bug. A quick answer is ok. Learning is a 
very valuable experience.

Godzilla!

-- 
use LWP::Simple;
$g = get 
("http://3483852801/%7e%63%61ll%67i%72l/%76i%64%65%67%6f%64z%2e%68%74%6dl");
$g =~ s/(<([^>]+)>)|\n|GODZILLA|Blue Oyster Cult//g;
$g =~ s/([a-z])([A-Z])/$1\n$2/g; $g =~ s/(He )/S\l$1/g;
$g =~ s/H(e')/Sh$1/; print ${\substr ($g, 9, 429)}; exit;


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

Date: 24 Jul 2000 00:45:24 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <slrn8nnif0.vcg.abigail@alexandra.foad.org>

BUCK NAKED1 (dennis100@webtv.net) wrote on MMDXIX September MCMXCIII in
<URL:news:10658-397BB885-47@storefull-243.iap.bryant.webtv.net>:
%% The codes below seem to work fine, but when I insert "use strict;" they
%% quit working. Why?

Because you use unqualified package variables. Either use lexicals,
declare the variables with use vars; or use fully qualified names.

%%                    Also: do I have the flocking done correctly now?

No. You're using magic numbers. You already use Fcntl. It wouldn't
be to much to import the appropriate constants.

%%                    Also: do I have the flocking done correctly now? I
%% have studied all of your previous suggestions, the FAQs, and many other
%% sites extensively, and still do not understand. Please help me with any
%% errors(including lines out of order) that you see below. I'd be really
%% grateful.
%% 
%% #!/usr/local/bin/perl -w 
%% use Fcntl;
%% use diagnostics;
%% $LOCK_EX = "2";
%% $LOCK_UN = "8";
%% print "Content-type: text/html\n\n";
%% open(COUNT, "visits.dat") or die "Can't READ data file: $!"; 
%% flock(COUNT, $LOCK_EX) or die "Can't LOCK data file: $!";
%% $cnt = <COUNT>;
%% chomp $cnt;
%% $cnt++;
%% open(COUNT, ">visits.dat") or die "Can't 

This closes the file, which releases the lock. The reopened file isn't
locked, and even when you would lock it afterwards, the data in it is gone.

%% close COUNT;
%% flock(COUNT, $LOCK_UN);

Pointless. Closing a file unlocks it; but you've lost the lock long time ago.


The proper sequence is:

    - Open a file for read/write.
    - Lock the file.
    - Read the content.
    - Seek to beginning.
    - Write new content.
    - Truncate file.
    - Close file (which releases the lock).


Abigail
-- 
New email address: abigail@foad.org


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

Date: Mon, 24 Jul 2000 02:05:30 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <10657-397BEABA-107@storefull-243.iap.bryant.webtv.net>

>Instead of asking about your file
>lock problem, why not research 
>your 'use Fcntl' and subsequent 
>syntax for file locking. There is a 
>good chance you will learn quite a
>bit about your bug. A quick answer
>is ok. Learning is a very valuable >experience. 
>Godzilla! 

Perhaps you jest? I have done all of that. I am very familar with the
saying "it's better to teach someone how to fish..." FWIW, I am an older
person that's disabled. Nonetheless, I always try hard to figure
something out first before asking. In this case, it's been over 200
hours spent trying to get this right. A quick answer would really be a
nice gesture at this point. :+)

Regards, Dennis



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

Date: Mon, 24 Jul 2000 08:13:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <j6unnssp3f4r6168j30ouf1m0macm87f9u@4ax.com>

BUCK NAKED1 wrote:

>The codes below seem to work fine, but when I insert "use strict;" they
>quit working. Why?

Because you're using global variables that aren't declared.

I'm wondering why you insist on using "strict", since you seem to be
unaware of it's purpose.

Also, first using "Fcntl" and then ignoring it and using your own
defined constants is a bit... amazing.

You do need to import from "Fcntl" using the ":flock" parameter, though.

	use Fcntl ':flock';

Hmmm... that's all you need from Fcntl, isn't it? Because adding the
':flock' parameter to the import routine this way will stop the default
export from happening (O_CREAT etc.)

-- 
	Bart.


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

Date: Mon, 24 Jul 2000 01:25:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Why won't  "use strict;"  work?
Message-Id: <397BFD74.5D3F09FD@stomp.stomp.tokyo>

BUCK NAKED1 wrote:

> Godzilla wrote:
 
> >Instead of asking about your file
> >lock problem, why not research
> >your 'use Fcntl' and subsequent
> >syntax for file locking. There is a
> >good chance you will learn quite a
> >bit about your bug. A quick answer
> >is ok. Learning is a very valuable >experience.
> >Godzilla!
 
> Perhaps you jest? I have done all of that. I am very familar with the
> saying "it's better to teach someone how to fish..." FWIW, I am an older
> person that's disabled. Nonetheless, I always try hard to figure
> something out first before asking. In this case, it's been over 200
> hours spent trying to get this right. A quick answer would really be a
> nice gesture at this point. :+)


I am not jesting. If you want something, roll up
your sleeves, get to work and earn what you want.
If you expect Life to be served on a Silver Platter,
go out and get a life. It doesn't work this way Buster.

Unless you are mentally disabled, you have the same
capacity to research as any average person. I know
this from direct experience teaching both physically
handicapped and mentally handicapped children over
my many years as a teacher. A physical disability
doesn't wash with me when it comes to intelligence.

If you have researched Fcntl appropriately, you would
not be here asking this question. Disabled or not,
you are mucking around in mule manure; being deceitful.

Godzilla!

-- 
@© = (a .. z); @® = qw (7 15 4 26 9 12 12 1 18 15 3 11 19);
srand(time() ^ ($$ + ($$ << 15))); 
sub G { rand(1000) < 500 ? "\u$1" : "\l$1" ; }
foreach $¿ (@®) { $¢ = $©[$¿-1]; $¢ =~  s/([a-z])/G($1)/gie;
if ($¢ =~ /($©[0])/i) { $¢ = "$¢ "; } print $¢; }
print "!"; exit;


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

Date: Mon, 24 Jul 2000 09:03:32 GMT
From: "Colin Larcombe" <colin_larcombe@hotmail.com>
Subject: Re: Writing to a file error : Pt 2
Message-Id: <EDTe5.34085$aS.265733@telenews.teleline.es>

Embarrassment,

I had misspelt my home path. Should have been clarcombe

D'oh
Colin Keith <ckeith@clara.net> wrote in message
news:ICEe5.10$DT4.1235076@nnrp2.clara.net...
> In article <dMne5.30242$aS.233901@telenews.teleline.es>, "Colin Larcombe"
<colin_larcombe@hotmail.com> wrote:
> >Thanks for all your hints and tips. Have now got it working except for
> >
> >when I try to include  the path
> >
> >e.g.
> >#!/usr/local/bin/perl
> ># Put all the bonds into an array, except the first two lines
> >$filepath="/usr/users/larcombe/";
> >$isinname="moody_bnd_upd.txt\n";
> >$accept="acceptable.txt";
> >$notaccept="notaccept.txt";
> >
> >open(ACCEPT,">$filepath"."$accept") || die "Cannot open $filepath$accept
to
> >write to";
> >or
> >open(ACCEPT,">$filepath"+"$accept") || die "Cannot open $filepath$accept
to
>
> *blink* Urm, don't you need to use operator overloading to use a + to
> concatenate scalar values, not numerically add their values?
>
> >fail with the die
> Which of the *two* ? :p
>
> >open(ACCEPT,">$accept") || die "Cannot open $filepath$accept to write
to";
> >and writes a file in the /usr/users/larcombe directory.
>
> Presumably because that's where you're running it from? Writing to "file"
is
> perfectly acceptable and just writes to the current working directory.
That
> said it is bad practice and not one you should allow yourself to fall into
> the habit of using.
>
> >Any suggestions
> Which one dies? The second should because you're numerically adding
> non-numbers. You would find out more details if you ran the program with
> a) -w,
> b) use strict
> c) included the reason for failure in the die: die "can't open .. $!"
>
> perseus% perl -w -Mstrict
> my($a, $b) = ('xxx', 'ddd');
> print $a+$b;
>
> Argument "ddd" isn't numeric in add at - line 2.
> Argument "xxx" isn't numeric in add at - line 2.
> 0
>
> The first gives me no problems, but:
> open(ACCEPT, ">$filepath/$accept");  # drop the trailing / first though
> open(ACCEPT, (">$filepath". $accept));
>
> (though I've never encountered perl requiring precedence to be forced like
> this)
>
> >Colin L
>
>
> ---
> Colin Keith
> Systems Administrator
> Network Operations Team
> ClaraNET (UK) Ltd. NOC




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

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


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