[31679] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2942 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 13 16:09:27 2010

Date: Thu, 13 May 2010 13:09: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           Thu, 13 May 2010     Volume: 11 Number: 2942

Today's topics:
        Debugging question: tracing the origin of an error. <r.ted.byers@gmail.com>
    Re: Debugging question: tracing the origin of an error. <derykus@gmail.com>
    Re: Debugging question: tracing the origin of an error. <r.ted.byers@gmail.com>
    Re: How to control reading socket without waiting <ben@morrow.me.uk>
    Re: MinGW and Perl 5.12 - Windows 32 bits ActiveState <dilbert1999@gmail.com>
    Re: MinGW and Perl 5.12 - Windows 32 bits ActiveState <dilbert1999@gmail.com>
        search and replace in a file tree, only for files that  <friendly@yorku.ca>
    Re: search and replace in a file tree, only for files t <jl_post@hotmail.com>
    Re: search and replace in a file tree, only for files t <jimsgibson@gmail.com>
    Re: search and replace in a file tree, only for files t <uri@StemSystems.com>
    Re: search and replace in a file tree, only for files t <nospam-abuse@ilyaz.org>
    Re: search and replace in a file tree, only for files t <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 13 May 2010 10:10:30 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Debugging question: tracing the origin of an error.
Message-Id: <e118a06b-f9ac-46d3-b708-6e5cb40ef6ba@l28g2000yqd.googlegroups.com>

I have done all the usual things (as specified in the FAQ), and more,
but it isn't enough.

Here is how my script starts:

use strict;
use warnings;
use DBI;
use DateTime::Format::MySQL;
use Date::Manip;
use DateTime::Format::DateManip;

BEGIN {
            $SIG{__WARN__} = sub{ print STDERR "Perl: ", @_; };
            $SIG{__DIE__}  = sub{ print STDERR "Perl: ", @_; exit 1};
}

$| = 1;

In the body of the script, this script does very little except make a
DB connection, place the values from the record set that results from
a trivial select query into a variable, and then prints it.  Then all
handles are closed and the progrma ends.  The error actually arises
after the last statement (and does not appear in ANY of my other
scripts that use the packes listed above).

Here is the error statement I get:

Perl: Can't call method "FETCH" on an undefined value at C:/Perl/site/
lib/Win32/TieRegistry.pm line 1485, <DATA> line 335 during global
destruction.

At no time have I made direct use of the file mentioned, so it must be
something one of the above packages has done.  However, there is no
information provided as to what happened that led to this error.  It
does not even say what object is being destructed or what package
created, or failed to create, it.

How can I modify the signal handling I set up above so that I can get
this information?

Thanks

Ted


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

Date: Thu, 13 May 2010 11:03:00 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Debugging question: tracing the origin of an error.
Message-Id: <67083dac-9d14-4d85-a99f-5bdf8af487cf@s13g2000prc.googlegroups.com>

On May 13, 10:10=A0am, Ted Byers <r.ted.by...@gmail.com> wrote:
> I have done all the usual things (as specified in the FAQ), and more,
> but it isn't enough.
>
> Here is how my script starts:
>
> use strict;
> use warnings;
> use DBI;
> use DateTime::Format::MySQL;
> use Date::Manip;
> use DateTime::Format::DateManip;
>
> BEGIN {
> =A0 =A0 =A0 =A0 =A0 =A0 $SIG{__WARN__} =3D sub{ print STDERR "Perl: ", @_=
; };
> =A0 =A0 =A0 =A0 =A0 =A0 $SIG{__DIE__} =A0=3D sub{ print STDERR "Perl: ", =
@_; exit 1};
>
> }
>
> $| =3D 1;
>
> In the body of the script, this script does very little except make a
> DB connection, place the values from the record set that results from
> a trivial select query into a variable, and then prints it. =A0Then all
> handles are closed and the progrma ends. =A0The error actually arises
> after the last statement (and does not appear in ANY of my other
> scripts that use the packes listed above).
>
> Here is the error statement I get:
>
> Perl: Can't call method "FETCH" on an undefined value at C:/Perl/site/
> lib/Win32/TieRegistry.pm line 1485, <DATA> line 335 during global
> destruction.
>
> At no time have I made direct use of the file mentioned, so it must be
> something one of the above packages has done. =A0However, there is no
> information provided as to what happened that led to this error. =A0It
> does not even say what object is being destructed or what package
> created, or failed to create, it.
>
> How can I modify the signal handling I set up above so that I can get
> this information?
>

