Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Non-re solution

by Rhys (Pilgrim)
on Sep 04, 2004 at 13:33 UTC ( #388499=note: print w/replies, xml ) Need Help??


in reply to Re: replace all but first
in thread replace all but first

Not bad, but to keep it a little more re-usable and flexible (suppose, for instance, more tags/values are added later), you can do away with the $company and $country variables altogether, and do:

... @myarray = split /></,$line; if ( $prev ne $myarray[0] ) { $prev = $myarray[0]; } else { $myarray[0] = "<TAB"; } $line = join '><', @myarray; print OUTFILE, $line; ...
This also takes care of the fact that I think the original author meant <TAB> literally. If I'm wrong, insert this after the join:

$line =~ s/<TAB>/\t/;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://388499]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2020-11-30 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?