Re: PERL's equivalent to an "include file"

2005-09-27 Thread Shelly Brown
Yes! That works. Thank you so much for your time.

On 9/27/05, Chris Devers <[EMAIL PROTECTED]> wrote:
>
> On Tue, 27 Sep 2005, Shelly Brown wrote:
>
> > I would like to display the daily calendar information from a perl
> > script: http://webapps.sbuniv.edu/daycal/ within an html page so it
> > looks like this: http://www.sbuniv.edu/. Right now I have to manually
> > enter the calendar information. I would like for it to be dynamic.
> > Make sense?
>
> Yes.
>
> If I were doing this on Apache, I'd consider using Server Side Includes.
> They aren't as dynamic or as cool as embedding a proper scripting
> language like Perl, but they're fast and they're easy.
>
> Easier still: HTML  tags.
>
> I'm not sure if IIS/ASP has an equivalent to SSI, but  will work
> anywhere.
>
>
>
> --
> Chris Devers
>
> '$폡^t[ê(B
>



--
Shelly Brown


Re: PERL's equivalent to an "include file"

2005-09-27 Thread Chris Devers
On Tue, 27 Sep 2005, Shelly Brown wrote:

> I would like to display the daily calendar information from a perl 
> script: http://webapps.sbuniv.edu/daycal/ within an html page so it 
> looks like this: http://www.sbuniv.edu/. Right now I have to manually 
> enter the calendar information. I would like for it to be dynamic. 
> Make sense?

Yes.

If I were doing this on Apache, I'd consider using Server Side Includes. 
They aren't as dynamic or as cool as embedding a proper scripting 
language like Perl, but they're fast and they're easy. 

Easier still: HTML  tags. 

I'm not sure if IIS/ASP has an equivalent to SSI, but  will work 
anywhere. 



-- 
Chris Devers

