Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by $new_guy (Acolyte)
on Jun 29, 2011 at 10:47 UTC ( [id://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";

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://911928]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-19 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found