[24507] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6687 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 13 21:05:44 2004

Date: Sun, 13 Jun 2004 18:05:07 -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, 13 Jun 2004     Volume: 10 Number: 6687

Today's topics:
        ActivePerl debug under rxvt <il.fogg@bigpond.nospam.net.au>
        ANN: List::SkipList 0.71 released <mutantrob_NOSPAM_@verizon.net>
        ANN: PerlAnim 0.1 utility - generate 2D animations from <nick@egyptus.co.uk>
        Beginner Perl/CGI Book <cooladamrichardson@yahoo.com>
    Re: Beginner Perl/CGI Book <geedotmuth@castcom.net>
    Re: Beginner Perl/CGI Book <cooladamrichardson@yahoo.com>
    Re: Beginner Perl/CGI Book <invalid-email@rochester.rr.com>
    Re: Beginner Perl/CGI Book <norfernuman@yahoo.com>
    Re: Extracting Metadata from Microsoft Office documents (nodata)
        File::Glob can't load module [cygwin], perl-5.8.4 9 (ne <mikeo@tconl.com>
    Re: foreach ($a, $b, $c)... <jurgenex@hotmail.com>
    Re: foreach ($a, $b, $c)... <tim@vegeta.ath.cx>
    Re: foreach ($a, $b, $c)... <ken_sington@nospam_abcdefg.com>
    Re: Getting started on perl on my PC <invalid-email@rochester.rr.com>
    Re: how about this one foreach... <gnari@simnet.is>
    Re: how about this one foreach... (Jay Tilton)
    Re: how about this one foreach... <bik.mido@tiscalinet.it>
    Re: how about this one foreach... <gnari@simnet.is>
    Re: how about this one foreach... <usenet@morrow.me.uk>
    Re: how about this one foreach... <gnari@simnet.is>
        Locale-Codes 2.07 (Neil Bowers)
    Re: Pattern matching problem <a@b.c>
        wrap a really long line <ken_sington@nospam_abcdefg.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 13 Jun 2004 15:24:03 GMT
From: "Iain Fogg" <il.fogg@bigpond.nospam.net.au>
Subject: ActivePerl debug under rxvt
Message-Id: <nk_yc.19501$sj4.11208@news-server.bigpond.net.au>

Folks,

This one is wierd...

If I run "perl -d example.pl" in either a DOS command shell, or in a Cygwin
bash shell everything works fine.

However, if I try to run the command in a bash shell under rxvt (Cygwin), it
will not respond - the cursor blinks until I get bored and kill the process
(^C).

I'm typically launch rxvt via a desktop shortcut using:

C:\local\Cygwin\bin\rxvt.exe -e C:\local\Cygwin\bin\bash.exe --login -i

Can anyone suggest a way to get ActivePerl debugging to work using rxvt?

Cheers, Iain




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

Date: Sun, 13 Jun 2004 08:04:33 GMT
From: Robert Rothenberg <mutantrob_NOSPAM_@verizon.net>
Subject: ANN: List::SkipList 0.71 released
Message-Id: <Hz94DL.vK0@zorch.sf-bay.org>


A significant update of List::SkipList has been uploaded to CPAN.

NAME
     List::SkipList - Perl implementation of skip lists

REQUIREMENTS
     Perl 5.6.1 is required.

     The following non-standard modules are required:

       enum

     Carp::Assert is no longer required.  However, the assertions can
     be uncommented for debugging.

SYNOPSIS
       my $list = new List::SkipList();

       $list->insert( 'key1', 'value' );
       $list->insert( 'key2', 'another value' );

       $value = $list->find('key2');

       $list->delete('key1');

