[23321] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5541 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 22 11:05:59 2003

Date: Mon, 22 Sep 2003 08:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 22 Sep 2003     Volume: 10 Number: 5541

Today's topics:
    Re: "my" declarations, only matter of taste? <peter@semantico.com>
    Re: "my" declarations, only matter of taste? <abigail@abigail.nl>
        Form problems, post method yeilds 0 at end of values <mills_nospam_@free.fr>
        Infra red port data dumper. <spikey-wan@bigfoot.com>
        is there an 'on key' command in perl? (firehand)
    Re: is there an 'on key' command in perl? (Anno Siegel)
    Re: is there an 'on key' command in perl? <jurgenex@hotmail.com>
    Re: killing zombie file lock (Anno Siegel)
    Re: killing zombie file lock news@roaima.freeserve.co.uk
    Re: length of the longest $_ in @_ <minceme@start.no>
    Re: length of the longest $_ in @_ <raisin@delete-this-trash.mts.net>
    Re: Operator Precedence (Anno Siegel)
        reading STDIN with Perl on Linux / Apache <someone@microsoft.com>
    Re: reading STDIN with Perl on Linux / Apache <someone@microsoft.com>
    Re: reading STDIN with Perl on Linux / Apache <bobsmith@jippii.fi>
    Re: reading STDIN with Perl on Linux / Apache <someone@microsoft.com>
        Rebuilding module list for CPAN <michael+USENET@www.heiming.de>
    Re: Sending html mail with inline images <zentara@highstream.net>
    Re: some stupid questions about string search & replace (Anno Siegel)
    Re: some stupid questions about string search & replace <raisin@delete-this-trash.mts.net>
    Re: some stupid questions about string search & replace <spam@thecouch.homeip.net>
    Re: SOS! how to do conditional search & replacement of  <spam@thecouch.homeip.net>
        string length? <bobsmith@jippii.fi>
    Re: string length? <glex_nospam@qwest.net>
        Text::Wrap::wrap difference <agw@cs.columbia.edu>
    Re: transforming an explicit range based on implicit ex (Anno Siegel)
    Re: wtf is the deal? (Chris Marshall)
    Re: WWW::Mechanize click() returns "Unexpected field va (Timur Tabi)
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 22 Sep 2003 12:07:03 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: "my" declarations, only matter of taste?
Message-Id: <3f6ed7d7$0$24108$afc38c87@news.easynet.co.uk>

Abigail wrote:
> Eric J. Roode (REMOVEsdnCAPS@comcast.net) wrote on MMMDCLXXIII September
> MCMXCIII in <URL:news:Xns93FD7E031ACEEsdn.comcast@206.127.4.25>:
> //  -----BEGIN xxx SIGNED MESSAGE-----
> //  Hash: SHA1
> //  
> //  Matija Papec <mpapec@yahoo.com> wrote in 
> //  news:bfhrmvgre842llne5rde01ouhmejpr3b2r@4ax.com:
> //  
> // > 
> // > a)
> // > for (1..20) {
> // >   my $mod = $_%3;
> // >   ...
> // > }
> // > 
> // > b)
> // > my $mod;
> // > for (1..20) {
> // >   $mod = $_%3;
> // >   ...
> // > }
> // > 
> // > Let's say we'll need $mod only inside of foreach, so both cases work as
> // > desired but is one more preferred then the other?
> //   
> //  Case (a) limits the scope of $mod to the for loop block.  In general, it 
> //  is good practice to limit the scope of variables as narrowly as possible, 
> //  since you're less likely to use its value by mistake later.  Or, suppose 
> //  you later add a variable $mod in an enclosing outer scope.  With case 
> //  (a), you don't have to worry about stomping on the new variable's value.  
> //  With case (b), you have two variables at the same scope that can 
> //  conflict.
> //  
> //  Case (a) creates a new lexical variable each time through the loop; this 
> //  probably slows the loop down by some microseconds.  That's almost 
> //  certainly inconsequential. 
> 
> 
> Actually, for a small loop that you run many times, it may matter:
> 
>     #!/usr/bin/perl
> 
>     use strict;
>     use warnings;
> 
>     use Benchmark qw /cmpthese/;
> 
>     our $loop = 1000;
> 
>     cmpthese -2 => {
>         inner => '       for (1 .. $::loop) {my $m = $_ % 3}',
>         outer => 'my $m; for (1 .. $::loop) {   $m = $_ % 3}',
>     };
>  
>     __END__
>     Benchmark: running inner, outer for at least 2 CPU seconds...
>          inner:  2 wallclock secs ( 2.04 usr +  0.00 sys =  2.04 CPU)
>                  @ 1982.35/s (n=4044)
>          outer:  2 wallclock secs ( 2.11 usr +  0.00 sys =  2.11 CPU)
>                  @ 2858.77/s (n=6032)
>             Rate inner outer
>     inner 1982/s    --  -31%
>     outer 2859/s   44%    --
> 
> 
> Abigail

