[18151] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 319 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 20 06:05:35 2001

Date: Tue, 20 Feb 2001 03:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982667109-v10-i319@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 20 Feb 2001     Volume: 10 Number: 319

Today's topics:
        Array length <x@x.x>
    Re: Array length <beable@my-deja.com>
        Change unknown filenames (BUCK NAKED1)
    Re: Change unknown filenames blah@blah.blah.invalid
    Re: Change unknown filenames <c_clarkson@hotmail.com>
        RE: chop and chomp <ncmncm@MailAndNews.com>
    Re: chop and chomp (Bernard El-Hagin)
    Re: chop and chomp <jasonahood@netmatters.co.uk>
    Re: chop and chomp (Abigail)
    Re: delete lock file, possible race condition or dead l (Garry Williams)
    Re: delete lock file, possible race condition or dead l <johnlin@chttl.com.tw>
    Re: FAQ 4.48:   How do I select a random element from a (Anno Siegel)
    Re: FAQ 4.48:   How do I select a random element from a <godzilla@stomp.stomp.tokyo>
    Re: FAQ 4.48:   How do I select a random element from a (Anno Siegel)
    Re: FAQ 4.48:   How do I select a random element from a <godzilla@stomp.stomp.tokyo>
    Re: FAQ 4.49:   How do I permute N elements of a list? <johnlin@chttl.com.tw>
    Re: IT Security Game (Mark Jason Dominus)
    Re: kill unix process (Villy Kruse)
    Re: kill unix process (Rafael Garcia-Suarez)
    Re: newbie regex linebreaks problem - my bad <"goodrow"@opencity. com>
    Re: newbie regex linebreaks problem - my bad <godzilla@stomp.stomp.tokyo>
    Re: passing a variable with a checkbox? emelin@my-deja.com
    Re: perl irc channel <jdf@pobox.com>
    Re: perl irc channel <comdog@panix.com>
    Re: PROPOSAL: Graphics::ColorNames (Abigail)
    Re: Reg Ex Help Pls (Anno Siegel)
    Re: removing carriage return from a string (Anno Siegel)
    Re: sending cookies with LWP user agent <gtoomey@usa.net>
    Re: term::readline gnu/stub current_history (News ax\)
        User_Agent <pbaumann@mail.worldnet.fr>
    Re: User_Agent <comdog@panix.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 20 Feb 2001 12:19:01 +0200
From: "wavetable" <x@x.x>
Subject: Array length
Message-Id: <96tg5g$36i$1@news.kolumbus.fi>

Although this seems like a simple task I couldn't find how to do it in the
FAQ. Does anyone know how/if it is possible to get the length of an array?




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

Date: Tue, 20 Feb 2001 10:55:50 GMT
From: Beable van Polasm <beable@my-deja.com>
Subject: Re: Array length
Message-Id: <m3k86lljfu.fsf@beable.van.polasm.bigpond.net.au>

"wavetable" <x@x.x> writes:
> Although this seems like a simple task I couldn't find how to do it in the
> FAQ. Does anyone know how/if it is possible to get the length of an array?

Huh. Maybe it's not frequently asked enough to get into the FAQ? 
You can find the answer in perldata:

    perldoc perldata

It says:
       The length of an array is a scalar value.  You may find
       the length of array @days by evaluating $#days, as in csh.
       (Actually, it's not the length of the array, it's the
       subscript of the last element, because there is
       (ordinarily) a 0th element.)

       If you evaluate a named array in a scalar context, it
       returns the length of the array.  

So you can do this:

--------------8<------------------------------------------------------
#!/usr/bin/perl -w
use strict;

my @array = qw(3 4 5 6 7 8 2 1 4 7 8 93 2 2 a f wewew gfd v);

print "index of the last element of of array is: ", $#array, "\n";

my $array_length = scalar(@array);
print "array length is $array_length\n";

$array_length = @array; # this is the same as the previous one
print "array length is $array_length\n";
--------------8<------------------------------------------------------

cheers
Beable van Polasm
-- 
STOP CAKEHOLING PLANKTON               IQC 78189333
-- Joe Bay, Society for Plankton Abuse PREVENTION
http://members.nbci.com/_______/index.html


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

Date: Tue, 20 Feb 2001 00:29:34 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Change unknown filenames
Message-Id: <11274-3A920ECE-96@storefull-244.iap.bryant.webtv.net>