DESCRIPTION
     This is an implementation of skip lists in Perl.  What are "skip
     lists"?

       Skip lists are a probabilistic data structure that seem likely
       to supplant balanced trees as the implementation method of
       choice for many applications. Skip list algorithms have the same
       asymptotic expected time bounds as balanced trees and are
       simpler, faster and use less space.(*)

     Skip lists are similar to linked lists, except that they have
     random links at various levels that allow searches to skip over
     sections of the list, like so:

       4 +---------------------------> +----------------------> +
         |                             |                        |
       3 +------------> +------------> +-------> +-------> +--> +
         |              |              |         |         |    |
       2 +-------> +--> +-------> +--> +--> +--> +-------> +--> +
         |         |    |         |    |    |    |         |    |
       1 +--> +--> +--> +--> +--> +--> +--> +--> +--> +--> +--> +
              A    B    C    D    E    F    G    H    I    J   NIL

     A search would start at the top level: if the link to the right
     exceeds the target key, then it descends a level.

     More information is available in the module documentation.

     (*) Bill Pugh, inventor of skip lists.  Quoted from WikiPedia
         <http://en.wikipedia.org/wiki/Skip_list>

REVISION HISTORY
     Changes since v0.65:

     0.71 Sat Jun 12 2004
	- updated POD
	- redesigned internals of first_key, next_key and last_key
	* delete now resets last_key
	* the parameters for last_key are changed (this interface was
           meant for internal use only, however)
	- added index_by_key, key_by_index and value_by_index methods
	- updated documentation on p and k parameters
	- added support for k parameter
	- redid probability distribution calculations
	- fixed bug in benchmarks (was "existing" bogus keys)
	- added support for duplicate values
	- added find_duplicates method
	- corrected typos in POD for new method

     0.71_01 Wed Jun  9 2004
	- fixed bug in benchmarks (was deleting bogus keys)
	- added some warnings
	- improved delete method
	- added truncate method
	- _search_with_finger now builds correct update vector
	- append calls _adjust_level_threshold
	- minor optimizations of node class
	* renamed internal key {LASTNODE} to {LIST_END} so as not to
	  be confused with last_key method
	- _first_node is not autoloading since it's now used by first_key
	- updated POD to reflect issue with undefined values
	- improved copy method (undef values handled)
	- copy method can accept an argument: copy from key
	* copy method no longer resets first_key
	* _first_node no longer returns a finger (it was never used)
	- updated documentation on values for max_level and p
	- corrected typos in documentation
	- added tests for deleted greatest bug
	- fixed bug with greatest method when deleting last node
	- added _greatest_node method to find the last node as needed
	- other minor code changes

     0.70_01 Sun Jun  6 2004
	- tests rewritten (work in progress)
	- fixed bug with next_key checking node when key was deleted
	- uses Test::More for tests
	- fixed "Too late to run INIT block" error with Test::More
	  use_ok, $NULL is now set in import() method
	- fixed bug where level sometimes exceeded user-set max level
	- P and max_level can now be set dynamically
	- added tests for max_level and p
	- checks for error when setting max_level or P
	- fixed bug with definition of List::SkipList::Null
	- $NULL is now an 'our' variable and accessible from outside
	- level method was changed to autoload, since it was redundant
	- minor optimization of _search_with_finger and _search
	* header method in Node is read-only - it returns a pointer
	  which can be used to change values anyway
	* key method in Node is read-only - it should not be
           changed once it is inside a list
	- added _adjust_level_threshold method from code that was in
	  _new_node_level to adjust SIZE_THRESHOLD/SIZE_LEVEL
	- _adjust_level_threshold is called upon inserts and deletes
	- SIZE_LEVEL does not decrease under MIN_LEVEL
	* removed null() method - it was never used
	* max_level cannot be greater than 32 (cleaner code)
	- increased coverage of "heavy" test script
	- minor updates to all test scripts

     A detailed revision history is in the Changes file included with
     this distribution.

CAVEATS
     Skip lists are non-deterministic.  Because of this, bugs in programs
     that use this module may be subtle and difficult to reproduce without
     many repeated attempts.

AUTHOR
     Robert Rothenberg <rrwo at cpan.org>

