split/Perl question

James Durham plug-discuss@lists.plug.phoenix.az.us
Mon, 11 Nov 2002 18:51:51 -0700


What you may think about doing is using the "escape subroutin" in perl module 
CGI.pm. that way every special char including the ":" is converted. Then you 
unescape everything before using it on your website etc...

#---start of example script---
#!/usr/local/bin/perl -w

use CGI;

$string = "http://www.slashdot.org";
$blea = CGI::escape($string);

print "Original String: $string\n";
print "Escaped String: $blea\n";

$aelb = CGI::unescape($string);

print "Unescaped the Escaped String: $aelb\n";
#---end of example script---
--Output--
Original String: http://www.slashdot.org
Escaped String: http%3A%2F%2Fwww.slashdot.org
Unescaped the Escaped String: http://www.slashdot.org
--end of output--

On Monday 11 November 2002 01:16 pm, Mike Starke wrote:
> I have a colon delimited text file that I need parse thru and grab each
> value. My problem is that some values actually contain a colon. Using the
> code below is not quite enough to extract the values:
>
> while (<>) {
>   @array = split(":", "$_");
>   }
>
> I seem to recall this same problem before but can not remember
> what I did to get around this. Can anyone point me in the right
> direction?
>
> v/r
> -Mike
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change  you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss