Forum Moderators: coopster & phranque

Message Too Old, No Replies

Removing everything after the hyphen

         

lindajames

1:25 pm on May 25, 2003 (gmt 0)

10+ Year Member



Hi there,

I have the following line of perl code

print "$prod{'description'}" ;

but the thing is that $prod{'description'} has some information that i dont want to display. $prod{'description'} displays something like this:

product - description - date

can anyone tell me how i can just get it to display everything before the hyphen?

any suggestions would be much apprecited.

Cheers
Linda

ShawnR

1:58 pm on May 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Many ways to do this. One way is to use index() to find the position of the first '-'. Then use substr() or splice() ro remove from tha position on.

Shawn