Re: Substitution Problem

2010-06-28 Thread Chas. Owens
On Mon, Jun 28, 2010 at 19:48, John W. Krahn wrote: snip > s/\((\d+)\)/($1)/g; snip Since Perl 5.8.0, \d does not mean [0-9], it means any character that is classified as a digit in Unicode. In Perl 5.12.1, there are five hundred seventy-seven characters that will match \d. If it is your intent

Re: Substitution Problem

2010-06-28 Thread Steve Bertrand
On 2010.06.28 20:39, jimston...@aol.com wrote: > > In a message dated 6/28/2010 7:49:47 P.M. Eastern Daylight Time, > jwkr...@shaw.ca writes: > > jimston...@aol.com wrote: >> >> can anyone give me some help on a perl program to change a file of mine. >> The string is: >> >> $_ = "from ''ala

Re: Substitution Problem

2010-06-28 Thread Jimstone77
In a message dated 6/28/2010 7:49:47 P.M. Eastern Daylight Time, jwkr...@shaw.ca writes: jimston...@aol.com wrote: > > can anyone give me some help on a perl program to change a file of mine. > The string is: > > $_ = "from ''alam' (481) or possibly (in the sense of dumbness); > solitary;

Re: Substitution Problem

2010-06-28 Thread John W. Krahn
jimston...@aol.com wrote: can anyone give me some help on a perl program to change a file of mine. The string is: $_ = "from ''alam' (481) or possibly (in the sense of dumbness); solitary; Ulam, the (6155) name of two Soldiers;--Ulam." Where each line is $_ I'm trying to substitute a hyperli

Re: Substitution Problem

2010-06-28 Thread John W. Krahn
jimston...@aol.com wrote: can anyone give me some help on a perl program to change a file of mine. The string is: $_ = "from ''alam' (481) or possibly (in the sense of dumbness); solitary; Ulam, the (6155) name of two Soldiers;--Ulam." Where each line is $_ I'm trying to substitute a hyperli

Re: Substitution Problem

2010-06-28 Thread Jimstone77
can anyone give me some help on a perl program to change a file of mine. The string is: $_ = "from ''alam' (481) or possibly (in the sense of dumbness); solitary; Ulam, the (6155) name of two Soldiers;--Ulam." Where each line is $_ I'm trying to substitute a hyperlink for each NUMBER tha

Re: Substitution problem

2005-09-06 Thread John W. Krahn
John W. Krahn wrote: > Moon, John wrote: >>Does any one know how to do this with just a substitution? >> >>perl -e '$a=q{Data.m1234.D1234567890}; >> $a =~/\d+$/; >> $numbers = q{#} x length($&); >> $a=~ s/\d+$/$numbers/; print "$a\n";' >> >>What " Data.m1234.D## " as a result

Re: Substitution problem

2005-09-06 Thread John W. Krahn
Moon, John wrote: > Does any one know how to do this with just a substitution? > > perl -e '$a=q{Data.m1234.D1234567890}; > $a =~/\d+$/; > $numbers = q{#} x length($&); > $a=~ s/\d+$/$numbers/; print "$a\n";' > > What " Data.m1234.D## " as a result. $ perl -le'$_ = q{Da

RE: Substitution problem

2005-09-06 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Moon, John wrote: > Does any one know how to do this with just a substitution? > > perl -e '$a=q{Data.m1234.D1234567890}; > $a =~/\d+$/; > $numbers = q{#} x length($&); > $a=~ s/\d+$/$numbers/; print "$a\n";' > > What " Data.m1234.D## " as a result. > > John W Moon Did

Re: substitution problem

2003-11-06 Thread John W. Krahn
Steve Massey wrote: > > Hi Hello, > I though I had sussed this s/ stuff but > > #! /usr/bin/perl -w > > $test = "BRIGHTON (Firm)"; > > print "$test\n"; > $test =~ s/,*/,/; > $test =~ s/,*$/,/g; > > print "$test\n"; > > does not work, I want to su

Re: substitution problem

2003-10-23 Thread R. Joseph Newton
Steve Massey wrote: > Hi > > I though I had sussed this s/ stuff but > > #! /usr/bin/perl -w > > $test = "BRIGHTON (Firm)"; > > print "$test\n"; > $test =~ s/,*/,/; > $test =~ s/,*$/,/g; > > print "$test\n"; > > does not work, I want to substitute all m

RE: substitution problem

