Re: search and replace

2016-06-29 Thread John SJ Anderson
> On Jun 29, 2016, at 09:20, Uri Guttman wrote: > > since you are correct about modules being already there, why do you write > your own versions of > slurp_file and write_file? the module File::Slurp has those functions which > are stable, fast and debugged. Please don’t use File::Slurp. Se

Re: search and replace

2016-06-29 Thread Eric de Hont
Op 29-06-16 om 19:26 schreef Uri Guttman: On 06/29/2016 01:17 PM, Eric de Hont wrote: Op 29-06-16 om 18:20 schreef Uri Guttman: since you are correct about modules being already there, why do you write your own versions of slurp_file and write_file? the module File::Slurp has those functions w

Re: search and replace

2016-06-29 Thread Uri Guttman
On 06/29/2016 01:17 PM, Eric de Hont wrote: Op 29-06-16 om 18:20 schreef Uri Guttman: On 06/29/2016 06:03 AM, Eric de Hont wrote: sub slurp_file { my $file = shift; local $/; open my $fh, '<', $file or die "Can't open $_: $!\n"; $_ is not set anywhere. you likely meant to use $f

Re: search and replace

2016-06-29 Thread Eric de Hont
Op 29-06-16 om 18:20 schreef Uri Guttman: On 06/29/2016 06:03 AM, Eric de Hont wrote: sub slurp_file { my $file = shift; local $/; open my $fh, '<', $file or die "Can't open $_: $!\n"; $_ is not set anywhere. you likely meant to use $file O, dear. Just a bit too quick and dirty.

Re: search and replace

2016-06-29 Thread Uri Guttman
On 06/29/2016 06:03 AM, Eric de Hont wrote: Op 29-06-16 om 06:35 schreef Danny Wong: Hi Perl GURUs, I have a json file that needs parsing. Here is a typical string I’m searching for. I want to delete everything but the last 2 character “],”. ], [ "ansible",

Re: search and replace

2016-06-29 Thread Danny Wong
ers@perl.org>> Subject: Re: search and replace Op 29-06-16 om 06:35 schreef Danny Wong: Hi Perl GURUs, I have a json file that needs parsing. Here is a typical string I’m searching for. I want to delete everything but the last 2 character “],”. ], [ "a

Re: search and replace

2016-06-29 Thread Eric de Hont
Op 29-06-16 om 06:35 schreef Danny Wong: Hi Perl GURUs, I have a json file that needs parsing. Here is a typical string I’m searching for. I want to delete everything but the last 2 character “],”. ], [ "ansible", "2.1.0.0-1ppa~trusty", false ], Here is wh

Re: search and replace

2016-06-29 Thread Shlomi Fish
Hi Danny, Please reply to all recipients. See below for my reply. On Wed, 29 Jun 2016 04:35:22 + Danny Wong wrote: > Hi Perl GURUs, > I have a json file that needs parsing. > Why not use a JSON parser? See http://perl-begin.org/uses/text-parsing/ . > Here is a typical string I’m searchin

search and replace

2016-06-28 Thread Danny Wong
Hi Perl GURUs, I have a json file that needs parsing. Here is a typical string I’m searching for. I want to delete everything but the last 2 character “],”. ], [ "ansible", "2.1.0.0-1ppa~trusty", false ], Here is what I tried: I slu

Re: Search and replace trouble with a variable

2014-02-01 Thread Shlomi Fish
Hi Omega, On Sat, 1 Feb 2014 11:36:20 -0500 Omega -1911 <1911...@gmail.com> wrote: > Good advice Shlomi. Thank you again. I should have caught that with fresh > eyes! You're welcome! ☺ Regards, Shlomi Fish -- - Shlomi Fis

Re: Search and replace trouble with a variable

2014-02-01 Thread Omega -1911
On Sat, Feb 1, 2014 at 4:57 AM, Shlomi Fish wrote: > Hi Omega, > > On Sat, 1 Feb 2014 03:40:01 -0500 > Omega -1911 <1911...@gmail.com> wrote: > > > Hello List: I am trying to go through a folder of php scripts to add a > > database prefix to lines that have a select statement. Since the database