Just for completeness there is also

middle => '       for my $m (1 .. $::loop) {   $m = $_ % 3}',

Which I favour which lies between the two.



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

Date: 22 Sep 2003 12:45:55 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: "my" declarations, only matter of taste?
Message-Id: <slrnbmtro3.ckn.abigail@alexandra.abigail.nl>

Peter Hickman (peter@semantico.com) wrote on MMMDCLXXIV September
MCMXCIII in <URL:news:3f6ed7d7$0$24108$afc38c87@news.easynet.co.uk>:
!!  Abigail wrote:
!! > 
!! > Actually, for a small loop that you run many times, it may matter:
!! > 
!! >     #!/usr/bin/perl
!! > 
!! >     use strict;
!! >     use warnings;
!! > 
!! >     use Benchmark qw /cmpthese/;
!! > 
!! >     our $loop = 1000;
!! > 
!! >     cmpthese -2 => {
!! >         inner => '       for (1 .. $::loop) {my $m = $_ % 3}',
!! >         outer => 'my $m; for (1 .. $::loop) {   $m = $_ % 3}',
!! >     };
!! >  
!! >     __END__
!! >     Benchmark: running inner, outer for at least 2 CPU seconds...
!! >          inner:  2 wallclock secs ( 2.04 usr +  0.00 sys =  2.04 CPU)
!! >                  @ 1982.35/s (n=4044)
!! >          outer:  2 wallclock secs ( 2.11 usr +  0.00 sys =  2.11 CPU)
!! >                  @ 2858.77/s (n=6032)
!! >             Rate inner outer
!! >     inner 1982/s    --  -31%
!! >     outer 2859/s   44%    --
!! > 
!! > 
!! > Abigail
!!  
!!  Just for completeness there is also
!!  
!!  middle => '       for my $m (1 .. $::loop) {   $m = $_ % 3}',
!!  
!!  Which I favour which lies between the two.


Well, that's something different. In both inner and outer, $_ iterates
from 1 to $::loop, and $m is derivated from that.  If you make $m the
loop variable, and then do something like $m = $m % 3; in the loop,
you don't have the original value anymore.


Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: Mon, 22 Sep 2003 16:40:29 +0200
From: "David Mills" <mills_nospam_@free.fr>
Subject: Form problems, post method yeilds 0 at end of values
Message-Id: <pan.2003.09.22.14.40.29.44104@free.fr>

First of all hello to the group

I'm relativly new to perl, so if this is a stupid question, I'll accept my
due flaming.

I've written a small script to take user information and insert it into a
database, before creating an account for the user (this is obviously for
internal use only, and has the relevant .htaccess to prevent unorthorised
use).

The problem is that when the form is submitted, I get 0 at the end of each
value field (and by this I mean a hex 0 in the field, I've checked this
with a hex editor).

My question is how to remove these zeros, since they muck up the user
creation and the insertion into the database.

Google has shown up nothing relating to this

I've quoted part of the script below which shows these symptomes


Thanks in advance for your time

David Mills

#!/usr/bin/perl -w
use DBI;
                                                                                
print "Content-type: text/html\n\n";
                                                                                
#get info from form, lifted from http://www.cgi101.com, great site
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
print "$buffer\n";
print "\n";
@pairs = split(/\n/, $buffer);
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
    $FORM{$name} =~ s/\0//eg;
print "$name = $FORM{$name}t<br>";#Puts a 0 between the variable and the t
}



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

Date: Mon, 22 Sep 2003 12:51:31 +0100
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Infra red port data dumper.
Message-Id: <bkmnqn$ovj$1@newshost.mot.com>

Guys,

I have a device that logs data, and has an infra red port on it. I also have
a laptop with a built in infra red port. So, I was hoping to be able to get
the two to talk

I have been playing with Win32::SerialPort, but how do I open the infra red
port under w98?

All I want to do for now is to put the data from the logger into a text file
on the laptop. Can anyone help me out?

Thanks,
-- 
R.
GPLRank +79.699




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

Date: 22 Sep 2003 06:06:10 -0700
From: hand-o-fire@web.de (firehand)
Subject: is there an 'on key' command in perl?
Message-Id: <7cf4f569.0309220506.643e6f95@posting.google.com>

