By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,244 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,244 IT Pros & Developers. It's quick & easy.

split function

P: 10
hi to all......am very new to perl....so dnt knw much abt it....
i have a txt file.....so i have to split the values using delimiters.eg have following text-
Colombian|The finest Colombian beans, low flame roasted to yield a rich flavour.|7.99|
but when i use the split function using '|' as delimiter, it gives me errors-
use of uninitialized value in concatenation (.) or string

i used the following function
split(/|/,$_);
Sep 29 '07 #1
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
the delimiter you are using - | - is a speacial character when used in a regular expression. To avoid the problem you need to escape the | character:

split(/\|/,$_);
Sep 29 '07 #2

P: 10
hey.......thx very much 4 ur help.......it works.....nice help 4 the beginners!!!!!
Sep 29 '07 #3

P: 10
hii....how do i generate html file from the text file using delimiters??
Sep 29 '07 #4

KevinADC
Expert 2.5K+
P: 4,059
I don't understand the question. But if you want to make html code, open a file and add html tags and content as required.

Expand|Select|Wrap|Line Numbers
  1. open(FH, "index.htm") or die "$!";
  2. print "<html><head><title>test</title></head><body>Hello World</body></html>";
  3. close(FH); 
Sep 29 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.