LICENSE
     Copyright (c) 2003-2004 Robert Rothenberg. All rights reserved. This
     program is free software; you can redistribute it and/or modify it
     under the same terms as Perl itself.

AVAILABILITY
   It should show up soon at a CPAN mirror near you in as:

      $CPAN/authors/id/R/RR/RRWO/List-SkipList-0.71.tar.gz




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

Date: Fri, 11 Jun 2004 19:53:55 GMT
From: Nick Humphries <nick@egyptus.co.uk>
Subject: ANN: PerlAnim 0.1 utility - generate 2D animations from images
Message-Id: <Hz94CE.AuD@zorch.sf-bay.org>

Hi there,

I've just uploaded the following onto PAUSE, so expect it on CPAN soon at the
following location:

  file: $CPAN/authors/id/E/EG/EGYPTUS/PerlAnim/perlanim0.1.tar.gz
  size: 14519 bytes
   md5: 4329cd11b4f0e02352f54a4cc82a5c75

If you have an animation in mind that can be designed using just a set
of images, PerlAnim can come in useful.

For example, the following config file is all that's needed to move a sequence
of images (say a 40x40 pixel sized animation) fading in from the left, turning
a curved corner then fading out:

ALIAS seq seq_images*.png
Line 0 3 (0,0|al0) (50,0|al1) seq
Curve 3 6 (50,0) (100,0) (100,50) seq
Line 6 9 (100,50|al1) (100,100|al0) seq

You can define as many layers of animation as you like, all you do is define a
config file for each layer and then merge all the layers into one image
sequence. You can set alpha-blending values as above and the perl scripts will
take care of it all. You can also set layers to loop, or stick on the final
frame, or run once and then disappear. The docs have details of the basic
functionality.

The functionality is all there - I've been using it to generate a
documentary MPEG (see http://www.ysrnry.co.uk/tvprog/ for what I'm
using it for) - but it could use a bit of tidying up, made robuster,
perhaps expand the functionality a little and also some decent
documentation. A few people have asked for it already, which is why
I'm doing such an early release.

It's geared towards *nix (although this is quite a nominal choice),
and requires the NetPBM, ImageMagick and animmaker commandline toolkits to be
in your PATH, together with animmaker to join the resulting series of TGA
images into an uncompressed AVI.

It's flakey, I know that :) But it is indeed sort of like rewriting
all the static image handling of Macromedia Flash in Perl! I just
don't have enough time to make it an all-singing all-dancing program.

Any Q's should be addressed to nick at egyptus dot co dot uk.

-- 
------------------------------------------------------------------------
| Nick Humphries  --  nick@egyptus.co.uk  --  http://www.egyptus.co.uk |
| ZX Spectrum stuff * Your Sinclair archive * Time-lapse weather MPEGs |
------------------------------------------------------------------------
 .




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

Date: Sun, 13 Jun 2004 19:36:03 +0100
From: Adam <cooladamrichardson@yahoo.com>
Subject: Beginner Perl/CGI Book
Message-Id: <2j3l3lFs5femU1@uni-berlin.de>

Hi All,

I wonder if someone can recommend a good perl/CGI book? Now, I have to 
admit, I don't know a whole lot about the subject (sorry) so my various 
searches haven't helped me out that much.

The book is actually a present for my dad. He has an idea that he wants 
to do some scripting stuff for his websites and has done a bit of 
programming in the past.

The common thing which has turned up in my searches is "Learning Perl" 
but I get the feeling this more of a tutorial on the actual language 
than a mixed perl/cgi guide.

Any pointers will be greatly appreciated!

Thanks,
Adam

-- 
Adam Richardson
Email me at: stonemonkey~but.not.this.monkey~@ntlworld.com
Carpe Diem


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

Date: Sun, 13 Jun 2004 19:20:02 GMT
From: GM <geedotmuth@castcom.net>
Subject: Re: Beginner Perl/CGI Book
Message-Id: <BN1zc.42485$HG.13947@attbi_s53>

