[30019] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1262 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 7 06:09:38 2008

Date: Thu, 7 Feb 2008 03:09:04 -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           Thu, 7 Feb 2008     Volume: 11 Number: 1262

Today's topics:
    Re: CPerl mode problem: syntax highlighting stumbles ov <meshulum@gmail.com>
        MIME::Head subsequent calls in a loop return empty valu ebg005@gmail.com
    Re: moving binary data from one RDBMS to Other <a@a.com>
        new CPAN modules on Thu Feb  7 2008 (Randal Schwartz)
        PerlCtrl, COM objects and callbacks <Bruce.Axtens@gmail.com>
    Re: PerlCtrl, COM objects and callbacks <ben@morrow.me.uk>
        problem with '>' character <jd@somewhere.com>
    Re: problem with '>' character <peter@makholm.net>
    Re: problem with '>' character <abigail@abigail.be>
    Re: To modify a file from the command line clearguy02@yahoo.com
    Re: To modify a file from the command line <ben@morrow.me.uk>
    Re: To modify a file from the command line <joe@inwap.com>
    Re: To modify a file from the command line <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 6 Feb 2008 21:46:06 -0800 (PST)
From: shul <meshulum@gmail.com>
Subject: Re: CPerl mode problem: syntax highlighting stumbles over my  $old_z=3; my $old_y=4;
Message-Id: <1710a0de-231c-4f41-af90-22ff113d0a3d@c4g2000hsg.googlegroups.com>

On Feb 6, 4:28 pm, OMouse <omo...@gmail.com> wrote:
> On Feb 5, 7:27 pm, shul <meshu...@gmail.com> wrote:
>
> > Hi I am using
> > emacs GNU Emacs 21.4.1, with CPerl mode enabled.
> > on debian sid.
>
> Try upgrading to GNU Emacs 22.x or at least try to grab the latest
> version of CPerl mode.

Thank you, I did the upgrade and the problem is gone.

>
> Could you please paste some more lines of code as an example? I tried
> the ones shown and I had no problem with it.

Thank you - that was precisely the code. Just 2 lines containing
variable names
$old_x and $old_y messed up the syntax highlighting for about 5 lines.

I also googled around some more last night and found earlier reports
of this and instructions on how to modify
the old .el file to fix this. As Ilya says there were some unfortunate
modifications of the cperl.el file.
The modifications considered _ in a variable name as some kind of
punctuation or something (it was over my head :)).

Anyway it is ok in emacs22.1.1 on my machine now. YAY!
thank you (I thought I was running up to date sid! shows you how out
of date I was!).

Thank you,

Mitchell



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

Date: Thu, 7 Feb 2008 01:45:32 -0800 (PST)
From: ebg005@gmail.com
Subject: MIME::Head subsequent calls in a loop return empty values
Message-Id: <7a381b46-a3d4-41fc-8369-716671cdc2fc@d4g2000prg.googlegroups.com>

Hi,

To read SMTP message header fields of multiple messages (in Maildir),
I have a foreach loop which is doing subsequent calls to the sub
routine below. The first call is OK and returns the from and the to
field in a hash (called by reference), but successive calls to the
same readHeader routine returns me no values into my hash and gives no
error.

sub readHeader ($$) {
        my ( $headRef, $msgFile ) = @_;
        # get header fields
        my $head = MIME::Head->from_file ( $msgFile );
        $headRef->{from} = lc $head->get ( 'From' );
        $headRef->{to} = lc $head->get ( 'To' );
}

I'm using the MIME-tools-5.425.
All ideas are welcome.

Thanks


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

Date: 7 Feb 2008 01:50:31 -0800
From: Perl Lover <a@a.com>
Subject: Re: moving binary data from one RDBMS to Other
Message-Id: <foek970925@drn.newsguy.com>