I'm trying to change all of the filenames in a directory called $tmpdir
to .txt if they end in .pl, .cgi, or .exe. I don't know what the
filenames in the directory are. Why won't this code change all of the
cgi, .pl, and .exe extensions to .txt, and do it recursively?

while (glob $tmpdir) { 
-f =~ s/\.cgi|\.pl|\.exe$/\.txt/ig 
   };

I've studied perlop. Any help would be greatly appreciated.

Thanks,
Dennis



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

Date: 20 Feb 2001 07:40:43 GMT
From: blah@blah.blah.invalid
Subject: Re: Change unknown filenames
Message-Id: <96t71r$487g$1@newssvr05-en0.news.prodigy.com>

BUCK NAKED1 <dennis100@webtv.net> wrote:
> I'm trying to change all of the filenames in a directory called $tmpdir
> to .txt if they end in .pl, .cgi, or .exe. I don't know what the
> filenames in the directory are. Why won't this code change all of the
> cgi, .pl, and .exe extensions to .txt, and do it recursively?

Use File::Find.  It's included in the standard distribution.



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

Date: Tue, 20 Feb 2001 02:09:04 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Change unknown filenames
Message-Id: <DE24797E4353F5B9.3E0B64283ABB4D8D.8679D9258A330877@lp.airnews.net>


Dennis <dennis100@webtv.net> wrote:
: I'm trying to change all of the filenames in a directory called $tmpdir
: to .txt if they end in .pl, .cgi, or .exe. I don't know what the
: filenames in the directory are. Why won't this code change all of the
: cgi, .pl, and .exe extensions to .txt, and do it recursively?
:
: while (glob $tmpdir) {
    What's in $tmpdir? Does it look something like:
        'c:/temp/*.*' or 'c:/temp' the second one doesn't work.

: -f =~ s/\.cgi|\.pl|\.exe$/\.txt/ig
    -f tests a file., it can't be used as an lvalue.
    Perhaps you should test it and operate on $_
        s/\.(cgi|pl|exe)$/.txt/i if -f;

This will change the name in your program, it does not effect
the file system. For that you should read perlfaq5: 'How can I
reliably rename a file?'

HTH,
Charles K. Clarkson



:    };
:
: I've studied perlop. Any help would be greatly appreciated.
:
: Thanks,
: Dennis
:




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

Date: Tue, 20 Feb 2001 02:25:27 -0500
From: Chandramohan Neelakantan <ncmncm@MailAndNews.com>
Subject: RE: chop and chomp
Message-Id: <3A95B569@MailAndNews.com>