2003-10-23 Thread Mark Anderson
> From: Steve Massey [mailto:[EMAIL PROTECTED] > Sent: 23 October 2003 11:33 > > #! /usr/bin/perl -w > > $test = "BRIGHTON (Firm)"; > > > print "$test\n"; > $test =~ s/,*/,/; > $test =~ s/,*$/,/g; > > print "$test\n"; It looks like the +/* issue has bee

RE: substitution problem

2003-10-23 Thread Wiggins d Anconia
> Ok scrub that > > + works but * doesn't > > i'm guess the * is matching anything > > took me 2 hours to figure that ;) > To de-mystify the regexes some have a look at: perldoc perlretut perldoc perlre http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comma

Re: substitution problem

2003-10-23 Thread Gary Stainburn
On Thursday 23 Oct 2003 11:52 am, Steve Massey wrote: > Ok scrub that > > + works but * doesn't > > i'm guess the * is matching anything > > took me 2 hours to figure that ;) > Hi Steve, + matches 1 or more, * matches 0 or more. for better efficiency, you really want to do s/,,+/,/; which

RE: substitution problem

2003-10-23 Thread Steve Massey
Ok scrub that + works but * doesn't i'm guess the * is matching anything took me 2 hours to figure that ;) -Original Message- From: Steve Massey [mailto:[EMAIL PROTECTED] Sent: 23 October 2003 11:33 To: [EMAIL PROTECTED] Subject: substitution problem Hi I though I had sussed

Re: Substitution Problem

2001-06-08 Thread M.W. Koskamp
> -Original Message- > From: Mark Martin [mailto:[EMAIL PROTECTED]] > Sent: Friday, June 08, 2001 10:01 > To: [EMAIL PROTECTED] > Subject: Substitution Problem > > > Hi, > I'm taking in a csv file and splitting it. One of the fields(doc) could > possibly have six spaces which will disrupt

RE: Substitution Problem

2001-06-08 Thread Dave Newton
Mart Marken said: > I'm taking in a csv file and splitting it. One of the fields(doc) could > possibly have six spaces which will disrupt the program later on so I need > to substitute in dummy values. $doc == " " finds the "empty" fields > okay but the substitution doesn't work. Clear as Mud

Re: Substitution Problem

2001-06-08 Thread Carl Rogers
Good day; At 05:01 PM 6/8/2001 +, Mark Martin wrote: > > if ($doc == " "){ > > doc =~ s/ /11/; should be: $doc =~ s/ /11/; #don't forget the "$" Also, try $doc =~ tr/ /11/; Being a newbie myself, I stumb

RE: Substitution Problem

2001-06-08 Thread Wagner-David
One thing is that you are doing a numeric compare(ie == vs eq) Perl tries it best to come up with a valid response. Since you are doing the compare, why not just do the re as $doc =~ s/^\s{6}$/11/; which says if you have six whitespace then change to 1's or whatever.

Re: substitution problem

2001-05-29 Thread Jeff Pinyan
On May 29, Me said: >If you will allow perl to make use of temporary files >behind the scenes (which is normally perfectly ok), >Cookbook recipe 7.9 is a whole heck of a lot >simpler. As a command line one liner: > >perl -pie 's/a/p/g' try.txt foo.txt > >will go thru files try.txt and foo.txt

Re: substitution problem

2001-05-29 Thread Me
Cookbook recipe 7.10, as quoted by JJ, has the virtue that it does not use a temporary file. If you will allow perl to make use of temporary files behind the scenes (which is normally perfectly ok), Cookbook recipe 7.9 is a whole heck of a lot simpler. As a command line one liner: perl -pie

Re: substitution problem

2001-05-29 Thread prachi shroff
Thanks! The method you suggested works, though it is not SIMPLE AND SWEET!! :-) Thanks, anyways. Prachi Original Message Follows From: "J. J. Horner" <[EMAIL PROTECTED]> To: prachi shroff <[EMAIL PROTECTED]> CC: [EMAIL PROTECTED] Subject: Re: substitution pro

Re: substitution problem

2001-05-29 Thread Brett W. McCoy
On Tue, 29 May 2001, prachi shroff wrote: > I am having problems using the "s///" operator for substitution in of a > particular pattern in a specified file. > For eg. > > open(TRY,"+ while() > { > $_ =~ s/a/p/g; > } This does nothing to your file. You need to write your data back out to

Re: substitution problem

2001-05-29 Thread Me
> I am having problems using the "s///" operator for substitution in of a > particular pattern in a specified file. > For eg. > > open(TRY,"+ while() > { > $_ =~ s/a/p/g; > } > > Is this the right way of doing it? And with what access mode shall I open > the file ( >> or +> or +< ) ? And is

Re: substitution problem

2001-05-29 Thread J. J. Horner
Is there any reason you chose not to do it this way: # From Perl Cookbook: open(TRY,"+< try.txt") or die "Couldn't open try.txt: $!\n"; my @lines =# Slurp all lines into an array. foreach my $line (@lines) { # Iterate