Adam wrote:
> Hi All,
> 
> I wonder if someone can recommend a good perl/CGI book? Now, I have to 
> admit, I don't know a whole lot about the subject (sorry) so my various 
> searches haven't helped me out that much.
> 
> The book is actually a present for my dad. He has an idea that he wants 
> to do some scripting stuff for his websites and has done a bit of 
> programming in the past.
> 
> The common thing which has turned up in my searches is "Learning Perl" 
> but I get the feeling this more of a tutorial on the actual language 
> than a mixed perl/cgi guide.
> 
> Any pointers will be greatly appreciated!
> 
> Thanks,
> Adam
> 

How many seconds did you spend searching..?

"CGI Programming with Perl"
Written by Guelich, Gundavaram & Birznieks
Published by O'Reilly & Assoiciates


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

Date: Sun, 13 Jun 2004 22:38:18 +0100
From: Adam <cooladamrichardson@yahoo.com>
Subject: Re: Beginner Perl/CGI Book
Message-Id: <2j3vp3Fsvui3U1@uni-berlin.de>

On 13/06/04 20:20, GM wrote:
> Adam wrote:
>> Hi All,
>> 
>> I wonder if someone can recommend a good perl/CGI book? Now, I have to 
>> admit, I don't know a whole lot about the subject (sorry) so my various 
>> searches haven't helped me out that much.
>> 
>> The book is actually a present for my dad. He has an idea that he wants 
>> to do some scripting stuff for his websites and has done a bit of 
>> programming in the past.
>> 
>> The common thing which has turned up in my searches is "Learning Perl" 
>> but I get the feeling this more of a tutorial on the actual language 
>> than a mixed perl/cgi guide.
>> 
>> Any pointers will be greatly appreciated!
>> 
>> Thanks,
>> Adam
>> 
> 
> How many seconds did you spend searching..?
Well, around 54,000 I'd say.

> 
> "CGI Programming with Perl"
> Written by Guelich, Gundavaram & Birznieks
> Published by O'Reilly & Assoiciates

 ...which gets slated for being absolutely full of errors :-(
Does it introduce perl at all? As I say above, I'm really looking for a 
book to introduce both perl and CGI together.

Thanks,
Adam

-- 
Adam Richardson
Email me at: stonemonkey~but.not.this.monkey~@ntlworld.com
Carpe Diem


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

Date: Sun, 13 Jun 2004 22:07:00 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Beginner Perl/CGI Book
Message-Id: <40CCCFF2.6010502@rochester.rr.com>

Adam wrote:

> On 13/06/04 20:20, GM wrote:
> 
>> Adam wrote:
 ...


> Does it introduce perl at all? As I say above, I'm really looking for a 
> book to introduce both perl and CGI together.


Try:  Practical Perl with CGI Applications by Elizabeth B. Chang, Scott 
Jones Publishers.


 ...
> Adam

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sun, 13 Jun 2004 22:19:03 GMT
From: norfernuman <norfernuman@yahoo.com>
Subject: Re: Beginner Perl/CGI Book
Message-Id: <rp4zc.71250$qA5.39426@newssvr29.news.prodigy.com>

Adam wrote:
> he wants
> to do some scripting stuff for his websites and has done a bit of 
> programming in the past.
> 


CGI Programming 101

This was recommended to me and it got me started, although I don't use 
99% of what I learned from it anymore, it's a BASIC starting point with 
Perl/CGI. Perl is used for so many things that it's hard to find a 
really good place to learn how to use it for specificlly web jobs, 
especially since PHP has risen to what ever it's risen to.

There is also, MySQL and Perl for the Web, but he goets into mod_perl 
kind of soon. You might want to look at it.

Perhaps a tie and a PHP book? ;-)

- NN



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