In article <pan.2008.02.06.21.14.21@rtij.nl.invlalid>, Martijn Lievaart says...
>
>On Wed, 06 Feb 2008 11:44:16 -0800, Perl Lover wrote:
>
>> In article <pan.2008.02.06.19.39.39@rtij.nl.invlalid>, Martijn Lievaart
>> says...
>> 
>>>I bet you are using windows and are seeing LF -> CRLF conversion. Try
>>>opening your files as binary files. See perldoc -f open and perldoc -f
>>>binmode.
>> 
>> No. The files are created on Solaris and are used locally.
>
>In that case, try to post a small but complete example that exhibits the 
>problem.

First of all thanks for your effort to help.

What exactly you want? Code or data. 

The binary data contains
non ascii, non printable characters. 
The source database stores it in a char field of 512 length. 
The target database (oracle) stores it as a BLOB field because that is
the only field type that can store binary data.



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

Date: Thu, 7 Feb 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Feb  7 2008
Message-Id: <Jvut6H.1FEw@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

AI-MaxEntropy-0.01
http://search.cpan.org/~laye/AI-MaxEntropy-0.01/
Perl extension for learning Maximum Entropy Models 
----
AI-MaxEntropy-0.02
http://search.cpan.org/~laye/AI-MaxEntropy-0.02/
Perl extension for learning Maximum Entropy Models 
----
Acme-BabyEater-0.03
http://search.cpan.org/~zoffix/Acme-BabyEater-0.03/
Baby eating has never been easier! 
----
Alien-Selenium-0.08
http://search.cpan.org/~domq/Alien-Selenium-0.08/
installing and finding the Selenium Web test framework 
----
Apache2-ASP-1.25
http://search.cpan.org/~johnd/Apache2-ASP-1.25/
Perl extension for ASP on mod_perl2. 
----
Apache2-ASP-1.26
http://search.cpan.org/~johnd/Apache2-ASP-1.26/
Perl extension for ASP on mod_perl2. 
----
Apache2-ASP-1.27
http://search.cpan.org/~johnd/Apache2-ASP-1.27/
Perl extension for ASP on mod_perl2. 
----
Apache2-ASP-1.28
http://search.cpan.org/~johnd/Apache2-ASP-1.28/
Perl extension for ASP on mod_perl2. 
----
Apache2-ASP-1.29
http://search.cpan.org/~johnd/Apache2-ASP-1.29/
Perl extension for ASP on mod_perl2. 
----
B-Generate-1.12_04
http://search.cpan.org/~jcromie/B-Generate-1.12_04/
Create your own op trees. 
----
CGI-Application-PhotoGallery-0.10
http://search.cpan.org/~bricas/CGI-Application-PhotoGallery-0.10/
module to provide a simple photo gallery 
----
CatalystX-CRUD-Model-RDBO-0.11
http://search.cpan.org/~karman/CatalystX-CRUD-Model-RDBO-0.11/
Rose::DB::Object CRUD 
----
Class-Dot-2.0.0_15
http://search.cpan.org/~asksh/Class-Dot-2.0.0_15/
Compatability layer for Class::Dot 1.x 
----
Config-Validate-0.1.0
http://search.cpan.org/~cmo/Config-Validate-0.1.0/
Validate data structures generated from configuration files. (Or anywhere else) 
----
Crypt-OpenSSL-CA-0.12
http://search.cpan.org/~domq/Crypt-OpenSSL-CA-0.12/
The crypto parts of an X509v3 Certification Authority 
----
DBIx-Class-HTMLWidget-0.16
http://search.cpan.org/~andremar/DBIx-Class-HTMLWidget-0.16/
Like FromForm but with DBIx::Class and HTML::Widget 
----
EekBoek-1.03.07
http://search.cpan.org/~jv/EekBoek-1.03.07/
Bookkeeping software for small and medium-size businesses 
----
Email-Fingerprint-0.16
http://search.cpan.org/~budney/Email-Fingerprint-0.16/
Calculate a digest for recognizing duplicate emails 
----
Fey-0.03
http://search.cpan.org/~drolsky/Fey-0.03/
Better SQL Generation Through Perl 
----
Fey-Test-0.02
http://search.cpan.org/~drolsky/Fey-Test-0.02/
Test libraries for Fey distros 
----
Hardware-Simulator-MIX-0.07
http://search.cpan.org/~litchie/Hardware-Simulator-MIX-0.07/
----
IO-CaptureOutput-1.08
http://search.cpan.org/~dagolden/IO-CaptureOutput-1.08/
capture STDOUT and STDERR from Perl code, subprocesses or XS 
----
InSilicoSpectro-1.3.17
http://search.cpan.org/~alexmass/InSilicoSpectro-1.3.17/
Open source Perl library for proteomics 
----
Log-Dispatch-2.21
http://search.cpan.org/~drolsky/Log-Dispatch-2.21/
Dispatches messages to one or more outputs 
----
Mail-SpamCannibal-0.89
http://search.cpan.org/~miker/Mail-SpamCannibal-0.89/
A tool to stop SPAM 
----
Net-Jabber-Bot-2.0.7
http://search.cpan.org/~toddr/Net-Jabber-Bot-2.0.7/
Automated Bot creation with safeties 
----
PAR-Dist-0.29
http://search.cpan.org/~smueller/PAR-Dist-0.29/
Create and manipulate PAR distributions 
----
POE-Component-IRC-5.60
http://search.cpan.org/~bingos/POE-Component-IRC-5.60/
a fully event-driven IRC client module. 
----
POE-Component-IRC-Plugin-CPAN-Info-0.01
http://search.cpan.org/~zoffix/POE-Component-IRC-Plugin-CPAN-Info-0.01/
PoCo::IRC plugin for accessing information about CPAN modules, distributions and authors. 
----
POE-Component-IRC-Plugin-CPAN-Info-0.02
http://search.cpan.org/~zoffix/POE-Component-IRC-Plugin-CPAN-Info-0.02/
PoCo::IRC plugin for accessing information about CPAN modules, distributions and authors. 
----
POE-Component-Server-RADIUS-0.01
http://search.cpan.org/~bingos/POE-Component-Server-RADIUS-0.01/
a POE based RADIUS server component 
----
POE-Component-Server-RADIUS-0.02
http://search.cpan.org/~bingos/POE-Component-Server-RADIUS-0.02/
a POE based RADIUS server component 
----
POE-Component-WWW-DoingItWrongCom-RandImage-0.01
http://search.cpan.org/~zoffix/POE-Component-WWW-DoingItWrongCom-RandImage-0.01/
non-blocking way to get URIs to random images from <http://www.doingitwrong.com> 
----
Pod-MultiLang-0.14
http://search.cpan.org/~hio/Pod-MultiLang-0.14/
multi languages in Pod 
----
Rose-DB-0.738
http://search.cpan.org/~jsiracusa/Rose-DB-0.738/
A DBI wrapper and abstraction layer. 
----
Rose-DB-Object-0.7664
http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.7664/
Extensible, high performance RDBMS-OO mapper. 
----
Rose-URI-0.022
http://search.cpan.org/~jsiracusa/Rose-URI-0.022/
A URI class that allows easy and efficient manipulation of URI components. 
----
SNMP-Class-0.10.00
http://search.cpan.org/~aduitsis/SNMP-Class-0.10.00/
A convenience class around the NetSNMP perl modules. 
----
SNMP-Class-0.11
http://search.cpan.org/~aduitsis/SNMP-Class-0.11/
A convenience class around the NetSNMP perl modules. 
----
SQL-Bibliosoph-1.4
http://search.cpan.org/~matiu/SQL-Bibliosoph-1.4/
A SQL Statements Library 
----
SVN-Notify-2.67
http://search.cpan.org/~dwheeler/SVN-Notify-2.67/
Subversion activity notification 
----
Safe-2.15
http://search.cpan.org/~rgarcia/Safe-2.15/
Compile and execute code in restricted compartments 
----
Text-Wrap-Smart-XS-0.01
http://search.cpan.org/~schubiger/Text-Wrap-Smart-XS-0.01/
Wrap text fast into chunks of (mostly) equal length 
----
Text-Wrap-Smart-XS-0.02
http://search.cpan.org/~schubiger/Text-Wrap-Smart-XS-0.02/
Wrap text fast into chunks of (mostly) equal length 
----
WWW-DoingItWrongCom-RandImage-0.01
http://search.cpan.org/~zoffix/WWW-DoingItWrongCom-RandImage-0.01/
fetch random image from <http://www.doingitwrong.com> 
----
WWW-MobileCarrierJP-0.12
http://search.cpan.org/~tokuhirom/WWW-MobileCarrierJP-0.12/
scrape mobile carrier information 
----
Win32-GUITaskAutomate-0.04
http://search.cpan.org/~zoffix/Win32-GUITaskAutomate-0.04/
A module for automating GUI tasks. 
----
list_versions-0.01
http://search.cpan.org/~zoffix/list_versions-0.01/
----
list_versions-0.02
http://search.cpan.org/~zoffix/list_versions-0.02/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 6 Feb 2008 22:43:31 -0800 (PST)
From: axtens <Bruce.Axtens@gmail.com>
Subject: PerlCtrl, COM objects and callbacks
Message-Id: <24ff7181-d970-49f9-be89-527cd5aa9ae4@e25g2000prg.googlegroups.com>

