Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Inserting a header into outfile

by kennethk (Abbot)
on Mar 14, 2017 at 17:01 UTC ( #1184565=note: print w/replies, xml ) Need Help??


in reply to Inserting a header into outfile

Please read How do I post a question effectively?. Please be sure when you post that the code runs, and provide expected output from provided inputs, all wrapped in <code> tags. In this scenario, that dangling use  ; at the top of the file is a syntax error and is a red flag that you didn't test what you posted.

What are you using as learning material? Try Learn Perl in 2 hours 30 minutes or http://learn.perl.org. I note that you do not use strict or warnings. It's understandable that an old script might not have these, but any new code should use them. See Use strict warnings and diagnostics or die.

The easiest solution for your spec would be to insert

print "ETXLinkID,TranscomLinkID,TranscomLen,TranscomLenFrac,EtxLenFrac +,EtxLen\n";
before that last foreach loop. Is there subtlety in the challenge I am missing?

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: Inserting a header into outfile
by jeretjordan (Initiate) on Mar 15, 2017 at 02:40 UTC

    It was really that simple I added that print statement and I got my result. Thanks for the help! I will be using the learning materials that you linked moving forward as I continue to learn.

      Dealing with legacy Perl can be a real challenge, and is a hard thing to cut your teeth on. Glad to have been helpful.

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re^2: Inserting a header into outfile
by Anonymous Monk on Mar 14, 2017 at 17:19 UTC

    I'm guessing that the use ; was something like use CompanyNameStuff; that pulls in Text::CSV_XS and ghod knows what else, but it got anonymized. The OP is too new to Perl to know what to replace it with.

    Strict and warnings should be considered mandatory in any new code. Don't try to add them to old code unless you know what you are doing, because you will get a million error messages and you will freak out and say "I'm never using strict and warnings again," and you mustn't say that!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2020-05-27 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (152 votes). Check out past polls.

    Notices?