jbl wrote:
> I have a lengthy list of data that I read in. I have substituted a one
> line example using __DATA__.
> The desired output would be
> 91416722      243rd St
> 
> I am getting this as output
> 
> 91416722rd St       <- just the rd St
> 
> The capturing reference on (\s)......$1
> 
> is not working
> 
> # Intent
> # Look for 243 preceded by any white space, followed by a space char
> # Capture the whitespace as $1
> # Replace with whatever the leading whitespace was, then the number,
> then the suffix rd and then the trailing space char
> 
> Basically add the suffix rd to the number 243, ie...243rd
> I can do something else but I was wondering what I am doing wrong here
> Thanks
> jbl
> 
> 
> #!/usr/bin/perl -w
>  use strict;
> 
> open MY_OUTPUT_FILE, "> Export_Output_mod.txt" or die "Can't write to
> out.txt: $!";
> 
>  while ( defined ( my $line = <DATA> ) ) {
>    $line =~ s/(\s)243 /$1243rd /g;

     $line =~ s/(\s)243 /${1}243rd /g;


>    print MY_OUTPUT_FILE $line;
>    }
> 
> close MY_OUTPUT_FILE;
> 
> __END__
> 91416722      243 St
> 
> 


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to