Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Count similar characters in a row - only once

by $new_guy (Acolyte)
on Jun 29, 2011 at 10:47 UTC ( #911928=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Count similar characters in a row - only once
in thread Count similar characters in a row - only once

I have edited the script above as follows (below): it writes out a temporary file that I will use while running my second script. The second script will now take the temporary file which I will delete afterwards. Please critisize as it must be 100% accurate.

#!/usr/bin/perl use strict; use warnings; my $file = 'my_data_file.txt'; my %seen = (); { local @ARGV = ($file); #remove all previous re-organized files my $remove = "my.txt.tmp"; if (unlink($remove) == 1) { print "Existing \"$remove\" file was removed\n +"; } while(<>){ #now make a file for the ouput my $outputfile = "my.txt.tmp"; if (! open(POS, ">>$outputfile") ) { print "Cannot open file \"$outputfile\" to write to!!\n\n" +; exit; } $seen{$_}++; if($seen{$_} !~/-/g){ next if $seen{$_} > 1; print POS; } } } print "\n\nfinished processing file.\n";


Comment on Re^4: Count similar characters in a row - only once
Download Code
Re^5: Count similar characters in a row - only once
by Anonymous Monk on Jun 29, 2011 at 13:11 UTC

    Please critisize as it must be 100% accurate.

    Does it perform the transformation you wanted correctly?

    If so, here is my criticism

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2015-07-03 03:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls