[17855] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 15 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 8 11:05:50 2001

Date: Mon, 8 Jan 2001 08:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978969913-v10-i15@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 8 Jan 2001     Volume: 10 Number: 15

Today's topics:
    Re: [Q] matching many regular expressions [..] <ren.maddox@tivoli.com>
    Re: Advanced HTML/DHTML, Perl, JavaScript, VBScript, Fl <rwoodman@verio.net>
        CGI Form read? <wavetable@birdmail.com>
    Re: CGI Form read? <fty@mediapulse.com>
        Confusion on system call exit value and Perl manpage <brannon@lnc.usc.edu>
    Re: Confusion on system call exit value and Perl manpag (Garry Williams)
        Creating simple GIF pictures??? <meisl@amvt.tu-graz.ac.at>
    Re: Creating simple GIF pictures??? <simon.andrews@bbsrc.ac.uk>
    Re: Enumerating Processes? (Anno Siegel)
    Re: File I/O giving weird results nobull@mail.com
        File Locking - Need Help <paul_wasilkoff@ucg.org>
    Re: File Locking - Need Help (Garry Williams)
    Re: File Locking - Need Help (Richard Zilavec)
    Re: Going from unix to windows server sandywadkins123@my-deja.com
    Re: how to use a perl module outside /lib <jasonh_/dev/null_autonomy.com>
    Re: how to use a perl module outside /lib nobull@mail.com
        HTML stripper simonharris44@my-deja.com
    Re: HTML stripper <nomail@please.not>
    Re: HTML stripper <julien.quint@imag.fr>
    Re: HTML stripper <joe+usenet@sunstarsys.com>
        map and chr <a.v.a@home.nl>
    Re: map and chr (Garry Williams)
    Re: map and chr <julien.quint@imag.fr>
    Re: map and chr (Richard Zilavec)
    Re: map and chr <a.v.a@home.nl>
        Matching special characters in a regular expression <ssandel@nextra.com>
        New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 05 Jan 2001 08:56:43 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: [Q] matching many regular expressions [..]
Message-Id: <m3r92i3v4k.fsf@dhcp11-177.support.tivoli.com>

"Ian Trudel" <ian.trudel@tr.cgocable.ca> writes:

> Thanks for the pointer. I have read the perlre document on (?{ <code> }). It
> says PERL will evaluate any PERL expression, but beside affectation and some
> prints', I was unable to put condition within it. The document refers to
> (?(condition)yes-pattern|no-pattern), which could also be interesting. As if
> the condition is met, the yes pattern is the next pattern to evaluate. If it
> is not met, you can omit the no pattern (or make it fails?) and the whole
> expression will fail [since it won't match]. However, yet again, I was
> unable to write the proper code. Honestly, I'm a PERL newbie with good
> understanding of programming languages concepts. ::)
> 
> Can you provide me help on this?

It's kind of hairy, but this seems like it might be what you want:

/\b                                          # word boundary
 (\d{2})                                     # two-digits
 (?(?{ $1 <= 40 }) (?=) | (?!) )             # check value
 ,                                           # comma
 (\d{2})                                     # two-dits
 \b                                          # word boundary
 (?(?{ $2 > 40 && $2 <= 50 }) (?=) | (?!) )  # check value
/x;


I added the word boundaries to avoid the case where you match only
part of a longer number.

HTH!

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 08 Jan 2001 07:23:08 -0600
From: Randall Woodman <rwoodman@verio.net>
Subject: Re: Advanced HTML/DHTML, Perl, JavaScript, VBScript, Flash, ASP and XML  Books For Sale
Message-Id: <3A59BF3C.620ED657@verio.net>



David wrote:

> Advanced HTML/DHTML, Perl, JavaScript, VBScript, Flash, ASP and XML Books
> For Sale
> All books are Brand New.
>

Just in case you were confused, and it looks like you are, this is not ebay.



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

Date: Mon, 8 Jan 2001 15:14:27 +0200
From: "Wavetable" <wavetable@birdmail.com>
Subject: CGI Form read?
Message-Id: <93cea5$lol$1@news.kolumbus.fi>

If someone could just post an example of a script used with a form doing
nothing but printing out the contents of one text field I would be very
grateful =)




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

Date: Mon, 08 Jan 2001 14:55:34 GMT
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: CGI Form read?
Message-Id: <Dxk66.208593$DG3.5010445@news2.giganews.com>

"Wavetable" <wavetable@birdmail.com> wrote in message
news:93cea5$lol$1@news.kolumbus.fi...
> If someone could just post an example of a script used with a form doing
> nothing but printing out the contents of one text field I would be very
> grateful =)

http://stein.cshl.org/WWW/software/CGI/cgi_docs.html



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

Date: Mon, 08 Jan 2001 14:21:08 GMT
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Confusion on system call exit value and Perl manpage
Message-Id: <lbitnqunu3.fsf@lnc.usc.edu>


I looked at the manpage for system and have several questions:


               The return value is the exit status of the program
               as returned by the 'wait' call.  To get the actual
               exit value divide by 256.  See also the exec entry

** Is dividing something by 256 the same as right shifting it 8
positions? If so, could someone explain why pictorially preferred?

                   @args = ("command", "arg1", "arg2");
                   system(@args) == 0
                        or die "system @args failed: $?"

** Why didn't the author divide by 256 first?! The above paragraph
clearly said you have to divide by 256 to get exit status!! This is
frustrating! 


               You can check all the failure possibilities by
               inspecting '$?' like this:

                   $exit_value  = $? >> 8;

** if I do $retval = system('syscmd'); is it true that
   $retval == $?

                   $signal_num  = $? & 127;
                   $dumped_core = $? & 128;



-- 
Terrence Brannon
Carter's Compass...
    I know I'm on the right track when by deleting code I'm adding
    functionality.


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

Date: Mon, 08 Jan 2001 14:57:27 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Confusion on system call exit value and Perl manpage
Message-Id: <rzk66.3771$UQ5.18484@eagle.america.net>

On Mon, 08 Jan 2001 14:21:08 GMT, Terrence Brannon <brannon@lnc.usc.edu> wrote:
>
>I looked at the manpage for system and have several questions:
>
>               The return value is the exit status of the program
>               as returned by the 'wait' call.  To get the actual
>               exit value divide by 256.  See also the exec entry
>
>** Is dividing something by 256 the same as right shifting it 8
>positions? If so, could someone explain why pictorially preferred?

Not really.  But the exit status is placed in the byte (eight bits)
that remains after shifting right.  

>                   @args = ("command", "arg1", "arg2");
>                   system(@args) == 0
>                        or die "system @args failed: $?"
>
>** Why didn't the author divide by 256 first?! The above paragraph
>clearly said you have to divide by 256 to get exit status!! This is
>frustrating! 

The picture might be cleared up by examining the wait(2) manual page: 

        o  If the child process  terminated  due  to  an  _exit()
           call, the low order 8 bits of status will be 0 and the
           high order 8 bits will contain the low order 8 bits of
           the argument that the child process passed to _exit();
           see exit(2).

        o  If the child process terminated due to a  signal,  the
           high  order  8  bits  of  status will be 0 and the low
           order 8 bits will contain the  number  of  the  signal
           that caused the termination. 

So the author was only interested in whether or not the process exited
without *any* error.  From wait(2), the exit status will be non-zero,
if the process calls _exit() with a non-zero argument of if the
process was terminated on a signal.  The actual values will be in
separate bits in the exit status, but they will be non-zero, if
something bad happened.  

The author's error message will be hard to interpret because the case
where command calls _exit() with a non-zero value will print a number
that is 256 times the argument passed to _exit().  

>               You can check all the failure possibilities by
>               inspecting '$?' like this:
>
>                   $exit_value  = $? >> 8;
>
>** if I do $retval = system('syscmd'); is it true that
>   $retval == $?
>
>                   $signal_num  = $? & 127;
>                   $dumped_core = $? & 128;

