Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: text files are printed after the end of second module

by Laurent_R (Canon)
on Jul 06, 2014 at 21:53 UTC ( [id://1092502]=note: print w/replies, xml ) Need Help??


in reply to text files are printed after the end of second module

You would do yourself a great favor if you followed the following guidelines:
  • indent your code consistently and properly;
  • use strict; (you are doing it for the second script, but apparently not for the first)
  • use warnings; (you are doing it for the second script, but apparently not for the first)
  • use the 3-argument syntax for opening files and directories (see open) and check if the opening was successful;
  • use lexical filehandles;
  • use the modern syntax for calling subroutines:
  • domain_check();
    and not:
    &domain_check();
  • remove extra vertical spaces that are not needed;
  • close your files when they are no longer needed;
  • lay-out your question and code snippets in a clearer fashion, using code tags not only for code, but also for displaying program output.

Nothing of the above is absolutely necessary, but these things are more important than being necessary, they are essential (i.e. they are part of the essence of good programming). I am sorry to say that, but I frankly don't feel like spending the time to go through such messy code (and I would certainly not hire a programmer who would show me such a sloppy work). You might find my comments so far to be harsh, but they are really meant to help you (and to help us, poor monks, helping you). I am not being extremist or fanatic, quite to the contrary. If I had decided to follow Damian Conway's Perl Best Practices, I would have at least three dozen additional recommendations, so be happy that it is me, and not TheDamian, answering your post. (Just in case, I am just jokingly saying that I might have been much harsher, this is by no means, and should not be understood, construed or interpreted as, a critique on Damian's guidelines.)

Having said that, I am not a bad guy, I am actually much nicer than you might think at this point and, despite everything I said so far, I took a bit of time to look a bit through your code, and I have a couple of additional comments.

You should probably not use the do function to include external Perl code, this is quasi obsolete. Take a look at the require and use functions and other documentation on Perl modules.

This piece of code:

$url=$_; foreach ($url) { #...
does not make much sense to me. The $_ scalar variable contains one single data item (in this case, a text line), and the $url scalar variable also contains one single data item. Why would you want to use foreach to loop on a single data item?

As for your precise question, I am sorry, I am unable to answer because your code is incomplete, you haven't shown a sample of the data files you are reading, we don't know what the scripts you are calling with the do function are doing, and your question is far from being clear. But if you do everything that I suggested above, you might actually see what the problem is and find a solution to it. And even if this is not sufficient, well, then post your cleaned-up code, I am sure many more monks (including myself) will feel like wanting to help you further.

Replies are listed 'Best First'.
Re^2: text files are printed after the end of second module
by Anonymous Monk on Jul 06, 2014 at 23:03 UTC
    You might find my comments so far to be harsh, but they are really meant to help you (and to help us, poor monks, helping you). I am not being fanatic.
    You're a nice guy! What the OP posted was a perfect illustration of "write-only Perl". But can Perl itself be blamed for it? I don't think so.
Re^2: text files are printed after the end of second module
by myfrndjk (Sexton) on Jul 07, 2014 at 12:31 UTC

    Hi Thanks for your suggestions and I take all your feed backs and try to improve myself.Thanks for your time

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found