Here's an purported cure:

   END { $^W =3D 0; }

--
Charles DeRykus


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

Date: Thu, 13 May 2010 11:56:38 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: Debugging question: tracing the origin of an error.
Message-Id: <b55cab70-af14-4076-a5e5-acd9ae325c45@g21g2000yqk.googlegroups.com>

On May 13, 2:03=A0pm, "C.DeRykus" <dery...@gmail.com> wrote:
> On May 13, 10:10=A0am, Ted Byers <r.ted.by...@gmail.com> wrote:
>
>
>
> > I have done all the usual things (as specified in the FAQ), and more,
> > but it isn't enough.
>
> > Here is how my script starts:
>
> > use strict;
> > use warnings;
> > use DBI;
> > use DateTime::Format::MySQL;
> > use Date::Manip;
> > use DateTime::Format::DateManip;
>
> > BEGIN {
> > =A0 =A0 =A0 =A0 =A0 =A0 $SIG{__WARN__} =3D sub{ print STDERR "Perl: ", =
@_; };
> > =A0 =A0 =A0 =A0 =A0 =A0 $SIG{__DIE__} =A0=3D sub{ print STDERR "Perl: "=
, @_; exit 1};
>
> > }
>
> > $| =3D 1;
>
> > In the body of the script, this script does very little except make a
> > DB connection, place the values from the record set that results from
> > a trivial select query into a variable, and then prints it. =A0Then all
> > handles are closed and the progrma ends. =A0The error actually arises
> > after the last statement (and does not appear in ANY of my other
> > scripts that use the packes listed above).
>
> > Here is the error statement I get:
>
> > Perl: Can't call method "FETCH" on an undefined value at C:/Perl/site/
> > lib/Win32/TieRegistry.pm line 1485, <DATA> line 335 during global
> > destruction.
>
> > At no time have I made direct use of the file mentioned, so it must be
> > something one of the above packages has done. =A0However, there is no
> > information provided as to what happened that led to this error. =A0It
> > does not even say what object is being destructed or what package
> > created, or failed to create, it.
>
> > How can I modify the signal handling I set up above so that I can get
> > this information?
>
> Here's an purported cure:
>
> =A0 =A0END { $^W =3D 0; }
>
> --
> Charles DeRykus

Thanks Charles.

Alas, the purported cure "END { $^W =3D 0; }" doesn't work in this
instance (unless I used it incorrectly).  In any event, do you know
how that purported cure is supposed to work?

I am using ActiveSate's perl (v5.10.0) on Windows, and have examined
each of the tools I thought might have something useful, but either
they didn't have something that would answer my question or I didn't
understand the documentation.