Date: 13 Jun 2004 11:42:48 -0700
From: groups@nodata.co.uk (nodata)
Subject: Re: Extracting Metadata from Microsoft Office documents
Message-Id: <aabe2b81.0406131042.64b3d7fa@posting.google.com>

> The easiest way, if you can manage it, is to save the docs as HTML with
> a recent version on Office on a Windows box. New (since 2k-ish) versions
> of Office actually produce XML, with pretty much everything in the
> original file intact (and, of course, the file is about one tenth the
> size...). You can then parse this with, say, XML::LibXML and get out the
> data you need.

Thanks.

I'll be using the metadata extraction to do smart indexing of
documents on an Apache server.
The users' store their documents in a folder, and the Apache server
provides a useful listing of what files are in which folder - the
metadata is key.

The problem with saving as XML is that we can't yet switch to XML as
the default file format, so putting a document on the Apache server
would mean first saving an XML version, then saving a normal version.
Not very efficient :/

On top of that, there are also a large number of legacy documents
which we need to keep in their current format because we haven't
tested how reliable the document conversion will be.

OpenOffice.org seems to have metadata storage it right. Maybe that'd
be a better direction to move in.

Wish me luck! :)


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

Date: Sun, 13 Jun 2004 17:15:50 -0500
From: "Mike O." <mikeo@tconl.com>
Subject: File::Glob can't load module [cygwin], perl-5.8.4 9 (newbie)
Message-Id: <jm4zc.425$sI2.35298@news.uswest.net>

I am playing with compiling Perl 5.8.4 under cygwin.  Can anyone help me fix
the error I seem not get past?

 ./perl harness
Can't load module File::Glob, dynamic loading not available in this perl.
  (You may need to build a new perl executable which either supports
  dynamic loading or has the File::Glob module statically linked into it.)
 at harness line 52
Compilation failed in require at harness line 52.
BEGIN failed--compilation aborted at harness line 52.

I was trying to compile using:
sh Configure -Duse64bitint \
-Duseshrplib \
-Dprefix=/u01/app/perl \
-Dinstallusrbinperl=n -Dcc=gcc  -Doptimize='-O2' \
-Dperladmin='<e-mail address>'  -des

Thanks!




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

Date: Sun, 13 Jun 2004 18:05:58 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: foreach ($a, $b, $c)...
Message-Id: <aI0zc.16656$H65.1674@nwrddc02.gnilink.net>

Ken Sington wrote:
> has anyone tried:

I'm sure many people have

> foreach ($a, $b, $c){
>      ...
> }
>
> well, it doesn't work.

Please define "doesn't work".
- What did you expect it to do?
- What actual behaviour did you observe?
- In which way was the observed behaviour different from the expected
behaviour?

> but what if I wanted to do that?

Please define "that". What did you expect this code fragment to do?

jue




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

Date: Sun, 13 Jun 2004 21:42:24 -0000
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: foreach ($a, $b, $c)...
Message-Id: <slrnccpifd.4ds.tim@vegeta.saiyix>

Ken Sington <ken_sington@nospam_abcdefg.com> wrote:
>  has anyone tried:
>  
>  foreach ($a, $b, $c){
>       ...
>  }
>  
>  well, it doesn't work.

You haven't responded to any requests for more information yet, but I'd
be willing to guess you aren't using it correctly, as it's worked for
many hundreds of times I've used it.

>  but what if I wanted to do that?

Then I'd suggest you read perlsyn.  Again, if necessary.

Tim Hammerquist
-- 
Don't hit the keys so hard, it hurts.


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

Date: Sun, 13 Jun 2004 20:45:04 -0400
From: Ken Sington <ken_sington@nospam_abcdefg.com>
Subject: Re: foreach ($a, $b, $c)...
Message-Id: <KXOdnbW1X6-TaFHdRWPC-g@speakeasy.net>

folks are too kind.
yeah, i read the guide lines.

I thought I was asking the right q. guess not.

