Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Creating a file by using perl

by space_monk (Chaplain)
on Mar 28, 2013 at 11:07 UTC ( #1025938=note: print w/ replies, xml ) Need Help??


in reply to Re: Creating a file by using perl
in thread Creating a file by using perl

My preferred method is to use heredoc style so there is only one print statement and your quotes can remain "natural"....

my $outfile = "skillfile.il"; open FH, ">> $outfile"; print FH <<EOF; libName = "cmos28shp" tech_lib = "cmos28shp" EOF close FH;

N.B. Note that using ">>" to open skillfile appends data to it, so running the program twice will duplicate the data in the file.

A Monk aims to give answers to those who have none, and to learn from those who know more.


Comment on Re^2: Creating a file by using perl
Download Code
Re^3: Creating a file by using perl
by freekngeek (Acolyte) on Mar 28, 2013 at 12:31 UTC

    Thanks a lot man, It's working fine. Just one more thing. Now, when I am printing out those lines, I need to use values from my array. I have a subroutine in which I am parsing values from a text file and the values are stored in an array, so can I just call a subroutine and use array reference to print out my text with the values from that array ? Because when I am doing that It's giving me this error

    Global symbol "$one_ref" requires explicit package name at testfile.pl + line 12.

      You would have to show more of what you're trying to do. It's difficult to nearly impossible to work out where you're going wrong if you showing errors without the lines where they're occurring.

      From the error, it seems as though you haven't declared $one_ref in the main program or the method, whichever it happens to be. Somewhere you need a my ($one_ref);. But that's just a guess.

      Put an update at the end of the original question, with the code attached as it stands now. PerlMonks allows questions to change dynamically.

      A Monk aims to give answers to those who have none, and to learn from those who know more.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-10-01 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (31 votes), past polls