in reply to 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
in thread Perl Monks, Newbie to perl, running this script below is not outputing any data, plforecast.txt is 0 bytes, any help will be great

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.
  • Comment on 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

Replies are listed 'Best First'.
Re^3: 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 17:38 UTC
    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