[25445] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7690 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 25 18:05:45 2005

Date: Tue, 25 Jan 2005 15:05:21 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 25 Jan 2005     Volume: 10 Number: 7690

Today's topics:
        *IMPORTANT* Message for Google Group, Usenet and AOL us google_groups_net@yahoo.com
        [newbie] rename not working <mstep@t-online.de>
    Re: [newbie] rename not working <mritty@gmail.com>
    Re: [newbie] rename not working <1usa@llenroc.ude.invalid>
    Re: [newbie] rename not working <perl@my-header.org>
    Re: [newbie] rename not working <terrylr@blauedonau.com>
        [perl-python] 20050125 standard modules <xah@xahlee.org>
    Re: [perl-python] 20050125 standard modules <danperl@rogers.com>
    Re: [perl-python] 20050125 standard modules <danperl@rogers.com>
    Re: [perl-python] 20050125 standard modules <mritty@gmail.com>
    Re: Compare 2 files and put the matching part in a 3rd  (David Combs)
    Re: Compare 2 files and put the matching part in a 3rd  (Anno Siegel)
    Re: Compare 2 files and put the matching part in a 3rd  xhoster@gmail.com
    Re: Compare 2 files and put the matching part in a 3rd  (Anno Siegel)
    Re: FAQ 5.5 How do I make a temporary file name? <www1@www1.com>
    Re: FAQ 6.17 Why don't word-boundary searches with "\b" (Peter Scott)
    Re: File::Find gives me current dir (.)? <ben.rogers@gmail.com>
    Re: File::Find gives me current dir (.)? <someone@example.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 25 Jan 2005 13:58:56 -0800
From: google_groups_net@yahoo.com
Subject: *IMPORTANT* Message for Google Group, Usenet and AOL users!
Message-Id: <1106690336.528896.280260@z14g2000cwz.googlegroups.com>

Good News!


Do you know how simple it is to go to Heaven after this life has ended?


Some people believe that belonging to a local church, temple, mosque or
synagogue will get them to Heaven.


Others believe that water baptism, obeying the ten commandments or just
being a good person will get them to Heaven.


There are many other beliefs as well, but the good news about God's way
to Heaven is found in the Holy Bible.


The good news is that God came from Heaven to earth in the person of
Jesus Christ over 2000 years ago and died for our sins(misdeeds). He
was born in the land of Israel supernaturally to a virgin Jewish woman
named Mary. He lived a sinless life for thirty-three years and then
sacrificed His sinless blood and died on a cross to pay the death
penalty for our sins. After Jesus was placed in a tomb He rose from the
dead three days later as He said He would. The Holy Bible also tells us
that Jesus Christ ascended into Heaven and that all who accept Him as
their Lord and Saviour will live forever with Him in Heaven where there
is no more death, sorrow, sickness and pain.


The Bible says, "For the wages of sin is death, but the gift of God is
eternal life through Christ Jesus our Lord." (Romans 6:23)


This verse in the Bible says, "For ALL HAVE SINNED, and come short of
the glory of God." (Romans 3:23)


This verse says, "But God demonstrates his own love for us in this:
While we were still sinners, Christ died for us." (Romans 5:8)


In this passage the Bible clearly explains how simple it is to be saved
and on your way to Heaven, "For if you confess with your mouth, "Jesus
is Lord," and believe in your heart that God raised him from the dead,
you WILL BE SAVED." (Romans 10:9)


You can be saved right now and on your way to Heaven if you will open
your heart to Jesus and pray the following prayer:

Dear Jesus Christ, I want to be saved so that I can have a home in
Heaven when I die. I agree with You that I am a sinner.
I believe You love me and want to save me. I believe that You bled and
died on the cross to pay the penalty for my sins. I believe that You
rose from the dead. Please forgive my sins and come into my heart and
be my Lord and Saviour. Thank You Lord Jesus Christ for forgiving me
and saving me through Your merciful grace. Amen.


You are now a Christian if you said the prayer and allowed God to save
you. Welcome to the family of God.