’$폡^t[ê(B
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: PERL's equivalent to an "include file"

2005-09-27 Thread Wiggins d'Anconia
Please bottom post...

Shelly Brown wrote:
> I would like to display the daily calendar information from a perl script:
> http://webapps.sbuniv.edu/daycal/ within an html page so it looks like this:
> http://www.sbuniv.edu/. Right now I have to manually enter the calendar
> information. I would like for it to be dynamic. Make sense?
> 

Most likely your web server software has the ability to parse pages, aka
server parsed pages, and you can probably make an include call exec on a
program on the local filesystem. The program should output on STDOUT the
HTML code for the calendar. Depending on which webserver you run you may
also be able to handle this directly with ASP or the like, but then that
wouldn't be Perl.

Going the embedded Perl route is probably more difficult and not the
direction to head...

http://danconia.org

> On 9/27/05, Shelly Brown <[EMAIL PROTECTED]> wrote:
> 
>>I would like to include a PERL file within an html or asp file. How do I
>>do that? I'm working on a Windows server.
>>--
>>Shelly Brown
>>
> 
> 
> 
> 
> --
> Shelly Brown
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: PERL's equivalent to an "include file"

2005-09-27 Thread Shelly Brown
I would like to display the daily calendar information from a perl script:
http://webapps.sbuniv.edu/daycal/ within an html page so it looks like this:
http://www.sbuniv.edu/. Right now I have to manually enter the calendar
information. I would like for it to be dynamic. Make sense?

On 9/27/05, Shelly Brown <[EMAIL PROTECTED]> wrote:
>
> I would like to include a PERL file within an html or asp file. How do I
> do that? I'm working on a Windows server.
> --
> Shelly Brown
>



--
Shelly Brown


Re: PERL's equivalent to an "include file"

2005-09-27 Thread Chris Devers
On Tue, 27 Sep 2005, Shelly Brown wrote:

> I would like to include a PERL file within an html or asp file. How do I do
> that? I'm working on a Windows server.

You're looking for a templating framework. Perl offers several, 
including:

 Template Toolkit ("TT")
 HTML::Template
 HTML::Mason (or simply "Mason")

Mason embeds snippets of Perl in your HTML, much like ASP or JSP does. 
This isn't necessarily the best way to go though -- a lot of people feel 
it's cleaner to keep the templates isolated from as much of the program 
logic as possible. That way, you can have separate groups working on 
your application logic and on your interface, and changes on one side 
are much less likely to cause problems with the other. 

HTML::Template makes this kind of isolation much simpler, while Template 
Toolkit is flexible enough that you can use it in a large variety of 
ways, from ASP/JSP/Masons style elbedding to HTML::Template style 
separation of code & templates, to processing everything offline, batch 
mode, so that you're just serving flat HTML. This makes for less dynamic 
sites, but very fast ones and very portable ones.

All of these frameworks behave most happily within the Apache web 
server, but while that will work just fine on Windows, most people 
running sites on Windows seem to prefer IIS. I *think* they can all be 
embedded with IIS/Perl, but I have no experience with that. 
 


-- 
Chris Devers

Çw{ï~…À͘‘Ç
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


PERL's equivalent to an "include file"

2005-09-27 Thread Shelly Brown
I would like to include a PERL file within an html or asp file. How do I do
that? I'm working on a Windows server.
--
Shelly Brown


Re: creating my own include file

2005-08-07 Thread Jeff 'japhy' Pinyan

On Aug 7, Shimon Ravid said:


package KPIDB;

%config;


That's doing nothing.  Nothing at all.


sub readDBConfigFile {

...

}

1;


That function is defined in the KPIDB package; therefore, to call it from 
your main program, you'd have to call it as KPIDB::readDBConfigFile().


I haven't looked at your function body at all, though, so I won't comment 
on what your function does and how it might possible do a better job.


But your KPIDB.pl file should be using 'strict' and 'warnings'.  It looks 
like you're declaring lexicals and all, so the only thing to change would 
be your "definition" of %config:


  package KPIDB;

  use strict;
  use warnings;

  our %config;

  ...

  1;


The problem is that when I call the function ' readDBConfigFile' it
seems that it is not executing the function and does not print any 
error.


If you had strict OR warnings turned on, you'd have a better idea why. 
It's generally a poor idea to call a function with no arguments AND omit 
its parentheses.  Perl sees a "bareword" and doesn't always know if it's a 
function or not.


If you'd written it as readDBConfigFile(), you'd have gotten an error 
telling you that the function doesn't exist.  That's because it's defined 
in a separate namespace.  Do what I said above, and change



   $status = readDBConfigFile;


to

  $status = KPIDB::readDBConfigFile();

Now you have another problem, since that function populates the %config 
hash in the KPIDB package.  To access it from main, you'll have to use 
$KPIDB::config{...} instead of $config{...}.



main;


Perl is not C.  Please do not define a main() function and then call it as 
the body of your program.  This is unnecessary.


--
Jeff "japhy" Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




creating my own include file

2005-08-07 Thread Shimon Ravid
Hello,

 

I have created the following include file located at /kpi/bin/KPIDB.pl

 

package KPIDB;

 

%config;

 

sub readDBConfigFile {

my $dbConfigFileName = '/kpi/cfg/databases.cfg';

my $cfgf;

my $db;

my $found = 0;

my $alias;

my $user;

 

my $fh = new FileHandle("$dbConfigFileName", "r");

if (!defined($fh)) {

print "Error: Can't open $dbConfigFileName file for
reading: $!\n" if ($debug);

exit(1);

}

 

while ($_ = $fh->getline) {

next if (/\s*#/);   # skip comments

next unless (/\S/); # skip empty lines

chomp;

if (/^\s*$hostName:/) {

$found = 1;

($host, $db, $user, $alias) = split(/:/);

if (exists($config{$host})) {

if (exists($config{$host}{$db})) {

print "Error: duplicate lines
for $host/$db\n" if ($debug);

} else {

$config{$host}{$db}{user} =
$user;

$config{$host}{$db}{alias} =
$alias;

}

} else {

$config{$host}{$db}{user} = $user;

$config{$host}{$db}{alias} = $alias;

}

}

}

$fh->close;

return($found);

}

 

1;

 

The following is the main program using the include file above.

The problem is that when I call the function ' readDBConfigFile' it
seems that it is not executing the function and does not

Print any error.

 

When inserting the code in the package to the main program, it works
well.

 

What am I doing wrong?

 

#!/usr/local/bin/perl5.8.5

 

use Getopt::Long;

use Sys::Hostname;

use FileHandle;

 

require "/kpi/bin/KPIDB.pl";

 

my $SU = '/bin/su';

 

sub usage {

print "Usage: $0 [-h] [-d]\n";

}

 

sub parseCommandLine {

my $retCode = GetOptions('h' => \$help,

'd' => \$debug);

usage and exit(1) if (!$retCode);

usage and exit(0) if ($help);

}

 

sub main {

my $status;

my $command;

my $db;

 

parseCommandLine;

$status = readDBConfigFile;

if ($status) {

foreach $db (keys %{$config{$host}}) {

$command = "$SU - $config{$host}{$db}{user} -c
\"$config{$host}{$db}{alias}; sqlplus -s /[EMAIL PROTECTED]
@/kpi/bin/KPI1010-DB_SORTS.sql\"";

system($command);

}

}

}

 

main;



---

orange mail - Connect to your e-mail anywhere with any handset
http://www.orange.co.il/web/corporate/app/omailadviser/webform1.aspx

---
This message contains information that may be confidential or privileged.
If you are not the intended recipient, you may not use, copy or disclose
to anyone any of the information in this message. If you have received
this message and are not the intended recipient, kindly notify the sender
and delete this message from your computer.



Re: Include file

2002-02-01 Thread jeff loetel

You could use the module that I am trying to use but having problems:
"AppConfig"

or you could use this (it works but is to limited for what I need):

#/usr/bin/perl

my $file = "/dir/somefile.txt";
open (CONFIG, "< $file") or die "Can't open $file";
while () {
   chomp;  #no newline
   s/#.*//;#no comments
   s/^\s+//;   #no leading white
   s/\s+$//;   #no trailing white
   next unless length; #anything left?
   my ($var, $value) = split(/\s*=\s*/, $_, 2);
   $config{$var} = $value;
}
close(CONFIG);

#then print everything or a specific $var 
exit;

That should do the trick for you, if you have any luck see my positing
on AppConfig. AppConfig is used to do the same thing plus it has a lot
more features in it, I just can't get the damn thing to work. If this
works for you and you have a spare minute I would appreciate any help
that I could get on the AppConfig (two brains are better than one). If
you don't have time, don't worry about it.

jeffl


On Fri, 2002-02-01 at 09:13, gross, cedric wrote:
> I have a set of program to do which is using always same var.
>  
> So I would like to defined a small file where I defined my var (like
> $database="toto" $host="localhost" etc..) and then include it in my
> other program, but
> How to do that ?
>  
> I try "use" but it's seems that is for complete module.
> "require" seems to be for version behavior
> and include seems not be supported...
>  
> I browse doc but I found nothing..
>  
>  



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Include file

2002-02-01 Thread gross, cedric

I have a set of program to do which is using always same var.
 
So I would like to defined a small file where I defined my var (like
$database="toto" $host="localhost" etc..) and then include it in my
other program, but
How to do that ?
 
I try "use" but it's seems that is for complete module.
"require" seems to be for version behavior
and include seems not be supported...
 
I browse doc but I found nothing..