How to remove everything after the last . dot?

2005-03-08 Thread Bastian Angerstein
I have a line: i.like.donuts.but.only.with.tea now I want to remove everything that follows the last . including the last .. in this case .tea I hav absulte no idea. I tried something like: @parts = splite /\./, $line; $parts[-1] = undef; foreach $parts (@parts) { $newline .= $parts.;

Re: How to remove everything after the last . dot?

2005-03-08 Thread John Doe
Hi I have a line: i.like.donuts.but.only.with.tea now I want to remove everything that follows the last . including the last .. [...] you can use a regex for that. === Documentation (from command line:) perldoc perlre === Code: use strict; use warnings; my

AW: How to remove everything after the last . dot?

2005-03-08 Thread Bastian Angerstein
-70469 Stuttgart +49 711 8939 1889 (Tel.) +49 711 8939 6604 (Fax) mailto:[EMAIL PROTECTED] http://www.t-com.de -Ursprüngliche Nachricht- Von: John Doe [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 8. März 2005 11:46 An: beginners@perl.org Betreff: Re: How to remove everything after the last

Re: AW: How to remove everything after the last . dot?

2005-03-08 Thread Ing. Branislav Gerzo
Bastian Angerstein [BA], on Tuesday, March 8, 2005 at 12:19 (+0100) wrote: BA use strict; use warnings; BA my $a=i.like.donuts.but.only.with.tea; BA $a=~s/\.\w+$//; # maybe w+ not d+??? BA print $a, \n; correct code is: use strict; use warnings; my $a = 'i.like.donuts.but.only.with.tea';

Re: AW: How to remove everything after the last . dot?

2005-03-08 Thread Ramprasad A Padmanabhan
Bastian Angerstein wrote: Hmmm... use strict; use warnings; my $a=i.like.donuts.but.only.with.tea; $a=~s/\.\w+$//; # maybe w+ not d+??? Better still $a =~s/\.[^.]+$//; Thanks Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to remove everything after the last . dot?

2005-03-08 Thread Ramprasad A Padmanabhan
Bastian Angerstein wrote: I have a line: i.like.donuts.but.only.with.tea now I want to remove everything that follows the last . including the last .. in this case .tea Use Regex To read the manual perldoc perlre Of course In your case you could simply do something like this $line

Re: How to remove everything after the last . dot?

2005-03-08 Thread Gretar Mar Hreggvidsson
Hi! There is actually slight error in this code. $a=~s/\.\d+$//; # this does the trick This handles only one or more digits (\d stand for digits), so unless the last part of the string is a number this won't work. Should be something like $a=~s/\.\w+$//; # (\w stands for word charachters)

Re: AW: How to remove everything after the last . dot?

2005-03-08 Thread John Doe
-Ursprüngliche Nachricht- Von: John Doe [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 8. März 2005 11:46 An: beginners@perl.org Betreff: Re: How to remove everything after the last . dot? Hi I have a line: i.like.donuts.but.only.with.tea now I want to remove everything

Re: How to remove everything after the last . dot?

2005-03-08 Thread John W. Krahn
Bastian Angerstein wrote: I have a line: i.like.donuts.but.only.with.tea now I want to remove everything that follows the last . including the last .. in this case .tea substr( $line, rindex( $line, '.' ) ) = '' if $line =~ tr/.//; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: