Monk_perl has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on how to create a perl program using filehandle and streams ?

Replies are listed 'Best First'.
Re: how to create a perl program using filehandle and streams ?
by davido (Cardinal) on Apr 01, 2011 at 08:36 UTC

    Open a text editor. Type into your text editor the following:

    use strict; use warnings; print "Hello world.\n";

    Now save the file with a name of "mytest.pl" in a directory that's easy to find from the command line. Then start a CMD shell. Change directory into the path where you just saved your file. Type the following:

    perl mytest.pl

    Your little test script will run, and will print "Hello world." Now you wrote your first program, and executed it. This may not be the sleekest way to start up a Perl script, but it's guaranteed to work as long as you've got Perl installed correctly. If it doesn't work for you, go ask if you can have your old job back instead.

    Once you've accomplished getting your script to run, you've resolved about half of what I understood you to be asking in your question... at least if I understood part of it. It was pretty incomprehensible in the first place.

    We've now shown you how to get the elevator to go to the 5th floor. I'm guessing we'll be asked which button to push to get it to go to the 6th next. It might be a good idea to hire a tutor for a few hours to get you started in the right direction. It seems like whatever is needed we're not succeeding in providing.

    By the way: After reading over your question a few times I just don't see how file handles and streams relate to the question. I realize i haven't provided any insight there, but it just seems like if you're having trouble getting a script to run, we ought to address that first before moving on to file IO.


    Dave

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: how to create a perl program using filehandle and streams ?
by cdarke (Prior) on Apr 01, 2011 at 07:55 UTC
    i used to name a program by clicking new and then by naming a program i click "save as" in both C,C++ and then i open a that named file for writing a program into it and at last i click save and whenever i need to run that program i open that program, but how i can start with perl?

    Now, breath slowly. What were you clicking on? Visual Studio I guess. You can use Visual Studio for perl, but it is an over-complication, you just need an ordinary text editor to create your program files, even Notepad would do if you are desperate. There is no compile/link phase that you have to invoke manually. Save the file with a '.pl' extension, then run it from the command-line. Now try your examples with open.

    A Perl file handle is (simply put) an abstraction of the FILE struct used by stdio, but it will not help you to think too much in C terms. Try to think in Perl terms instead, and read the tutorials.
Re: how to create a perl program using filehandle and streams ?
by Anonymous Monk on Apr 01, 2011 at 08:15 UTC
Re: how to create a perl program using filehandle and streams ?
by Anonymous Monk on Apr 01, 2011 at 07:39 UTC
    Absolutely, its 42, congratulations