Re: Help with substitution

2005-05-12 Thread perlocean
- Original Message - From: Moon, John [EMAIL PROTECTED] To: 'Tham, Philip' [EMAIL PROTECTED] Cc: beginners@perl.org Sent: Tuesday, May 10, 2005 4:55 PM Subject: RE: Help with substitution To: 'Tham, Philip' Subject: RE: Help with substitution Subject: Help with substitution Hi I have

RE: Help with substitution

2005-05-10 Thread Moon, John
To: 'Tham, Philip' Subject: RE: Help with substitution Subject: Help with substitution Hi I have a string which reoccuring patterns 1abc2abc3abc4abc567 How do I remove everything before the 1st occrence of abc to get the result 2abc3abc4abc567 s/^.*abc// Gives me 567 Thanks in advance

RE: Help with substitution

2005-05-10 Thread David Aldridge
This worked for me. Don't forget the 'greedy' regex: s/^.*?(abc)//; -Original Message- From: Tham, Philip [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 10, 2005 3:59 PM To: beginners@perl.org Subject: Help with substitution Hi I have a string which reoccuring patterns

Re: Help! Perl Substitution

2004-02-19 Thread david
Jeff Westman wrote: I'm trying to help out another developer with a mini-Perl script. He has a file that contains one very long line, about 28M in size. He needs to do a replacement of all occurances of |^NEWLINE^|^ to a literal newline (HPUX, 0x0a or \n). When I ran this $

Re: Help! Perl Substitution

2004-02-19 Thread Paul Johnson
On Thu, Feb 19, 2004 at 04:36:55PM -0800, david wrote: Jeff Westman wrote: I'm trying to help out another developer with a mini-Perl script. He has a file that contains one very long line, about 28M in size. He needs to do a replacement of all occurances of |^NEWLINE^|^ to a

Re: Help! Perl Substitution

2004-02-19 Thread david
Paul Johnson wrote: [panda]# perl -ne 'BEGIN{$/=\10} s/\|\^NEWLINE\^\|\^/\n/g; print' [loadFile The trouble with this approach is that you will miss any separators which are split. Your example actually reads 10 bytes at a time, but using $/ is the right idea: perl -ple 'BEGIN {

Re: Help! Perl Substitution

2004-02-19 Thread Jeff Westman
Paul Johnson [EMAIL PROTECTED] wrote: On Thu, Feb 19, 2004 at 04:36:55PM -0800, david wrote: Jeff Westman wrote: I'm trying to help out another developer with a mini-Perl script. He has a file that contains one very long line, about 28M in size. He needs to do a replacement of

Re: Help! Perl Substitution

2004-02-19 Thread WC -Sx- Jones
Jeff Westman wrote: When I ran this $ perl -ne 's/|^NEWLINE^|^/\n/g;print' loadFile The program loads the ENTIRE loadfile and then splits characters at whitespace between characters and then prints every character followed by a newline. So, how big is loadfile?

Re: Help! Perl Substitution

2004-02-19 Thread Jeff Westman
WC -Sx- Jones [EMAIL PROTECTED] wrote: Jeff Westman wrote: When I ran this $ perl -ne 's/|^NEWLINE^|^/\n/g;print' loadFile The program loads the ENTIRE loadfile and then splits characters at whitespace between characters and then prints every character followed by a

Re: help with substitution

2002-12-11 Thread Rob Dixon
Hello Erik It's not clear exactly what you want, but something like this should do the job: for (my $i = 0; $i length $word; ++$i) { substr ($word, $i, 1) = '-' unless substr ($givenword, $i, 1) eq 'X'; } HTH, Rob - Original Message - From: Erik Browaldh [EMAIL

Re: help with substitution

2002-12-11 Thread Erik Browaldh
Hi! no, its still not changing the letters (but thanks Rob).. I have a string: $givenword=YY- and another string (the original) $word=not now I want $givenword to look like this: $givenword=no- ? thanks in advanced! Erik Rob Dixon wrote: Hello Erik It's not clear exactly what you want,

Re: help with substitution

2002-12-11 Thread Rob Dixon
Hi Erik You might like this! $givenword =~ s/[a-z]/substr $word, pos $givenword, 1/egi; Cheers, R - Original Message - From: Erik Browaldh [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, December 11, 2002 4:01 PM Subject: Re: help with substitution Hi! no, its