>===== Original Message From anotherway83@aol.com (Another Way) =====
>hey
>whats the diff. between chop and chomp (please don't say sumthing like "chomp
>has an M, chop doesn't", lol)they seem to work the same way
>
>thanks
>peace


chomp removes the newline at the end of the string on which it was called,if 
it exists.
chop removes the last character of the string on which it was called

regrds
CM

------------------------------------------------------------
 Get your FREE web-based e-mail and newsgroup access at:
                http://MailAndNews.com

 Create a new mailbox, or access your existing IMAP4 or
 POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------



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

Date: Tue, 20 Feb 2001 09:50:27 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: chop and chomp
Message-Id: <slrn994fdl.lgi.bernard.el-hagin@gdndev32.lido-tech>

On Tue, 20 Feb 2001 02:25:27 -0500, Chandramohan Neelakantan
<ncmncm@MailAndNews.com> wrote:
>>===== Original Message From anotherway83@aol.com (Another Way) =====
>>hey
>>whats the diff. between chop and chomp (please don't say sumthing like "chomp
>>has an M, chop doesn't", lol)they seem to work the same way
>>
>>thanks
>>peace
>
>
>chomp removes the newline at the end of the string on which it was called,if 
>it exists.

That's not entirely accurate. chomp removes whatever $\ is set to,
whether it's a newline or not.

>chop removes the last character of the string on which it was called

And returns it.

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Tue, 20 Feb 2001 09:23:21 -0000
From: "Jason Hood" <jasonahood@netmatters.co.uk>
Subject: Re: chop and chomp
Message-Id: <3a923765_3@news1.vip.uk.com>

chomp - Removes line feed or newline characters from the end of a string,
nothing else.
chop - Removes the last character from a string no matter what.

If you get stuck read perlfunc manual or goto www.perl.com for function
help.

Jason Hood

"Toleration In Moderation"

"Another Way" <anotherway83@aol.com> wrote in message
news:20010219232256.04852.00000222@ng-ch1.aol.com...
> hey
> whats the diff. between chop and chomp (please don't say sumthing like
"chomp
> has an M, chop doesn't", lol)they seem to work the same way
>
> thanks
> peace




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

Date: 20 Feb 2001 10:29:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: chop and chomp
Message-Id: <slrn994hnj.ii5.abigail@tsathoggua.rlyeh.net>

Another Way (anotherway83@aol.com) wrote on MMDCCXXX September MCMXCIII
in <URL:news:20010219232256.04852.00000222@ng-ch1.aol.com>:
() hey
() whats the diff. between chop and chomp (please don't say sumthing like "chomp
() has an M, chop doesn't", lol)they seem to work the same way


Did you read the manual?


Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: Tue, 20 Feb 2001 06:26:01 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: delete lock file, possible race condition or dead lock?
Message-Id: <Z5ok6.199$oF1.7589@eagle.america.net>

On Tue, 20 Feb 2001 10:02:54 +0800, John Lin <johnlin@chttl.com.tw> wrote:
><nobull@mail.com> wrote
>> "John Lin" writes:
>>
>> > For some reason (to keep the directory clean) I have to delete
>> > the lock file after locking.

[snip]

>> If the filesystem and OS support it, you can use sysopen to atomically
>> create a lock file.  In this case the flock() becomes redundant.
>
>Hmm...  Here I picture out the model
>
>atomic_create_and_lock($filename);
>    critical_section_here();
>atomic_unlock_and_delete($filename);

This from perlopentut: 

     To open a file for writing, creating a new file which must
     not previously exist:

         sysopen(FH, $path, O_WRONLY | O_EXCL | O_CREAT);

So the presence of the file *is* the lock.  

This, unfortunately requires some sort of polling to handle the
failure of the sysopen() and try again.  

Unlinking the file *is* unlocking the resource represented by the lock
file.  (Thus, it's atomic.)  

Don't forget handling "stale" lock files caused by program or system
failures.  Check the mtime and throw away a stale lock.  

All in all, this is a pretty poor way to handle locking.  I wouldn't
recommend it.  

What is the objection to a zero length file hanging around in a
directory anyway?  

-- 
Garry Williams


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

Date: Tue, 20 Feb 2001 17:07:53 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: delete lock file, possible race condition or dead lock?
Message-Id: <96tcfi$q4@netnews.hinet.net>

"Garry Williams" wrote
>> "John Lin" writes:
>> > For some reason (to keep the directory clean) I have to delete
>> > the lock file after locking.

> The presence of the file *is* the lock.
> Unlinking the file *is* unlocking the resource represented by the lock
> file.  (Thus, it's atomic.)

Good logic!!!  And it works!!!

> sysopen(FH, $path, O_WRONLY | O_EXCL | O_CREAT);
> This, unfortunately requires some sort of polling to handle the
> failure of the sysopen() and try again.

Fortunately, my application is LOCK_NB.
Hmm...  I wonder how flock do the polling...

> Don't forget handling "stale" lock files.

OK.  I'll do it in END {} block.

> All in all, this is a pretty poor way to handle locking.
> I wouldn't recommend it.

But I think it is convenient.  : )
Besides, I can observe which jobs are in process by checking lock files.
I like it!!!

> What is the objection to a zero length file hanging around in a
> directory anyway?

: p  Just a clean-up.  Keep everything unchanged after running program.

Thank you very much.

John Lin





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

Date: 20 Feb 2001 08:28:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FAQ 4.48:   How do I select a random element from an array?
Message-Id: <96t9qo$kpr$1@mamenchi.zrz.TU-Berlin.DE>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote in comp.lang.perl.misc:

[about rand() and srand()]

>For safety, to assure better portability for older
>versions of Perl, an if conditional can call srand
>only if needed:
>
>  $index   = rand @array;
>
>  if (!($index))
>   { srand; $index = rand @array }

You seem to believe that rand() returns a false value when a call to
srand() is missing.  This is not so, as a look at the documentation
would have told you.

Anno


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

Date: Tue, 20 Feb 2001 01:25:43 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: FAQ 4.48:   How do I select a random element from an array?
Message-Id: <3A923817.DB744163@stomp.stomp.tokyo>

Anno Siegel wrote:
 
> Godzilla! wrote:

(snippage not noted by Siegel)
 
> [about rand() and srand()]
 
> > For safety, to assure better portability for older
> > versions of Perl, an if conditional can call srand
> > only if needed:

> >  $index   = rand @array;

> >  if (!($index))
> >   { srand; $index = rand @array }
 
> You seem to believe that rand() returns a false value when a call to
> srand() is missing.  This is not so, as a look at the documentation
> would have told you.
 

You seem to believe a bare beginner level knowledge 
of Perl qualifies you to respond to my articles.

Believe this. You are displaying zero knowledge
of Perl programming.

Godzilla!


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

Date: 20 Feb 2001 09:47:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FAQ 4.48:   How do I select a random element from an array?
Message-Id: <96tef9$qrq$1@mamenchi.zrz.TU-Berlin.DE>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote in comp.lang.perl.misc:

[...]

>You seem to believe a bare beginner level knowledge 
>of Perl qualifies you to respond to my articles.
>
>Believe this. You are displaying zero knowledge
>of Perl programming.

Fascinating.  Firm self-confidence, justified by absolutely nothing.

Anno


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

Date: Tue, 20 Feb 2001 01:59:49 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: FAQ 4.48:   How do I select a random element from an array?
Message-Id: <3A924015.DB8CB537@stomp.stomp.tokyo>

Anno Siegel wrote:
 
> Godzilla! wrote:

(snippage not noted by Siegel)
 
> [...]
 
> >You seem to believe a bare beginner level knowledge
> >of Perl qualifies you to respond to my articles.

> >Believe this. You are displaying zero knowledge
> >of Perl programming.
 
> Fascinating.  Firm self-confidence, justified by absolutely nothing.


Normally, for a person of your intellectual capacity,
I would offer to draw pictures to assist you, to guide
you to understanding of my statements. However, you reside
amongst and, are a member of the well noted arseholes
populating this group. My personal policy is adamantly
"hands off" when it comes to arseholes.

Godzilla!


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

Date: Tue, 20 Feb 2001 16:08:45 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: FAQ 4.49:   How do I permute N elements of a list?
Message-Id: <96t8pv$k91@netnews.hinet.net>

"PerlFAQ Server" wrote
>   How do I permute N elements of a list?

Ah, I remember this FAQ has come up several weeks ago.
The PerlFAQ server has finished a cycle?  So soon.





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

Date: Tue, 20 Feb 2001 07:50:01 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: IT Security Game
Message-Id: <3a9221a8.2a1e$14b@news.op.net>
Keywords: Brainard, NOAA, hysteria, notoriety

In article <3a915232$1@new01.bendcable.com>,
Mellissa <mellissa@intrapromote.com> wrote:
>The IT Security Game, a two-dimensional, multi-level game that puts
>the player in the place of an overworked, stressed IT person.

Gosh, that does sound like fun.

P.S.  You misspelled 'Melissa'.  Hope this helps.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 20 Feb 2001 08:12:32 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: kill unix process
Message-Id: <slrn9949nf.cem.vek@pharmnl.ohout.pharmapartners.nl>

On Tue, 20 Feb 2001 03:21:01 GMT, John W. Krahn <krahnj@acm.org> wrote:
>Ji Lee wrote:
>> 
>> here is my code:
>> 
>> exec "/usr/bin/ksh", "-c", <<EOF;
>> ps -ef|grep slapd |grep -v grep |awk '{print $2}'|xargs kill -9
>> sleep 2
>
>system( "ps -ef|grep slapd |grep -v grep |awk '{print $2}'|xargs kill
>-9" );
>
>Or for a more Perlish way:
>
>kill 9, map { (split " ")[1] } grep( /slapd/, `ps -ef` );
>
>> I will to convert the above line to perl. can anyone help?
>
>And of course if you have the command killall do:
>killall -9 slapd
>
>

WATCH OUT!  On systems where you would use "ps -ef" the killall function
will kill all processes, only limited by the permissions granted
to the current efective user id.  

Also, kill -9 is usualy a bad idea.



Villy


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

Date: Tue, 20 Feb 2001 09:56:49 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: kill unix process
Message-Id: <slrn994fq1.6i5.rgarciasuarez@rafael.kazibao.net>

John W. Krahn wrote in comp.lang.perl.misc:
> Ji Lee wrote:
> > 
> > here is my code:
> > 
> > exec "/usr/bin/ksh", "-c", <<EOF;
> > ps -ef|grep slapd |grep -v grep |awk '{print $2}'|xargs kill -9
> > sleep 2
> 
> system( "ps -ef|grep slapd |grep -v grep |awk '{print $2}'|xargs kill
> -9" );
> 
> Or for a more Perlish way:
> 
> kill 9, map { (split " ")[1] } grep( /slapd/, `ps -ef` );
> 
> > I will to convert the above line to perl. can anyone help?
> 
> And of course if you have the command killall do:
> killall -9 slapd

On Solaris you have the pgrep and pkill commands. Look also at the
arguments provided by your version of ps, it may avoid you some extra
work in parsing the output of ps.

As an example, here's how I kill netscape on linux :
  ps -eo pid,comm,args | perl -ne '/netscape/&&!/grep/&&kill 9,(split)[0]'

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


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

Date: Tue, 20 Feb 2001 00:18:10 -0500
From: Jason Goodrow <"goodrow"@opencity. com>
Subject: Re: newbie regex linebreaks problem - my bad
Message-Id: <96sum1$qgf$1@news.panix.com>

Regarding regex html

uh ... I'm an idiot -

#!/usr/local/bin/perl5

$aa = $ENV{'QUERY_STRING'};
$aa =~s/%0D%0A/<br>/g;

print "Content-type: text/html\n\n<html>$aa</html>";

works fine. I was using cgi.pm which was adding something.

Thanks for the help





Bart Lateur wrote:

> Jason Goodrow <"goodrow"@opencity. com> wrote:
>
> >I've tried s/%0D%0A/<br>/ and lots of variations.
>
> Your input is probably already decoded when you get at it. So you'll
> never see any "%0D" or "%0A" andy more. Instead, you get "\r" and "\n".
>
> You don't need the "\r", so get rid of those:
>
>         $textarea =~ tr/\r//d;
>
> You can add "<BR>" for every "\n" if you like, but be very aware: if you
> accept just any user supplied HTML just like that, you're in for some
> deep shit. People can post malicious Javascripts on your site, or
> example.
>
>         <http://www.devshed.com/News/CERT_HTML/>
>
> --
>         Bart.



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

Date: Mon, 19 Feb 2001 21:43:18 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: newbie regex linebreaks problem - my bad
Message-Id: <3A9203F6.A3E0CDEC@stomp.stomp.tokyo>

Jason Goodrow wrote:
 
(snippage)

> Regarding regex html
 
> $aa = $ENV{'QUERY_STRING'};
> $aa =~s/%0D%0A/<br>/g;
 
> print "Content-type: text/html\n\n<html>$aa</html>";
 
> works fine. I was using cgi.pm which was adding something.


Examine your html document source once you incorporate
this change. If you wish to avoid a single line mile
long document source, if you wish to have a clean,
crisp and easy-to-read document source, incorporate
a method similar to this for your html print call,

$your_html =~ s/<br>/<br>\n/g;

If you are not using CGI.pm, easy to do with your code,

$aa =~s/%0D%0A/<br>\n/g;

I never use CGI.pm to avoid its numerous inherent
bugs, difficulty in use and, to avoid its significant
memory bloat. I 'believe' trying to change to <br>\n 
within your Query String will still result in CGI.pm 
screwing up your html, if you are using CGI.pm in your 
code. Doesn't read like you are. Check me on this; 
I've never tested pumping \n into CGI.poopmaker to
discover what type of mule manure comes out its end.

Godzilla!


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

Date: 20 Feb 2001 08:30:54 GMT
From: emelin@my-deja.com
Subject: Re: passing a variable with a checkbox?
Message-Id: <96t9vu$a23$1@news.netmar.com>

Umm, nevermind about this, naturally it's just me being stupid... I was
tired, okay? :) :) All solved now.

In article <96r90r$tdt$1@news.netmar.com>, <emelin@my-deja.com> writes:
>Hi,
>
>I'm trying to do something in perl/cgi that lets you search through a csv
>stocklist. I want to send the search result to another cgi, and I've tried
to
>do this with a checkbox with the value $partnr. The problem is that the
value
>gets sent as "$partnr" (literally), and not the current value of the
>variable. 
>
>I am using CGI qw(import_names); to fetch the info.
>
>How can I do this?
>
>thankful for help,
>(i haven't found anything in the docs that makes sense to me)
>emelin
>
>
>Part of code from search cgi below. 
>
>open (STOCK, "stock.csv") or die "The database could not be accessed, please
>try again later.\n";
>
>@stock = <STOCK>;
>
>foreach $item (@stock) {
>	if ($item =~ /$FORM::part/ig) {
>		($partnr,$quantity,$manufacturer,$datecode,$package) = split(/,/, $item);
>
>		if ($partnr =~ /$FORM::part/ig) {
>			print "<td><font face=verdana size=1>$partnr</td>";
>			print "<td><font face=verdana size=1>$quantity</td>";
>			print "<td><font face=verdana size=1>$manufacturer</td>";
>			print "<td><font face=verdana size=1>$datecode</td>";
>			print "<td><font face=verdana size=1>$package</td>";
>			print '<td><form action="rfq.cgi" method="post"><input type="checkbox"
>name="rfq" value="$partnr"><input type="submit" 
>
>######### $partnr is sent as "$partnr", not the value of the variable!
>
>value="RFQ"></form></td>';
>			print "<tr>";
>		}
>	}	
>}
>
> -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web 
-----
>  http://newsone.net/ -- Free reading and anonymous posting to 60,000+
groups
>   NewsOne.Net prohibits users from posting spam.  If this or other posts
>made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: 20 Feb 2001 00:15:21 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: perl irc channel
Message-Id: <8zn2c4uu.fsf@pobox.com>

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

> lol randal, somehow i doubt that anyone would fire you

You would be *amazed* at what Randal's "employers" might do.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 20 Feb 2001 00:52:51 -0800
From: brian d foy <comdog@panix.com>
Subject: Re: perl irc channel
Message-Id: <comdog-E1F0D1.00525120022001@news.panix.com>

In article <slrn993rus.s3i.tjla@thislove.dyndns.org>, 
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:

> I was shocked! How could AvA <a.v.a@home.nl>
> say such a terrible thing:
> >lol randal, somehow i doubt that anyone would fire you, but okay if you change
> >ur mind
> >one day then then we would be honoured

> He is being disingenuous I think. He can't fire himself. 

Randal doesn't necessarily work for himself. i think you assume to
much.

-- 
brian d foy <comdog@panix.com>



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

Date: 20 Feb 2001 10:20:28 GMT
From: abigail@foad.org (Abigail)
Subject: Re: PROPOSAL: Graphics::ColorNames
Message-Id: <slrn994h7c.ii5.abigail@tsathoggua.rlyeh.net>

Sam Kington (sam@illuminated.co.uk) wrote on MMDCCXXX September MCMXCIII
in <URL:news:3A91BFA2.47AF8B2E@illuminated.co.uk>:
!! Abigail wrote:
!! > 
!! > Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDCCXXIX September
!! > MCMXCIII in <URL:news:slrn9939rg.2th.mgjv@verbruggen.comdyn.com.au>:
!! > $$
!! > $$ Of course, no one says that you need to load all colours on startup.
!! > $$ You could store them in several files, and load them on demand. One
!! > $$ file with all the most common ones. Several files with the less common
!! > $$ ones, broken up by name or so. Some logic could load them when needed.
!! > $$ However, I probably wouldn't even bother :)
!! > 
!! > A dbm file comes in mind...
!! 
!! Having torn my hair out regarding all the different types of
!! implementation of dbm files on different systems (just Unices; let's not
!! even talk about Windows systems; they're fairly harmless, inasmuch as
!! all the weird behaviours have already been claimed by random Unix
!! variants, and Windows is reduced to emulating one of the cruftiest) --
!! I'd say that dbm files are one of those things that seem like a good
!! idea until you've had to deal with them, on a cross-platform basis.
!! 
!! Bear in mind that you have to construct the dbm file at the Makefile.PL
!! level, unless you know something that I don't (in which case, *please*
!! tell me.)

Well, ideally from 'make', not 'perl Makefile.PL'.

!! Yes, dbm files are an obvious Good Idea. But good luck on your
!! supporting them. (Your ExtUtils::MakeMaker rules, in particular, are
!! going to be pretty ugly - unless you know something I don't. Mail me for
!! more details.)

Why would they need to be pretty ugly? use AnyDBM_File should take care
of most of the problems, right?

!! > map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
!! > print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
!! 
!! Damn, Abigail, I thought I'd escaped your evil sigs by unscribing from
!! the scary devil monastery. Damn, damn, damn. Have you ever considered
!! collating them into book-form, or at least some handy web page?


Haven't used the sigs in the monastery for ages. As for collating them,
there was my talk on YAPC::NA last year, and I might give a sequel
this year.


Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: 20 Feb 2001 09:53:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Reg Ex Help Pls
Message-Id: <96teqn$qrq$2@mamenchi.zrz.TU-Berlin.DE>

Gabriel Richards <grichards@endertechnology.com> wrote in comp.lang.perl.misc:
>Hi. I need more reg ex help please.
>
>The string is a directory structure or arbitrary length like:
>
>/<anything>/<anything>/anything/anything/
>
>I want to extract the last "anything". So I tried:
>
>$temp =~ /\/(.+?)\/$/;
>$name = $1;
>
>but that grabs everything except the opening and closing "/". I thought the
>"$" told it to match at the end of the string (i.e. furthest to the right?).
>I don't think I'm understanding its use correctly.

There has been ample advice on how to correct your regex.

You should also look into the module File::Basename which does exactly
what you want, but in a portable way.  File::Basename comes with Perl.

Anno


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

Date: 20 Feb 2001 10:11:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: removing carriage return from a string
Message-Id: <96tfro$qrq$3@mamenchi.zrz.TU-Berlin.DE>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote in comp.lang.perl.misc:
>Waarddebon wrote:
> 
>> How can I remove a carriage return from the end of a string ?
>
>My presumption is you are referring to a standard
>carriage return character " \r " rather than a 
>newline character " \n " as is commonplace.
>
>$string =~ tr/\r//d;

This removes all \r characters, not only the one at the end of the string.

>Use a " s " switch if you need single line treatment of input,
>
>$string =~ tr/\r//sd;

The /s modifier has a different meaning with tr/// than with s///.
Its function is to squeeze adjacent occurrences of a character
(after replacement) into a single one.  The combination with /s
makes no sense.

Anno


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

Date: Tue, 20 Feb 2001 19:16:30 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: sending cookies with LWP user agent
Message-Id: <8oqk6.405$722.793@newsfeeds.bigpond.com>

The following code fragments get web page and store/send a cookie!!
You can use this code to emulate what a browser.


1. Open a Web page and store a cookie in a file.

use LWP::UserAgent;
use HTTP::Cookies;

      $ua = new LWP::UserAgent;
      $ua->agent("$0/0.1 " . $ua->agent);
      $ua->timeout(30);
       $req = new HTTP::Request 'GET' => 'http://www.somesite.com';  #change
as apprporiate
      $req->header('Accept' => 'text/html');
      $res = $ua->request($req);

      if ($res->is_success) {
              $cookie_jar = new HTTP::Cookies( ignore_discard =>TRUE);
              $cookie_jar->extract_cookies($res);
               $cookie_jar->save('/usr/local/cookie_jar);   #change as
appropriate
                #web page is now in the variable$res
}

2. Open a Web page and send the stored cookie

                $ua = new LWP::UserAgent;
                $ua->agent("$0/0.1 " . $ua->agent);
                $ua->timeout(30);
                $req = new HTTP::Request 'GET' =>
'http://www.somesite.com/';
               $req = new HTTP::Request 'GET' =>
'http://www.somesite.com/somepage.htm';  #change as apprporiate


                $req->header('Accept' => 'text/html');
                $cookie_jar = new HTTP::Cookies( ignore_discard =>TRUE);
                $cookie_jar->load('/usr/local/cookie_jar') #change as
appropriate
                $cookie_jar->add_cookie_header($req);
                $res = $ua->request($req);

                if ($res->is_success) {
                #web page is now in the variable $res
                }

Enjoy!
gtoomey
-----------------------
"Murali K Inaganti" <inaganami@email.uc.edu> wrote in message
news:3A91D409.61290686@email.uc.edu...
> Hi all,
>
> I am writing simple a auto mail check program, which gets mail from
> yahoo id. I was using LWP::Useragent for sending for sending all the
> login passwd etc,
> Its returning a 302 Found (redirection) and it never logs me in.
>
> but if i input the generated  URL  through netscape, I logs me in.
>
> can anyone tell me whats wrong or give  me some pointers to
> such programs
>
> thanking you,
>
> Murali
>
>
>
>




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

Date: Tue, 20 Feb 2001 10:37:17 -0000
From: "Mark Hamlin \(News ax\)" <mark.hamlin@artdigital.co.uk>
Subject: Re: term::readline gnu/stub current_history
Message-Id: <96thmu$o52$1@pheidippides.axion.bt.co.uk>

I've adapted Perl Cookbook Recepie 15.4: vbsh to query the history on
command. The script runs, but when I enter 'shi' to query the history I get
the error:

Can't locate object method "GetHistory" via package "Term::ReadLine::Stub"
at termpl line 17, <FIN> chunk 2.

#!/usr/bin/perl -w
# vbsh -  very bad shell
use strict;

use Term::ReadLine;
use POSIX qw(:sys_wait_h);

my $term = Term::ReadLine->new("Simple Shell");
my $OUT = $term->OUT() || *STDOUT;
my $cmd;
my $item;
my @history;

while (defined ($cmd = $term->readline('$ ') )) {
    if ($cmd eq 'shi')
    {
 @history = $term->GetHistory;
 foreach $item (@history) { print $item, "\n" }
    }
    else
    {
 my @output = `$cmd`;
 my $exit_value  = $? >> 8;
 my $signal_num  = $? & 127;
 my $dumped_core = $? & 128;
 printf $OUT "Program terminated with status %d from signal %d%s\n",
        $exit_value, $signal_num,
        $dumped_core ? " (core dumped)" : "";
 print @output;
 $term->addhistory($cmd);
    }
}



Many Thanks,

Mark


"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m37l2me8we.fsf@mumonkan.sunstarsys.com...

> "Mark Hamlin \(News axion\)" <mark.hamlin@artdigital.co.uk> writes:
>
> > I'm using the above on a Solaris box.  I specify use Term::ReadLine,
> > when I call a history management command (other than addhistory) I
> > get the following
> >
> > Can't locate object method "current_history" via package
> > "Term::ReadLine::Stub"
> >
> > What do I need to do.
>
> You need to post the offending code so people can reproduce
> the problem.
>
> Joe Schaefer
> --
> %ENV=(); $A="\rr jpeurls ht\ba \rcankotehe"x666;END{ system
> "$^X -wT $0 $^S";print"r\n"}sub foo{$_=pop||exit;/$_/;print
> eval 'BEGIN{$^H='. ($^H+=666) .'}$_[-(()=$A=~//g)+$[]';}@_=
> reverse$A=~/./g;&foo while$ARGV[0]=~//g;#evil mess for *nix




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

Date: Tue, 20 Feb 2001 06:29:06 +0100
From: "Baumann" <pbaumann@mail.worldnet.fr>
Subject: User_Agent
Message-Id: <96svbr$foq$1@news6.isdnet.net>

Can someone tell me where I can find the signification of the User_Agent
parameters that my perl script return. For example : Mozilla/4.0
(compatible; MSIE 5.0; Windows 98; DigExt) ; Mozilla/4.75 [fr] (Win98; U) ;
Mozilla/4.5 [fr] (Win95; I). What does DigExt or I or U mean ?
Thank You





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

Date: Tue, 20 Feb 2001 00:54:59 -0800
From: brian d foy <comdog@panix.com>
Subject: Re: User_Agent
Message-Id: <comdog-7E59C3.00545920022001@news.panix.com>

In article <96svbr$foq$1@news6.isdnet.net>, "Baumann" 
<pbaumann@mail.worldnet.fr> wrote:

> Can someone tell me where I can find the signification of the User_Agent
> parameters that my perl script return. For example : Mozilla/4.0
> (compatible; MSIE 5.0; Windows 98; DigExt) ; Mozilla/4.75 [fr] (Win98; U) ;
> Mozilla/4.5 [fr] (Win95; I). What does DigExt or I or U mean ?

ask the people who make the user agent.  there is no standard, and
even if there was, it doesn't have anything to do with Perl. ;)

-- 
brian d foy <comdog@panix.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 319
**************************************


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