
shawnhcorey
Enthusiast

Jan 2, 2009, 6:03 AM
Post #2 of 2
(1178 views)
|
|
Re: [perl_newbie10] need a solution or logic
[In reply to]
|
Can't Post
|
|
Hi, I have orginal text file like this: orange, 10, 20, 30. apple banana, 20, 30, 40. I wanted the the original text file to be rewritten as: orange, 10 orange, 20 orange, 30 apple banana, 20 apple banana, 30 apple banana, 40 using perl and regular expression. If any solutions or suggestions would be nice and very much appreciated. many thanks newbie.
my ( $fruit, @amount ) = split /\s*,\s*/, $_; for my $amount ( @amount ){ print "$fruit, $amount\n"; } __END__ I love Perl; it's the only language where you can bless your thingy. Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib. Get Markup Help. Please note the markup tag of "code".
|