Re: Replace only once.

2005-12-05 Thread mohd sharif
But it will fail if we have spaces before $modtager = " 45247"; You should probably write like this. #!/usr/bin/perl $modtager = "45247"; $modtager =~ s/^\s+//g; # deletes all leading spaces in variable $modtager =~ s/^(45)//; # guarantees match of 45 -Sharif On 12/2/05, Alexandre Checin

Re: Replace only once.

2005-12-02 Thread Alexandre Checinski
unless you use this syntax : $modtager =~s/45//g; only the first occurence of the searched string will be replace... so what you wrote should work fine... BR Mads N. Vestergaard wrote: Hi Everybody, I have a script where I need to replace 45 in the beginning, with nothing in a variable...

Re: Replace only once.

2005-12-02 Thread Alois Heuboeck
On Fri, Dec 02, 2005 at 10:22:47AM +, Mads N. Vestergaard wrote: I have a script where I need to replace 45 in the beginning, with nothing in a variable It looks like this: #!/usr/bin/perl $modtager = "45247"; $modtager =~s/45//; Then $modtager is 247, but if forinstance the

Re: Replace only once.

2005-12-02 Thread Paul Johnson
On Fri, Dec 02, 2005 at 10:22:47AM +, Mads N. Vestergaard wrote: > I have a script where I need to replace 45 in the beginning, with nothing > in a variable > > It looks like this: > > #!/usr/bin/perl > > $modtager = "45247"; > > $modtager =~s/45//; > > Then $modtager is 247, but i

Replace only once.

2005-12-02 Thread Mads N. Vestergaard
Hi Everybody, I have a script where I need to replace 45 in the beginning, with nothing in a variable It looks like this: #!/usr/bin/perl $modtager = "45247"; $modtager =~s/45//; Then $modtager is 247, but if forinstance the number is 4545247, it should return 45247, how do I do this