G'day everyone

I have a VB application (though it could easily be any other 3GL)
which calls a PerlCtrl'd COM object. What I'd like to be able to do is
to create a real (or ersatz) callback mechanism. The idea would be to
pass to the Perl object a long containing the address of a function or
procedure and have Perl call that address. IIRC, the COM object would
run in-process so the address would be meaningful within that
context.

I can generate the address and pass it in to the COM. What I don't
know is how to have Perl either call or jump to that address.

Any ideas? Should I give up now, before I do any damage?

Kind regards,
Bruce.


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

Date: Thu, 7 Feb 2008 07:16:35 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: PerlCtrl, COM objects and callbacks
Message-Id: <jrnq75-fh62.ln1@osiris.mauzo.dyndns.org>


Quoth axtens <Bruce.Axtens@gmail.com>:
> 
> I have a VB application (though it could easily be any other 3GL)
> which calls a PerlCtrl'd COM object. What I'd like to be able to do is
> to create a real (or ersatz) callback mechanism. The idea would be to
> pass to the Perl object a long containing the address of a function or
> procedure and have Perl call that address. IIRC, the COM object would
> run in-process so the address would be meaningful within that
> context.

Better would be if you could pass some sort of COM object with a single
method Perl can invoke (the Java 'functor' pattern, commonly used in OO
languages as a poor substitute for closures). I've no idea how you might
do this from VB, but I would have thought it's possible.

