[22680] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4901 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 27 14:05:55 2003

Date: Sun, 27 Apr 2003 11:05:08 -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           Sun, 27 Apr 2003     Volume: 10 Number: 4901

Today's topics:
    Re: "make tardist" does not include subdirectories (Anno Siegel)
        Can Perl enter data into web page form fields?  "Fake"  <SeeMessageBody@nospam.com>
    Re: Can Perl enter data into web page form fields?  "Fa <wsegrave@mindspring.com>
        Can't load 'C:/cygwin/lib/perl5/site_perl/5.6.1/cygwin- (IKNIR)
    Re: Conditional use of perl modules <usenet@tinita.de>
        Convert Shift-JIS codepage to CJK <schmidt.2002@gmx.de>
    Re: Convert Shift-JIS codepage to CJK <jurgenex@hotmail.com>
        Dates (PeterReid)
    Re: Dates <dorward@yahoo.com>
    Re: Dates <nobody@dev.null>
    Re: Extracting line from file (Anno Siegel)
    Re: Extracting line from file <tom @ abwaerts . be>
    Re: Find and replace a block of lines with PERL <aschiano@redesdelsur.com>
    Re: Isolating Sentences (Not Lines) With Regex <nobody@dev.null>
    Re: Parsing HTML pages... best way out of the dozens of <nerdy1@snet.net>
        perl hash - help request (shree)
    Re: perl hash - help request <jkeen@concentric.net>
    Re: perl hash - help request <mbudash@sonic.net>
        pod-mode.el for (X)Emacs <schwigon@webit.de>
    Re: Regex greediness question (Anno Siegel)
        Running a perl script (LondonDeveloper)
    Re: Running a perl script <nobody@dev.null>
        Style: Using 'no warnings' in a module <jaspax@u.washington.edu>
    Re: Style: Using 'no warnings' in a module <jkeen@concentric.net>
    Re: Style: Using 'no warnings' in a module <mjcarman@mchsi.com>
        Test::Harness annoyance <kalinabears@hdc.com.au>
    Re: Test::Harness annoyance <jkeen@concentric.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 27 Apr 2003 13:56:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: "make tardist" does not include subdirectories
Message-Id: <b8gnj5$4s$1@mamenchi.zrz.TU-Berlin.DE>

peter pilsl  <pilsl_usenet@goldfisch.at> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> 
> > 
> > Have you re-run "perl Makefile.PL" after adding the additional modules?
> > That should fix it.
> > 
> 
> yep - I tried this several times. It didnt fix the issue. I had to change 
> the MANIFEST-file like Janek suggested.

Ah, but once you have an up-to-date Makefile you can create the MANIFEST
with "make manifest".  (You may want to adapt MANIFEST.SKIP first.)  I
must have imagined that was included in "make dist".

Anno


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

Date: Sun, 27 Apr 2003 17:21:21 GMT
From: "John" <SeeMessageBody@nospam.com>
Subject: Can Perl enter data into web page form fields?  "Fake" key strokes?
Message-Id: <lkUqa.42604$ey1.3967699@newsread1.prod.itd.earthlink.net>

Anybody know a way to get Perl to enter data into fields on a web page form?