Re: Search and replace trouble with a variable

2014-02-01 Thread Shlomi Fish
Hi Omega, On Sat, 1 Feb 2014 03:40:01 -0500 Omega -1911 <1911...@gmail.com> wrote: > Hello List: I am trying to go through a folder of php scripts to add a > database prefix to lines that have a select statement. Since the database > prefix will differ, I am simply trying to add: > > ".$database

Re: Search and replace trouble with a variable

2014-02-01 Thread Hal Wigoda
What error? (Sent from iPhone, so please accept my apologies in advance for any spelling or grammatical errors.) > On Feb 1, 2014, at 2:40 AM, Omega -1911 <1911...@gmail.com> wrote: > > Hello List: I am trying to go through a folder of php scripts to add a > database prefix to lines that have

Search and replace trouble with a variable

2014-02-01 Thread Omega -1911
Hello List: I am trying to go through a folder of php scripts to add a database prefix to lines that have a select statement. Since the database prefix will differ, I am simply trying to add: ".$database_prefix." to those lines. For example, instead of the line looking like: $sql = "SELECT * FROM

Re: compare and replace each line with Hash

2012-11-18 Thread Jim Gibson
e "Could not open '$file'\n"; > while (my $line = <$data>) > { >if ($csv->parse($line)) >{ >my @row = $csv->fields(); >print "$row\n"; >// compare and replace string name to id. >} >else &g

compare and replace each line with Hash

2012-11-15 Thread Mohan L
"Cannot use CSV: ".Text::CSV->error_diag (); open(my $data, '<', $file) or die "Could not open '$file'\n"; while (my $line = <$data>) { if ($csv->parse($line)) { my @row = $csv->fields(); print "$row\n";

Re: search and replace

2012-08-18 Thread timothy adigun
Hi Irfan Sayed, Please check my comments below. On 8/18/12, Irfan Sayed wrote: > hi, > > i have string like this : > $a = '$(workspace)\convergence\trunk'; > > i need to replace $(workspace) with 'c:\p4\abc' > i wrote regex like this : > > $a

Re: search and replace

2012-08-17 Thread Irfan Sayed
thanks a lot regards irfan From: Shawn H Corey To: beginners@perl.org Cc: Irfan Sayed Sent: Saturday, August 18, 2012 6:50 AM Subject: Re: search and replace On Fri, 17 Aug 2012 18:02:23 -0700 (PDT) Irfan Sayed wrote: > i have string like this : &

Re: search and replace

2012-08-17 Thread Shawn H Corey
On Fri, 17 Aug 2012 18:02:23 -0700 (PDT) Irfan Sayed wrote: > i have string like this : > $a = '$(workspace)\convergence\trunk'; > > i need to replace $(workspace) with 'c:\p4\abc' > i wrote regex like this : > > $a =~ s/$\(workspace)/c:\\p4\\abc/; The

search and replace

2012-08-17 Thread Irfan Sayed
hi, i have string like this : $a = '$(workspace)\convergence\trunk'; i need to replace $(workspace) with 'c:\p4\abc' i wrote regex like this : $a =~ s/$\(workspace)/c:\\p4\\abc/; however, the string which i am getting is : $(c:\p4\abc)\convergence\trunk i need output l

Re: search and replace

2012-08-16 Thread Shawn H Corey
On Thu, 16 Aug 2012 10:55:03 +0200 Gergely Buday wrote: > Notice that in order to put a literal backslash into a perl string, > you should escape it. In your original program, you have put a \b, a > bell character into the string. Actually, "\b" is the backspace character. The bell or alarm char

Re: search and replace

2012-08-16 Thread Irfan Sayed
Awesome thanks all for reply . got it regards irfan From: midhun To: Rob Coops Cc: Gergely Buday ; Irfan Sayed ; "beginners@perl.org" Sent: Thursday, August 16, 2012 2:41 PM Subject: Re: search and replace The issue is $cs_project = &qu

Re: search and replace

2012-08-16 Thread midhun
_text\n"; > > > > Notice that in order to put a literal backslash into a perl string, > > you should escape it. In your original program, you have put a \b, a > > bell character into the string. > > > > - Gergely > > > > On 16 August 2012 10:48, I

Re: search and replace

2012-08-16 Thread Rob Coops
ckslash into a perl string, > you should escape it. In your original program, you have put a \b, a > bell character into the string. > > - Gergely > > On 16 August 2012 10:48, Irfan Sayed wrote: > > hi, > > > > i have following code to search single "

Re: search and replace

2012-08-16 Thread Gergely Buday
l character into the string. - Gergely On 16 August 2012 10:48, Irfan Sayed wrote: > hi, > > i have following code to search single "\" and replace it with "\\" > but it is not doing as expected: > > $csproj_text = "C:\build.txt"; > > $csproj_tex

search and replace

2012-08-16 Thread Irfan Sayed
hi, i have following code to search single "\" and replace it with "\\" but it is not doing as expected: $csproj_text = "C:\build.txt"; $csproj_text =~ s/\\//g; print "$csproj_text\n"; the output is : "Cuild.txt" instead the output shou

Re: search and replace with an array

2012-02-21 Thread Shawn H Corey
On 12-02-21 11:37 AM, Adams Paul wrote: Sent from my LG phone Is this is what is called a bum dial? -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. It's Mutual Aid, not fierce competition, that's the dom

Re: search and replace with an array

2012-02-21 Thread Adams Paul
Sent from my LG phone "John W. Krahn" wrote: >Chris Stinemetz wrote: >> I am trying ot find a way to use an array as a reference to remove >> lines from a file. >> The array @keyFields has the elements "rcsm and cdmno". My objective >> is to remove any line from the input that matches the regex

Re: search and replace with an array

2012-02-20 Thread Chris Stinemetz
Thank you everyone that replied. Your suggestions helped me with finding a solution. Take care, Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: search and replace with an array

2012-02-20 Thread John W. Krahn
Chris Stinemetz wrote: I am trying ot find a way to use an array as a reference to remove lines from a file. The array @keyFields has the elements "rcsm and cdmno". My objective is to remove any line from the input that matches the regex /rcsm\d/ and cdmno\d/. AND means matching BOTH in the sam

RE: search and replace with an array

2012-02-20 Thread Ken Slater
> -Original Message- > From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] > Sent: Monday, February 20, 2012 3:51 PM > To: beginners@perl.org > Subject: Re: search and replace with an array > > Looks like I was able to figure it out with the below: > >

RE: search and replace with an array

2012-02-20 Thread Wagner, David --- Sr Programmer Analyst --- CFS
>-Original Message- >From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] >Sent: Monday, February 20, 2012 13:51 >To: beginners@perl.org >Subject: Re: search and replace with an array > >Looks like I was able to figure it out with the below: > >But how do I

Re: search and replace with an array

2012-02-20 Thread Chris Stinemetz
Looks like I was able to figure it out with the below: But how do I remove all the blank lines? Output: cdmno=1 rdnt_cdmno=1 cdmno=2 rcsm=801 rcsm=801 rcsm=802 #!/usr/bin/perl use warnings; use strict; my $file = "nonKeys.txt"; my $newFile = "cleanKeys.txt"; my @keyFields

search and replace with an array

2012-02-20 Thread Chris Stinemetz
I am trying ot find a way to use an array as a reference to remove lines from a file. The array @keyFields has the elements "rcsm and cdmno". My objective is to remove any line from the input that matches the regex /rcsm\d/ and cdmno\d/. I'm not sure if I'm using the best approach. I am getting t

Re: Replace words in a file using perl script

2011-12-16 Thread Brandon McCaig
On Thu, Dec 15, 2011 at 07:36:37AM -0800, Melvin wrote: > Hi, Hello: > I was trying to write a script to replace baby to bigboy in a file:- > However the below script doesn't work Could someone help me??? > > #!/usr/bin/perl -w > use strict; > > open (FILE_IN , $A

Re: Replace words in a file using perl script

2011-12-16 Thread Uri Guttman
On 12/16/2011 03:23 PM, Chris Stinemetz wrote: Hello Melvin, Give this a try. I used the advice Jim gave and this is what I came up with. It seems to do what you are asking for. #!/usr/bin/perl use warnings; use strict; my $inFile = "input.txt"; my $outFile = "output.txt"; open my $fin, '<',

Re: Replace words in a file using perl script

2011-12-16 Thread Chris Stinemetz
Hello Melvin, Give this a try. I used the advice Jim gave and this is what I came up with. It seems to do what you are asking for. #!/usr/bin/perl use warnings; use strict; my $inFile = "input.txt"; my $outFile = "output.txt"; open my $fin, '<', $inFile or die "ERROR opening $inFile: $!"; open

RE: Replace words in a file using perl script

2011-12-16 Thread Kronheim, David (Contr)
Metakey/LIA 484-213-1315 From: Melvin [whereismel...@gmail.com] Sent: Thursday, December 15, 2011 10:36 AM To: beginners@perl.org Subject: Replace words in a file using perl script Hi, I am a Perl baby :-) I was trying to write a script to replace baby to bigboy in a file:-

Re: Replace words in a file using perl script

2011-12-16 Thread Jim Gibson
On 12/15/11 Thu Dec 15, 2011 7:36 AM, "Melvin" scribbled: > Hi, > > I am a Perl baby :-) > > I was trying to write a script to replace baby to bigboy in a file:- > However the below script doesn't work Could someone help me??? The problem with your script is

