Link to home
Start Free TrialLog in
Avatar of koppcha
koppchaFlag for United States of America

asked on

PERL format

I have string $str = "20090630|A|0.5
                                 20090630|B|0.7";
basically a file wiht 2 lines is read in to a string.
I want to output string in the format 20090630,0.5,0.7
Can this be done in one liner ?
I know we can split with "\n" first and then with "|" but i want to know if it can be done in one line ?

Thanks for your help
SOLUTION
Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
my $str = "20090630|A|0.5
        20090630|B|0.7";
print join",",split/(?:\s+\d+)?\|\w+\|/,"$str\n";