Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another I want to replace the last comma with a quotation mark.

Status
Not open for further replies.

timgerr

IS-IT--Management
Jan 22, 2004
364
US
I want to replace the last comma with nothing.
Code:
my $test = 'this,is,a,test,";

not user how do do this one.

thanks

-T


-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
Something like this might work for you:
Code:
$test =~ s/(.+),/$1/;
That hasn't been tested, but it should work.
 
or maybe this conveluted way
Code:
$test = substr($test,0,len($test)-1) . "?";
- lol

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
or simply:

Code:
$test =~ s/,$//;

but if you know for sure there is a comma on the end that needs removing and there is no newline or something else:

Code:
chop($test);





- Kevin, perl coder unexceptional!
 
or...

chop(chomp($test));

that will take of a newline if it's there

Mike

The options are: fast, cheap and right - pick any two. [orientalbow] & [anakin]

Want great answers to your Tek-Tips questions? Have a look at faq219-2884

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top