Please provide a minimal code example which actually can be complied, run and shows your problem. When I fixed syntax errors in your code, it actually ran and splitted your string into pieces:

use warnings; use strict; my $text='--------------- 1.74 --> 1.75 :test/document.txt'; sub func { my ($text) = (@_); $text =~ s/[\s|\n]*//g; $text =~ s/^[---]+//; my ( $aa, $cd ) = split( /:/, $text ); my ( $values, $cf ) = split( /-->/, $aa ); print "$values,$cf\n"; } func($text); __END__ 1.74,1.75
It looks like what you wanted, isn't it?

By the way, if you want just to extract these two values from this string, it may be better to match them, not to split:

my $str = '--------------- 1.74 --> 1.75 :test/document.txt'; my ($values,$cf) = $str =~ /([\d.]+)\s*-->\s*([\d.]+)/; print "$values,$cf\n"; __END__ 1.74,1.75
What I used is m/PATTERN/ operator described in perldoc perlop -> Regexp Quote-Like Operators in array context (with Capture groups).

Sorry if my advice was wrong.

In reply to Re: Split using special charater data type scalar by aitap
in thread Split using special charater data type scalar by kapila

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.