On Fri, May 11, 2001 at 12:16:17PM -0400, FLAHERTY, JIM-CONT wrote:
: I am trying to substite , I want to replace <> between the words and
: replacing them with </td><td>
: because I am reading a file that is uploaded and making a table in a web
: page when this script is run
:
: $test1 = " the is a test";
:
: $test1 = s/<>/</td></td>/g
:
: I dont get the desired result , can anyone help ?
Well, your string in $test1 doesn't contain the substring '<>' so I'll
asume you wan output like: 'the</td><td>is</td><td>a</td><td>test'.
Try using split() and join() to do the trick:
$test1 = " the is a test";
$test1 =~ s/^\s+//; # these two remove
$test1 =~ s/\s+$//; # space at the beginning and end of the string
my @words = split /\s+/, $test1; # split the string on spaces
$test1 = join '</td><td>', @words; # replace $test1 with all the
# @words delimited by '</td><td>'
Enjoy!
Casey West
--
"If I had thought about it, I wouldn't have done the experiment. The
literature was full of examples that said you can't do this."
-- Spencer Silver on the work that led to the unique adhesives for
3-M "Post-It" Notepads.