C.DeRykus wrote:
If you're permitted a one-liner:
perl -pi.bak -e '$c=s/Dood\/Dude/ if !$c++' file
$ perl -c -pi.bak -e '$c=s/Dood\/Dude/ if !$c++'
Substitution replacement not terminated at -e line 1.
John
--
Any intelligent fool can make things bigger and
more complex... It takes a t
On Aug 21, 4:33 am, xecro...@yahoo.com (Ron Weidner) wrote:
> Recently, I was asked to find the first occurrence of a word in a text file
> and replace it with an alternate word. This was my solution. As a new Perl
> programmer, I feel like this solution was too C like and not enough Perl
> li
> "John" == "John W Krahn" writes:
John> ?Dood? && s/Dood/Dude/;
Deprecated in 5.14. Replace with m?Dood? and you're good though.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technica
> "JWK" == John W Krahn writes:
JWK> There are a few ways to do what you require:
and you missed the simplest one so far (i did mention edit_file):
JWK> #!/usr/bin/perl
JWK> use strict;
JWK> use warnings;
use File::Slurp qw( edit_file ) ;
my $file = 'data.txt' ;
> "JWK" == John W Krahn writes:
JWK> There are a few ways to do what you require:
and you missed the simplest one so far (i did mention edit_file):
JWK> #!/usr/bin/perl
JWK> use strict;
JWK> use warnings;
use File::Slurp qw( edit_file ) ;
edit_file { s/Dood/Dude/g } $file
Ron Weidner wrote:
Recently, I was asked to find the first occurrence of a word in a text
file and replace it with an alternate word. This was my solution. As
a new Perl programmer, I feel like this solution was too C like and
not enough Perl like. So, my question is what would have been the
P
> "SHC" == Shawn H Corey writes:
SHC> On 11-08-21 07:33 AM, Ron Weidner wrote:
>> Recently, I was asked to find the first occurrence of a word in a text
file and replace it with an alternate word. This was my solution. As a new
Perl programmer, I feel like this solution was too C like
On 21/08/2011 13:21, Rob Dixon wrote:
Hey Ronald
Here is a program like yours, that reads the entire file into memory and
then outputs the altered version.
#!/usr/bin/perl
use strict;
use warnings;
#program finds the first occurrence of the word Dood and
#replaces it with the word Dude in the
On 21/08/2011 12:33, Ron Weidner wrote:
>
> Recently, I was asked to find the first occurrence of a word in a
> text file and replace it with an alternate word. This was my
> solution. As a new Perl programmer, I feel like this solution was too
> C like and not enough Perl like. So, my question is
On 11-08-21 07:33 AM, Ron Weidner wrote:
Recently, I was asked to find the first occurrence of a word in a text file and
replace it with an alternate word. This was my solution. As a new Perl
programmer, I feel like this solution was too C like and not enough Perl like.
So, my question is w
10 matches
Mail list logo