Related:  anyone know a way to get Perl to simulate key strokes?
Net::Telnet works great for this on a remote host, entering commands and
trapping the output, but can one do it on the local machine?  (As usual, I
get the hard part figured out and can't do the easy part.  LOL)

Aside:  Having fun with LWP::Simple; it gets web pages for me.  Curious:
what does LWP stand for?

--
------------------------------------------------
Feel free to mail me:  workingstiff19
 ...and that's at hotmail.





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

Date: Sun, 27 Apr 2003 12:57:15 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Can Perl enter data into web page form fields?  "Fake" key strokes?
Message-Id: <b8h5ue$6di$1@slb5.atl.mindspring.net>

"John" <SeeMessageBody@nospam.com> wrote in message
news:lkUqa.42604$ey1.3967699@newsread1.prod.itd.earthlink.net...
> Anybody know a way to get Perl to enter data into fields on a web page
form?

See restore_parameters in the CGI.pm documentation.

Bill Segraves




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

Date: 27 Apr 2003 08:33:57 -0700
From: as400tips@lycos.com (IKNIR)
Subject: Can't load 'C:/cygwin/lib/perl5/site_perl/5.6.1/cygwin-multi/auto/DBD/Pg/Pg.dll'
Message-Id: <204f0ba7.0304270733.6a553a50@posting.google.com>

I am struggling with the DBD-Pg installation almost 3 weeks. Please
somebody out there could help me. Thank you in advance.

I have installed the following on WINDOWS XP:
CYGWIN
POSTGRESQL 7.3.1
APACHE 2.0.43
ACTIVESTATE PERL 5.8
DBI 1.35 (Installed using cygwin)
DBD-Pg 1.22 (Installed using cygwin perl makefile.pl, make, make test,
and make install)
 
I have no problem in running the following script in CYGWIN:

#!/perl/bin/perl -w
BEGIN {
  push(@INC, 'C:/cygwin/lib/perl5/site_perl/5.6.1/cygwin-multi');
}
use DBI;
use DBD::Pg;
print "Content-type: text/html\n\n";
print "hi";
 
However, I cannot run this using the browser. I get the following
error.
 
Can't load 'C:/cygwin/lib/perl5/site_perl/5.6.1/cygwin-multi/auto/DBD/Pg/Pg.dll'
for module DBD::Pg:load_file:The specified module could not be found
at C:/Perl/lib/DynaLoader.pm line 229.

What am I doing wrong? Why this works in CYGWIN but not in browser?


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

Date: 27 Apr 2003 15:35:18 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Conditional use of perl modules
Message-Id: <tinhe0e10$1ms$tina@news01.tinita.de>

012 <motis@lyciumnetworks.com> wrote:

> I'm using a script which can work in both UNIX and Windows. In case I use
> Windows OS, I have additional features in the script for handling Excel
> files. For that I should use the following modules:

put these lines around the use-statements:
if ($cond) {
  eval <<EOM;
	
> use Win32::OLE qw(in with);
> use Win32::OLE::Const 'Microsoft Excel';
> use Win32::OLE::Variant;
> use Win32::OLE::NLS qw(:LOCALE :DATE);

EOM
}
hth, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: Sun, 27 Apr 2003 15:15:54 +0200
From: Andreas Schmidt <schmidt.2002@gmx.de>
Subject: Convert Shift-JIS codepage to CJK
Message-Id: <20030427151554.3a7877bd.schmidt.2002@gmx.de>

Hi,

I have a Japanese word list in Shift-JIS encoding. Since I want to
embed the words in a LaTeX file, I have to use CJK encoding rather. 

Is there a perl tool that converts between Shift-JIS and CJK encoding?
(I know there is an Emacs module, but I need a perl script)

Thanks!
Andi


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

Date: Sun, 27 Apr 2003 13:47:48 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Convert Shift-JIS codepage to CJK
Message-Id: <8cRqa.8110$B61.5613@nwrddc01.gnilink.net>

Andreas Schmidt wrote:
> Hi,
>
> I have a Japanese word list in Shift-JIS encoding. Since I want to
> embed the words in a LaTeX file, I have to use CJK encoding rather.
>
> Is there a perl tool that converts between Shift-JIS and CJK encoding?

Text::Iconv should be able to help you.

jue




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

Date: 27 Apr 2003 07:23:10 -0700
From: peter.reid2000@ntlworld.com (PeterReid)
Subject: Dates
Message-Id: <71780191.0304270623.2b2c3348@posting.google.com>

Hi,

I have a date in DD/MM/YYYY format and I would like to know how to
work out how long ago in the past it was in years and months. Any
ideas?

Thanks,

Pete


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

Date: Sun, 27 Apr 2003 15:33:42 +0100
From: David Dorward <dorward@yahoo.com>
Subject: Re: Dates
Message-Id: <b8gpov$3sa$2$830fa79d@news.demon.co.uk>

PeterReid wrote:

> I have a date in DD/MM/YYYY format and I would like to know how to
> work out how long ago in the past it was in years and months. Any
> ideas?

Look at the Date::Manip module.

-- 
David Dorward                                     http://david.us-lot.org/
         Redesign in progress: http://stone.thecoreworlds.net/
2 and 5 are objects, as opposed to Java, where they are primitive thingies.


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

Date: Sun, 27 Apr 2003 14:35:21 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Dates
Message-Id: <3EABEA73.8030103@dev.null>



PeterReid wrote:

> Hi,
> 
> I have a date in DD/MM/YYYY format and I would like to know how to
> work out how long ago in the past it was in years and months. Any
> ideas?
> 
> Thanks,
> 
> Pete
> 

This is a FAQ:


Found in C:\usr\lib\pod\perlfaq4.pod
   How can I compare two dates and find the difference?

If you're storing your dates as epoch seconds then simply
subtract one from the other. If you've got a structured date
(distinct year, day, month, hour, minute, seconds values), then
for reasons of accessibility, simplicity, and efficiency, merely
use either timelocal or timegm (from the Time::Local module in
the standard distribution) to reduce structured dates to epoch
seconds. However, if you don't know the precise format of your
dates, then you should probably use either of the Date::Manip
and Date::Calc modules from CPAN before you go hacking up your
own parsing routine to handle arbitrary date formats.



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

Date: 27 Apr 2003 15:01:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Extracting line from file
Message-Id: <b8grbd$31g$1@mamenchi.zrz.TU-Berlin.DE>

Tom  <tom@abwaerts.be> wrote in comp.lang.perl.misc:
> Hey ho,
> 
> I downloaded an xmms' plugin, which creates a fifo in /tmp, called
> xmms-info. It goes like this:
> 
> [14:28][tom][~] $ cat /tmp/xmms-info
> XMMS protocol version: 2467
> InfoPipe Plugin version: 1.3
> Status: Playing
> Tunes in playlist: 1037
> Currently playing: 624
> uSecPosition: 99430
> Position: 1:39
> uSecTime: 309706
> Time: 5:09
> Current bitrate: 299251
> Sampling Frequency: 44100
> Channels: 2
> Title: Orphx - Mother Tongue (ogg)
> File: /home/tom/mp3s/Orphx*Mother_Tongue.ogg
> [14:29][tom][~] $
> 
> Now I wanted to extract the title of the track currently being played to
> print it in my .signature, thus the line starting with "Title: without
> that very "Title: " part. With a lot of help from more, ehm, proficient
> Perl-users, I managed to get something like this:
> 
> #!/usr/bin/perl;
> use warnings;
> 
> $bestandje = "/tmp/xmms-info";
> if (-e $bestandje) {
>         open(BLEH,"cat /tmp/xmms-info|");

This is a roundabout way of reading a file.  Open the file directly, and
take care of possible errors.

>         while (<BLEH>) {
>                 if (/^Title:\b(.*$)/) {
                              ^^
Well, that doesn't match your data.  There is no word-boundary directly
following "Title:", what follows is a blank.  Use "\s+" (one or more
spaces) instead and it will match.

>                         print $1;
>                 } else {
>                         print "Something must be wrong...\n";

You print this each time a line is found that is not the "Title:" line.
No wonder you see a lot of them.

>                 }
>         }
>         close(BLEH);
> } else {
>         print "No music is currently being played.\n";
> }
> 
> When no music is playing, the correct message is printed. However, when
> I *am* listening to some music, it's not the title that gets displayed,
> but the line reporting that something's wrong. Moreover, that very line
> gets printed as much times as there are lines in the xmms-info file...
> 
> Could someone please enlighten me? 

You need to catch the title in the loop over BLEH and decide if you
have found one only afterwards.  About like this (untested)

    unless ( -e $bestandje ) {
        print "No music is currently being played.\n";
        exit; # or whatever
    }
    my $title;
    if ( open BLEH, '/tmp/xmms-info' ) {
        while ( <BLEH> ) {
            $title = $1 if /^Title:\s+(.*$)/;
        }
    }
    if ( defined $title ) {
        print "$title\n";
    } else {
        print "Something must be wrong...\n";
    }

Anno


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

Date: Sun, 27 Apr 2003 17:21:20 +0200
From: Tom <tom @ abwaerts . be>
Subject: Re: Extracting line from file
Message-Id: <1391833.zjRMUFW8jU@abwaerts.be>

[Sunday 27 April 2003 17:01] Anno Siegel in comp.lang.perl.misc:

<explanation cut>

I'll look into it.

Thanks a lot!
Tom

-- 
http://%77%77%77%2E%61%62%77%61%65%72%74%73%2E%62%65%2F/
ICQ 303884489
JBR kaiser_der_Mongolei@amessage.be
MSN tom@abwaerts.be


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

Date: Sun, 27 Apr 2003 12:44:22 -0300
From: "Alberto Adrián Schiano" <aschiano@redesdelsur.com>
Subject: Re: Find and replace a block of lines with PERL
Message-Id: <b8gtsb$9jdl8$1@ID-107944.news.dfncis.de>

Couldn't you read 3 lines instead of only one?
Then, your replacement would happen on the 3 lines. I mean, increment the
reading by one line, but every time, read 3 lines of text. Beter done if you
load everything in memory before doing the replacement...
"KP" <kunal.patel@motorola.com> escribió en el mensaje
news:b58ef5$ne8$1@newshost.mot.com...




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

Date: Sun, 27 Apr 2003 14:27:42 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Isolating Sentences (Not Lines) With Regex
Message-Id: <3EABE8A7.6040908@dev.null>



Tad McClellan wrote:

> Andras Malatinszky <nobody@dev.null> wrote:
> 
>>Scott Edward Skinner wrote:
>>
>>
>>>Although I'm doing this project in Java, 
>>>
> 
>>trying Text::Autoformat.
>>
> 
> 
> I don't think it will work from Java.  :-)
> 



I think the OP made it clear that he was not expecting to get Java code out of a Perl NG. He was looking for ideas, and looking at Perl code that achieves the goal he is trying to achieve in Java is likely to be helpful.



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

Date: Sun, 27 Apr 2003 14:23:15 GMT
From: "Tman" <nerdy1@snet.net>
Subject: Re: Parsing HTML pages... best way out of the dozens of options?
Message-Id: <nJRqa.2057$Ev1.492211266@newssvr10.news.prodigy.com>


"Greg" <greg@hassan.com> wrote in message
news:3EAAD4EA.6010701@hassan.com...
> Tman wrote:
> Seems like a simple funciton to split the page on table and
> /table will find your table.  Then you can split on </td> and
> </tr> and return the data in an array if you like.  Not sure
> why you need a library.

But I need a more robust solution than this...
- it breaks with a nested table.  nested tables are pretty common to arrange
layout.
- it breaks if you have the word table anywhere within your page (although
this could be fixed i think by splitting on <table and </table...

T





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

Date: 27 Apr 2003 07:50:45 -0700
From: srigowrisn@hotmail.com (shree)
Subject: perl hash - help request
Message-Id: <49b5740e.0304270650.20d8bf5b@posting.google.com>

I'm a novice perl programmer and run into difficulties in writing code
that involves hash and am hoping that someone can guide me with a
snipett. Any help/guidance will be greatly appreciated. Thanks

I have log file of dates in MM/DD/YYYY format that looks like this and
would like to extract totals of each type for each month

Input Log File
ID	Submitted	Required	Implemented
1	02/16/2003	02/20/2003	02/21/2003
2	02/22/2003	02/24/2003	03/04/2003
3	03/05/2003	03/06/2003	03/10/2003
4	03/05/2003	03/15/2003	03/10/2003
5	03/07/2003	03/10/2003	03/11/2003
6	04/04/2003	04/05/2003	04/07/2003
7	04/08/2003	04/12/2003	04/12/2003

Desired Output File (Totals of each type per month)
Month	Tot_Sub	Tot_Req	Tot_Impl
Feb 2003	2	2	1
Mar 2003	3	3	4
Apr 2003	2	2	2

Note that in each row, Submitted date will always be the earliest. It
would be nice (if possible), to provide overall totals of target
completion. i.e.
No. of ID completed ahead of time:	1
No. of ID completed on time: 1
No. of ID completed later than requested time: 5

Thanks in advance,
Shree


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

Date: 27 Apr 2003 15:17:11 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: perl hash - help request
Message-Id: <b8gs9n$nav@dispatch.concentric.net>


"shree" <srigowrisn@hotmail.com> wrote in message
news:49b5740e.0304270650.20d8bf5b@posting.google.com...
> I'm a novice perl programmer and run into difficulties in writing code
> that involves hash and am hoping that someone can guide me with a
> snipett. Any help/guidance will be greatly appreciated. Thanks
>
> I have log file of dates in MM/DD/YYYY format that looks like this and
> would like to extract totals of each type for each month
>
> Input Log File
> ID Submitted Required Implemented
> 1 02/16/2003 02/20/2003 02/21/2003
> 2 02/22/2003 02/24/2003 03/04/2003
> 3 03/05/2003 03/06/2003 03/10/2003
> 4 03/05/2003 03/15/2003 03/10/2003
> 5 03/07/2003 03/10/2003 03/11/2003
> 6 04/04/2003 04/05/2003 04/07/2003
> 7 04/08/2003 04/12/2003 04/12/2003

If the data is as consistent as the above, then you should:
1.  split each line on the whitespace
2.  assign results to a hash of arrays using 'ID' as key
2a.  or if all IDs are numeric, to an array of arrays using 'ID' as each
element's index (leaving element 0 blank)
3.  Then split each date on the / , rearrange the results into a string in
YYYYMMDD order.  At this point the numeric, alphabetical and Perl's default
ASCII-betical sort are equivalent.
>
> Desired Output File (Totals of each type per month)
> Month Tot_Sub Tot_Req Tot_Impl
> Feb 2003 2 2 1
> Mar 2003 3 3 4
> Apr 2003 2 2 2
>
4.  Then compare the dates to determine whether Implemented <= Required or
not.  Assign results to a hash of arrays where month is element's key.  You
can take it from there.

Jim Keenan




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

Date: Sun, 27 Apr 2003 17:15:58 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: perl hash - help request
Message-Id: <mbudash-37CEC7.10155727042003@typhoon.sonic.net>

In article <49b5740e.0304270650.20d8bf5b@posting.google.com>,
 srigowrisn@hotmail.com (shree) wrote:

> I'm a novice perl programmer and run into difficulties in writing code
> that involves hash and am hoping that someone can guide me with a
> snipett. Any help/guidance will be greatly appreciated. Thanks
> 
> I have log file of dates in MM/DD/YYYY format that looks like this and
> would like to extract totals of each type for each month
> 
> Input Log File
> ID	Submitted	Required	Implemented
> 1	02/16/2003	02/20/2003	02/21/2003
> 2	02/22/2003	02/24/2003	03/04/2003
> 3	03/05/2003	03/06/2003	03/10/2003
> 4	03/05/2003	03/15/2003	03/10/2003
> 5	03/07/2003	03/10/2003	03/11/2003
> 6	04/04/2003	04/05/2003	04/07/2003
> 7	04/08/2003	04/12/2003	04/12/2003
> 
> Desired Output File (Totals of each type per month)
> Month	Tot_Sub	Tot_Req	Tot_Impl
> Feb 2003	2	2	1
> Mar 2003	3	3	4
> Apr 2003	2	2	2
> 
> Note that in each row, Submitted date will always be the earliest. It
> would be nice (if possible), to provide overall totals of target
> completion. i.e.
> No. of ID completed ahead of time:	1
> No. of ID completed on time: 1
> No. of ID completed later than requested time: 5
> 
> Thanks in advance,
> Shree

one way:

#------------------
use strict;

my @months = qw/Jan Feb Mar
                Apr May Jun
                Jul Aug Sep
                Oct Nov Dec/;
my (%all, %sub, %req, %imp, $early, $on, $late);

open (D, 'thedata');
while(<D>) {
        chomp;
        my (undef, $s, $r, $i) = split /\s+/;

        my ($sm, undef, $sy) = split /\//, $s;
        $all{"$sy-$sm"} = 1;
        $sub{"$sy-$sm"}++;

        my ($rm, $rd, $ry) = split /\//, $r;
        $all{"$ry-$rm"} = 1;
        $req{"$ry-$rm"}++;

        my ($im, $id, $iy) = split /\//, $i;
        $all{"$iy-$im"} = 1;
        $imp{"$iy-$im"}++;

        $early++ if ("$iy$im$id" lt "$ry$rm$rd");
        $on++    if ("$iy$im$id" eq "$ry$rm$rd");
        $late++  if ("$iy$im$id" gt "$ry$rm$rd");
}

foreach (sort keys %all) {
        my ($y, $m) = split /-/;
        $m = $months[$m-1];
        printf ("$m $y\t%0d\t%0d\t%0d\n", $sub{$_}, $req{$_}, $imp{$_});
}

print qq|
No. of ID completed ahead of time: $early
No. of ID completed on time: $on
No. of ID completed later than requested time: $late
|;

#------------------

hth-

-- 
Michael Budash


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

Date: Sun, 27 Apr 2003 14:03:13 GMT
From: Steffen Schwigon <schwigon@webit.de>
Subject: pod-mode.el for (X)Emacs
Message-Id: <b7eb2c767c16e828e57483b1e618d3a7@TeraNews>

Hi!

I have written a small major mode for editing .pod files in (X)Emacs.
Currently it mainly defines regexes for font-lock-mode highlighting.

You can find it here:

  http://search.cpan.org/author/SCHWIGON/pod-mode-0.1/

Usage:

 ;;; Put the file pod-mode.el into your load-path 
 ;;; and the following lines into your ~/.emacs:

 (require 'pod-mode)
 (setq auto-mode-alist
    (append auto-mode-alist
      '(("\\.pod$" . pod-mode))))
 (add-hook 'pod-mode-hook 'font-lock-mode)

Tested on XEmacs 21.4 and GNU Emacs 21.2.1.

Steffen
-- 
Steffen Schwigon <schwigon@webit.de>




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

Date: 27 Apr 2003 14:19:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex greediness question
Message-Id: <b8got0$1hl$1@mamenchi.zrz.TU-Berlin.DE>

Kevin Shay <kevin_shay@yahoo.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<b89fe6$3bn$1@mamenchi.zrz.TU-Berlin.DE>...
> > Well, that's a lot of critique occasioned by an innocent little bit of
> > code (which actually works, to boot).  Anyway, to avoid the issues,
> > I'd code it along these lines:
> > 
> >     while ( $html =~ m[(<table>.*?</table>)]sg ) {
> >         my $table = $1;
> >         if ( ... ) {}
> >     }
> 
> What do you think of this approach?
> 
> $html =~ s[(<table>.*?</table>)][ deal_with_a_table($1) ]egi;
> 
> sub deal_with_a_table {
> ...
> }

Absolutely.  If the purpose of s/// is indeed to make non-trivial changes
to (some of) the tables, inserting a sub is the way to go.  In the
concrete case t would have a more concrete name.

[snip good reasons]

Besides the reasons you mention, written like this the s/// still looks
like an s///.

> Hard to tell which is better without knowing the specific
> circumstances, but in cases when you actually need to substitute
> something into the original text, I don't think a while (m//) {} loop
> always fits the bill...

Quite.  The loop is preferable if the code in s/// is called for its
side effects.

Anno


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

Date: 27 Apr 2003 06:59:32 -0700
From: filmstar@blueyonder.co.uk (LondonDeveloper)
Subject: Running a perl script
Message-Id: <642b74a7.0304270559.1a70ad73@posting.google.com>

Hi
I'm new to Perl scripting.  I've taken a perl test script from
cgi101.com and uploaded it (making sure its an Ascii upload) onto my
test website.  I've checked the website and it enables perl to be run
on it. I've updated the permissions on the script to 755.  However
when I access the test script all it does is displays the script, it
doesn't run.  Should it be compiled?  Does it need a parameter?  I'm a
confused newboy

Cheers
And

The test script is:

#!/usr/local/bin/perl

print "Status: 200\r\nContent-type: text/plain\r\n\r\n";

print "I'm a Perl Script :-)\n";


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

Date: Sun, 27 Apr 2003 14:45:13 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Running a perl script
Message-Id: <3EABECC2.4070700@dev.null>



LondonDeveloper wrote:

> Hi
> I'm new to Perl scripting.  I've taken a perl test script from
> cgi101.com and uploaded it (making sure its an Ascii upload) onto my
> test website.  I've checked the website and it enables perl to be run
> on it. I've updated the permissions on the script to 755.  However
> when I access the test script all it does is displays the script, it
> doesn't run.  


The problem is likely to be with the configuration of the web server. 
Your web server needs some way of knowing whether a file is to be run as 
a CGI script or displayed as an HTML page. There are many ways to let 
the server know, but the most common one is to set aside one directory, 
typically called cgi-bin, to hold CGIs with the understanding that 
anyhing in that directory needs to be executed. If you have a cgi-bin 
directory, make sure your script is in there.

If this doesn't help, ask the tech support people of your web server, as 
  your issue is not Perl-related.

If your server is Apache, you might want to check out 
http://httpd.apache.org/docs/misc/FAQ-F.html



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

Date: Sun, 27 Apr 2003 08:23:17 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Style: Using 'no warnings' in a module
Message-Id: <Pine.A41.4.53.0304270817360.102618@dante18.u.washington.edu>

I've got a questions about proper Perl style for a module I'm writing. I
always use strict, of course, but when testing my module with use
warnings, a handful of trivial warnings crop up. The cases that these
warnings describe are expected and unimportant for the overall execution
of the module.

So, should simply ignore the warnings? Or should I sprinkle 'no warnings'
throughout the module to temporarily disable warnings for the offending
sections? Which is worse Perl style: a handful of trivial errors, or
constantly overriding the users wish to be warned?

Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog

Jesus asked them, "Who do you say that I am?"

And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."

And Jesus said, "What?"


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

Date: 27 Apr 2003 16:03:45 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Style: Using 'no warnings' in a module
Message-Id: <b8gv11$r3b@dispatch.concentric.net>


"JS Bangs" <jaspax@u.washington.edu> wrote in message
news:Pine.A41.4.53.0304270817360.102618@dante18.u.washington.edu...
> I've got a questions about proper Perl style for a module I'm writing. I
> always use strict, of course, but when testing my module with use
> warnings, a handful of trivial warnings crop up. The cases that these
> warnings describe are expected and unimportant for the overall execution
> of the module.
>
> So, should simply ignore the warnings? Or should I sprinkle 'no warnings'
> throughout the module to temporarily disable warnings for the offending
> sections? Which is worse Perl style: a handful of trivial errors, or
> constantly overriding the users wish to be warned?
>
(1) Depends on the warnings.  (2) Depends on the end-users.

Without a more specific description, we can't say whether the errors are
trivial or not.  In my own work, I find that the most frequent source of
warnings is uninitialized variables.  The fix for that is usually simple:
go back and write code like '$y = $x if defined $x;'.  OTOH, I once had a
script which used a module that I wrote wherein I got warnings that did not
affect the final output but nonetheless were due to a bug in Perl itself
(since patched).  Only when I posted the warnings to this list was that bug
discovered.

(2) Who's going to be sitting in front of the console when the warnings
appear?  Will they be annoyed? perplexed? discombobulated? when the warnings
appear?  If any of the above, then my advice would be track down the source
of the warnings and fix them.

Jim Keenan




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

Date: Sun, 27 Apr 2003 11:43:12 -0500
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Style: Using 'no warnings' in a module
Message-Id: <b8h1b2$ic18@onews.collins.rockwell.com>

On 4/27/2003 10:23 AM, JS Bangs wrote:
> 
> I've got a questions about proper Perl style for a module I'm 
> writing. when testing my module with use warnings, a handful of 
> trivial warnings crop up. The cases that these warnings describe are 
> expected and unimportant for the overall execution of the module.
> 
> So, should simply ignore the warnings? Or should I sprinkle 'no 
> warnings' throughout the module to temporarily disable warnings for 
> the offending sections?

It depends -- What are the warnings, where do they occur, and are they
expected or unexpected but harmless?

The situation where I usually run into this is stringification of
undefined variables. If it's normal and acceptable for things to be
undef at that point, and I want them to stringify as '', then I'll wrap
the offending code in a block with "no warnings 'uninitialized'".

If my data shouldn't be undef at that point, I let it squawk, regardless
of whether or not the undefined value is harmful. That way, I know that
_something_ is broken, even if it's not the code that issues the warning.

Finally, don't put a blanket "no warnings" in. The warnings pragma
allows you to enable/disable specific types of warnings, use it that
way. That way, you don't disable warnings for things that may not be
harmless. It also aids maintenance: it's sign that you've put some
thought into what you're doing instead of just telling perl to shut up.

-mjc



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

Date: Sun, 27 Apr 2003 23:28:28 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Test::Harness annoyance
Message-Id: <3eabdbf5$0$19903@echo-01.iinet.net.au>

Hi,

On Windows2000, perl 5.8, if any test scripts use Test::Harness, then a
newline gets printed for every test that is run.
So, at the end of 'nmake test', I find I frequently have to scroll back
through hundreds of blank lines to find out what happened. Often I find I'm
unable to scroll back to the beginning of the tests, as my console only
saves 400 lines. I guess I could raise that when I run 'nmake test', but I'd
sooner fix the problem than work around it.

Anyone know where the offending 'print "\n";' is coming from ?

I guess I'll find it, but if someone can save me a few hours of searching,
all the better :-)

Cheers,
Rob




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

Date: 27 Apr 2003 15:06:46 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Test::Harness annoyance
Message-Id: <b8grm6$em@dispatch.concentric.net>


"Sisyphus" <kalinabears@hdc.com.au> wrote in message
news:3eabdbf5$0$19903@echo-01.iinet.net.au...
> Hi,
>
> On Windows2000, perl 5.8, if any test scripts use Test::Harness, then a
> newline gets printed for every test that is run.
> So, at the end of 'nmake test', I find I frequently have to scroll back
> through hundreds of blank lines to find out what happened.

If you call 'nmake test TEST_VERBOSE=1' you should get hundreds of lines if
you have hundreds of tests -- but they should not be blank.  It's the
blank-ness that I find puzzling, not the hundreds of lines.

Right now I'm looking at an older version of Test::Harness (v1.1604) and I
don't see any code calling 'print "\n";'.  There are several lines that call
things like 'print $_' with no specific newline character, but I haven't
looked at it closely enough to see where the next newline is coming from.

> Often I find I'm
> unable to scroll back to the beginning of the tests, as my console only
> saves 400 lines. I guess I could raise that when I run 'nmake test', but
I'd
> sooner fix the problem than work around it.
>
That does seem to be a separate problem from that of the blankness of the
Harness output lines.

Am perplexed too.




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

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


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