Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: VarStructor II -- Abbreviation tool

by jeffa (Bishop)
on Jun 01, 2004 at 14:18 UTC ( [id://358082]=note: print w/replies, xml ) Need Help??


in reply to VarStructor II -- Abbreviation tool

Since you give no usage what so ever, i can only speculate just exactly what you want to output to look like. And more importantly, what the "rules" are. But i can say that you have a lot of needless code there. Try this instead:

use Data::Dumper; my (%symbol,@old,@new); my $max = 10; my $ws_replace = '_'; my $letters_only = 1; while (<DATA>) { chomp; push @old, $_; $_ = substr $_,0,10 if $max; s/\s+/$ws_replace/g if $ws_replace; s/\W+//g if $letters_only; $_ .= $. if $symbol{$_}++; push @new, $_; } print Dumper \@old, \@new; my %compare; @compare{@old} = @new; print Dumper \@compare; __DATA__ Line one Line two xxxxxxxxxxx Another line xxxxxxxxxxx Lines end here not xxxxxxxxxxx Fourth line (used to be) Line five Lines end here Lines end here too
And read The Dynamic Duo --or-- Holy Getopt::Long, Pod::UsageMan!

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-12-07 20:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (50 votes). Check out past polls.