[24685] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6846 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 8 21:07:50 2004

Date: Sun, 8 Aug 2004 18: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, 8 Aug 2004     Volume: 10 Number: 6846

Today's topics:
    Re: $class::SUPER as well as $instance::SUPER? <mb@uq.net.au.invalid>
    Re: creating shell scripts using #!/usr/local/env perl (Peter J. Acklam)
    Re: creating shell scripts using #!/usr/local/env perl <gnari@simnet.is>
    Re: creating shell scripts using #!/usr/local/env perl <abigail@abigail.nl>
    Re: File::Glob - can it recurse? (J. Romano)
    Re: find two halves of a word? <gnari@simnet.is>
    Re: find two halves of a word? <odyniec-usenet@odyniec.net>
    Re: Hash reference question <junk@blackwater-pacific.com>
    Re: Hash reference question <uri@stemsystems.com>
    Re: Joining 2 strings <someone@example.com>
    Re: name of perl jobs newsgroup? <matthew.garrish@sympatico.ca>
    Re: name of perl jobs newsgroup? <sbryce@scottbryce.com>
        Newbie problem with perl and rsh (zenshade)
    Re: Newbie problem with perl and rsh <nobull@mail.com>
    Re: Newbie problem with perl and rsh <gnari@simnet.is>
        News::Scan question <mr@sandman.net>
        perl modules <bckumari@yahoo.com>
    Re: perl modules <gnari@simnet.is>
        Problem with accentued characters <p.thibault@bigfoot.com>
    Re: transforming german characters <someone@example.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 09 Aug 2004 10:05:48 +1000
From: Matthew Braid <mb@uq.net.au.invalid>
Subject: Re: $class::SUPER as well as $instance::SUPER?
Message-Id: <cf6f4s$krd$2@bunyip.cc.uq.edu.au>

Sherm Pendley wrote:

> Matthew Braid wrote:
> 
>> Just a quick question - I just found out that this:
> 
> ...
> 
>>   $class::SUPER->woo();  # EEK!
> 
> ...
> 
>> does not work
> 
> 
> It works if you write it correctly. ;-)
> 
> $class->SUPER::woo();
> 
> sherm--
> 
> 

D'oh! That's what I get for writing code on a friday afternoon. Sheesh.

Thanks :)


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

Date: 08 Aug 2004 22:30:59 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <1xihqsn0.fsf@online.no>

merlyn@stonehenge.com (Randal L. Schwartz) wrote:

> >>>>> "Peter" == Peter J Acklam <pjacklam@online.no> writes:
> 
> Peter> What I meant was:  If "env" is present and has the same
> Peter> location on all the machines used by "zzapper", I see no
> Peter> problem with it.
> 
> You can replace "env" with "perl" there, and it still applies,
> and my statement applies as well.  I don't know why you keep
> wanting to introduce an additional complexity and inefficiency.

What gibberish.  Introducing additional complexity?  Give me a
break.  What's the alternative?  I can write

    #!/usr/bin/env perl

    print "Hello, world!\n";

and it works on all systems I have.  The alternative is something like

    #!/bin/sh
    exec perl -wSx $0 ${1+"$@"}

    #!perl

    print "Hello, world!\n";

    # Local Variables:
    # mode: perl
    # End:

which is *far* more complex.

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


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

Date: Sun, 8 Aug 2004 21:23:51 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <cf65h5$sqk$1@news.simnet.is>

"Peter J. Acklam" <pjacklam@online.no> wrote in message
news:1xihqsn0.fsf@online.no...
> merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>
> > >>>>> "Peter" == Peter J Acklam <pjacklam@online.no> writes:
> >
> > Peter> What I meant was:  If "env" is present and has the same
> > Peter> location on all the machines used by "zzapper", I see no
> > Peter> problem with it.
> >
> > You can replace "env" with "perl" there, and it still applies,
> > and my statement applies as well.  I don't know why you keep
> > wanting to introduce an additional complexity and inefficiency.
>
> What gibberish.  Introducing additional complexity?  Give me a
> break.  What's the alternative?  I can write
>
>     #!/usr/bin/env perl
>
>     print "Hello, world!\n";
>
> and it works on all systems I have.  The alternative is something like
[snip a bunch of different shebangs]

