in reply to Re: extracting from 1 file and adding to another.
in thread extracting from 1 file and adding to another.

Sorry about the indentation.. trying so many different things at the moment and it got messy. Yes I dont plan to append to the output file just yet. But given I got more than ten or more lines when I printed out "$email" to screen, I would of expected the same to be on the file I had written.
  • Comment on Re^2: extracting from 1 file and adding to another.

Replies are listed 'Best First'.
Re^3: extracting from 1 file and adding to another.
by reisinge (Hermit) on Oct 19, 2013 at 12:35 UTC

    You don't even have to do the indentation manually, Perl::Tidy will do it for you: $ perltidy your-script.pl (output goes to your-script.pl.tdy). Also, you can get some useful information from Perl::Critic:

    $ perlcritic your-script.pl Loop iterator is not lexical at line 13, column 1. See page 108 of PB +P. (Severity: 5) Bareword file handle opened at line 15, column 1. See pages 202,204 o +f PBP. (Severity: 5) Two-argument "open" used at line 15, column 1. See page 207 of PBP. +(Severity: 5)

    Update: As for your concrete problem, can you supply some (scrambled) input data?

    Well done is better than well said. -- Benjamin Franklin

Re^3: extracting from 1 file and adding to another.
by scripter87 (Novice) on Oct 19, 2013 at 12:29 UTC
    Spot on for that ">" nudge. But I seem to missing the concept of it... I thought using >> was to add on to a file without overwriting. Didnt think it was necessary for the first file write. I still dont have it right but using that method atleast adds a bit more to my file.

      You probably don't want to open the file for each element of the @emails list.

      Well done is better than well said. -- Benjamin Franklin

        But even if you did want to open the file with each entry, I suspect you would want to close it with each entry, also.  openand closeare reciprocal functions; they should be used reciprocally.

        Of course, that would only enhance the inherent inefficiency of repeatedly opening the same file over and over again.  :-)

      What do you mean by "first file write"?

      Maybe you should really think about (or modify your program to output) how often your output file is opened.

        As in the first time I execute the program I expected the same data that the print to the screen showed, then if I was to run the program again but using the ">" I would of expected that to overwrite my first executions output.