I'm writing a program that takes many <stdin> after each other. All
the inputs are only one charters long (some are two but i can change
them if i habe to). That's why it would make my program work much
faster, if i didn't have to push 'enter' after every input and perl
would just do the next action after i pressed the letter or number. Is
this possible? I know it works in q-basic with a command called 'on
key' so I guess that's what I'm looking for for perl now.

please help me, thanks a lot,

 firehand


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

Date: 22 Sep 2003 13:18:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: is there an 'on key' command in perl?
Message-Id: <bkmsqt$mcj$6@mamenchi.zrz.TU-Berlin.DE>

firehand <hand-o-fire@web.de> wrote in comp.lang.perl.misc:
> I'm writing a program that takes many <stdin> after each other. All
> the inputs are only one charters long (some are two but i can change
> them if i habe to). That's why it would make my program work much
> faster, if i didn't have to push 'enter' after every input and perl
> would just do the next action after i pressed the letter or number. Is
> this possible? I know it works in q-basic with a command called 'on
> key' so I guess that's what I'm looking for for perl now.

Check out the module Term::ReadKey.

Anno


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

Date: Mon, 22 Sep 2003 13:36:48 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: is there an 'on key' command in perl?
Message-Id: <QVCbb.8080$iJ.1937@nwrddc01.gnilink.net>

firehand wrote:
> I'm writing a program that takes many <stdin> after each other. All
> the inputs are only one charters long (some are two but i can change
> them if i habe to).

Please see 'perldoc -q character':
     "How can I read a single character from a file?  From the keyboard?"

jue




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

Date: 22 Sep 2003 11:53:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: killing zombie file lock
Message-Id: <bkmnsh$mcj$3@mamenchi.zrz.TU-Berlin.DE>

Ryan Tate  <ryantate@ryantate.com> wrote in comp.lang.perl.misc:
> I have a perl script that runs reports on a log file. It locks this
> file with
> 
> (flock $fh, LOCK_EX|LOCK_NB) or die "Could not lock file: $!";
> 
> Several days ago I invoked the script via CGI. While my browser was
> still receiving lines from the script, and before it had time to
> finish its run, I hit "Stop" in my browser, presumably before the
> filehandle could close and release the lock. Ever since, the script
> cannot get a new lock on the file. I get the $! error "Resource
> temporarily unavailable." When I remove the lock code from my script,
> it works as it did before.
> 
> So I suspect I have a days-old zombie lock still tying up the file,
> and I want to know how to get rid of it.

Locks don't exist independent of a process.  There must be a process
holding the lock.

> I have tried running the script with LOCK_UN in place of LOCK_EX, but
> I don't think this is what I'm looking for. I have tried ps -u
> myusername at the console and don't see any unusual
> processes to kill.

If it's a CGI process you're looking for, it runs under the user id
the web server is running under.  That may be a different user from
your own.

> I have no idea what the lock file name would be for my platform, SunOS
> 5.8, otherwise I would rm the file manually.

There are no lock files.  Locking is handled by the kernel.

> Anyone have any suggestions?

To make sure no process can still hold a lock, reboot the computer
the web server is running on.

Anno


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

Date: Mon, 22 Sep 2003 15:05:26 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: killing zombie file lock
Message-Id: <66c341-m07.ln1@news.roaima.co.uk>

Ryan Tate <ryantate@ryantate.com> wrote:
> I have a perl script that runs reports on a log file. It locks this
> file with
> (flock $fh, LOCK_EX|LOCK_NB) or die "Could not lock file: $!";

A non-blocking attempt to get an exclusive lock, which aborts the program
if it fails. Unusual (especially given that your introduction implies
read-only access to the log file), but if that's what you want...

> Several days ago I invoked the script via CGI.

Ah, a CGI question...

> Ever since, the script
> cannot get a new lock on the file. I get the $! error "Resource
> temporarily unavailable." When I remove the lock code from my script,
> it works as it did before.

That's because there's another process (still) holding the lock.

> So I suspect I have a days-old zombie lock still tying up the file,
> and I want to know how to get rid of it.

That's OS specific.

> I have tried running the script with LOCK_UN in place of LOCK_EX, but
> I don't think this is what I'm looking for.

LOCK_UN removes a lock that the current process has already applied. You
can't remove someone else's lock.

> I have tried ps -u myusername at the console and don't see any unusual
> processes to kill.

Ah. UNIX. Depending on the complexity of your web server, this may give
you a process id:

	ps -ef | grep YOUR_CGI_PROGRAM_NAME

> I have no idea what the lock file name would be for my platform, SunOS
> 5.8, otherwise I would rm the file manually.

There is no lock file. A lock is applied to a file by the kernel.