Replace words in a file using perl script

2011-12-16 Thread Melvin
Hi, I am a Perl baby :-) I was trying to write a script to replace baby to bigboy in a file:- However the below script doesn't work Could someone help me??? #!/usr/bin/perl -w use strict; open (FILE_IN , $ARGV[0]) || die ("ERROR: Gimme Input pleease"); my @array_of_lines = ; f

Re: Find and Replace in Textfile

2011-08-22 Thread John W. Krahn
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

Re: Find and Replace in Textfile

2011-08-22 Thread C.DeRykus
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 en

Re: Find and Replace in Textfile

2011-08-22 Thread Randal L. Schwartz
>>>>> "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.sto

Re: Find and Replace in Textfile

2011-08-21 Thread Uri Guttman
> "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' ;

Re: Find and Replace in Textfile

2011-08-21 Thread Uri Guttman
> "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

Re: Find and Replace in Textfile

2011-08-21 Thread John W. Krahn
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

Re: Find and Replace in Textfile

2011-08-21 Thread Uri Guttman
>>>>> "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

Re: Find and Replace in Textfile

2011-08-21 Thread Rob Dixon
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

Re: Find and Replace in Textfile

2011-08-21 Thread Rob Dixon
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.

Re: Find and Replace in Textfile

2011-08-21 Thread Shawn H Corey
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

