Haskell: reading multiple command line arguments
Posted
by Survot
on Stack Overflow
See other posts from Stack Overflow
or by Survot
Published on 2010-03-19T12:00:32Z
Indexed on
2010/03/19
12:01 UTC
Read the original article
Hit count: 213
Hi all,
Okay, so I am making a program in Haskell that needs to change certain words based on two command line arguments. I have made the replace function and everything works great, but I am stumped getting it to work with command line arguments.
Here is the main code: (replace function not included)
main = do
text <- getContents
(command1:command2:_) <- getArgs
putStrLn (replace (read command1) (read command2) text)
So for intstance in the terminal I want to be able to type something like: "---> cat textfile.txt | ./replace oldword newword"
I know this code is close since I have seen others do it this way. O_o
Thanks for any help
© Stack Overflow or respective owner