Salvation is not a reward but a gift. The Bible says it this way, "For
it is by GRACE you have been SAVED, through FAITH and this not from
yourselves, it is the GIFT of God." (Ephesians 2:8)


Nothing in the world is more important than your eternal destiny.


The Bible says, "In Him(Jesus) we have redemption through His blood,
the forgiveness of sins..." (Ephesians 1:7)


If you have not yet made a decision to be saved, please do so now
before it is too late. The reason why it is so important to be saved
now is because you do not know exactly when you will die. You may die
prematurely in a traffic accident, terrorist attack or some other way
before you get another chance to be saved.


The Bible tells us that we will spend eternity in Heaven or a place of
eternal torment called Hell. It would be terrible to die and go to Hell
when all you have to do is accept Jesus Christ as your personal Lord
and Saviour.


Some people that have already made Jesus Christ their Lord and Saviour
worry about losing their salvation. The Bible teaches Christians that
we can never lose our salvation no matter what happens.


The Bible says it this way, "My dear children, I write this to you so
that you will not sin. But if anybody does sin, we have one who speaks
to the Father in our defense Jesus Christ, the Righteous One."


Yes my friend, Jesus Christ is able to save you and keep you saved.


Please tell your family and friends, thanks!


Have a great day!
Internet Evangelist R.L. Grossi





1. http://www.biblegateway.com << Free Online Bible
2. http://www.free-hoster.com/goodnews << Passion of the Christ
3. http://www.carm.org/cults/cultlist.htm << Beware Of Cults
4. http://www.equip.org/free/DH198.htm << About Hell
5. http://www.powertochange.com/questions/qna2.html << Is Jesus God?



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

Date: Tue, 25 Jan 2005 21:14:08 +0100
From: Marek Stepanek <mstep@t-online.de>
Subject: [newbie] rename not working
Message-Id: <BE1C6720.ED0F%mstep@t-online.de>



Hello Perlers,



I am ashamed : this simple script should work but I don't see the mistake.
With uncommented 

    # rename ...

the test print is working. But the rename itself is not working with
following error message :

    Use of uninitialized value in -e at ./rename_files.pl line 20.
    Use of uninitialized value in rename at ./rename_files.pl line 33.
    Use of uninitialized value in concatenation (.) or string at
     ./rename_files.pl line 33.
    couldn't rename h2armenia.gif to : No such file or directory at
     ./rename_files.pl line 33.

thank you for your patience



marek


******************


#!/usr/bin/perl

# rename_files.pl - rename "files.gif" keeping the original name
# and adding at the beginning a h2 to "h2files.gif"


use strict;
use warnings;

my ($file, $new);

foreach $file (@ARGV) {
    
    if ($file =~ m/^page\d+\.gif$/) {
        $new = "h2" . $file;
    }

    if (-e $new) {
        warn "$new already exists. Skipping...\n";
        next;
    }

    if ($file =~ m{/}) {
        warn "$file contains a slash. Skipping...\n";
        next;
    }
    
    # test before renaming finally the files :
    # print "the old files will be renamed from\t\t$file\t\tto\t\t$new\n\n";
    
    rename $file, $new or die "couldn't rename $file to $new: $!";
    
    print "Perl renamed the old files from\t\t$file\t\tto\t\t$new\n\n";
}







-- 
______________________________________________________________________
___PODIUM_INTERNATIONAL_//_the_embassy_for_talented_young_musicians___
_______Marek_Stepanek__mstep_[at]_PodiumInternational_[dot]_org_______
__________________http://www.PodiumInternational.org__________________
______________________________________________________________________





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

Date: Tue, 25 Jan 2005 20:34:52 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: [newbie] rename not working
Message-Id: <M3yJd.10282$hC2.7944@trndny04>