Find and Replace in Textfile

2011-08-21 Thread Ron Weidner
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 Perl like solution

Re: Search and replace w/ ignoring arbitrary characters

2011-08-10 Thread Frank Müller
in f[##o]o(ba##r) ? again, thanks for any ideas and hints, Frank On 9 Aug., 02:34, jwkr...@shaw.ca ("John W. Krahn") wrote: > Frank Müller wrote: > > dear all, > > Hello, > > > i want to make some search and replace within a string where I can > > define a s

Re: Search and replace w/ ignoring arbitrary characters

2011-08-08 Thread John W. Krahn
Frank Müller wrote: dear all, Hello, i want to make some search and replace within a string where I can define a set of characters, especially parenthesis, brackets etc., which are to be ignored. For example, I have the following string: sdjfh sdf sjkdfh sdkjfh sdjkf f[o]o(bar) hsdkjfh

Search and replace w/ ignoring arbitrary characters

2011-08-08 Thread Frank Müller
dear all, i want to make some search and replace within a string where I can define a set of characters, especially parenthesis, brackets etc., which are to be ignored. For example, I have the following string: sdjfh sdf sjkdfh sdkjfh sdjkf f[o]o(bar) hsdkjfh sdkljfhs sjfh sdkj sdjkfh sdjfh

Re: Replace digit by equivalent in words.

2010-10-12 Thread Jon Hermansen
help.I am trying to read the file contents line by > line and if there are any number in the word (like 1,2,...) then i hav to > replace that digit by its equivalent in terms of words. > Ex:if input is hi*5*go > Output has to be hi*five*go..This changes has to be reflected in original

Replace digit by equivalent in words.

2010-10-12 Thread pawan kumar
Hi Folks, I need an help.I am trying to read the file contents line by line and if there are any number in the word (like 1,2,...) then i hav to replace that digit by its equivalent in terms of words. Ex:if input is hi*5*go Output has to be hi*five*go..This changes has to be

Re: XML Replace

2010-05-02 Thread Klaus
On 28 avr, 19:12, trevor.do...@gmail.com (Trev) wrote: > I'm trying to use Perl to replace a line in a few XML files I have. > > Example XML below, I'm wanting to change the Id= part from  Id="/Local/ > App/App1" to Id=/App1". I know there's an easy wa

Re: XML Replace

2010-04-30 Thread Shlomi Fish
Hi, sorry for the late response. On Wednesday 28 Apr 2010 20:12:36 Trev wrote: > I'm trying to use Perl to replace a line in a few XML files I have. > > Example XML below, I'm wanting to change the Id= part from Id="/Local/ > App/App1" to Id=/App1". I kno

Re: XML Replace

2010-04-30 Thread Brad Baxter
Trev wrote: I'm trying to use Perl to replace a line in a few XML files I have. Example XML below, I'm wanting to change the Id= part from Id="/Local/ App/App1" to Id=/App1". I know there's an easy way to do this with perl alone however I'm trying to use XML

XML Replace

2010-04-29 Thread Trev
I'm trying to use Perl to replace a line in a few XML files I have. Example XML below, I'm wanting to change the Id= part from Id="/Local/ App/App1" to Id=/App1". I know there's an easy way to do this with perl alone however I'm trying to use XML

Re: how do I replace all the spaces in a string with +

2010-02-25 Thread Jenda Krynicky
From: Erik Lewis > Thanks that probably explains my higher than expected ungeocoded > rate. Two weeks of playing with perl and I feel like I know less than > when I started. The more you learn the more you find out you know nothing ;-) This feeling is to be expected. Don't let it overwhelm

