Remove certain text from scalar
Hello,
Me again. Just wondering how I would go about removing .shtml from my scalars.
Say my scalar is $linkname = "somepage.shtml"
What code would I use to remove ".shtml" from
it and assign it to a new scalar?
Thanks for your help.
You guys rule
VulKen
Keepin' It Realistic
Pimpin like a pimp with an electrofied pimpin machine!
Rob Pengelly posted this at 00:15 — 19th June 2000.
They have: 850 posts
Joined: Jul 1999
You would use a regular expression to do that (If you have Perl installed, in DOS type perldoc perlre)
You would use the search and replace function.
$file = "index.shtml";
$file =~ s/.shtml//;
the ~ after the = means that the following is a regular expression. The rest means "find '.shtml' in $file and replace it with nothing (//)". The above would only search and replace in $file once. If you had for instance
$file = "index.shtml,another.shtml,onemore.shtml";
You would use
$file =~ s/.shtml//g;
Hope that helps.
------------------
click here to help save lives
http://www.wiredstart.com : The Technology Start Page
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
Ken Elliott posted this at 00:32 — 19th June 2000.
They have: 358 posts
Joined: Jun 1999
Thanx RobP...just what I was looking for.
VulKen
[B]Keepin' It Realistic[\B]
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.