I think the point is that you are just lucky that you
have env in the same location on all your systems, or even
that you have env at all on all your systems.

gnari






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

Date: 08 Aug 2004 22:56:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <slrnchdbs3.ec9.abigail@alexandra.abigail.nl>

Peter J. Acklam (pjacklam@online.no) wrote on MMMCMXCV September MCMXCIII
in <URL:news:1xihqsn0.fsf@online.no>:
__  merlyn@stonehenge.com (Randal L. Schwartz) wrote:
__  
__ > >>>>> "Peter" == Peter J Acklam <pjacklam@online.no> writes:
__ > 
__ > Peter> What I meant was:  If "env" is present and has the same
__ > Peter> location on all the machines used by "zzapper", I see no
__ > Peter> problem with it.
__ > 
__ > You can replace "env" with "perl" there, and it still applies,
__ > and my statement applies as well.  I don't know why you keep
__ > wanting to introduce an additional complexity and inefficiency.
__  
__  What gibberish.  Introducing additional complexity?  Give me a
__  break.  What's the alternative?  I can write


The point is that assuming that "env" is present, and has the same
location on all system doesn't differ from assuming that "perl" is
present and has the same location on all machines.

__      #!/usr/bin/env perl
__  
__      print "Hello, world!\n";
__  
__  and it works on all systems I have.  The alternative is something like


        #!/usr/bin/perl

works on all systems *I* have. And that's simpler than your solution,
as it doesn't has a dependancy on env.



Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: 8 Aug 2004 07:33:23 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: File::Glob - can it recurse?
Message-Id: <b893f5d4.0408080633.723e4347@posting.google.com>

rgp@systame.com (Randall Perry) wrote in message news:<fac8f6c0.0408060739.537c19bf@posting.google.com>...
>
> I'd like to use the perl chown() command so I tried this:
>
>    @filenames = glob "/admin/new_account_page/*";
>    chown $uid, $gid, @filenames || die;
> 
> But it doesn't recurse through subdirectories. Is there a better way
> to accomplish this than by using system()?

   There is a simple work-around to your problem, but it's not really
all that elegant.

   One of the nice things about the glob() function is that it can
take wildcards in the directory names, as well as in the file names. 
So you can replace your line:

    @filenames = glob "/admin/new_account_page/*";

with:

    @filenames = glob "/admin/new_account_page/*";
    push @filenames, glob "/admin/new_account_page/*/*";
    push @filenames, glob "/admin/new_account_page/*/*/*";

    push @filenames, glob "/admin/new_account_page/*/*/*/*";
    push @filenames, glob "/admin/new_account_page/*/*/*/*/*";
    push @filenames, glob "/admin/new_account_page/*/*/*/*/*/*";

and now you have recursion that's five levels deep.

   Like I said, this isn't really all that elegant of a solution,
since your directory structure may have more (or less) than five
levels of recursion.  If it had twenty levels of nested directories,
you'd have to have 21 total glob() lines to get all your files!  If it
had only two levels of recursion, then three of those lines would be
useless.

   There is a work-around for this problem, too.  You can always put
the glob string in a loop that stops when it finds no more files, like
this:

   $globString = "/admin/new_account_page/*";
   while ( @globbedFiles = glob($globString) )  # note the single "="
   {
       push @filenames, @globbedFiles;
       $globString .= "/*";  # for the next time through the loop
   }
   print "Found files: @filenames\n";

   This approach should work, but I have to say that the standard
approach is to use the File::Find module, as it was meant to be used
for tasks just like yours.  If you find the documentation for
File::Find to be a bit confusing, you can use the "find2perl"
executable (which you probably already have) to create most of the
code for you, with this command:

   find2perl /admin/new_account_page -name "*"

Then all you'd have to do is put this line of yours in the wanted()
subroutine:

   chown $uid, $gid, @filenames or die;

and then run that script.

   I hope this helps, Randy.

   -- Jean-Luc


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

Date: Sun, 8 Aug 2004 09:29:31 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: find two halves of a word?
Message-Id: <cf4rmk$o5q$1@news.simnet.is>

"Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
news:q4-dnSZmSpjkV4jcRVn-iQ@speakeasy.net...
> is it possible to find a word that's broken?
>
> if:
> $str="hel
> lo larry";
> # that is, "hel" + "\n" line break + "lo larry"
>
> and I want to find "hello" in that string.
> is that possible?