Re: how do I replace all the spaces in a string with +

2010-02-25 Thread Erik Lewis
v = get("http://maps.google.com/maps/geo?q=$geoaddress&output=csv&sensor=false&key=$googlekey ") or die 'Unable to get page'; As if I did not think so. No you do not need to replace spaces by plus signs! You need to escape the string for inclusion in a query s

Re: how do I replace all the spaces in a string with +

2010-02-25 Thread Jenda Krynicky
ww8R4s0VhTfTt-19vTI9qA-_V1pUf4-_TcfpQ"; > #get your google http://code.google.com/apis/maps/signup.html > > my $geocode_csv = > get("http://maps.google.com/maps/geo?q=$geoaddress&output=csv&sensor=false&key=$googlekey";) > > or die 'Unable to get p

Re: how do I replace all the spaces in a string with +

2010-02-20 Thread Robert Citek
On Fri, Feb 19, 2010 at 3:23 PM, John W. Krahn wrote: > Sergey Matveev wrote: >> >> Greetings, >> >> On Fri, Feb 19, 2010 at 03:54:27PM -0500, Erik Lewis wrote: >> >>> I have to changes all the spaces in a string to +'s.  Is there an >>> easy way to do this.  The length of the string and the numbe

Re: how do I replace all the spaces in a string with +

2010-02-20 Thread Dr.Ruud
space? To for example replace space and tab runs by a single plus, try this: s{ [[:blank:]]+ } {+}xg; which is equivalent to tr { \t} {+}s; Example: perl -wle ' my $var = "abc def \t g"; (my $v1 = $var ) =~ s{ [[:blank:]]+ } {+}xg; (my $v2 = $var ) =~ tr {

