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

Yet Another Newbie Code...

by majin (Acolyte)
on Aug 18, 2002 at 22:57 UTC ( #191034=sourcecode: print w/ replies, xml ) Need Help??

Category: Miscellaneous
Author/Contact Info Majin
Description: Takes any file as an input and adds it to a file thats acts as a wordlist. This word list has several "uses"... I shall not tell about these uses as it might give some wannabies ideas but those who need it shall know it...
#!/usr/bin/perl -w

print "Input: ";
chomp ($input = <>);
print "Output: ";
chomp ($output = <>);
chmod 0700, "$input";
chmod 0700, "$output";
open (OUTPUT, ">> $output") || die "Error opening Output: $!\n";
open (INPUT, "< $input") || die "Error opening Input: $!\n";

while (<INPUT>) {
print OUTPUT join("\n",split(/\W+/g, $_));
}

Comment on Yet Another Newbie Code...
Download Code
Replies are listed 'Best First'.
(jeffa) Re: Yet Another Newbie Code...
by jeffa (Bishop) on Aug 19, 2002 at 00:57 UTC
      Can this take files as input and/or output? I am just asking and not questioning your ways.

      Majin
        The in you see in jeffa's post is a filename.. you can actually use any number of input filenames as in perl -F'\W+' -ane 'print join $/,@F' in1 in2 in3 in4 in5 in6 in7 >> wordlist
        Personally I would amend this to read perl -F'\W+' -alne '@word{@F}=(); END { print sort keys %word }' in >> wordlist
        which outputs only unique words, sorted alphanumerically.

        Makeshifts last the longest.

Back to Code Catacombs

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2015-07-08 08:28 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 (96 votes), past polls