I must admit, I'm quite intrigued as to /why/ you think you want an
exclusive lock on a file that you're reading. Is there anything wrong
with LOCK_SH instead?

Cheers,
Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Mon, 22 Sep 2003 12:32:38 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: length of the longest $_ in @_
Message-Id: <bkmq55$vp1$1@troll.powertech.no>

Sam <samj2@austarmetro.com.au> wrote:

> after I search my book and the online hlep. trying to find it there is
> a built-in function to get the length of the longest item in a givin
> array.

No builtin, but it's quite easy to make one (this one's a little
contorted to handle references to arrays):
   
    sub amax(@;\$) { # prototype to make it work like built-in (no parens)
        my $max = 0;
        map { $max = length if $max < length } 
              ref $_[0] eq 'ARRAY' ?  @{$_[0]}  : @_;
        return $max;
    }

    my @ary = qw( one two three four five );

    printf "Max length in array: %d\n", amax @ary;
    printf "Max length in aref : %d\n", amax \@ary;


> length will not do it and scalar @array will not do it.

Nope, length measures the length of a string, and scalar @array returns
number of elements in the array.

> and how would you know if there is a built-in-function for a task you
> want to do? or is it by time-experiance combo?

You have to read about the built-ins and remember them, or look them up:

    perldoc perlfunc

Nice thing is that the functions are categorised. For example, here's
the built-ins that applies to arrays:

       Functions for real @ARRAYs
	   "pop", "push", "shift", "splice", "unshift"

Read and re-read perlfunc.
All experts do it from time to time.

Cheers,
-- 
Vlad



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

Date: Mon, 22 Sep 2003 09:09:01 -0500
From: Barry Kimelman <raisin@delete-this-trash.mts.net>
Subject: Re: length of the longest $_ in @_
Message-Id: <MPG.19d8be73e70233e798968b@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <3F6EB301.6080302@austarmetro.com.au>, samj2
@austarmetro.com.au says...
> Hello .... again :)
> after I search my book and the online hlep. trying to find it there is a 
>   built-in function to get the length of the longest item in a givin 
> array. length will not do it and scalar @array will not do it. I can 
> loop through the array but just wanted to ask if there is a built in 
> function for it. and how would you know if there is a built-in-function 
> for a task you want to do? or is it by time-experiance combo?
> 
> thanks
> 
> 

$maxlen = (sort { $b <=> $a } map { length $_ } @names)[0];


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

Date: 22 Sep 2003 11:29:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Operator Precedence
Message-Id: <bkmmff$mcj$2@mamenchi.zrz.TU-Berlin.DE>

Jeff Mott <mjeff1@twcny.rr.com> wrote in comp.lang.perl.misc:
> Since the assignment operator has higher precedence than comma,
> shouldn't the following line
> 
>     my $s = substr "foo", 0, 1;
> 
> technically be interpreted as
> 
>     (my $s = substr "foo"), 0, 1;
> 
> ?

 ...and then return a syntax error because substr() doesn't have enough
arguments?  Fortunately, that is not how it works.

When Perl sees "substr" it begins to parse for arguments for the
substr function, until it finds a marker (a closing ")" or ";") that
indicates that a complete expression has been parsed.  Only then does
it begin to look for more list elements on the right side, and only
these compete with "=" for precedence.

Anno


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

Date: Mon, 22 Sep 2003 14:34:23 GMT
From: "John Smith" <someone@microsoft.com>
Subject: reading STDIN with Perl on Linux / Apache
Message-Id: <PLDbb.13752$Ej.1997190@ursa-nb00s0.nbnet.nb.ca>

I hope I am not posting this to the wrong group, as it deals with HTML and
PERL.


I had a script that read information from the QUERY_STRING environment
variable, such as:
    $temp=$ENV{'QUERY_STRING'};

It received this information from an HTML document that used the GET method
to send its form data to the perl script, such as:
    <FORM method="get" action="/cgi-bin/script.pl">

This worked fine, but the form data ends up as part of the URL, such as:
    http://domainname/cgi-bin/script.pl?year=2003&pwd=12345

This would not be too bad except that part of the information sent to the
perl script is a password.
I would prefer that this information not be part of the URL.

As it turns out, an HTML document can also use the POST method to send its
form data to a perl script, such as:
    <FORM method="post" action="/cgi-bin/script.pl">

Using this method, the data is apparently sent via the STDIN.
From what I can find on the Internet, a perl script would read this info
something like this:
    read(STDIN, $temp, $CONTENT_LENGTH);

When I submit my form data from the HTML document using the POST method, the
CONTENT_LENGTH environment variable does reflect the amount of information I
am sending, but the read statement doesn't store that data to the $temp
variable, the $temp variable is just empty.