Re: how do I replace all the spaces in a string with +

2010-02-19 Thread Sergey Matveev
Greetings, On Fri, Feb 19, 2010 at 02:23:07PM -0800, John W. Krahn wrote: > You don't have to escape a plus sign in a quoted string: > > $string =~ s/ /+/g; Yeah. I see. I understand my fault. -- Happy hacking, Sergey Matveev FSF Associate member #5968 | FSFE Fellow #1390 -- To unsubscribe,

Re: how do I replace all the spaces in a string with +

2010-02-19 Thread Uri Guttman
> "SM" == Sergey Matveev writes: SM> $string =~ s/ /\+/g; why are you escaping the + there? that is a replacement string, not a regex. it is double quotish but not much more than that. + is just a regular char there like almost all chars in double quoted strings. this is a common thing i

Re: how do I replace all the spaces in a string with +

2010-02-19 Thread John W. Krahn
Sergey Matveev wrote: Greetings, On Fri, Feb 19, 2010 at 03:54:27PM -0500, Erik Lewis wrote: I have to changes all the spaces in a string to +'s. Is there an easy way to do this. The length of the string and the number of spaces will always be changing. $string =~ s/ /\+/g; That is all.

Re: how do I replace all the spaces in a string with +

2010-02-19 Thread Erik Lewis
Thanks Sergey, That was just staring at me in the face. If anyone is interested a little code to spit back the latitude and longitude of an address. Next step is to get it too pull the address from a mysql database and then update it. #!/usr/bin/perl use war

Re: how do I replace all the spaces in a string with +

2010-02-19 Thread Sergey Matveev
Greetings, On Fri, Feb 19, 2010 at 03:54:27PM -0500, Erik Lewis wrote: > I have to changes all the spaces in a string to +'s. Is there an easy way to > do this. The length of the string and the number of spaces will always be > changing. $string =~ s/ /\+/g; That is all. All spaces will b

how do I replace all the spaces in a string with +

2010-02-19 Thread Erik Lewis
I have to changes all the spaces in a string to +'s. Is there an easy way to do this. The length of the string and the number of spaces will always be changing. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl

Re: search replace saved to a variable

2009-09-03 Thread Jenda Krynicky
From: Noah Garrett Wallach > okay a step further - is there a way to make the following a one liner? > > (my $filename_cmd = $cmd[-1]) =~ s/\|//g; > $filename_cmd =~ s/\s+/\./g; > $filename_cmd =~ s/save.*//g; There's no point in making it a one liner. Plus anything may be writen

Re: search replace saved to a variable

2009-09-02 Thread Uri Guttman
>>>>> "NGW" == Noah Garrett Wallach writes: NGW> Jim Gibson wrote: >> At 7:22 PM -0700 9/2/09, Noah Garrett Wallach wrote: >>> Hi there, >>> >>> what is the way to collapse this search/replace to one line? >>&

Re: search replace saved to a variable

2009-09-02 Thread Noah Garrett Wallach
Jim Gibson wrote: At 7:22 PM -0700 9/2/09, Noah Garrett Wallach wrote: Hi there, what is the way to collapse this search/replace to one line? my $filename_cmd = $cmd[-1]; my $filename_cmd =~ s/\s/\./; (my $filename_cmd = $cmd[-1]) =~ s/\s/\./; thanks, okay a step further

Re: search replace saved to a variable

2009-09-02 Thread Jim Gibson
At 7:22 PM -0700 9/2/09, Noah Garrett Wallach wrote: Hi there, what is the way to collapse this search/replace to one line? my $filename_cmd = $cmd[-1]; my $filename_cmd =~ s/\s/\./; (my $filename_cmd = $cmd[-1]) =~ s/\s/\./; -- Jim Gibson jimsgib...@gmail.com -- To

search replace saved to a variable

