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:
It looks like what you wanted, isn't it?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
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:
What I used is m/PATTERN/ operator described in perldoc perlop -> Regexp Quote-Like Operators in array context (with Capture groups).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
In reply to Re: Split using special charater data type scalar
by aitap
in thread Split using special charater data type scalar
by kapila
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |