split function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grey15
    New Member
    • Sep 2007
    • 10

    split function

    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(/|/,$_);
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    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(/\|/,$_);

    Comment

    • grey15
      New Member
      • Sep 2007
      • 10

      #3
      hey.......thx very much 4 ur help.......it works.....nice help 4 the beginners!!!!!

      Comment

      • grey15
        New Member
        • Sep 2007
        • 10

        #4
        hii....how do i generate html file from the text file using delimiters??

        Comment

        • KevinADC
          Recognized Expert Specialist
          • Jan 2007
          • 4092

          #5
          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.

          Code:
          open(FH, "index.htm") or die "$!";
          print "<html><head><title>test</title></head><body>Hello World</body></html>";
          close(FH);

          Comment

          Working...