Here is a look at part of my script.

  #!/usr/bin/perl

  use CGI qw(:standard);
  my $query = new CGI;
  print"Content-type: text/html\n\n";

  $cl=$ENV{'CONTENT_LENGTH'};
  if ($cl > 0)
    {
    read(STDIN, $temp, $cl);                   # Read POST data from STDIN
    print" 11.. temp = $temp <br>\n";
    }
  else
    {
    $temp=$ENV{'QUERY_STRING'};                # Get info submitted from
HTML form
    print" 12.. temp = $temp <br>\n";
    }

The script will print the following
    11.. temp=

The server belongs to my ISP.
It's a Linux server with apache (I guess the Apache is for the Perl to work
or something).





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

Date: Mon, 22 Sep 2003 14:35:35 GMT
From: "John Smith" <someone@microsoft.com>
Subject: Re: reading STDIN with Perl on Linux / Apache
Message-Id: <XMDbb.13757$Ej.1996977@ursa-nb00s0.nbnet.nb.ca>

Oops, by the way, my name is not John Smith, it's Guy Doucet :-)




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

Date: Mon, 22 Sep 2003 17:36:59 +0300
From: Bob Smith <bobsmith@jippii.fi>
Subject: Re: reading STDIN with Perl on Linux / Apache
Message-Id: <3F6F090B.494FF9B0@jippii.fi>

John Smith wrote:

> I hope I am not posting this to the wrong group, as it deals with HTML and
> PERL.
>
> I had a script that read information from the QUERY_STRING environment
> variable, such as:
>     $temp=$ENV{'QUERY_STRING'};
>
> It received this information from an HTML document that used the GET method
> to send its form data to the perl script, such as:
>     <FORM method="get" action="/cgi-bin/script.pl">
>
> This worked fine, but the form data ends up as part of the URL, such as:
>     http://domainname/cgi-bin/script.pl?year=2003&pwd=12345
>
> This would not be too bad except that part of the information sent to the
> perl script is a password.
> I would prefer that this information not be part of the URL.
>
> As it turns out, an HTML document can also use the POST method to send its
> form data to a perl script, such as:
>     <FORM method="post" action="/cgi-bin/script.pl">
>
> Using this method, the data is apparently sent via the STDIN.
> From what I can find on the Internet, a perl script would read this info
> something like this:
>     read(STDIN, $temp, $CONTENT_LENGTH);
>
> When I submit my form data from the HTML document using the POST method, the
> CONTENT_LENGTH environment variable does reflect the amount of information I
> am sending, but the read statement doesn't store that data to the $temp
> variable, the $temp variable is just empty.
>
> Here is a look at part of my script.
>
>   #!/usr/bin/perl
>
>   use CGI qw(:standard);
>   my $query = new CGI;

print header;

>
>   print"Content-type: text/html\n\n";
>
>   $cl=$ENV{'CONTENT_LENGTH'};
>   if ($cl > 0)
>     {
>     read(STDIN, $temp, $cl);                   # Read POST data from STDIN

use this:
my $parameter = param('name_of_the_parameter_you_want');
print "parameter value is:$parameter";


>
>     print" 11.. temp = $temp <br>\n";
>     }
>   else
>     {
>     $temp=$ENV{'QUERY_STRING'};                # Get info submitted from
> HTML form
>     print" 12.. temp = $temp <br>\n";
>     }
>
> The script will print the following
>     11.. temp=
>
> The server belongs to my ISP.
> It's a Linux server with apache (I guess the Apache is for the Perl to work
> or something).



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

Date: Mon, 22 Sep 2003 15:03:54 GMT
From: "John Smith" <someone@microsoft.com>
Subject: Re: reading STDIN with Perl on Linux / Apache
Message-Id: <ubEbb.13779$Ej.1998814@ursa-nb00s0.nbnet.nb.ca>

Well, as it turns out, it appears to work for some reason!
What I don't understand is why.
I don't even have to read the STDIN such as:
    read(STDIN, $temp, $ENV{'CONTENT_LENGTH'});

So does Apache or something else automatically assign the STDIN parameters
to param?
I guess it's not that important if it works!

Thanks for all,
Guy Doucet

> use this:
> my $parameter = param('name_of_the_parameter_you_want');
> print "parameter value is:$parameter";




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

Date: Mon, 22 Sep 2003 14:03:50 +0200
From: Michael Heiming <michael+USENET@www.heiming.de>
Subject: Rebuilding module list for CPAN
Message-Id: <6fomkb.qg2.ln@news.heiming.de>

Hi!

I have mirrored CPAN locally, which works great.