"Marek Stepanek" <mstep@t-online.de> wrote in message
news:BE1C6720.ED0F%mstep@t-online.de...
>
> I am ashamed : this simple script should work but I don't see the
mistake.
> With uncommented
>
>     # rename ...
>
> the test print is working. But the rename itself is not working with
> following error message :
>
>     Use of uninitialized value in -e at ./rename_files.pl line 20.
>     Use of uninitialized value in rename at ./rename_files.pl line 33.
>     Use of uninitialized value in concatenation (.) or string at
>      ./rename_files.pl line 33.
>     couldn't rename h2armenia.gif to : No such file or directory at
>      ./rename_files.pl line 33.

In the future, it would be helpful to know which lines are lines 20 and
33...

> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my ($file, $new);
>
> foreach $file (@ARGV) {
>
>     if ($file =~ m/^page\d+\.gif$/) {
>         $new = "h2" . $file;
>     }

What if $file doesn't match that pattern?  Then what is $new?  At the
moment, it's nothing - that is, it's  undefined.

>
>     if (-e $new) {

And here you check to see if a possibly undefined value is an existing
filename.

You need either figure out what $new should be in this case, or -
depending on what this program is supposed to do - skip the remainder of
the loop if $file doesn't match.

perldoc -f next will help you with that.

<remainder snipped>

Paul Lalli



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

Date: Tue, 25 Jan 2005 20:39:31 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: [newbie] rename not working
Message-Id: <Xns95E99F53B1381asu1cornelledu@127.0.0.1>

Marek Stepanek <mstep@t-online.de> wrote in
news:BE1C6720.ED0F%mstep@t-online.de: 

>     Use of uninitialized value in -e at ./rename_files.pl line 20.
>     Use of uninitialized value in rename at ./rename_files.pl line 33.
>     Use of uninitialized value in concatenation (.) or string at
>      ./rename_files.pl line 33.
>     couldn't rename h2armenia.gif to : No such file or directory at
>      ./rename_files.pl line 33.

This is what you get for not declaring your variable sin the smallest 
applicable scope. See below.

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

Good.
 
> my ($file, $new);

Bad.

> foreach $file (@ARGV) {
>     
>     if ($file =~ m/^page\d+\.gif$/) {
>         $new = "h2" . $file;
>     }

A-ha! If the $file does not match the pattern, $new is not initialized.
 
>     if (-e $new) {
>         warn "$new already exists. Skipping...\n";
>         next;
>     }

But you go ahead and use it anyway.

>     if ($file =~ m{/}) {
>         warn "$file contains a slash. Skipping...\n";
>         next;
>     }

But that's impossible if $file matches the pattern above.

Here's a revised (but untested) version:

#! /usr/bin/perl

use strict;
use warnings;

for my $src (@ARGV) {
    next unless $src =~ /^page\d+\.gif$/;
    my $dest = "h2$src";
    
    if(-e $dest) {
        warn "$dest already exists. Skipping ...\n";
        next;
    }
    print "Renaming $src => $dest\n";
    
    rename $src, $dest 
        or warn "Failed to rename $src => $dest: $!";
}

__END__

Sinan.


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

Date: Tue, 25 Jan 2005 21:43:01 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: [newbie] rename not working
Message-Id: <jabdv0907prsqm8v639fenhl7e2vmrj030@4ax.com>

X-Ftn-To: Marek Stepanek 

Marek Stepanek <mstep@t-online.de> wrote:
># rename_files.pl - rename "files.gif" keeping the original name
># and adding at the beginning a h2 to "h2files.gif"
>
>
>use strict;
>use warnings;

absolutely no flaw here. :)

>my ($file, $new);
>
>foreach $file (@ARGV) {
>    
>    if ($file =~ m/^page\d+\.gif$/) {
>        $new = "h2" . $file;
>    }
>
>    if (-e $new) {
>        warn "$new already exists. Skipping...\n";
>        next;
>    }

This conditions should be nested inside of the first one as $new isn't set
if matching fails.

if ($file =~ /../) {
  ..
  if (-e $new) { warn .. }
  else { rename .. print .. }
}
elsif ..



-- 
Matija


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

Date: Tue, 25 Jan 2005 14:58:04 -0600
From: "terry l. ridder" <terrylr@blauedonau.com>
Subject: Re: [newbie] rename not working
Message-Id: <Pine.LNX.4.61.0501251445570.9364@johann.blauedonau.com>

On Tue, 25 Jan 2005, Marek Stepanek wrote:

>
>
> Hello Perlers,
>
>
>
> I am ashamed : this simple script should work but I don't see the mistake.
> With uncommented
>
>    # rename ...
>
> the test print is working. But the rename itself is not working with
> following error message :
>
>    Use of uninitialized value in -e at ./rename_files.pl line 20.
>    Use of uninitialized value in rename at ./rename_files.pl line 33.
>    Use of uninitialized value in concatenation (.) or string at
>     ./rename_files.pl line 33.
>    couldn't rename h2armenia.gif to : No such file or directory at
>     ./rename_files.pl line 33.
>

the above error msgs clearly tell you want to look for.

>
> thank you for your patience
>
>
>
> marek
>
>
> ******************
>
>
> #!/usr/bin/perl
>
> # rename_files.pl - rename "files.gif" keeping the original name
> # and adding at the beginning a h2 to "h2files.gif"
>
>
> use strict;
> use warnings;
>
> my ($file, $new);
>
> foreach $file (@ARGV) {
>
>    if ($file =~ m/^page\d+\.gif$/) {
>        $new = "h2" . $file;
>    }
>

the variable $new may or may not be defined at this point in the code.

>
>    Use of uninitialized value in -e at ./rename_files.pl line 20.
>    if (-e $new) {

clearly at some point $new is uninitialized. that is what the above
error msg is telling you.

>        warn "$new already exists. Skipping...\n";
>        next;
>    }
>
>    if ($file =~ m{/}) {
>        warn "$file contains a slash. Skipping...\n";
>        next;
>    }
>
>    # test before renaming finally the files :
>    # print "the old files will be renamed from\t\t$file\t\tto\t\t$new\n\n";
>
>    Use of uninitialized value in rename at ./rename_files.pl line 33.
>    rename $file, $new or die "couldn't rename $file to $new: $!";
>

since $new is uninitialized above it will be uninitialized here also.
you are attempting to rename a file with a valid filename to a file with
a filename that is uninitialized.

>
>    Use of uninitialized value in concatenation (.) or string at
>    print "Perl renamed the old files from\t\t$file\t\tto\t\t$new\n\n";
>

since $new is uninitialized above it will be uninitialized here also.
you are attempting to concatenate using $new which is uninitialized.

>
> }
>

one way of doing it.

use strict;
use warnings;

my ($file, $new);

foreach $file (@ARGV)
{
     if ($file =~ m{/})
     {
         warn "$file contains a slash. Skipping...\n";
         next;
     }
     elsif ($file =~ m/^page\d+\.gif$/)
     {
         $new = "h2" . $file;

         if (-e $new)
         {
             warn "$new already exists. Skipping...\n";
             next;
         }

#
# test before renaming finally the files :
#
#       print "the old files will be renamed from\t\t$file\t\tto\t\t$new\n\n";

         rename $file, $new or die "couldn't rename $file to $new: $!";

         print "Perl renamed the old files from\t\t$file\t\tto\t\t$new\n\n";
     }
}


-- 
terry l. ridder ><>


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

Date: 25 Jan 2005 08:13:34 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] 20050125 standard modules
Message-Id: <1106669614.666772.17750@z14g2000cwz.googlegroups.com>

# -*- coding: utf-8 -*-
# Python

# some venture into standard modules

import os

# print all names exported by the module
print dir(os)

# print the module's online manual
print help(os)
# the above is also available in
# interactive mode in Python terminal

# example of using a function
print 'current dir is:', os.getcwd()

# this prints a list of existing modules
print help('modules')

# referecnce
# http://python.org/doc/2.3.4/tut/node12.html

# in Python terminal, type help() then
# modules
# to get a list
# then a module name to see its doc.

# take a gander of its richness and
# suitability

--------------------------
in perl, i don't think there is one way to
list available modules.

one can write a program to find out. Start by
use Data::Dumper; print Dumper \@INC;
to see where is the standard modules located,
then search for *.pm files to get an idea.

-------------------------
Note: this post is from the Perl-Python a-day mailing list at
http://groups.yahoo.com/group/perl-python/
to subscribe, send an email to perl-python-subscribe @ yahoogroups.com
if you are reading it on a web page, program examples may not run
because html conversion often breaks the code.
Xah
 xah@xahlee.org
 http://xahlee.org/PageTwo_dir/more.html



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

Date: Tue, 25 Jan 2005 12:10:55 -0500
From: "Dan Perl" <danperl@rogers.com>
Subject: Re: [perl-python] 20050125 standard modules
Message-Id: <yfSdnWbW5rw84GvcRVn-sw@rogers.com>

I sent the following feedback message to Yahoo! Groups about this abusive 
use of their service.

Feel free to also report this as an abuse of the Yahoo! Groups service until 
the problem is resolved.

Dan

-----------
As the owner of the perl-python group, p0lyglut (aka Xah Lee), has added two 
newsgroups to the mailing list of the group: comp.lang.perl.misc and 
comp.lang.python.

First of all, I don't think anyone could have given Xah Lee an authorization 
on behalf of the newsgroups.  I am not sure, but that is probably a 
violation of the Terms of Service in itself.  I will leave this matter up to 
you to investigate.

The daily messages of the perl-python group are unwanted by the two 
newsgroups.  Just take a look at the follow-ups in the newsgroups that the 
perl-python postings have generated.

I hope that not only the newsgroups will be removed from the perl-python 
group but that such an abuse will also be prevented in the future.

Thanks,

Dan Perl 




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

Date: Tue, 25 Jan 2005 12:50:25 -0500
From: "Dan Perl" <danperl@rogers.com>
Subject: Re: [perl-python] 20050125 standard modules
Message-Id: <5didnV2i-YV_G2vcRVn-iw@rogers.com>

I was wrong.  He is just crossposting to the newsgroups without having them 
as members of the group.

I wish there was a good way like that to stop these daily postings!

Dan

"Dan Perl" <danperl@rogers.com> wrote in message 
news:yfSdnWbW5rw84GvcRVn-sw@rogers.com...
>I sent the following feedback message to Yahoo! Groups about this abusive 
>use of their service.
>
> Feel free to also report this as an abuse of the Yahoo! Groups service 
> until the problem is resolved.
>
> Dan
>
> -----------
> As the owner of the perl-python group, p0lyglut (aka Xah Lee), has added 
> two newsgroups to the mailing list of the group: comp.lang.perl.misc and 
> comp.lang.python.
>
> First of all, I don't think anyone could have given Xah Lee an 
> authorization on behalf of the newsgroups.  I am not sure, but that is 
> probably a violation of the Terms of Service in itself.  I will leave this 
> matter up to you to investigate.
>
> The daily messages of the perl-python group are unwanted by the two 
> newsgroups.  Just take a look at the follow-ups in the newsgroups that the 
> perl-python postings have generated.
>
> I hope that not only the newsgroups will be removed from the perl-python 
> group but that such an abuse will also be prevented in the future.
>
> Thanks,
>
> Dan Perl
> 




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

Date: Tue, 25 Jan 2005 18:36:52 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: [perl-python] 20050125 standard modules
Message-Id: <8lwJd.10520$Dz2.6624@trndny09>

"Xah Lee" <xah@xahlee.org> wrote in message
news:1106669614.666772.17750@z14g2000cwz.googlegroups.com...
--------------------------
> in perl, i don't think there is one way to
> list available modules.
>

<set followups to c.l.p.m, as this reply deals only with Perl>

I'm torn between knowing that I shouldn't feed trolls, and my hatred of
leaving faulty information about Perl unchecked, where some unsuspecting
newbie might stumble across it.

So to those newbies, you should know that just because this clown
doesn't think there's a way, does not in any way imply that there
actually isn't a way.

For a list of standard modules included in your distribution of Perl,
run the following command in your shell:
perldoc perlmodlib

To get a list of non-standard modules that have already been installed,
read the documentation for the ExtUtils::Installed module:
perldoc ExtUtils::Installed

To see what other modules are available to be downloaded, visit
http://www.cpan.org

Paul Lalli



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

Date: Tue, 25 Jan 2005 18:10:07 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Compare 2 files and put the matching part in a 3rd file
Message-Id: <ct621v$3q9$1@reader1.panix.com>

In article <yzdvf9qkcn7.fsf@invalid.net>,
Arndt Jonasson  <do-not-use@invalid.net> wrote:
>
<SNIP>
>
>That seems to mean that no valuable information is lost if you sort
>the files first, which makes the job of comparing them much easier (I'd
>say trivial, but maybe that's overstating it). Is that enough for an
>idea, or is there some particular aspect of it which you don't know
>how to do in Perl?
>
>If the files are not very large, reading in their contents into perl (*)
>and sorting there will be OK, otherwise it's better to sort them on disk.

If you're allowed to sort them, then do that, and do "comm"
on those two.

  (It's *exactly* what comm was designed for.)

David


PS: Question: does the following conjecture make any sense?:

   Oh, by the way, make you sort via the same scheme that comm uses,
   otherwise comm won't think it's sorted.  Ie, beware of -u, -r, etc.






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

Date: 25 Jan 2005 19:37:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Compare 2 files and put the matching part in a 3rd file
Message-Id: <ct674u$9ki$3@mamenchi.zrz.TU-Berlin.DE>

David Combs <dkcombs@panix.com> wrote in comp.lang.perl.misc:

[...]

> If you're allowed to sort them, then do that, and do "comm"
> on those two.
> 
>   (It's *exactly* what comm was designed for.)
> 
> David
> 
> 
> PS: Question: does the following conjecture make any sense?:
> 
>    Oh, by the way, make you sort via the same scheme that comm uses,
>    otherwise comm won't think it's sorted.  Ie, beware of -u, -r, etc.

Conjecture?

No, the remark doesn't make sense.  All comm requires is that identical
lines be next to each other.  Any sort that considers the whole line will
guarantee that.

My comm man page doesn't even specify the sort to be ascending or descending,
though it does (unnecessarily) specify "lexically".

Anno


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

Date: 25 Jan 2005 20:33:50 GMT
From: xhoster@gmail.com
Subject: Re: Compare 2 files and put the matching part in a 3rd file
Message-Id: <20050125153350.702$ZE@newsreader.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> David Combs <dkcombs@panix.com> wrote in comp.lang.perl.misc:
>
> [...]
>
> > If you're allowed to sort them, then do that, and do "comm"
> > on those two.
> >
> >   (It's *exactly* what comm was designed for.)
> >
> > David
> >
> >
> > PS: Question: does the following conjecture make any sense?:
> >
> >    Oh, by the way, make you sort via the same scheme that comm uses,
> >    otherwise comm won't think it's sorted.  Ie, beware of -u, -r, etc.
>
> Conjecture?
>
> No, the remark doesn't make sense.  All comm requires is that identical
> lines be next to each other.

The only way you can ensure that identical lines are next to each other by
sorting the separate files is if the files are identical in the first
place. If you already know that, then you are already done.

In the non-trivial case, comm needs a way to re-align the files once it
encounters a non-indentical lines.  In order to do that, the sort order
of the files needs to be done the same way that comm expects.

> My comm man page doesn't even specify the sort to be ascending or
> descending, though it does (unnecessarily) specify "lexically".

Apparently man wasn't good enough, now if you want to know how a
commandline tool works you have read the "info" page too.


from info comm:<<EOF
Before `comm' can be used, the input files must be sorted using the
collating sequence specified by the `LC_COLLATE' locale.  If an input
file ends in a non-newline character, a newline is silently appended.
The `sort' command with no options always outputs a file that is
suitable input to `comm'.
                                                EOF

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 25 Jan 2005 21:38:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Compare 2 files and put the matching part in a 3rd file
Message-Id: <ct6e8r$e6f$2@mamenchi.zrz.TU-Berlin.DE>

 <xhoster@gmail.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> > David Combs <dkcombs@panix.com> wrote in comp.lang.perl.misc:
> >
> > [...]
> >
> > > If you're allowed to sort them, then do that, and do "comm"
> > > on those two.
> > >
> > >   (It's *exactly* what comm was designed for.)
> > >
> > > David
> > >
> > >
> > > PS: Question: does the following conjecture make any sense?:
> > >
> > >    Oh, by the way, make you sort via the same scheme that comm uses,
> > >    otherwise comm won't think it's sorted.  Ie, beware of -u, -r, etc.
> >
> > Conjecture?
> >
> > No, the remark doesn't make sense.  All comm requires is that identical
> > lines be next to each other.
> 
> The only way you can ensure that identical lines are next to each other by
> sorting the separate files is if the files are identical in the first
> place. If you already know that, then you are already done.

You are so very right.  Both files must be sorted according to the same
sort specification, or comm can foul up.  Sorry.

Anno


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

Date: Tue, 25 Jan 2005 22:31:27 +0100
From: "www1" <www1@www1.com>
Subject: Re: FAQ 5.5 How do I make a temporary file name?
Message-Id: <ct6dn2$ovc$1@ls219.htnet.hr>

you can find it here: http://www.plsgoogleit.com


"PerlFAQ Server" <comdog@panix.com> wrote in message
news:ct4ju5$in5$1@reader1.panix.com...
> This message is one of several periodic postings to comp.lang.perl.misc
> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with Perl.
>
> --------------------------------------------------------------------
>
> 5.5: How do I make a temporary file name?
>
>     If you don't need to know the name of the file, you can use "open()"
>     with "undef" in place of the file name. The "open()" function creates
an
>     anonymous temporary file.
>
>             open my $tmp, '+>', undef or die $!;
>
>     Otherwise, you can use the File::Temp module.
>
>       use File::Temp qw/ tempfile tempdir /;
>
>       $dir = tempdir( CLEANUP => 1 );
>       ($fh, $filename) = tempfile( DIR => $dir );
>
>       # or if you don't need to know the filename
>
>       $fh = tempfile( DIR => $dir );
>
>     The File::Temp has been a standard module since Perl 5.6.1. If you
don't
>     have a modern enough Perl installed, use the "new_tmpfile" class
method
>     from the IO::File module to get a filehandle opened for reading and
>     writing. Use it if you don't need to know the file's name:
>
>         use IO::File;
>         $fh = IO::File->new_tmpfile()
>             or die "Unable to make new temporary file: $!";
>
>     If you're committed to creating a temporary file by hand, use the
>     process ID and/or the current time-value. If you need to have many
>     temporary files in one process, use a counter:
>
>         BEGIN {
>             use Fcntl;
>             my $temp_dir = -d '/tmp' ? '/tmp' : $ENV{TMPDIR} ||
$ENV{TEMP};
>             my $base_name = sprintf("%s/%d-%d-0000", $temp_dir, $$,
time());
>             sub temp_file {
>                 local *FH;
>                 my $count = 0;
>                 until (defined(fileno(FH)) || $count++ > 100) {
>                     $base_name =~ s/-(\d+)$/"-" . (1 + $1)/e;
>                     # O_EXCL is required for security reasons.
>                     sysopen(FH, $base_name, O_WRONLY|O_EXCL|O_CREAT);
>                 }
>                 if (defined(fileno(FH))
>                     return (*FH, $base_name);
>                 } else {
>                     return ();
>                 }
>             }
>         }
>
>
>
> --------------------------------------------------------------------
>
> Documents such as this have been called "Answers to Frequently
> Asked Questions" or FAQ for short.  They represent an important
> part of the Usenet tradition.  They serve to reduce the volume of
> redundant traffic on a news group by providing quality answers to
> questions that keep coming up.
>
> If you are some how irritated by seeing these postings you are free
> to ignore them or add the sender to your killfile.  If you find
> errors or other problems with these postings please send corrections
> or comments to the posting email address or to the maintainers as
> directed in the perlfaq manual page.
>
> Note that the FAQ text posted by this server may have been modified
> from that distributed in the stable Perl release.  It may have been
> edited to reflect the additions, changes and corrections provided
> by respondents, reviewers, and critics to previous postings of
> these FAQ. Complete text of these FAQ are available on request.
>
> The perlfaq manual page contains the following copyright notice.
>
>   AUTHOR AND COPYRIGHT
>
>     Copyright (c) 1997-2002 Tom Christiansen and Nathan
>     Torkington, and other contributors as noted. All rights
>     reserved.
>
> This posting is provided in the hope that it will be useful but
> does not represent a commitment or contract of any kind on the part
> of the contributers, authors or their agents.




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

Date: Tue, 25 Jan 2005 16:08:20 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: FAQ 6.17 Why don't word-boundary searches with "\b" work for me?
Message-Id: <U9uJd.169457$Xk.119808@pd7tw3no>

In article <ct39o5$an5$1@reader2.panix.com>,
 PerlFAQ Server <comdog@panix.com> writes:

>6.17: Why don't word-boundary searches with "\b" work for me?
>
>    Two common misconceptions are that "\b" is a synonym for "\s+" and that
>    it's the edge between whitespace characters and non-whitespace
>    characters. Neither is correct. "\b" is the place between a "\w"
>    character and a "\W" character (that is, "\b" is the edge of a "word").

That seems unnecessarily misleading.  /\b is \b/x matches "is" without
any \W characters in sight.  How about this instead:

  "\b" is the place between a "\w" character and something that is not a
  "\w" character (either a "\W" character or the edge of the string; that
  is, "\b" is the edge of a "word").

>    It's a zero-width assertion, just like "^", "$", and all the other
>    anchors, so it doesn't consume any characters. perlre describes the
>    behavior of all the regex metacharacters.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


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

Date: 25 Jan 2005 12:02:29 -0800
From: "ben.rogers@gmail.com" <ben.rogers@gmail.com>
Subject: Re: File::Find gives me current dir (.)?
Message-Id: <1106683349.177202.224050@c13g2000cwb.googlegroups.com>

Of course, all of this advice is good and it all work. Thanks, I
learned alot. 

b



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

Date: Tue, 25 Jan 2005 21:35:13 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: File::Find gives me current dir (.)?
Message-Id: <lYyJd.7012$Ob.1329@edtnps84>

ben.rogers@gmail.com wrote:
> I made a mistake in my original post and Tad managed to get through the
> garbage to figure it out. Yes, I am writing a program-writing program.
> The code example was originally in a HERE block and I did a poor job of
> making it working code (instead of code-writing code) before asking for
> help.
> 
> Anyway, it took the ($recursive) suggestion and switched to glob to
> simplify non-recursive searching. I now have this (it works):
> 
> #!C:\\Perl -w
> use File::Find;
> 
> $recursive = 0;
> 
> if ($recursive){
> find (\&wanted, "C:/Adobe/mifaliscious/b4");
> sub wanted(){
> if ($File::Find::name =~ /(.fm)$/i && -f){
> print STDOUT "FOUND: $File::Find::name\n";
> push @files, $File::Find::name;
> }
> }
> } else {
> chdir "C:/Adobe/mifaliscious/b4";
> @files = glob "*.fm";
> foreach (@files) {print STDOUT "FOUND: $_\n";}
> }
> 
> 
> I can't see how to make it simpler or more elegant, but if there is a
> way please let me know. Your responses made me analyze things more
> carefully and I appreciate the help. Hope I got it right! works anyway.


#!C:\\Perl -w
use File::Find::Rule;

my $dir = 'C:/Adobe/mifaliscious/b4';

my $recursive = 0;

my @files = $recursive
     ? File::Find::Rule->name( qr/\.fm$/i )->file()->in( $dir )
     : glob "$dir/*.fm";

print map "FOUND: $_\n", @files;




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


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