just remove the newline before matching
my ($str2=$str)=~s/\n//g;
print "Match!\n" if $str2=~/hello/;

>
> or better yet:
> $str = "hel$^%&*&*&lo larry";

this might not contain what you think
assuming you meant
  $str = 'hel$^%&*&*&lo larry';
and that $str = '$^%&*&*&' is a fixed string that you
want to ignore:
  my $ign='$^%&*&*&';
  my ($str2=$str)=~s/\Q$ign\E//g;
  print "Match!\n" if $str2=~/hello/;

gnari





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

Date: Sun, 08 Aug 2004 17:16:33 +0200
From: Michal Wojciechowski <odyniec-usenet@odyniec.net>
Subject: Re: find two halves of a word?
Message-Id: <87wu09ek32.fsf@orion.odyniec.net>

Ken Sington <ken_sington@nospam_abcdefg.com> writes:

[...]

> # that is, "hel" + "\n" line break + "lo larry"
>
> and I want to find "hello" in that string.
> is that possible?
>
> or better yet:
> $str = "hel$^%&*&*&lo larry";

I suppose what you're trying to find is actually "two words separated
by non-alphabetic characters (excluding spaces)". You could use a
regular expression such as:

  $str =~ /(\w+)[^[:alpha:] ]+(\w+)/s;
  $word = $1 . $2;

But be aware that this will also turn "hello\nlarry" into
"hellolarry".