2009-09-02 Thread Noah Garrett Wallach
Hi there, what is the way to collapse this search/replace to one line? my $filename_cmd = $cmd[-1]; my $filename_cmd =~ s/\s/\./; Cheers, Noah -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Shawn H. Corey [mailto:shawnhco...@gmail.com] > Sent: Monday, August 24, 2009 11:57 > To: Wagner, David --- Senior Programmer Analyst --- CFS > Cc: Tony Esposito; Beginners Perl > Subject: Re: one liner in Windows to replace string

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Shawn H. Corey [mailto:shawnhco...@gmail.com] > Sent: Monday, August 24, 2009 11:00 > To: Tony Esposito > Cc: Beginners Perl > Subject: Re: one liner in Windows to replace string > > Tony Esposito wrote: > > perl -p -i.b

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
replace string Looks good but it bombs ... the Perl interpreter crashes from the DOS prompt ... using version 5.10.0 build 1005 from ActiveState. I am running AS 5.8.9 and when I run from cmd32.exe, it never comes back to me again. If I run under MKS Korn shell

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
replace string I am happy that it works with double quotes BUT now, when I try to get all files in a directory with a certain extension, the following does not work ... perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\*.txt To

RE: one liner in Windows to replace string

2009-08-25 Thread Wagner, David --- Senior Programmer Analyst --- CFS
> -Original Message- > From: Tony Esposito [mailto:tony1234567...@yahoo.co.uk] > Sent: Monday, August 24, 2009 10:46 > To: Beginners Perl > Cc: tony1234567...@yahoo.co.uk > Subject: one liner in Windows to replace string > > perl -p -i.bak -e 's/CO

Re: one liner in Windows to replace string

2009-08-24 Thread Shawn H. Corey
Telemachus wrote: Ok, not to be a jerk, but look at it this way: it's clear that Windows + one-liners are not going well. In the time we've all gone back and forth on this, you could have written a 10 line script and run it about 20 times. Pick your battles, I say. True, but it means "A Poor

Re: one liner in Windows to replace string

2009-08-24 Thread Telemachus
On Mon Aug 24 2009 @ 8:08, Tony Esposito wrote: > Looks good but it bombs ... the Perl interpreter crashes from the DOS prompt > ... using version 5.10.0 build 1005 from ActiveState. > > But it was better than what I had, that's for sure > > This makes for a bit of a mind teaser thanks to it be

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
ndoze ... :-) From: Shawn H. Corey To: Tony Esposito Cc: "Wagner, David --- Senior Programmer Analyst --- CFS" ; Beginners Perl Sent: Monday, 24 August, 2009 14:49:47 Subject: Re: one liner in Windows to replace string Tony Esposito wrote: > I am happy that it works with double quotes BUT

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
Ok, I can glob() ... perl -e "use File::DosGlob qw(glob);print glob('test.*')"   # works ok!! but I can not replace (my syntax is incorrect but where) ... perl -e "use File::DosGlob qw(glob);'s/CONSTANT/VARIABLE/' glob('test.*&#

Re: one liner in Windows to replace string

2009-08-24 Thread Shawn H. Corey
Tony Esposito wrote: I am happy that it works with double quotes BUT now, when I try to get all files in a directory with a certain extension, the following does not work ... perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\***.txt does not like th leading * in the file name when I try to pull

RE: one liner in Windows to replace string

2009-08-24 Thread Bob McConnell
. Corey; Wagner, David --- Senior Programmer Analyst --- CFS Cc: Beginners Perl Subject: Re: one liner in Windows to replace string I am happy that it works with double quotes BUT now, when I try to get all files in a directory with a certain extension, the following does not work ... perl -p -i.bak

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
txt files ... Help again. From: Shawn H. Corey To: "Wagner, David --- Senior Programmer Analyst --- CFS" Cc: Tony Esposito ; Beginners Perl Sent: Monday, 24 August, 2009 12:57:27 Subject: Re: one liner in Windows to replace string Wagner, David

Re: one liner in Windows to replace string

