
I was trying to hide Perl code inside Haskell program like the following:
module Main where
import System.Environment (getArgs) import System.Cmd
main = do args <- getArgs rawSystem pl args where pl = "#!/usr/bin/perl\n" ++ "print \"testing ...\n\";"
The program can run, but generates no output at all. Can someone tell me any other tricks which might be missing? (Do we need to use pipe here?) Thanks, Hong

you are putting the perl script as the name of the command
you can do something like: rawSystem "perl" ["-e","print \"testing ...\n\";"
]
this is equivalent to call in the shell: perl -e "print \"testing ...\";"
(sorry Hong I din't put reply to all in the fist mail)
On Thu, Sep 10, 2009 at 1:24 PM, Hong Yang
I was trying to hide Perl code inside Haskell program like the following:
module Main where
import System.Environment (getArgs) import System.Cmd
main = do args <- getArgs rawSystem pl args where pl = "#!/usr/bin/perl\n" ++ "print \"testing ...\n\";"
The program can run, but generates no output at all. Can someone tell me any other tricks which might be missing? (Do we need to use pipe here?)
Thanks,
Hong
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

This way works fine if the program has no arguments. What if I have to pass
arguments such as "-i input -o output"?
Thanks,
Hong
On Thu, Sep 10, 2009 at 12:45 PM, José Prous
you are putting the perl script as the name of the command you can do something like: rawSystem "perl" ["-e","print \"testing ...\n\";" ] this is equivalent to call in the shell: perl -e "print \"testing ...\";" (sorry Hong I din't put reply to all in the fist mail) On Thu, Sep 10, 2009 at 1:24 PM, Hong Yang
wrote: I was trying to hide Perl code inside Haskell program like the following:
module Main where
import System.Environment (getArgs) import System.Cmd
main = do args <- getArgs rawSystem pl args where pl = "#!/usr/bin/perl\n" ++ "print \"testing ...\n\";"
The program can run, but generates no output at all. Can someone tell me any other tricks which might be missing? (Do we need to use pipe here?)
Thanks,
Hong
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

В сообщении от Суббота 12 сентября 2009 01:18:01 автор Hong Yang написал:
This way works fine if the program has no arguments. What if I have to pass arguments such as "-i input -o output"?
You can just run perl and feed you program to perl's stdin. With this you can add all flags you like Shell $ echo 'print "fff\n"; $i=1; print "$i\n";' | perl fff 1
participants (3)
-
Hong Yang
-
José Prous
-
Khudyakov Alexey