> I can generate the address and pass it in to the COM. What I don't
> know is how to have Perl either call or jump to that address.

You can't call a function by machine address from Perl. If you have a
compiler you can write a tiny bit of XS to do this, trivially (assuming
you know the prototype/calling convention at compile time). If you
don't, but the called functions use the __stdcall calling convention
(likely if they're not C functions) then you ought to be able to fake up
a Win32::API object using the address given and then invoke that.

> Any ideas? Should I give up now, before I do any damage?

Just be aware that poking about in memory like this undercuts the safety
of a high-level language like Perl or VB: you need to be as careful as
you would be in C or assembler. If you get segfaults or random memory
corruption, they're your fault :).

Ben



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

Date: 07 Feb 2008 10:47:52 GMT
From: JD <jd@somewhere.com>
Subject: problem with '>' character
Message-Id: <47aae1d8$0$5124$e4fe514c@dreader25.news.xs4all.nl>


Hello,

I have a html-like string, and would like to remove the left part,
including the leftmost '>'. I use s/^.*>//;
but it does not work as expected (neither does s/^.*\076//;).
Something funny is going on, but I do not know what. It looks like a
shift-operator comes into action.

Can someone tell me what the problem might be, and how to get it right?

Thank you.


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

Date: Thu, 07 Feb 2008 10:51:02 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: problem with '>' character
Message-Id: <87odatghux.fsf@hacking.dk>

JD <jd@somewhere.com> writes:

> I have a html-like string, and would like to remove the left part,
> including the leftmost '>'. I use s/^.*>//;
> but it does not work as expected (neither does s/^.*\076//;).

Do you string consist of multipli lines, then you'll have to remember
that . doesn't matches the newline character unless you put you regexp
in multi line mode (with either m og s - read the docs).

//Makholm


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

Date: 07 Feb 2008 10:53:00 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: problem with '>' character
Message-Id: <slrnfqlooc.ifi.abigail@alexandra.abigail.be>

                               _
JD (jd@somewhere.com) wrote on VCCLXXIII September MCMXCIII in
<URL:news:47aae1d8$0$5124$e4fe514c@dreader25.news.xs4all.nl>:
&&  
&&  Hello,
&&  
&&  I have a html-like string, and would like to remove the left part,
&&  including the leftmost '>'. I use s/^.*>//;
&&  but it does not work as expected (neither does s/^.*\076//;).
&&  Something funny is going on, but I do not know what. It looks like a
&&  shift-operator comes into action.
&&  
&&  Can someone tell me what the problem might be, and how to get it right?


Could you give an example of what you did, and what you had expected?
I know one thing that's wrong about s/^.*>//, but that's not "funny",
nor does it have anything to do with a shift-operator.


Abigail
-- 
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


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

Date: Wed, 6 Feb 2008 18:39:39 -0800 (PST)
From: clearguy02@yahoo.com
Subject: Re: To modify a file from the command line
Message-Id: <2c106324-1e77-4617-b7fb-04d182d7a3f0@k2g2000hse.googlegroups.com>

On Feb 6, 6:08=A0pm, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "BM" =3D=3D Ben Morrow <b...@morrow.me.uk> writes:
>
> =A0 BM> Under Unix, -i with no backup unlinks the old file (holding it ope=
n) and
> =A0 BM> then creates the new file in its place, so there's no need for ano=
ther
> =A0 BM> filename. Under systems that don't have close-behind semantics (be=
cause
> =A0 BM> they don't have an inode layer), this is impossible: under Win32, =
you
> =A0 BM> cannot delete a file while it is open. Therefore, under such syste=
ms you
> =A0 BM> have to provide a backup filename so that both input and output fi=
les
> =A0 BM> get to have a name. (In principle perl could work around this by m=
aking
> =A0 BM> up a temporary filename in the same directory to use instead, but =
at
> =A0 BM> least under Win32 it doesn't.)
>
> interesting. i didn't think about that way of doing things.
>
> =A0 >> i use the same idea in File::Slurp in write_file with the atomic op=
tion
> =A0 >> on. it writes the whole file to a temp name and when done calls ren=
ame
> =A0 >> (which is atomic) so you always have a legit file around.
>
> =A0 BM> This is actually somewhat safer than inplace edit, of course, as t=
he
> =A0 BM> file is replaced atomically. Even with a backup name, -i does thin=
gs in
> =A0 BM> the wrong order: first it renames the old file to the backup, then=
 it
> =A0 BM> creates a new file by the original name for the output, so if the
> =A0 BM> process is interrupted the file is left corrupted. I guess the per=
l core
> =A0 BM> doesn't want to get involved with the issue of safely creating a
> =A0 BM> temporary filename, and just avoids the issue.
>
> well, that is why i call that option atomic. the idea is to always have
> a proper file around. i have plans for inplace edit functions in
> file::slurp (line by line or whole file) and those will call write_file
> with the atomic option. then you can do inplace editing from a program
> with just a single sub call (passing it a code ref to do the editing).
>
> =A0 BM> I have often thought Unix could do with flink(2) and mkstemp(2)
> =A0 BM> syscalls, that create a new link to an open fd and create a new fi=
le
> =A0 BM> with no name respectively. It would save a whole lot of mucking ab=
out
> =A0 BM> with temporary names.
>
> open can create temp files now (i think it uses file::temp
> underneath). in slurp i take the old file name and append the pid to it
> for the temp file. maybe i need to make that part more robust but no one
> has mentioned it. one reason i don't use the open temp feature is that
> slurp is backwards compatible to 5.005.
>
> uri
>
> --
> Uri Guttman =A0------ =A0u...@stemsystems.com =A0-------- =A0http://www.sy=
sarch.com--
> ----- =A0Perl Architecture, Development, Training, Support, Code Review =
=A0------
> ----------- =A0Search or Offer Perl Jobs =A0-----http://jobs.perl.org=A0--=
-------
> --------- =A0Gourmet Hot Cocoa Mix =A0---- =A0http://bestfriendscocoa.com-=
--------

Can some one tell the command line perl one-liner (windows xp) to
replace a word with another with in the same file, with out backing up
the file?

C:\> perl -i~ -pe "s/bsmith/brsmith/g" test.txt
    is backing up the file.

Thanks,
J



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

Date: Thu, 7 Feb 2008 03:26:31 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: To modify a file from the command line
Message-Id: <7caq75-6bl1.ln1@osiris.mauzo.dyndns.org>


Quoth clearguy02@yahoo.com:
> 
> Can some one tell the command line perl one-liner (windows xp) to
> replace a word with another with in the same file, with out backing up
> the file?
> 
> C:\> perl -i~ -pe "s/bsmith/brsmith/g" test.txt
>     is backing up the file.

Apply a small amount of imagination.

    perl -i~ -pe "s/bsmith/brsmith/g; END { unlink 'test.txt~' }'
        test.txt

or more generally

    perl -i~ -pe "s/bsmith/brsmith/g; END { unlink map qq/$_$^I/, @ARGV }"
        test.txt

Ben



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

Date: Wed, 06 Feb 2008 20:03:45 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: To modify a file from the command line
Message-Id: <jf6dnQcLYvW_HjfanZ2dnUVZ_o-mnZ2d@comcast.com>

clearguy02@yahoo.com wrote:

> Can some one tell the command line perl one-liner (windows xp) to
> replace a word with another with in the same file, with out backing up
> the file?

For arbitrary-length files on Windows, the answer is No.

> C:\> perl -i~ -pe "s/bsmith/brsmith/g" test.txt
>     is backing up the file.

For files that can fit into memory:

C:\> perl -0le "$f=$ARGV[0];$_=<>;s/bsmith/brsmith/g;open F,'>',$f;print F $_" test.txt

	-Joe


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

Date: Thu, 07 Feb 2008 04:25:10 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: To modify a file from the command line
Message-Id: <x7tzkl1jh5.fsf@mail.sysarch.com>

>>>>> "JS" == Joe Smith <joe@inwap.com> writes:

  JS> clearguy02@yahoo.com wrote:
  >> Can some one tell the command line perl one-liner (windows xp) to
  >> replace a word with another with in the same file, with out backing up
  >> the file?

  JS> For arbitrary-length files on Windows, the answer is No.

  >> C:\> perl -i~ -pe "s/bsmith/brsmith/g" test.txt
  >> is backing up the file.

  JS> For files that can fit into memory:

  JS> C:\> perl -0le "$f=$ARGV[0];$_=<>;s/bsmith/brsmith/g;open F,'>',$f;print F $_" test.txt

untested

perl -MFile::Slurp -e '$f = shift ; $t = read_file $f; $t =~
s/bsmith/brsmith/g; write_file $f, $t' test.txt

when edit_file is added to file::slurp you will be able to do:

perl -MFile::Slurp=edit_file -e 'edit_file shift, sub{ s/bsmith/brsmith/g }'

maybe i will also add an edit_file script that takes a file name and
code ref arg:

edit_file 'sub{ s/bsmith/brsmith/g }' test.txt

that looks kinda nice!

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Architecture, Development, Training, Support, Code Review  ------
-----------  Search or Offer Perl Jobs  ----- http://jobs.perl.org  ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

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 V11 Issue 1262
***************************************


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