2009-08-24 Thread Shawn H. Corey
Wagner, David --- Senior Programmer Analyst --- CFS wrote: I ran under windows with what Tony sent, both the cmd and a korn shell and both worked and updated as expected.. If you have any questions and/or problems, please let me know. Thanks. What version of Windows?

Re: one liner in Windows to replace string

2009-08-24 Thread Telemachus
On Mon Aug 24 2009 @ 4:45, Tony Esposito wrote: > perl -p -i.bak -e 's/CONSTANT/VARIABLE/' C:\test.txt > > Trying to replace a string with this one line perl ... in Windows it does not > seem to work ... > > File test.txt contents is ... > > CONSTANT 100 &

Re: one liner in Windows to replace string

2009-08-24 Thread Shawn H. Corey
Tony Esposito wrote: perl -p -i.bak -e 's/CONSTANT/VARIABLE/' C:\test.txt Trying to replace a string with this one line perl ... in Windows it does not seem to work ... File test.txt contents is ... CONSTANT 100 CONSTANT 200 nothing changes ... acts as if it does not 'se

one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
perl -p -i.bak -e 's/CONSTANT/VARIABLE/' C:\test.txt Trying to replace a string with this one line perl ... in Windows it does not seem to work ... File test.txt contents is ... CONSTANT 100 CONSTANT 200 nothing changes ... acts as if it does not 'see' the CONSTANT stri

Re: Replace System("Dir") call Help

2009-06-21 Thread Telemachus
On Sun Jun 21 2009 @ 7:40, AndrewMcHorney wrote: > Hello > > I have written a perl script and I am in the debugging and imroving the > code. The first improvement is want to make is to replace the > system("Dir c:/s") call because it is not portable. So I was told t

Replace System("Dir") call Help

2009-06-21 Thread AndrewMcHorney
Hello I have written a perl script and I am in the debugging and imroving the code. The first improvement is want to make is to replace the system("Dir c:/s") call because it is not portable. So I was told to use the File package. I have not found a good example. So I am lookin

Re: Replace pattern with a variable num of spaces

2009-06-18 Thread John W. Krahn
Steve Bertrand wrote: John W. Krahn wrote: Steve Bertrand wrote: +sub is_word ($) { +return unless defined $_[0] && $_[0] ne ''; +return if $_[0] =~ /[\w\s]+/; +return 1; +} The other is_* functions in that module use anchors with their regular expressions so you probably should

Re: Replace pattern with a variable num of spaces

2009-06-18 Thread Steve Bertrand
John W. Krahn wrote: > Steve Bertrand wrote: >> I wasted about two hours of my coding time trying to come up with a >> special JAPH, but I just haven't been able to make map() do what I think >> it should do ;) > > What did you think it should do? What did you want it to do? Originally, I was t

Re: Replace pattern with a variable num of spaces

2009-06-17 Thread John W. Krahn
acter class and it has no meaning in a string context. If you want to replace a pattern with the value of $_[1] space characters then you could do this: s/blah/ ' ' x $_[1] /eg; The /e option treats the string on the right as Perl code and evaluates it and returns the result. Wow

Re: Replace pattern with a variable num of spaces

2009-06-17 Thread Steve Bertrand
annot put "whitespace" in the string half because whitespace is a > regular expression character class and it has no meaning in a string > context. > > If you want to replace a pattern with the value of $_[1] space > characters then you could do this: > > s/blah/ ' &

Re: Replace pattern with a variable num of spaces

2009-06-17 Thread John W. Krahn
uot;whitespace" in the string half because whitespace is a regular expression character class and it has no meaning in a string context. If you want to replace a pattern with the value of $_[1] space characters then you could do this: s/blah/ ' ' x $_[1] /eg; The /e option

Replace pattern with a variable num of spaces

2009-06-17 Thread Steve Bertrand
I'm attempting to write a patch for a module that I feel I can use within one of my own modules, and I've run into something that I can't solve (I can't come up with the proper query in Google). Perhaps code will help here. First, I know 'word' does not include whitespace, and I know that one shou

  1   2   3   4   5   6   7   8   >