Yup.  From perlvar: 

     $?      The status returned by the last pipe close, backtick
             (```') command, successful call to wait() or
-->          waitpid(), or from the system() operator.  This is
-->          just the 16-bit status word returned by the wait()
             system call (or else is made up to look like it).
             Thus, the exit value of the subprocess is really
             (`$? >> 8'), and `$? & 127' gives which signal, if
             any, the process died from, and `$? & 128' reports
             whether there was a core dump.  

-- 
Garry Williams


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

Date: 08 Jan 2001 14:29:02 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Creating simple GIF pictures???
Message-Id: <m33deurx41.fsf@famvtpc59.tu-graz.ac.at>

Hello everybody!

I want to create a very simple GIF picture with a perl application
(which does not use Tk). In the picture, there should be shown several
rectangles of a certain color (black), and a HUGE amount of single
dots of another color (red). The background of the GIF should be
white, the size should be 1280x1024.

I haven't found any appropriate module, so can anybody help me?

Best regards,
Christian

-- 
Christian Meisl <meisl@amvt.tu-graz.ac.at>        www.amft.tu-graz.ac.at
   Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
---------------- What color is a chameleon on a mirror? ----------------
PGP fingerprint:      DF48 2503 0411 F0EF 149C  851B 1EF0 72B9 78B6 034A


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

Date: Mon, 08 Jan 2001 15:02:09 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Creating simple GIF pictures???
Message-Id: <3A59D671.199A47A7@bbsrc.ac.uk>

Christian Meisl wrote:
> 
> Hello everybody!
> 
> I want to create a very simple GIF picture with a perl application
> (which does not use Tk). In the picture, there should be shown several
> rectangles of a certain color (black), and a HUGE amount of single
> dots of another color (red). The background of the GIF should be
> white, the size should be 1280x1024.
> 
> I haven't found any appropriate module, so can anybody help me?


Older versions of the GD module will allow you to do this.  Look for GD
v1.19, there are still many copies of this around.  The current version
creates PNGs, which may be an acceptable alternative.


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

Date: 8 Jan 2001 13:42:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Enumerating Processes?
Message-Id: <93cg4e$jqd$2@mamenchi.zrz.TU-Berlin.DE>

Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote in comp.lang.perl.misc:
>[fixed quoting]
>
>Here's one way to do it:
>
>1) Read the output of `ps aux` into an array:
>
>	my @ps = `ps aux`;
>
>2) Weed out the lines which have the username you want;
>
>	@ps = grep /username/, @ps;

What if "username" appears somewhere else in the ps output?  It's
probably best to let ps decide itself which processes belong to
a user.  How you do that depends on your flavor of the ps command.

>3) Split each remaining entry on whitespace and retrieve the second
>field (which will be the PID) and use it to kill the process:
>
>	foreach (@ps){
>		my $pid = (split/\s+/)[1];
>		`kill -9 $pid`;
>	}

Uh, kill -9 on the first try?  Not a good idea, if you don't know
what processes you're killing.  It's best to try a lesser caliber
first.

Anno



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

Date: 08 Jan 2001 11:35:32 +0000
From: nobull@mail.com
Subject: Re: File I/O giving weird results
Message-Id: <u9k88646pn.fsf@wcl-l.bham.ac.uk>

fenderstratocaster@my-deja.com writes:

> Subject: File I/O giving weird results

A better subject would be "input from output-only filehandle giving
weird results" :-)

Yes I agree the results are weird, reading from an append-only
filehandle should fail - not return garbage.

After appending to the file you should close it and re-open it for
input.  You _can_ also open the file for read/append but this is
messy.  You can also open a file for read/write which is less messy.

I suggest open the file read/write, read the file into an array.  Add
the new element to the array then truncate() the file to empty and
write the contents out again.

Note there are also some other problems with your code:

You say you want the line to be delimited by ', ' but you do:

print FREECELL "@array";

By default this uses space a the delimiter. You need to explicitly use
join() or set:

 $" = ', '; 


-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 8 Jan 2001 09:54:42 -0500
From: "Paul Wasilkoff" <paul_wasilkoff@ucg.org>
Subject: File Locking - Need Help
Message-Id: <t5jl8t8eucla97@corp.supernews.com>

I am trying to add file locking to a script but am unsure of the syntax and
convention needed.

The script will be running on apache.  Its purpose is to prevent
simultaneous write attempts to a data file.

I am a newbie, so please use small words! :-)

PAW




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

Date: Mon, 08 Jan 2001 15:03:44 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: File Locking - Need Help
Message-Id: <kFk66.3772$UQ5.18484@eagle.america.net>

On Mon, 8 Jan 2001 09:54:42 -0500, Paul Wasilkoff
<paul_wasilkoff@ucg.org> wrote:

>I am trying to add file locking to a script but am unsure of the
>syntax and convention needed.
>
>The script will be running on apache.  Its purpose is to prevent
>simultaneous write attempts to a data file.
>
>I am a newbie, so please use small words! :-)

Are these small enough?  :-)  

  perlopentut, "File Locking"
  perlfaq5,    "How can I lock a file?"

The words on the left refer to the manual pages that are installed on
your computer.  The others you've probably seen before.  

-- 
Garry Williams


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

Date: Mon, 08 Jan 2001 15:12:28 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: File Locking - Need Help
Message-Id: <3a59d59c.2278099@news.tcn.net>

On Mon, 8 Jan 2001 09:54:42 -0500, "Paul Wasilkoff"
<paul_wasilkoff@ucg.org> wrote:

>I am trying to add file locking to a script but am unsure of the syntax and
>convention needed.

perldoc -f flock

>The script will be running on apache.  Its purpose is to prevent
>simultaneous write attempts to a data file.

open(FH, ">> file.txt") || die "file.txt: $!";
flock(FH, 2);
# the file is locked

perldoc -f seek

>I am a newbie, so please use small words! :-)


--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Mon, 08 Jan 2001 14:09:14 GMT
From: sandywadkins123@my-deja.com
Subject: Re: Going from unix to windows server
Message-Id: <93chm6$hhm$1@nnrp1.deja.com>

All I know is the new server is Windows 2000, perl v5. They just
install perl on it for me (ISP), and this is there 1st experiance with
perl (new small company).

I noticed in my FTP that my domain =
c:\web  sites\domain.com, is it looking at c:\web and doesn't like the
space? Don't know where the c:\web message is coming from.

The site I'm creating (my first) is on my (ISP)server which is unix, is
this going to be a problem going to a windows 2000 server?  All I want
to do is move it from unix  to windows.

any help would be appreciated.
thanks sandy















In article <2ea66.52$Z4.36076@nntp3.onemain.com>,
  "Dennis Wilson" <lincwils@teleport.com> wrote:
> There isn't a shebang line for Windows NT, and I don't know from your
post
> which webserver you are using. From my experience Apache will find the
> relevant perl interpreter using the shebang.
>
> If you are using Activestate perl, it has registered some extensions.
You
> would find these be plumming the registry. What I have done in the
past is
> add these to the CMDEXT system variable under NT to get it to
recognize perl
> for scripting. The most relevant for you may be the .pls. This is
Perlscript
> and may be recognized by IIS( if that is your web server) to load and
> interprete web pages.
>
> Hope this helps and good luck. I won't say welcome to the world of
windows
> because I would not wish that on you.
>
> sandywadkins123@my-deja.com wrote in message
> <9376vn$ivn$1@nnrp1.deja.com>...
> >Help...
> >what should I use instead of shebang line???
> >here's error message I keep getting..
> >Is it me or server config, I don't have any path saying c:\web
> >
> >thanks sandy
> >
> >CGI Error
> >The specified CGI application misbehaved by not returning a complete
> >set of HTTP headers. The headers it did return are:
> >
> >
> >Can't open perl script "C:\web": No such file or directory
> >
> >
> >Sent via Deja.com
> >http://www.deja.com/
>
>


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


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

Date: Mon, 8 Jan 2001 10:58:45 -0000
From: "Jason Holland" <jasonh_/dev/null_autonomy.com>
Subject: Re: how to use a perl module outside /lib
Message-Id: <3a599f2c_2@nnrp1.news.uk.psi.net>

man perlrun

use the -I switch to specify the additional lib directory to search

Jason

<marjou@my-deja.com> wrote in message news:93c3hq$75c$1@nnrp1.deja.com...
> Hello,
>
> I would like to use a perl module (foo.pm) that is not located into the
> directory ~perl/lib/ . Is it possible ? If yes what is the syntax of
> the directive line "use ..." (or "require ...") to be able to use it in
> my perl files ?
>
> Thanks,
> Xavier Marjou
>
>
> Sent via Deja.com
> http://www.deja.com/




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

Date: 08 Jan 2001 11:09:11 +0000
From: nobull@mail.com
Subject: Re: how to use a perl module outside /lib
Message-Id: <u9n1d247xk.fsf@wcl-l.bham.ac.uk>

marjou@my-deja.com writes:

> I would like to use a perl module (foo.pm) that is not located into the
> directory ~perl/lib/ . Is it possible ?

I would like people to realise that they should read the FAQ _before_ they post.  
Is it possible?

FAQ: "How do I keep my own module/library directory?"

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 08 Jan 2001 11:18:45 GMT
From: simonharris44@my-deja.com
Subject: HTML stripper
Message-Id: <93c7mi$a2d$1@nnrp1.deja.com>

Could somebody point me in the direction of a regexp or script to strip
HTML tags from form submissions (you guessed it - its for a message
board)

cheers,
Simon


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


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

Date: Mon, 08 Jan 2001 13:31:10 GMT
From: "Olav" <nomail@please.not>
Subject: Re: HTML stripper
Message-Id: <yij66.8304$k03.479858@news01.chello.no>

<simonharris44@my-deja.com> wrote in message
news:93c7mi$a2d$1@nnrp1.deja.com...
> Could somebody point me in the direction of a regexp or script to strip
> HTML tags from form submissions (you guessed it - its for a message
> board)
>

$string =~ s/<[^>]*>//g;

Olav

> cheers,
> Simon
>
>
> Sent via Deja.com
> http://www.deja.com/






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

Date: 08 Jan 2001 15:13:08 +0100
From: Julien Quint <julien.quint@imag.fr>
Subject: Re: HTML stripper
Message-Id: <khv8zomf7yj.fsf@imag.fr>

simonharris44@my-deja.com writes:

> Could somebody point me in the direction of a regexp or script to strip
> HTML tags from form submissions (you guessed it - its for a message
> board)

This is a FAQ found in perlfaq9 (perldoc perlfaq9):

     How do I remove HTML from a string?

     The most correct way (albeit not the fastest) is to use
     HTML::Parser from CPAN.  Another mostly correct way is to
     use HTML::FormatText which not only removes HTML but also
     attempts to do a little simple formatting of the resulting
     plain text. (...)

-- 
Julien


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

Date: 08 Jan 2001 09:19:55 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: HTML stripper
Message-Id: <m38zom15ys.fsf@mumonkan.sunstarsys.com>

"Olav" <nomail@please.not> writes:

> <simonharris44@my-deja.com> wrote in message
> news:93c7mi$a2d$1@nnrp1.deja.com...
> > Could somebody point me in the direction of a regexp or 
> > script to strip HTML tags from form submissions (you 
> > guessed it - its for a message board)

It's a FAQ, and you guessed wrong by asking here w/o
checking the FAQ's first.
 
> $string =~ s/<[^>]*>//g;

<!-- That thing don't work!
--><a href="#bzzt" onClick="
javascript:alert('1>2- D?OH');">
da'Nast-E boYZ><img src="prOn" 
name="A > B" /></a
>

  Subject: Re: HTML stripper
               ^^^^ ^^^^^

% perldoc -q strip  (almost)
% perldoc -q HTML  (got it!)

Looking for the answer yourself would have given
you what you wanted, but surely neither of the 
above was tried. How impolite; the signal-noise 
ratio of this thread reflects the rudeness of 
the original question.

-- 
Joe Schaefer


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

Date: Mon, 08 Jan 2001 14:19:41 GMT
From: AvA <a.v.a@home.nl>
Subject: map and chr
Message-Id: <3A59CE04.FD51F8EA@home.nl>

im trying to get a random character in the 0-9a-Z range.
there is way i have that working (with a subroutine) but i wanted to
shorten the code.

i create an array that holds the characters, but when i try rand() on
that array in gives me just odd numbers.
i didnt use strict in this code (for those who dont like that).

#!/usr/bin/perl

@array = (48..57, 97..122);

@chars = map {chr($_)} @array;

print @chars . "\n";         #to see if they are in there (yes)
print rand(@chars) . "/n";         #that doesnt do as i intended i.e.
0-9a-Z range

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

what am i missing?



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

Date: Mon, 08 Jan 2001 15:12:36 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: map and chr
Message-Id: <ENk66.3773$UQ5.18484@eagle.america.net>

On Mon, 08 Jan 2001 14:19:41 GMT, AvA <a.v.a@home.nl> wrote:

>im trying to get a random character in the 0-9a-Z range.  there is
>way i have that working (with a subroutine) but i wanted to shorten
>the code.
>
>i create an array that holds the characters, but when i try rand() on
>that array in gives me just odd numbers.  i didnt use strict in this
>code (for those who dont like that).

That's a good way to *not* get answers to questions here.  

>#!/usr/bin/perl
>
>@array = (48..57, 97..122);
>
>@chars = map {chr($_)} @array;
>
>print @chars . "\n";         #to see if they are in there (yes)
>print rand(@chars) . "/n";   #that doesnt do as i intended i.e.
>
>what am i missing?

Two things: 

1.  The rand section of the perlfunc manual page: 

    Returns a random fractional number greater than or equal to `0'
    and less than the value of EXPR. (EXPR should be positive.) If 
    EXPR is omitted, the value `1' is used. 

The expression 

    rand(@chars)

evaluates to 

    rand($#chars + 1)

so all you have done is printed a random number between zero and
$#chars.  

2.  You are also missing the perlfaq4 section entitled "How do I
    select a random element from an array?".  

That FAQ answer shows precisely how to do what you want to do.  

-- 
Garry Williams


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

Date: 08 Jan 2001 16:28:30 +0100
From: Julien Quint <julien.quint@imag.fr>
Subject: Re: map and chr
Message-Id: <khvzoh2dpwh.fsf@imag.fr>

AvA <a.v.a@home.nl> writes:

> #!/usr/bin/perl
> 
> @array = (48..57, 97..122);
> 
> @chars = map {chr($_)} @array;
> 
> print @chars . "\n";         #to see if they are in there (yes)
> print rand(@chars) . "/n";         #that doesnt do as i intended i.e.

> what am i missing?

Well, what you print is a number in the range [0..@chars[ (in this case, an
integer >= 0 and < 36). What you want is the character at that position in
the array of characters, i.e. chars[rand @chars].

BTW, you could write

	@chars = ('0'..'9', 'a'..'z');

which is shorter and clearer.

-- 
Julien


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

Date: Mon, 08 Jan 2001 15:33:02 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: map and chr
Message-Id: <3a5adc6a.4020329@news.tcn.net>

On Mon, 08 Jan 2001 14:19:41 GMT, AvA <a.v.a@home.nl> wrote:


>i didnt use strict in this code (for those who dont like that).

Why not?

>
>#!/usr/bin/perl
>
>@array = (48..57, 97..122);
>
>@chars = map {chr($_)} @array;

Why not:
@array = (0..9,'a'..'z','A'..'Z');

Then you don't have to figure out what 48,49, etc.. is.

perdoc -f srand
perldoc -f rand

>print @chars . "\n";         #to see if they are in there (yes)
>print rand(@chars) . "/n";         #that doesnt do as i intended i.e.

print $array[rand(@array = (0..9,'a'..'z','A'..'Z'))];

--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Mon, 08 Jan 2001 15:47:49 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: map and chr
Message-Id: <3A59E2AB.7257C131@home.nl>


--------------9A253BB92573DD11AE20C8AE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Richard Zilavec wrote:

> On Mon, 08 Jan 2001 14:19:41 GMT, AvA <a.v.a@home.nl> wrote:
>
> print $array[rand(@array = (0..9,'a'..'z','A'..'Z'))];
>
> --
>  Richard Zilavec
>  rzilavec@tcn.net

That works perfectly Richard, thanks for that and the others aswell.
Now the hard part is to find the logic in it.
I read the perlfunc and faq, but i couldnt make from it what you just
described.

--
AvA
irc.chatjunkies.org #perl



--------------9A253BB92573DD11AE20C8AE
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Richard Zilavec wrote:
<blockquote TYPE=CITE>On Mon, 08 Jan 2001 14:19:41 GMT, AvA &lt;a.v.a@home.nl>
wrote:
<p>print $array[rand(@array = (0..9,'a'..'z','A'..'Z'))];
<p>--
<br>&nbsp;Richard Zilavec
<br>&nbsp;rzilavec@tcn.net</blockquote>
That works perfectly Richard, thanks for that and the others aswell.
<br>Now the hard part is to find the logic in it.
<br>I read the perlfunc and faq, but i couldnt make from it what you just
described.
<pre>--&nbsp;
AvA
irc.chatjunkies.org #perl</pre>
&nbsp;</html>

--------------9A253BB92573DD11AE20C8AE--



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

Date: Mon, 8 Jan 2001 17:01:09 +0100
From: "Simen Sandelien" <ssandel@nextra.com>
Subject: Matching special characters in a regular expression
Message-Id: <Uwl66.13742$v46.400033@news1.oke.nextra.no>

I want to write a regular expression that performs a validity check on my
input string $message

It's a requirement that $message must be made up of the letters assigned to
the $legalChar variable below....

my $legalChar = 'abcdefghijklmnopqrstuvwxyzæøå';
#ordinary letters
$legalChar .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ';  #capital letters
$legalChar .= '0123456789';
#digits
$legalChar .= '-/,<=>&#%"!:;@£¥¤§¿';
#Special characters
$legalChar .= 'ßäÉÄöÖñÑ éèùìòÇ_üÜà';
#Special characters
$legalChar .= '\'\+\*\(\)\$\?\.';
# Escaped Special characters

I've tried to do a test with matching against the following regexp, but...
of course :-)  - it doesn't work.

if (!($message =~ m/^[$legalChar]$/ )) {
    # Take measures to get input corrected
}

I'm pretty sure I'm treating (some of) the special characters the wrong way,
but I have no idea what to do...

please help me!

sincerely,
Simen




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

Date: Mon, 08 Jan 2001 15:01:43 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <t5jlinn7ts5o5d@corp.supernews.com>

Following is a summary of articles from new posters spanning a 7 day
period, beginning at 01 Jan 2001 15:05:38 GMT and ending at
08 Jan 2001 13:23:08 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 2001 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Totals
======

Posters:  165 (43.2% of all posters)
Articles: 292 (26.9% of all articles)
Volume generated: 527.8 kb (25.5% of total volume)
    - headers:    233.6 kb (4,650 lines)
    - bodies:     286.0 kb (9,699 lines)
    - original:   188.9 kb (6,835 lines)
    - signatures: 7.9 kb (187 lines)

Original Content Rating: 0.660

Averages
========

Posts per poster: 1.8
    median: 1 post
    mode:   1 post - 110 posters
    s:      1.7 posts
Message size: 1851.0 bytes
    - header:     819.1 bytes (15.9 lines)
    - body:       1003.1 bytes (33.2 lines)
    - original:   662.3 bytes (23.4 lines)
    - signature:  27.7 bytes (0.6 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   14    22.6 ( 10.3/ 11.5/  5.7)  Rocky Raccoon <rrocky@bigfoot.com>
    8    12.5 (  5.6/  6.9/  4.8)  ben-fuzzybear@geocities.com
    8    13.9 (  5.6/  8.3/  4.2)  "David Cunningham" <newsonly@please.com>
    7    14.0 (  6.3/  7.7/  3.7)  "Géry" <ducateg@info.bt.co.uk>
    7     7.4 (  5.3/  2.1/  1.5)  Paul <mustbe@pdelahunta.cjb.com>
    5    14.4 (  5.5/  9.0/  3.1)  "Charles K. Clarkson" <c_clarkson@hotmail.com>
    5    32.6 (  5.9/ 26.6/ 20.2)  nadie@latino-2000.com
    5     8.1 (  4.0/  4.0/  1.9)  "Mike McPherson" <hafateltec@hotmail.com>
    5    12.9 (  4.5/  8.4/  3.9)  "Ian Trudel" <ian.trudel@tr.cgocable.ca>
    5    11.2 (  4.4/  6.8/  3.3)  feldspar@cryogen.com

These posters accounted for 6.4% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  32.6 (  5.9/ 26.6/ 20.2)      5  nadie@latino-2000.com
  22.6 ( 10.3/ 11.5/  5.7)     14  Rocky Raccoon <rrocky@bigfoot.com>
  15.0 (  2.4/ 12.6/ 11.4)      3  abme75@my-deja.com
  14.4 (  5.5/  9.0/  3.1)      5  "Charles K. Clarkson" <c_clarkson@hotmail.com>
  14.0 (  6.3/  7.7/  3.7)      7  "Géry" <ducateg@info.bt.co.uk>
  13.9 (  5.6/  8.3/  4.2)      8  "David Cunningham" <newsonly@please.com>
  12.9 (  4.5/  8.4/  3.9)      5  "Ian Trudel" <ian.trudel@tr.cgocable.ca>
  12.5 (  5.6/  6.9/  4.8)      8  ben-fuzzybear@geocities.com
  11.2 (  4.4/  6.8/  3.3)      5  feldspar@cryogen.com
   8.6 (  2.8/  5.9/  1.6)      3  "Sean" <sunymoon@geocities.com>

These posters accounted for 7.6% of the total volume.

Top 10 Posters by OCR (minimum of three posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

1.000  (  2.2 /  2.2)      4  tunneling@my-deja.com
1.000  (  1.4 /  1.4)      3  Bin - Lu <b0l4549@cs.tamu.edu>
1.000  (  1.7 /  1.7)      3  2obvious@my-deja.com
0.967  (  3.0 /  3.1)      3  "John Hall" <jhall@ifxonline.com>
0.902  ( 11.4 / 12.6)      3  abme75@my-deja.com
0.809  (  3.7 /  4.5)      3  Ilmari Karonen <usenet11325@itz.pp.sci.fi>
0.765  (  3.6 /  4.7)      3  Kevin Michael Vail <kevin@vaildc.net>
0.762  ( 20.2 / 26.6)      5  nadie@latino-2000.com
0.737  (  2.7 /  3.7)      3  Steven Smolinski <sjs@linux.ca>
0.735  (  3.3 /  4.5)      3  Soren Andersen <soren2000@noYOUknowWHAT.juno.com>

Bottom 10 Posters by OCR (minimum of three posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.480  (  3.7 /  7.7)      7  "Géry" <ducateg@info.bt.co.uk>
0.473  (  2.2 /  4.7)      3  "Chris" <CHRISVAL@bigpond.com.au>
0.464  (  3.9 /  8.4)      5  "Ian Trudel" <ian.trudel@tr.cgocable.ca>
0.398  (  2.1 /  5.2)      3  "Daneman" <daneman@planet.nl>
0.392  (  1.7 /  4.3)      4  sarbayo@telis.org
0.365  (  0.8 /  2.3)      3  "matthias tarasiewicz" <t@inode.at>
0.347  (  3.1 /  9.0)      5  "Charles K. Clarkson" <c_clarkson@hotmail.com>
0.285  (  0.6 /  2.0)      3  "Wavetable" <wavetable@birdmail.com>
0.272  (  1.6 /  5.9)      3  "Sean" <sunymoon@geocities.com>
0.262  (  0.4 /  1.5)      3  Nicolas Jaworsky <Nicolas@Jaworsky.com>

30 posters (18%) had at least three posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      14  comp.sys.mac.programmer.help
      14  comp.sys.mac.programmer.tools
      14  comp.sys.mac.system
       9  comp.lang.perl
       5  microsoft.public.inetserver.iis
       5  comp.sys.mac.programmer
       5  alt.perl
       4  comp.lang.perl.modules
       3  comp.lang.c
       2  comp.answers

Top 10 Crossposters
===================

Articles  Address
--------  -------

       4  David Burgun <NOdburgunSPAM@earthlink.net>
       4  Michael Ash <mail@mikeash.com>
       3  Matthew T. Russotto <russotto@wanda.vf.pond.com>
       2  Thomas j. Evans <thomas42@no.spam.bellatlantic.net>
       2  "Sean" <sunymoon@geocities.com>
       2  Jack Klein <jackklein@spamcop.net>
       1  "djinni" <genie.us@@home.com>
       1  "pricesteve" <pricesteve@yahoo.com>
       1  "Elisaweta" <MAR@kraitor.hh.uunet.de>
       1  "Andre Lacroix" <lacroix_andre@emc.com>


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 15
*************************************


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