well, the problem was solved.
I was just playing around with foreach loops.

but thanks folks.

great hobby, that PERL.


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

Date: Mon, 14 Jun 2004 00:54:12 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Getting started on perl on my PC
Message-Id: <40CCF722.7020109@rochester.rr.com>

None wrote:

> In article <40c9045a$0$196$58c7af7e@news.kabelfoon.nl>, 
> postmaster@castleamber.com says...
> 
>>None wrote:


 ...


> Camel and the Llama. All I want to know is what the shebang line 
> (assuming there is one in "local" programming) should be, and I will use 


Just to clarify:  the "shebang" line doesn't matter much in Windoze. 
Perl, however, will read the line if it is there and use the switches 
(if any) from it.  You could use a typical "shebang" from Unix with no 
problem:

   #!/usr/bin/perl
   use warnings;
   use strict;
   ...

That way, if you put your script on your Unix/Linux box or run Perl 
under Cygwin, your script will still work.  Note, however, that if you 
transfer your script to Unix, you must be sure to convert the line-end 
sequence from Windoze (CR-LF) to Unix (just LF) -- most Unix kernels 
don't properly interpret the "shebang" line unless it is properly 
terminated.
 ...
 > my Edit Pad as usual, save the file, and call it up with my Netscape.

I don't follow the "call it up with my Netscape" bit.  Are you writing 
CGI scripts and running a web server on your computer?  If so, OK, but 
"normally" Perl is run from the command prompt ("Command Window" or 
"MSDOS Prompt" window, depending on your Windoze version).  That is done 
by changing directory to the directory where your script is and entering:

   perl scriptname.pl

where "scriptname.pl" is the name of your Perl script.  That is much 
easier to deal with than all the hassles that befall a CGI script -- if 
the script won't compile, you just get a 500-error, for example. 
Usually you would debug your script at the command prompt (perhaps using 
Perl's built-in debugger and the CGI module's off-line capabilities) 
and, when it is working well, then call it up through your web 
server/browser.


 ...


> BTW, I am one of the diehards that is clinging desperately to W98SE :)