The question, how can I rebuild modlist.data.tar.gz
and alike, if I put other/own modules in the
CPAN tree.

Searched google and the docs that came with CPAN,
but I couldn't find any info, how to proceed?

Thx for reading

-- 
Michael Heiming

Remove +SIGNS and www. if you expect an answer, sorry for 
inconvenience, but I get tons of SPAM


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

Date: Mon, 22 Sep 2003 09:41:08 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Sending html mail with inline images
Message-Id: <3outmvg5lsp00fhkhv69i2bhv9v9oehgqp@4ax.com>

On Sun, 21 Sep 2003 23:17:57 +0200, "Sebastian Scholz"
<mcbass@lightsphere.de> wrote:

>Thanks, but MIME::Lite does not seem to be enable me to login onto the smtp
>server as I can with Mail::Sender ..... or am I wrong ?
>
>Sebastian

I don't know about using Mail::Sender with MIME::Lite, but the point is
if you use the ID and cid tags as shown in the example, your original
script can be made to work with MIME::Lite.

The ID and cid tags are part of the html mail specifications, and are
not part of MIME::Lite.  You just need to tag the image with ID and a
name, then in the html refer to the image with the cid: tag.  The cid
tag tells the html to look for the image as an attached document.


Our body's 20 milligrams of beta radioactive Potassium 40
emit about 340 million neutrinos per day, which go at
lightspeed to the ends of the universe!..even thru the earth. 


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

Date: 22 Sep 2003 12:50:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <bkmr64$mcj$5@mamenchi.zrz.TU-Berlin.DE>

walala <mizhael@yahoo.com> wrote in comp.lang.perl.misc:
> Daer John,
> 
> sorry, for that problem 3, I guess what I want is to remove the "\" at the
> end of each line and add a "+" to the beginning of the next line(not the
> front of that line, but next line)...
> 
> Can you statement still do the work?
> 
> Thanks a lot,
> 
> -Walala

This is the third answer to your original query that you have answered with
that very same canned reply, requesting that the author adapt their solution
to different requirements.  Where is *your* effort to adapt the suggestions?

This is not how a Usenet dialog works.  And don't top-post.

Anno

[TOFU snipped]



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

Date: Mon, 22 Sep 2003 09:05:41 -0500
From: Barry Kimelman <raisin@delete-this-trash.mts.net>
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <MPG.19d8bdae2335016898968a@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <bkkpmq$5nc$1@mozo.cc.purdue.edu>, mizhael@yahoo.com says...
> Dear all,
> 
> I have been learning Perl for several days by reading online tutorials...
> now when I really need it to some serious work, I found I still have a bunch
> of questions:
> 
> 1. How to make a string all to "UPPER CASE"?
     $string = uc $string;