Almost a decade ago, I wrote a C++ template class that I used to wrap
all exception classes and, using RTTI, I made exceptions traceable,
including not only the line and file of the source code where the
exception arose but also the class affected and all functions applied
to it from the time an instance of the class was created to the time
the exception was produced; and this in addition to a simple call
stack.  This proved priceless in debugging my own code (and
identifying cases where I was hit by a bug in one or another of the
libraries I used, so I could focus on finding a work-around rather
than seeking a bug that didn't exist in my code).  But, it was  useful
only when I could compile it into my code which normally meant my own
code only.  Alas, it relied on compiler specific macros in addition to
a couple of my own, and the language has changed since I did that.

Anyway, in addition to making this specific error go away, what I
really need is something I can include at the top of my script and
have it produce info about any object the script makes (whether
explicitly or indirectly as part of the internals of a package that
had been included), and what happens to it, but prints this info only
if that object is involved in an error: basically a perl equivalent of
the traceable exceptions I'd made in C++ so very long ago.  I realize
Perl isn't C++, and that the specific method I'd used is probably not
viable in perl, but since both languages are Turing complete, anything
that is possible in one ought to be possible in the other.

So, then, what to do?

Thanks

Ted


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

Date: Wed, 12 May 2010 06:38:32 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to control reading socket without waiting
Message-Id: <ofrpb7-mfp.ln1@osiris.mauzo.dyndns.org>


Quoth Hans <hansyin@gmail.com>:
> Hi,
> I'm trying to write a udp client script, I already have:
> 
> my $sock = new IO::Socket::INET (
>                         PeerAddr => $host,
>                         PeerPort => $port,
>                         Proto => $proto,
>                         );
> die "Could not create socket: $!\n" unless $sock;
> my $do =1;
> while $do {

Please only post code *which you have actually run*.

>         print $sock "ping request from initiator,id is $i \n";
>         if ($line = <$sock>) {
>                 print "receive: $line \n";
>         }
>         $i++;
>         sleep(1);
> }
> 
> 
> My problem is it will always wait to receive something before sending
> next ping request. if no response from server, then it stops sending.
> 
> I hope it can keep sending no matter if there is response.

You need to put the socket in non-blocking mode and write a select loop,
or use some module like POE that wraps that for you. (An alternative
would be to go multi-process/thread, but unless this is a tiny program
that quickly becomes more trouble than the alternative.)

Ben



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

Date: Thu, 13 May 2010 03:52:19 -0700 (PDT)
From: Dilbert <dilbert1999@gmail.com>
Subject: Re: MinGW and Perl 5.12 - Windows 32 bits ActiveState
Message-Id: <6e536a22-76bf-45c8-bce5-5525987628ef@k2g2000yqe.googlegroups.com>

On 17 avr, 10:36, sisyphus <sisyphus...@gmail.com> wrote:
> On Apr 17, 1:52=A0am, Dilbert <dilbert1...@gmail.com> wrote:
>
> > With Windows 32 bits Activestate perl 5.10, I used to have (and
> > enjoy !) the "MinGW" package.
>
> > However, I have now migrated to Windows 32 bits ActiveState Perl 5.12,
> > and theMinGWpackage seems to have disappeared !
>
> > C:\>ppm installMinGW
> > ppm install failed: Can't find any package that providesMinGW
>
> As Ben said, the ppm repo for 5.12 isn't fully stocked yet.
>
> > (...and, while we're on the subject, if possible, also for Windows 64
> > bits ActiveState Perl 5.12, too, but I think that it would be
> > difficult to find a 64 bit version ofMinGW... )
>
> You'll get MinGW64 easy enough athttp://mingw-w64.sourceforge.net/-
> though, as I write this, it seems that the site is undergoing an
> upgrade.
>
> Unfortunately, mingw64 won't work straight out of the box with x64
> ActivePerl. Coincidentally, I've been hacking at this today. Having
> got everything to the stage where extensions would build, pass their
> tests, and install just fine, I then found that there can be weird
> runtime failures when DynaLoader tries to load the extension's dll.
> (Only seems to affect some extensions - and even then only under
> certain conditions ... I really can't yet make much sense of what's
> happening.)
>
> In short, for the moment at least, you'd be better off grabbing the
> freely available "Microsoft Platform SDK for Windows Server 2003 R2"
> compiler and using it with the x64 ActivePerl builds (irrespective of
> which version of Windows 64 you're running). That's the same compiler
> as was used to build the x64 ActiveState perls, and it therefore works
> very well with those builds.

I know, I can get MinGW64 at http://mingw-w64.sourceforge.net/ or I
can grab the freely available "Microsoft Platform SDK for Windows
Server 2003 R2", but I like the "no brain, no pain" philosophy of a
"ppm install MinGW". So I tried "ppm install MinGW" on Activestate
Perl 5.12 - Windows 64 bits, but there is still no MinGW Package
available for 64 bits on the Activestate repo.

Then I tried "ppm install MinGW" on Perl 5.12 - Windows 32 bits, and
guess what -- it worked.

Hurray, the MinGW Package for Perl 5.12 (Windows 32 bits) is now
available from the Activestate repo. -- *** A big thank you to all
those who made this possible !!! *** -- I don't take MinGW for granted
(next step for me is to test CPANPLUS with Activestate Perl 5.12 to
install xs based modules under Windows)

Anyway, here is proof that  "ppm install MinGW" on Perl 5.12 (Windows
32 bits) really did work:

C:\>perl -v

This is perl 5, version 12, subversion 0 (v5.12.0) built for MSWin32-
x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2010, Larry Wall

Binary build 1200 [292396] provided by ActiveState http://www.ActiveState.c=
om
Built Apr 11 2010 11:30:56

C:\>ppm install MinGW

Downloading ActiveState Package Repository packlist...done
Updating ActiveState Package Repository database...done
Syncing site PPM database with .packlists...done
Syncing perl PPM database with .packlists...done
Downloading MinGW-5.1.4.1...done
Downloading dmake-4.11.20080107...done
Unpacking MinGW-5.1.4.1...done
Unpacking dmake-4.11.20080107...done
Generating HTML for MinGW-5.1.4.1...done
Generating HTML for dmake-4.11.20080107...done
Updating files in site area...done
1070 files installed

C:\>


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

Date: Thu, 13 May 2010 11:17:22 -0700 (PDT)
From: Dilbert <dilbert1999@gmail.com>
Subject: Re: MinGW and Perl 5.12 - Windows 32 bits ActiveState
Message-Id: <7a2bbeee-a72a-4949-8697-7dc86dd42829@n15g2000yqf.googlegroups.com>

On 17 avr, 10:36, sisyphus <sisyphus...@gmail.com> wrote:
> On Apr 17, 1:52=A0am, Dilbert <dilbert1...@gmail.com> wrote:
> > (...and, while we're on the subject, if possible, also for Windows 64
> > bits ActiveState Perl 5.12, too, but I think that it would be
> > difficult to find a 64 bit version of MinGW ... )
>
> You'll get MinGW64 easy enough athttp://mingw-w64.sourceforge.net/-
> though, as I write this, it seems that the site is undergoing an
> upgrade.

I went to http://mingw-w64.sourceforge.net/ and I downloaded what I
thought would be a MinGW executable package, that is a zip-package
that contains precompiled Windows files like "g++.exe", "gcc.exe" and
"dmake.exe":

Under address
http://sourceforge.net/projects/mingw-w64/files/

I downloaded
\External binary packages (Win64 hosted)
  \Binaries
     \Coin-2.5.0-bin-x64.zip
     \jpeg-8-bin-x64.zip
     \expat-2.0.1-bin-x64.zip
     \yasm-0.8.0-bin-x64.zip
     \fftw-3.2.2-src.zip
     \libiconv-1.13.1-bin-x64.zip
     \gsl-1.14-src.zip
     \openssl-snapshot20100331-bin-x64.zip
     \zlib-1.2.4-bin-x64.zip

I was hoping to find precompiled files like "g++.exe", "gcc.exe" and
"dmake.exe",
but none of these packages had any of the required exe-files.

> In short, for the moment at least, you'd be better off grabbing the
> freely available "Microsoft Platform SDK for Windows Server 2003 R2"
> compiler and using it with the x64 ActivePerl builds

I can't seem to get the Windows *.exe-files I need for 64 bits from
MinGW, so I grabbed the freely available Microsoft Visual C++ 2008
Compiler (*** a whopping 200 meg !!! ***).

I am currently downloading (45%...) ...let's see how this works out...


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

Date: Wed, 12 May 2010 13:37:19 -0400
From: Michael Friendly <friendly@yorku.ca>
Subject: search and replace in a file tree, only for files that match
Message-Id: <hsep0f$660$1@sunburst.ccs.yorku.ca>

I'm wondering if there is a perl script or a simpler way to accomplish 
the task of doing global search/replace in all files, possibly of 
specified file types in a file tree, where *only* the files that match
the search string will be modified (because I need to preserve time 
stamps so that only truly modified files will be rsync'd with a server).

Here's what I do now, using modified version of tcgrep (supporting a -E
flag to limit search to specified file extensions) to generate the list
of files to which the perl -pi~ command will apply:

% perl -pi~ -e 
's|http://www.math.yorku.ca/SCS/Online|http://www.datavis.ca/online|g' 
`tcgrep -lE html '/SCS/Online' .`

That is, I want to do the global search/replace, only among those files
whose names are returned by the tcgrep command.

I'm doing this a lot in moving stuff from one web server to another,
so it would be nice to simplify this someway.

-Michael

-- 
Michael Friendly     Email: friendly@yorku.ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA


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

Date: Wed, 12 May 2010 11:12:30 -0700 (PDT)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: search and replace in a file tree, only for files that match
Message-Id: <c1261541-d6c5-4c87-83cc-b12473e82e48@q36g2000prg.googlegroups.com>

On May 12, 11:37=A0am, Michael Friendly <frien...@yorku.ca> wrote:
> Here's what I do now, using modified version of tcgrep (supporting a -E
> flag to limit search to specified file extensions) to generate the list
> of files to which the perl -pi~ command will apply:
>
> % perl -pi~ -e
> 's|http://www.math.yorku.ca/SCS/Online|http://www.datavis.ca/online|g'
> `tcgrep -lE html '/SCS/Online' .`
>
> That is, I want to do the global search/replace, only among those files
> whose names are returned by the tcgrep command.


Dear Michael,

   I confess that I'm not familiar with the tcgrep command.  However,
I think you can do what you want by just setting the @ARGV array to
whatever files you want inside a BEGIN block.

   So you might use something like this:

perl -pi~ -e 'BEGIN{@ARGV=3D`command`; chomp(@ARGV)} s/old/new/'

For your purposes, "command" would probably be:

      tcgrep -lE html '/SCS/Online' .

   I hope this helps, Michael.

   -- Jean-Luc


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

Date: Wed, 12 May 2010 11:25:01 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: search and replace in a file tree, only for files that match
Message-Id: <120520101125019375%jimsgibson@gmail.com>

In article <hsep0f$660$1@sunburst.ccs.yorku.ca>, Michael Friendly
<friendly@yorku.ca> wrote:

> I'm wondering if there is a perl script or a simpler way to accomplish 
> the task of doing global search/replace in all files, possibly of 
> specified file types in a file tree, where *only* the files that match
> the search string will be modified (because I need to preserve time 
> stamps so that only truly modified files will be rsync'd with a server).
> 
> Here's what I do now, using modified version of tcgrep (supporting a -E
> flag to limit search to specified file extensions) to generate the list
> of files to which the perl -pi~ command will apply:
> 
> % perl -pi~ -e 
> 's|http://www.math.yorku.ca/SCS/Online|http://www.datavis.ca/online|g' 
> `tcgrep -lE html '/SCS/Online' .`
> 
> That is, I want to do the global search/replace, only among those files
> whose names are returned by the tcgrep command.
> 
> I'm doing this a lot in moving stuff from one web server to another,
> so it would be nice to simplify this someway.

You can certainly implement this procedure with a Perl program using
standard Perl features and modules. I would:

  1. Find all of the files in a directory (or directory tree) using
opendir, readdir (just one directory) or File::Find (directory tree).
  2. Ignore files without the proper suffix.
  3. Read a candidate file and see if it contains the string.
  4. If it does, then seek to the beginning of the file, re-read it,
copy it to a temporary, change the lines as needed, rename the file as
a backup, and rename the temporary file to the original name.

If the files are short, you can avoid re-reading the file by reading
the lines into an array, searching the array for the string,
substituting if necessary, and writing out the modified file if any
lines have been modified.

You could also use the Tie::File module to avoid coding the reading and
writing steps.

-- 
Jim Gibson


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

Date: Wed, 12 May 2010 14:38:12 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: search and replace in a file tree, only for files that match
Message-Id: <87iq6t7yp7.fsf@quad.sysarch.com>

>>>>> "JG" == Jim Gibson <jimsgibson@gmail.com> writes:

  JG> In article <hsep0f$660$1@sunburst.ccs.yorku.ca>, Michael Friendly
  JG> <friendly@yorku.ca> wrote:

  >> I'm wondering if there is a perl script or a simpler way to accomplish 
  >> the task of doing global search/replace in all files, possibly of 
  >> specified file types in a file tree, where *only* the files that match
  >> the search string will be modified (because I need to preserve time 
  >> stamps so that only truly modified files will be rsync'd with a server).
  >> 
  JG>   1. Find all of the files in a directory (or directory tree) using
  JG> opendir, readdir (just one directory) or File::Find (directory tree).
  JG>   2. Ignore files without the proper suffix.
  JG>   3. Read a candidate file and see if it contains the string.
  JG>   4. If it does, then seek to the beginning of the file, re-read it,
  JG> copy it to a temporary, change the lines as needed, rename the file as
  JG> a backup, and rename the temporary file to the original name.

  JG> If the files are short, you can avoid re-reading the file by reading
  JG> the lines into an array, searching the array for the string,
  JG> substituting if necessary, and writing out the modified file if any
  JG> lines have been modified.

or even simpler, use file::slurp. why do seeking and such which is a
waste?

untested pseudo code. run this on each file. the s/// needs to be done
with the proper args.

	use File::Slurp ;

	my $text = read_file( $file_name ) ;

	if ( $text =~ s/$old/$new/g ) {

		write_file( $file_name, $text ) ;
	}


you can add the atomic option to write_file if you want to make sure you
always have a clean file present. this is not difficult to do. the
harder part is finding all the files you want first with file::find. you
still need to scan them to see if they are needing the change. whether
that is done externally with a grep or internally with perl's s/// is a
minor issue. my version does the scan and replace in one step which may
be faster in some cases (where most of the files needed
replacements). in either case, the code is very simple.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Wed, 12 May 2010 20:34:06 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: search and replace in a file tree, only for files that match
Message-Id: <slrnhum45u.j32.nospam-abuse@powdermilk.math.berkeley.edu>

On 2010-05-12, Uri Guttman <uri@StemSystems.com> wrote:
>  >> I'm wondering if there is a perl script or a simpler way to accomplish 
>  >> the task of doing global search/replace in all files, possibly of 
>  >> specified file types in a file tree, where *only* the files that match
>  >> the search string will be modified (because I need to preserve time 
>  >> stamps so that only truly modified files will be rsync'd with a server).

  pfind

should be on ilyaz.org/software/tmp

>  JG>   1. Find all of the files in a directory (or directory tree) using
>  JG> opendir, readdir (just one directory) or File::Find (directory tree).
>  JG>   2. Ignore files without the proper suffix.
>  JG>   3. Read a candidate file and see if it contains the string.
>  JG>   4. If it does, then seek to the beginning of the file, re-read it,
>  JG> copy it to a temporary, change the lines as needed, rename the file as
>  JG> a backup, and rename the temporary file to the original name.

  pfind . -f '/\.suff$/' '=~ /pattern/' '=~ s/pattern2/replace/g'

This would not keep backup, but you can easily add this via File::Copy::copy.

Hope this helps,
Ilya


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

Date: Wed, 12 May 2010 17:47:20 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: search and replace in a file tree, only for files that match
Message-Id: <rtimu5pqh0hgb2hh14e1g96dhbqk2smoih@4ax.com>

Michael Friendly <friendly@yorku.ca> wrote:
>I'm wondering if there is a perl script or a simpler way to accomplish 
>the task of doing global search/replace in all files, possibly of 
>specified file types in a file tree, where *only* the files that match
>the search string will be modified (because I need to preserve time 
>stamps so that only truly modified files will be rsync'd with a server).

File::Find is your friend. In the wanted() function you can specify
whatever search criteria comes to your mind.

jue


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 2942
***************************************


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