Me too.  Too cheap to give M$ any more $'s.  And the software I want to 
run runs under Windoze :-(.  I find it too much hassle to boot back and 
forth between Windoze and Linux.


> Dave

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sun, 13 Jun 2004 13:26:44 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: how about this one foreach...
Message-Id: <cahkj3$8t9$1@news.simnet.is>

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:cahi9f$g0$1@mamenchi.zrz.TU-Berlin.DE...
> gnari <gnari@simnet.is> wrote in comp.lang.perl.misc:
> > "Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
> > news:OtWdnfmpWYcPX1bdRWPC-w@speakeasy.net...
> > >
> >
> > in case you really want to use the literal
> > list in the foreach statement, just use
> > a non-aliased temporary variable if you
> > need to modify the index value.
>
> The variable in "foreach ( ... )" is always an aliased to list elements,
> whether it's named $_ or otherwise.
>
> >
> > >          foreach ("remote_host",
> >            foreach my $x ("remote_host",
>
> That gets the same complaint about read-only values.

that is why I made a change to another line a bit below,
which you snipped away, namely:
               ($_ = $x) =~ s/_/ /;
so there!

gnari






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

Date: Sun, 13 Jun 2004 15:32:24 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: how about this one foreach...
Message-Id: <40cc7297.133856906@news.erols.com>

"gnari" <gnari@simnet.is> wrote:

: "Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
: news:OtWdnfmpWYcPX1bdRWPC-w@speakeasy.net...
: >
: 
: in case you really want to use the literal
: list in the foreach statement, just use
: a non-aliased temporary variable if you
: need to modify the index value.
: 
: >          foreach ("remote_host",
:            foreach my $x ("remote_host",
: 
: > ...
: >              $_ =~ s/_/ /; # with this line, no I get no output!
:                ($_ = $x) =~ s/_/ /;

We don't want to step on $_ if it's the loop variable somewhere else.

                 (local $_ = $x) =~ s/_/ /;



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

Date: Sun, 13 Jun 2004 20:14:16 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: how about this one foreach...
Message-Id: <jcboc098600pr6t93359mg00q8frpj21q7@4ax.com>

On Sat, 12 Jun 2004 22:57:22 -0400, Ken Sington
<ken_sington@nospam_abcdefg.com> wrote:

>
>         foreach ("remote_host",
>                  "remote_user",

(You'd better, IMO) use

  for ( qw/remote_host
           remote_user
           ...
           download_time/) {           

>             $_ =~ s/_/ /; # with this line, no I get no output!

              $_ =~

is not necessary, 

              s/_/ /;

would be fine instead, if you *could* modify $_ which you can't, as
others have already duly told you. Also, if you could,

              tr/_/ /;

would be better. Oh, and BTW, I suppose that as a general rule you
wouldn't want to substitute only the *first* underscore, would you?

To circumvent the problem you're facing you can do e.g.

              local $_=$_;

as soon as you enter the loop. But definitely what you're trying to do
is awkward...

>             print "$_\n";

Aargh!! Set $\="\n" and

              print;

To sum up things, for example,

  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  
  print for map {local $_=$_; tr/_/ /; $_} qw/a_bc a_bcd/;
                 
  __END__

does work as expected...


HTH,
Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Sun, 13 Jun 2004 18:37:43 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: how about this one foreach...
Message-Id: <cai6q7$as7$1@news.simnet.is>

"Jay Tilton" <tiltonj@erols.com> wrote in message
news:40cc7297.133856906@news.erols.com...
> "gnari" <gnari@simnet.is> wrote:
>
> : "Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
> : news:OtWdnfmpWYcPX1bdRWPC-w@speakeasy.net...
> : >
> :
> : in case you really want to use the literal
> : list in the foreach statement, just use
> : a non-aliased temporary variable if you
> : need to modify the index value.
> :
> : >          foreach ("remote_host",
> :            foreach my $x ("remote_host",
> :
> : > ...
> : >              $_ =~ s/_/ /; # with this line, no I get no output!
> :                ($_ = $x) =~ s/_/ /;
>
> We don't want to step on $_ if it's the loop variable somewhere else.
>
>                  (local $_ = $x) =~ s/_/ /;

that's not very likely, as $_ was the OP's original loop variable.
I chose to do it this way just to minimize the changes from the OP's
code and make the difference clear.

I would actually prefer to use another lexical instead of $_ anyways;
although I am not a 'local' hater, this would not be a good example
of it's use, IMHO.

gnari






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

Date: Sun, 13 Jun 2004 21:06:06 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: how about this one foreach...
Message-Id: <caifjt$9ui$1@wisteria.csv.warwick.ac.uk>


Quoth "gnari" <gnari@simnet.is>:
> "Jay Tilton" <tiltonj@erols.com> wrote in message
> news:40cc7297.133856906@news.erols.com...
> > "gnari" <gnari@simnet.is> wrote:
> >
> > :                ($_ = $x) =~ s/_/ /;
> >
> > We don't want to step on $_ if it's the loop variable somewhere else.
> >
> >                  (local $_ = $x) =~ s/_/ /;
> 
> that's not very likely, as $_ was the OP's original loop variable.

If $_ is an implicit loop variable it is implicitly localized to the
loop. A frequent gotcha is that 'while (<$FH>)' *doesn't* localize.

> I chose to do it this way just to minimize the changes from the OP's
> code and make the difference clear.

I would have gone the other way:

for (...) {
   ...
   (my $x = $_) =~ s/_/ /;
}

Not that it really makes any difference :).

> of it's use, IMHO.
       ^
      grrr

Ben

-- 
               We do not stop playing because we grow old; 
                  we grow old because we stop playing.
                            ben@morrow.me.uk


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

Date: Sun, 13 Jun 2004 21:18:07 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: how about this one foreach...
Message-Id: <caig6v$bud$1@news.simnet.is>

"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:caifjt$9ui$1@wisteria.csv.warwick.ac.uk...
>
> Quoth "gnari" <gnari@simnet.is>:
> I would have gone the other way:
>
> for (...) {
>    ...
>    (my $x = $_) =~ s/_/ /;
> }
>
> Not that it really makes any difference :).

no, I agree i should have done it that way. I would have
had to change the print statement too, but at least the
changes would have been together

>
> > of it's use, IMHO.
>        ^
>       grrr

not native english speaker, but sorry.

gnari






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

Date: Fri, 11 Jun 2004 09:42:09 GMT
From: neil@bowers.com (Neil Bowers)
Subject: Locale-Codes 2.07
Message-Id: <Hz94D2.Av3@zorch.sf-bay.org>

Version 2.07 of the Locale-Codes distribution is now on CPAN:

  file: $CPAN/authors/id/N/NE/NEILB/Locale-Codes-2.07.tar.gz
  size: 25886 bytes
   md5: af0537cc4a882096d0320612c440df6d

Changes in this release:
 - Locale::Country updated to reflect changes in ISO 3166
 - fixed bug where $_ wasn't being local'd
 - "Canadian Dollar" was mis-spelled in Locale::Currency
 - added some aliases

What is Locale-Codes?

This distribution contains four Perl modules which can be used to process ISO codes
for identifying languages, countries, scripts, and currencies & funds.

Neil




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

Date: Sun, 13 Jun 2004 17:22:57 GMT
From: "BCC" <a@b.c>
Subject: Re: Pattern matching problem
Message-Id: <R30zc.1603$H87.932@newssvr27.news.prodigy.com>


"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnccl1ua.hor.tadmc@magna.augustmail.com...
> Bryan <bryan@akanta.com> wrote:
>
> > if ($sequence =~ m/$subseq/g) {
>
>
> What do you think the m//g option is doing for you there?
>
>

I thought it would match my $subseq pattern in the $sequence, and return
pos() if it is found.  Maybe Im not using this correctly?  Looks like since
$sequence is only one big line, I dont need the g, and maybe not even the m.
But will I still get pos() back?

Anyways, I tried it without the m, and without the g, it still fails 5 out
of 23 times.

B




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

Date: Sun, 13 Jun 2004 20:41:13 -0400
From: Ken Sington <ken_sington@nospam_abcdefg.com>
Subject: wrap a really long line
Message-Id: <KXOdnbq1X6-1aVHdRWPC-g@speakeasy.net>

criticism is good.
here's my function to wrap really long lines:
very basic.

# wrap long lines ###################################
sub wrapLine {
     my ($line) = @_;
     $line =~ s/.{70}/$&\n/g;
     return "$line";  #(yeah, I know, last value is returned  automatically)
}

using standards:
#!/usr/bin/perl
use strict;
use warnings;
of course.

PROG 1
my $longline="blah, " x 300;
print &wrapLine($longline);


--- OR ---

PROG 2
open READ, "twoMB_bigFile.txt;
while (<READ>){
     print &wrapLine($_);
}
close READ;


--- OR ---

PROG 3
open READ, "twoMB_bigFile.txt";
my @big = <READ>;
close READ;

foreach (@big) {
     print &wrapLine($_);
}



--- OR ---

PROG 4
open READ, "twoMB_bigFile.txt";
my @big = <READ>;
close READ;

while (@big) {
     print &wrapLine($_);
}




Anyone think there's a better way to wrap a long line?


I notice that in PROG.4, with the while loop, the script seems to just 
hang. however, the foreach in PROG 3 seems to run just fine.
I was told by some "expert" that while handles large input better than 
foreach.

PROG 1 and PROG 2 work as expected.


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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