Cheers,
-- 
Michal Wojciechowski : for(<>){/\s/,$l{$m=$`}=$'}$_ : 10 PRINT "Yet another"
odyniec()odyniec;net : =$l{$c},/O\s/?$c=$'-1:y/"//d : 20 PRINT "Perl hacker"
 http://odyniec.net  : ,/T\s/?print$':0while$c++<$m : 30 GOTO 10


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

Date: Sun, 08 Aug 2004 16:26:17 -0700
From: Steve May <junk@blackwater-pacific.com>
Subject: Re: Hash reference question
Message-Id: <10hddjo3vssjf91@corp.supernews.com>

ChrisO wrote:

> Kristofer Pettijohn wrote:
> 
>> I'm defining a hash similiar to what follows:
>>
>> my $HASH = (
>>   'key1' => (
>>     'sub1' => 'key1value1',
>>     'sub2' => 'key1value2'
>>   ),
>>   'key2' => (
>>     'sub1' => 'key2value1',
>>     'sub2' => 'key2value2')
>> )
>>
>> and I would like to pass the reference of $HASH{'key1'} to a sub.  How
>> do I go about doing this?
>>
> 
> First of all, define the hash properly using matching braces and not 
> parens and end with a semicolon:
> 
> my $hash = {
>    key1 => {
>       sub1 => 'key1value1',
>       sub2 => 'key1value2',
>    },
>    key2 => {
>       sub1 => 'key2value1',
>       sub2 => 'key2value2',
>    },
> };
> 
> The quoting of the keys is not required unless you are going to include 
> whitespace in your key values.
> 

Ah.... that is not totally correct. When warnings are on and using 
strict, a key like this-is-a-key will *not* compile.

Just a thought.

\s




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

Date: Mon, 09 Aug 2004 01:02:37 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Hash reference question
Message-Id: <x71xih86p6.fsf@mail.sysarch.com>

>>>>> "SM" == Steve May <junk@blackwater-pacific.com> writes:

  >> The quoting of the keys is not required unless you are going to
  >> include whitespace in your key values.
  >> 

  SM> Ah.... that is not totally correct. When warnings are on and using
  SM> strict, a key like this-is-a-key will *not* compile.

he should have said when using => you don't need to quote simple word
keys (a leading - is allowed because too many packages use -foo as
args). pretty much anything else needs normal quoting.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Mon, 09 Aug 2004 00:12:13 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Joining 2 strings
Message-Id: <xjzRc.72042$T_6.35203@edtnps89>

Sim wrote:
> Hi! Thanks for looking at my problem. I have a problem with joining 2
> strings together.
> 
> Here is the problem:
> 
> I read a file into perl line by line. Each line becomes a string
> element in an array. I need to recognize the first, second and third
> elements of the array and join them on a single line in the output;
> then join the fourth,fifth and sixth elements on the second line. My
> inital plan was to use the join() function, but I had problems.  The
> join function does not join 2 strings on the same line. Can someone
> help?(Pardon me if this is supposed to be an easy problem. I am new to
> Perl)

You don't really need an array, you can just use string concatenation.

open FILE, '<', 'sample.out' or die "Cannot open sample.out: $!";
my $line;
while ( <FILE> ) {
     chomp;
     if ( $. % 3 ) {
         $line .= "$_ ";
         }
     else {
         print "$line$_\n";
         $line = '';
         }
     }


Of course, if you really want to use an array:

open FILE, '<', 'sample.out' or die "Cannot open sample.out: $!";
my @lines;
while ( <FILE> ) {
     chomp;
     if ( $. % 3 ) {
         push @lines, $_;
         }
     else {
         print join( ' ', splice( @lines ), $_ ), "\n";
         }
     }



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 8 Aug 2004 11:53:15 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: name of perl jobs newsgroup?
Message-Id: <s0sRc.3496$a65.59587@news20.bellglobal.com>


"Scott Bryce" <sbryce@scottbryce.com> wrote in message
news:10h4p4bdl9fbm02@corp.supernews.com...
>
> There is also alt.cgi.perl.freelance, but it is used more like a help
> desk than a jobs board. I don't think people are finding much work there.
>

There is? I know that alt.comp.perlcgi.freelance exists, but I haven't seen
much evidence that anyone posts there.

Matt




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

Date: Sun, 08 Aug 2004 15:19:38 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: name of perl jobs newsgroup?
Message-Id: <10hd67b9dac309@corp.supernews.com>

Matt Garrish wrote:
> "Scott Bryce" <sbryce@scottbryce.com> wrote in message
> news:10h4p4bdl9fbm02@corp.supernews.com...
> 
>>There is also alt.cgi.perl.freelance, but it is used more like a help
>>desk than a jobs board. I don't think people are finding much work there.
>>
> 
> 
> There is? I know that alt.comp.perlcgi.freelance exists, but I haven't seen
> much evidence that anyone posts there.

My bad. You have the name right. A few people post there, but it isn't 
very busy. Most of the posts are newbies looking for perl help, or help 
modifying scripts they have found on the net.



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

Date: 8 Aug 2004 10:58:36 -0700
From: zenshade@wowway.com (zenshade)
Subject: Newbie problem with perl and rsh
Message-Id: <76a99d19.0408080958.44c6a70b@posting.google.com>

I'm trying to invoke a perl script with command line arguments on
server 2 from server 1.  Here's what I do on S1:

$output=`rsh $host ./getdigits.pl $co_id $contact_id`;

Here's what I have on S2:

die "Wrong number of arguments." if $#ARGV!=1;
my ($co_id, $contact_id)=($ARGV[0],$ARGV[1]);

The script dies every time on S2 with "wrong args" message.  Only one
argument is being passed to the script on S2.  The second argument is
interpreted as a bad command on S1.

How do I work around this?


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

Date: Sun, 08 Aug 2004 19:33:22 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Newbie problem with perl and rsh
Message-Id: <cf5rk1$lt9$1@slavica.ukpost.com>

zenshade wrote:

 > Subject: Newbie problem with perl and rsh

I council you not to use the word "newbie" in subject lines - it tends 
to predispose people against you.  To see why see numerous previous 
thread with "newbie" in the subject.  Many the OPs in those threads 
display behaviour with which you would do well not to associate yourself.

Similarly avoid the words "Perl" and "problem" in subject line in 
comp.lang.perl.* as they are usually redundant.  Clear and concise 
subject lines are very important to the co-operative nature  of Usenet. 
Wasting space in them will be perceived as an uncooperative act and so 
will also serve to predispose people against you.

Your problem has nothing to do with rsh.  Had you tried replacing 'rsh' 
with 'echo' you'd have found the problem persisted.  This process is 
known as "problem partitioning".  It is an absolutely vital skill in 
programming.  If you think your problems lies elsewhere than it does 
then you are unlikely to find a solution.

On the whole not a great subject line :-)

> I'm trying to invoke a perl script with command line arguments on
> server 2 from server 1.  Here's what I do on S1:
> 
> $output=`rsh $host ./getdigits.pl $co_id $contact_id`;
> 
> Here's what I have on S2:
> 
> die "Wrong number of arguments." if $#ARGV!=1;
> my ($co_id, $contact_id)=($ARGV[0],$ARGV[1]);
> 
> The script dies every time on S2 with "wrong args" message.  Only one
> argument is being passed to the script on S2.  The second argument is
> interpreted as a bad command on S1.
> 
> How do I work around this?

At a guess I'd say remove the linefeed from the end of $co_id.

Most likely you have a chomp() missing in your program somewhere.
I can't say where because you didn't show us a minimal but complete 
script.  It is stongly recommened that you post a minimal but complete 
script to illustrate your problem.  This process alone will often solve 
your problem or at least serve to verify your partitioning of the problem.

Pretty much all the advice I've given here (and much more besides) can 
be found in the posting guidelines for this group.  I stongly advised 
you to take a look.



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

Date: Sun, 8 Aug 2004 20:20:09 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Newbie problem with perl and rsh
Message-Id: <cf61pn$sce$1@news.simnet.is>

"Brian McCauley" <nobull@mail.com> wrote in message
news:cf5rk1$lt9$1@slavica.ukpost.com...
> zenshade wrote:
>
>  > Subject: Newbie problem with perl and rsh
>

[good criticism of subject line snipped]
>
> > I'm trying to invoke a perl script with command line arguments on
> > server 2 from server 1.  Here's what I do on S1:
> >
> > $output=`rsh $host ./getdigits.pl $co_id $contact_id`;
> >
> > Here's what I have on S2:
> >
> > die "Wrong number of arguments." if $#ARGV!=1;
> > my ($co_id, $contact_id)=($ARGV[0],$ARGV[1]);
> >
> > The script dies every time on S2 with "wrong args" message.  Only one
> > argument is being passed to the script on S2.  The second argument is
> > interpreted as a bad command on S1.

let me add to Brian's comments:
a) you show us a snippet with a error message "Wrong number of arguments."
and then you say that the script dies with "wrong args"
I spent some time trying to figure if you whether you were complaining
that the die was executed or not.

b) the error message and test for the die are very poor. always
flesh out the error messages so that they say something more
than the obvious 'something failed'. for example:
  die "Wrong number of arguments ($#ARGV):["
      .join('][',@ARGV).']' if if $#ARGV!=1;
this would have shown the actual number of arguments, and
what they were. the square brackets would have made it very clear
if the problem for example happens to be a linefeed in the arguments.

gnari






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

Date: Sun, 08 Aug 2004 23:10:37 +0200
From: Sandman <mr@sandman.net>
Subject: News::Scan question
Message-Id: <mr-9E44F5.23103708082004@individual.net>

Ok, I've been looking at the News::Scan package, and I can't get my head around 
it.

My situation is that I have downloaded the contents of a newsgroup from my 
server using 'suck'. I then run a perl script that will iterate this file and 
insert every post into a MySQL database.

The problem I am having is with headers, and I thought that News::Scan::Article 
could help me with that - but I can't understand how to use - if it even can be 
used in the way I want to use it.

Basically, this is how my script looks like:



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

my($thepost, $all, $theheader,$scan);
my $ihead = 1;
my $nr = 0;

open FILE, "<news.txt";
while (<FILE>){
    if (/^\.$/){
        # Ok, we've completed one article, let's
        # process what we've got - but how?
        # I'd like to make a News::Scan::Article
        # object of it and call it with $art->subject
        # and vice versa
        

        # Now lets reset the values.
        ($thepost, $theheader, $all) = "";
        $ihead = 1;
        next;
    }
    $ihead = 0 if /^$/;
    if ($ihead == 1){
        # We're in the header part of the message
        $theheader .= $_;
    } else {
        # We're in the body
        $thepost.=$_;
    }
    # Lets say the entire post as well.
    $all.=$_;
}

-- 
Sandman[.net]


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

Date: Sun, 08 Aug 2004 04:49:24 -0400
From: "kums" <bckumari@yahoo.com>
Subject: perl modules
Message-Id: <c40da045d60ff60484be3b0642c25ff2@localhost.talkaboutprogramming.com>

i have written one module program ie CaseConversion.pm program in foll.dir
/home/arulmozi/visu

now i want to use that CaseConversion.pm program in  
/home/arulmozi

but i couldn't use it.b'caz i throw the foll.error
Can't locate /home/kumari/packages/CaseConversion in @INC

how to define @INC and where i have to define @INC ?



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

Date: Sun, 8 Aug 2004 09:38:30 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: perl modules
Message-Id: <cf4s6u$o7f$1@news.simnet.is>

"kums" <bckumari@yahoo.com> wrote in message
news:c40da045d60ff60484be3b0642c25ff2@localhost.talkaboutprogramming.com...
> i have written one module program ie CaseConversion.pm program in foll.dir
> /home/arulmozi/visu
>
> now i want to use that CaseConversion.pm program in
> /home/arulmozi
>
> but i couldn't use it.b'caz i throw the foll.error
> Can't locate /home/kumari/packages/CaseConversion in @INC
>
> how to define @INC and where i have to define @INC ?

look up @INC in perldoc perlvar
(in short: 'use lib')






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

Date: Sun, 08 Aug 2004 04:22:13 -0400
From: Pierre Thibault <p.thibault@bigfoot.com>
Subject: Problem with accentued characters
Message-Id: <p.thibault-53B618.04221308082004@news.videotron.net>

Hello,

I am having problems with a perl script.  The fellowing script is 
working well except for directory or file names using accented 
characters. The last line (!system...) is giving me errors when I'm 
using the result from the 'find' command if the file or the directory 
contain accented characters. The error is "No such file or directory".

I'm using Perl 5.0 version 8 subversion 1 RC3 on Mac OS 10.3.4.

I really don't know how to solve this problem. Any help would be 
appreciated.

#!/usr/bin/perl
#
# Create a list of files with their MD5 sums

use strict;

`mkdir -p /Users/pierreth/M5`;

my @path_list = ((split /:/, $ENV{"PATH"}), "/Applications");
for(@path_list) {
   my $file_name_for_path = $_;
   $file_name_for_path =~ s#/#-#g;
   $file_name_for_path =~ s#^-##;
   my $save_path = "/Users/pierreth/M5/$file_name_for_path";
   `rm $save_path -f > /dev/null 2>&1`;
   print "Now processing $file_name_for_path\n";
   for(`find -L $_ -type f`) {
      chomp;
      s#\\#\\\\#g; # Paying attention to special character like \ 
      s#'#\\'#g; # or '
      !system ("md5sum '".$_."' >> '".$save_path."'") or die "Error $_ 
$save_path";
   }
}

------------------------
Pierre


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

Date: Sun, 08 Aug 2004 23:41:42 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: transforming german characters
Message-Id: <WSyRc.71726$T_6.52887@edtnps89>

steve_f wrote:
> 
>>John W. Krahn wrote:
>>
>>Using a hash you could write that as:
>>
>>my %set1 = (
>>    "\xDF" => 'ss',
>>    );
>># Use a character class because all keys are single characters
>># If keys are multiple characters use alternation instead
> 
> can you explain this a bit further? I'm not quite sure what you mean
> by alternation, but I really only looked up the escaped values for
> this particular problem.

Gunnar's example uses alternation.


>>my $key1 = '[' . join( '', keys %set1 ) . ']';

Changing this to use alternation would look something like:

my $key1 = '(?:' . join( '|', keys %set1 ) . ')';


> also here I start to get really lost....ok, you are loading into a scalar
> the keys as one long string...joining them with no space between...
> with two brackets so
> 
> $key1 = [\xDF]
> $key2 = [\xC4\xD6\xDC\xE4\xF6\xFC]
> correct?

Yes.


> I see you use it down below in this substitution but it is a bit hard
> for me to understand:
> 
> if ( $string =~ s/($key1)/$set1{$1}/og )
> 
> well, if you have the time please give me a bit more clarrification
> on this because I haven't seen it before.

The substitution and match operators interpolate variables like double
quoted strings so after interpolation the substitution operator sees:

if ( $string =~ s/([\xDF])/ss/g )


John
-- 
use Perl;
program
fulfillment


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

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


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