Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Oct 2002
Posts: 5
Junior Member
Junior Member
Offline
Joined: Oct 2002
Posts: 5
This has been bugging me for a few weeks now and I really can't figure out whats causing it.

I am working on a simple news feeder (to update the homepage of my site).

To try and clean up the code a little I want to distribute the subroutines into groups spanned across .pl files.

So I have the core file, I want a .pl file for each of the following types of subroutine:

1. For connecting to the mySQL Database
2. For Template Stuff and related bits (as the admin side doesn't have a template)
3. For Validation Subroutines
4. For Security Subroutines
5. For the Edit/Post/Delete/Archive subroutines.

I want to do this through requiring the .pl files.

The files are created and required. I have required them correctly:

as: require "filename.pl";

Each .pl file simply contains a set of subroutines that can be called within the program (which is complete).

The problem is:

I get a blank screen instead of the application.
Now for the wierd part.
I made a really simple program to test requiring files.

Heres the results:
If I require any 2 .pl files (doesn't matter which - to a point, certain ones don't seem to like each other) it will work.

If I add any more than 2 .pl files I get a blank screen.

I have tried just about every combination of the .pl files too see if there is a "bad" .pl file that was screwing it up, but there isn't.

I'm really confused about this one...

confused

Anyone have any ideas as to why its happening and how to fix it?

Sponsored Links
Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
add this after perl path:

Code
BEGIN { use CGI::Carp 'fatalsToBrowser'; }
if you didnt code it carefully, disable warnings and if you are using "use strict;", delete it...

Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
also try to run it with

use strict;
use diagnostics;

they'll give you detailed info...

Joined: Oct 2002
Posts: 5
Junior Member
Junior Member
Offline
Joined: Oct 2002
Posts: 5
Thanks a lot, will do that smile

* crosses fingers hoping it will work *

Joined: Oct 2002
Posts: 5
Junior Member
Junior Member
Offline
Joined: Oct 2002
Posts: 5
The code segment kind of helped, in ONE instance. However it was the "use" statements that helped most.

By the way,

thanks the probem is kind of solved (thanks guys).

For some reason the subroutine that my date, time and user time routines are in requires a variable declaration before the subroutines.

Before it was like this:

as a download if ya like too see: (its unfinished)

www.rgamers.com/datetimeoriginal.txt

If I move some variables ourside the subroutine:

www.rgamers.com/datetimenew.txt

If suddenly works...

Now I have "looked into this" on programmersheaven.com to see if there is any logic behind this happening. And I can't see anything that would imply this.

I just feel as if this is a bit of a "cowboy fix" for want of a better phrase.

Not hugely important as the script is only going to be used for my site (although the news program may get put on distribution on free script archives).

But as anyone who is serious about programming will appreciate. If you are going to learn a language, you should learn it properly.

Any ideas why this is making a difference?

Sponsored Links
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
I've been using PHP so much lately, that I've forgotten much of how Perl handles variables. frown

In the first file above, the statements
Code
$timezone = "GMT";
$offset = "0";
are executed when sub getdatetime is called. In the second file, those statements are executed when the file is required. I think that's the only difference.

My preference would be to include package declarations in each of the .pl files, and declare all local variables using my. I would also use strict and taint modes. It takes some time to figure out how to do that correctly, but it makes the code more reliable, and less prone to unexpected behavior, so I think it's worthwhile in the long term.

Joined: May 2000
Posts: 1,356
Addict
Addict
Joined: May 2000
Posts: 1,356
I cant see any errors... Maybe the way you call the function causes an error? If it does not compile under strict (as I see, it doess not) it can be anything... What error did you get? After putting the codes I wrote, you must get something.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,575
Posts293,930
Members13,823
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)