title: Perl Split function with comma
body: <p>I have a file which shall have lines like,</p>
  
  <pre><code>&lt;tag host="xyz|abc" some info /&gt;
  &lt;tag host="ijk,cdf" some info /&gt;
  </code></pre>
  
  <p>I'm getting the information of the host by using pattern matching and I'd like to split the value of the host. For some reason the following code doesn't seem to work for comma even though it looks correct.</p>
  
  <pre><code>if($line =~ m/(\s\S)*host=\"(\S+)\"(\s\S)*/)
  {
  ($val) = ($2);
  $val=~tr/!$()//ds;
  my @values;
  if($val =~ m/((\S+)\|(\S+))*/ )
  {
      @values=split('\|',$val);
  }
  else
  {
  @values=split(',',$val);
  }
  #Perform some action on Values.
  }
  </code></pre>
  
  <p>Can any one help me with this ? Thanks in advance.</p>