> 
> 2. Suppose there is a "(" (bracket character) in the string $str, and I want
> to remove it, how can I do that?
     $string =~ s/\(//g;  # remove all "(" from $string
> 
> 3. Suppose there are two lines in my text file:
> 
> M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6 \
> AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6 \
> PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> 
> I want to change the "\ ^n" ( The "\" plus an "LF" at the end of each line)
> to "^n +" (first do an "LF", then add a "+" to the front of each line)
> 
> The result is:
> 
> M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
> +AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
> +PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
> 
> How can I do that?
> 
> Thanks a lot,
> 
> -Walala
> 
> 
> 


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

Date: Mon, 22 Sep 2003 10:19:37 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: some stupid questions about string search & replace in perl
Message-Id: <3yDbb.33526$dp6.774659@weber.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

walala wrote:

[Your writing relocated _AGAIN_ because it was posted on top. Please see 
http://www.caliburn.nl/topposting.html for what that means]

>>walala wrote:
>>>>>3. Suppose there are two lines in my text file:
>>>>>
>>>>>M1834 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6 \
>>>>>AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
> 
> \
> 
>>>>>PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
>>>>>
>>>>>I want to change the "\ ^n" ( The "\" plus an "LF" at the end of each
>>>
>>>line)
>>>
>>>
>>>>>to "^n +" (first do an "LF", then add a "+" to the front of each line)
>>>>
>>>>$data =~ s/\\\n/\n+/g;
>>>>
>>>>See perldoc perlop
>>>>
>>
>> >
>> > Dear Mina,
>> >
>> > sorry, for that problem 3, I guess what I want is to remove the "\" at
> 
> the
> 
>> > end of each line and add a "+" to the beginning of the next line(not
> 
> the
> 
>> > front of that line, but next line)...
>> >
>> > Can you statement still do the work?
>>
>>Assuming that the whole chunk of data is in $data, yes.
 > Mina,
 >
 > I guess our program should only read line-by-line... The reason is that I am
 > going to use this program run on a big input file which is 15MByte in
 > size... can I take in the whole chunk of data all at once?

Unless you're working on embedded systems (in which case Perl might not be your best option) then 
15MBytes of text isn't that big.

Besides, even if you do read it in line-by-line, since it's a text file you can't do direct 
modifications to it, which means you'll need a temporary holder (memory or a temp file) to hold your 
results before overwriting the original.

So I would suggest you read the whole file in memory, try the regex I gave you, the write it back to 
the file.

And to answer your question, yes, there are several ways to read the whole file in memory.  A good 
Perl book would show you a few.

Here are some:


while (<FH>) {
	$data .= $_;
}

# or

$data = join("", <FH>);

# or

{
	local $/ = "";
	$data = <FH>;
}

# and a few others.

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/bwT/eS99pGMif6wRAn/5AJ40EaaEO9s6Ey6XU0WAVuQ/jfb1eQCdEmBk
fEnYqKjepNpga3OflqEYU5c=
=xuRT
-----END PGP SIGNATURE-----



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

Date: Mon, 22 Sep 2003 10:30:55 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: SOS! how to do conditional search & replacement of strings in perl?
Message-Id: <CIDbb.33750$dp6.776357@weber.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

John W. Krahn wrote:
> walala wrote:
> 
>>Suppose I want to do conditional search & replacement:
>>
>>I have the following input text file:
>>-------------------------------------------------------------------
>>_INST1832 B_1 59  135.301588688164E-18 M=1.0
>>
>>_INST1833 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
>>+AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
>>+PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
>>-------------------------------------------------------------------
>>
>>I want to change the "_INST" in the lines where there is no "PCH" or "NCH"
>>patterns to "C", and change the "_INST" in the lines where there is "PCH" or
>>"NCH" to "M".
>>
>>The result should be:
>>-------------------------------------------------------------------
>>C1832 B_1 59  135.301588688164E-18 M=1.0
>>
>>M1833 S_4 47 52 VDD!  PCH  L=239.99999143598E-9 W=3.99999998990097E-6
>>+AD=2.04320002757108E-12 AS=1.58200004745507E-12 PD=5.36000015927129E-6
>>+PS=829.999976303952E-9 NRD=+2.50000001E-01 NRS=+2.50000001E-01 M=1.0
>>-------------------------------------------------------------------
>>
>>What do I do? Can you give me the right "regular expression" which can do
>>such thing?
> 
> 
> 
> perl -pe'/PCH|NCH/ ? s/^_INST/M/ : s/^_INST/C/' yourfile

Or with a hint of evil obfuscation ;)

perl -pe 's#^_INST# /[PN]CH/ ? "M" : "C" #e' yourfile


-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/bweieS99pGMif6wRAs5QAJ9loH3W2db0iE2AQ3+5+Br/Ghvh/wCfcp5P
aZcZXvivxYcCGA6dVYrBfb8=
=zV3t
-----END PGP SIGNATURE-----



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

Date: Mon, 22 Sep 2003 17:50:21 +0300
From: Bob Smith <bobsmith@jippii.fi>
Subject: string length?
Message-Id: <3F6F0C2D.20514EE8@jippii.fi>

how do I get the string length of a string?
/B



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

Date: Mon, 22 Sep 2003 10:01:48 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: string length?
Message-Id: <d7Ebb.11$EK2.32696@news.uswest.net>

Bob Smith wrote:
> how do I get the string length of a string?


perldoc -f length



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

Date: 22 Sep 2003 10:36:47 -0400
From: Art Werschulz <agw@cs.columbia.edu>
Subject: Text::Wrap::wrap difference
Message-Id: <ylafzioopog.fsf@sobolev.cs.columbia.edu>

Hi.

I have moved from a Solaris box (running perl 5.6.0) to an Intel Linux
box (running perl 5.8.0).

I have a script that processes msgs I get from certain mailing lists
(which procmail kindly puts into files for me).  It wordwraps the msgs
(since some of them have ridiculously long lines) and replaces certain
encoded chars by their plain text equivalents.  It looks like this

%<------%<--%<--%<---cut here---%<--%<--%<----------------------------
use Text::Wrap;

$Text::Wrap::columns = 79;

while (<>) {
    s/\c]/\"/g;
    s/\cA//g;
    s/\cS/--/g;
    s/\cY/\'/g;
    s/=$//;
    s/=20//;
    s/=85/.../g;
    s/=91/\'/g;
    s/=92/\'/g;
    s/=93/\"/g;
    s/=94/\"/g;
    s/=96/--/g;
    s/\205/.../g;
    s/\221/\'/g;
    s/\222/\'/g;
    s/\223/\"/g;
    s/\224/\"/g;
    s/\226/--/g;
    s/\227/.../g;
    s/\255/--/g;
    $_ = wrap("", "", $_) unless /^[^\s]+:\s/;
    print $_;
}
%<------%<--%<--%<---cut here---%<--%<--%<----------------------------

I want blank lines to remain in the text.  When running this script on
the Solaris box, the blank lines are maintained.  However, they
disappear if I run this script on the Linux box.

Why the difference between these platforms?  Has something changed
between versions 5.6 and 5.8?  

I would appreciate suggestions for making this work on the Linux box.

Thanks. 

-- 
Art Werschulz (8-{)}   "Metaphors be with you."  -- bumper sticker
GCS/M (GAT): d? -p+ c++ l u+(-) e--- m* s n+ h f g+ w+ t++ r- y? 
Internet: agw@cs.columbia.edu<a href="http://www.cs.columbia.edu/~agw/">WWW</a>
ATTnet:   Columbia U. (212) 939-7060, Fordham U. (212) 636-6325


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

Date: 22 Sep 2003 11:13:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: transforming an explicit range based on implicit exceptions
Message-Id: <bkmlgu$mcj$1@mamenchi.zrz.TU-Berlin.DE>

YAPoster <yaposter@yahoo.com> wrote in comp.lang.perl.misc:
> i have this problem:
> i have an explit range, say:
> 
> $range = "1-1000";
> and implicit exceptions to it, say:
> $excepts = "3,5-7,12,14,16-18..."
> how do i convert $range into:
> 
> $newrange = "1,2,8-11,13,15,19..."
> 
> with efficiency in time and processing at a premium.

One candidate for your benchmarks is Bit::Vector.  Using a size of
20 instead of 1000:

    use Bit::Vector;

    use constant SIZE => 20;
    my $excepts = "3,5-7,12,14,16-18";

    my $v = Bit::Vector->new( SIZE);
    $v->Fill;                                        # set all bits
    my $ex = Bit::Vector->new_Enum( SIZE, $excepts); # set exception bits
    my $w = Bit::Vector->new( SIZE);
    $w->Difference( $v, $ex);                        # clear exceptions
    print $w->to_Enum, "\n";                         # generate string


Like mostly in Perl, Bit::Vector counts from 0, so the printed result
is "0-2,4,8-11,13,15,19", not "1,2,8-11,13,15,19...".

Anno


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

Date: 22 Sep 2003 05:52:28 -0700
From: c_j_marshall@hotmail.com (Chris Marshall)
Subject: Re: wtf is the deal?
Message-Id: <cb9c7b76.0309220452.5ce8401d@posting.google.com>

"Tom" <tom@nosleep.net> wrote in message news:<3f6df2e6$1@nntp0.pdx.net>...
> > If you travelled to Britain, would you insist on driving on the
> > right-hand side of the road?  After all, it's just a convention, and
> > those silly Brits will surely see the light after you show them how
> > to drive properly.  What would actually happen, though, is that
> > everyone would honk at you and you would cause a wreck.
> 
> Lol, are you kidding, those Brits are all nuts when it comes to driving,
> regardless of what side of the road it is :)
> 
> I take a taxi when I'm there...

