CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: How do I... User definable split character: Edit Log



S_Shrum
User

Jan 12, 2001, 11:16 PM


Views: 814
Re: How do I... User definable split character

Well, normally I guess you would be right however...

In the case of special characters (i.e. the pipe character I refered to in my initial post); the syntax is like:

$field = split /\.../, $_

...it is the "\" (literal?) that is causing problems.

Example: create a flatfile out of the following data:

field1|field2
Sean|Shrum
The|Sleuth

Now, write the script to take the file and split the fields using a variable like:
$variable = "|";
$data = split /$variable/, ...

or

$data = split /\$variable/, ...

...bearing in mind that some characters need to have the pre-\ (like pipe characters) and some don't (like commas). I tried both; either does not work or it splits on every character.

I hope this makes sense to someone out there.

Sean Shrum
sean@shrum.net

PS. I still need to clean it up but if you wnat to give the script a look, I have moved a copy of the script to my site at:

http://www.shrum.net/db_table.pl

It currently is hard coded to handle the split function with "|"

PSS. This script works beautifully on my NT Intranet but after posting it to a UNIX machine (Host: 1dollarhosting.com) I get "Internal Server Error"? I have the Unix path information in the script. Did I code the script wrong for UNIX-use? Any help in getting this script to work on UNIX would be great.


(This post was edited by S_Shrum on Jan 12, 2001, 10:44 PM)


This post has not been edited


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives