Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perl Monks, Newbie to perl, running this script below is not outputing any data, plforecast.txt is 0 bytes, any help will be great

by blindluke (Hermit)
on Jan 07, 2015 at 16:28 UTC ( [id://1112514]=note: print w/replies, xml ) Need Help??


in reply to Perl Monks, Newbie to perl, running this script below is not outputing any data, plforecast.txt is 0 bytes, any help will be great

Hello, perlnobie, and welcome to the Monastery.

Please, use  <code> </code> tags to make your code readable. Try telling us what the script is supposed to do. You seem to be troubled by the fact that it does not output any data. What data should it produce?

The code you posted starts by opening a file for input. What is this input? The code you posted manipulates the input data. If it is empty, or does not fit the expected patterns, then no wonder that the output file is empty.

Help us by providing some further information.

- Luke

  • Comment on Re: Perl Monks, Newbie to perl, running this script below is not outputing any data, plforecast.txt is 0 bytes, any help will be great
  • Download Code

Replies are listed 'Best First'.
Re^2: Perl Monks, Newbie to perl, running this script below is not outputing any data, plforecast.txt is 0 bytes, any help will be great
by perlnobie (Initiate) on Jan 07, 2015 at 16:33 UTC
    Thanks Luke, The script is looking at a source file and then outputing to produce new formatted file. when exportign it is creating the file with the name but not the content in it.
      The script is looking at a source file and then outputing to produce new formatted file. When exporting it is creating the file with the name but not the content in it.

      The first sentence is obvious, and the second sentence repeats the fact that you stated in the title of your original post. You still are not telling us what the script should do. Should it copy all lines from input to output? Only some of them? Should it manipulate the lines in some way?

      The code itself would benefit greatly from adding use warnings;, and, as toolic already suggested to you, running your script with warnings enabled would tell you what is wrong with it.

      In addition, the script you posted relies very heavily on the implicit variables,  $_ and  @_. Both those variables are very useful, but require some understanding. Take a look at a good explanation of their usage in the Modern Perl book.

      Take a good look at the split(/,/); line. It should split the line from the input file into separate fields. Are you sure you understand how it works here? Have you tried looking at the documentation for split? Usually, it's used like this:

      my @values = split(',', $data);

      Think about split usage in your script. You do not specify the $data variable. What is being split? You do not specify the @values variable. Where do the split values go? And probably the most important question: are you sure that is where the split values go?

      - Luke

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2025-12-05 18:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (85 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.