oh yeah - that's the way to see Brits driving at their most refined
and respectful :)

Besides there's a perfectly good reason to travel on the left
(presenting your swordarm to the approaching person) - where did right
hand side driving come from ?


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

Date: 22 Sep 2003 08:01:36 -0700
From: nospam_timur@tabi.org (Timur Tabi)
Subject: Re: WWW::Mechanize click() returns "Unexpected field value"
Message-Id: <53bb806a.0309220701.4c45d904@posting.google.com>

Bart Lateur <bart.lateur@pandora.be> wrote in message news:<20cpmvgc2esnpcsp502i262v62mhmfmod4@4ax.com>...
> Timur Tabi wrote:
> 
> >A friend of mine wrote a Perl script that works fine on his machine
> >but dies on mine.  I know very little about Perl, so I need help in
> >determining the problem. 
> 
> Are you behind a fierwall? Do you need to use a proxy? If so, set the
> HTTP_PROXY environment variable, format

My friend and I are in the same subnet, and we're not behind a
firewall.  Regardless, neither he nor I have the HTTP_PROXY variable
set.

Besides, I know that can't be the problem.  The WWW::Mechanize get()
command works just fine.  It's the click() command that doesn't work.

BTW, I want to thank you for trying to solve my problem.  All of the
other replies I received were flames because I was trying to ask for
help.  Apparently, I'm not supposed to do that here.


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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


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