Re: "Hash as object attribute"-Problem with "use strict"

2004-07-08 Thread Luis
Oh no, what a simple mistake. :)
I thank you so much!
Best regards
Luis
Jeff 'Japhy' Pinyan schrieb:
On Jul 7, Luis said:

"Can't use string ("1") as a HASH ref while "strict refs" in use at
TestObject.pm line 21."

sub insertFriends {
my $self = @_;

The problem is that $self is not what you think it is.  You have stored
the number of elements in @_ into $self.  You meant
  my ($self) = @_;
or
  my $self = $_[0];
or
  my $self = shift;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: ${DBI::errstr} vs $DBI::errstr

2004-07-08 Thread Bob Showalter
perl.org wrote:
> If my Perl contains ${DBI::errstr} I get warnings like this:
> 
> Ambiguous use of ${DBI::errstr} resolved to $DBI::errstr at (eval 20)
> line 284. 
> 
> If my Perl contains $DBI::errstr (without the braces) I don't get
> these warnings.  Is there an explanation for this?

When Perl sees the ${ blah } notation, it's usually expecting "blah" to be a
scalar reference that you're dereferencing. But you're not doing that;
you're just giving the name of a symbol. You should just write it as
$DBI::errstr and leave the braces off.

It's only a warning, because Perl lets you use this notation inside double
quotes where you need to delimit the symbol name. Consider:

   my $package = 'DBI';

   print "The error is $package::errstr\n";# oops, doesn't work
   print "The error is ${package}::errstr\n";  # that does it

The latter can also be written as:

   print "The error is $package\::errstr\n";

Bottom line is: you only need the braces inside double quotes, and even then
you don't usually need them. They are only used to tell Perl where your
identifier ends. If the identifier name is followed by a character that
can't be part of an identifier name (e.g. the backslash above), it will stop
there and no braces are needed.

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




Write to file with shared server certificate

2004-07-08 Thread Ron Goral
Greetings -

I need to write to a log file to record things happening in a cgi script.
The environment is secured using a server-wide, shared certificate.  I
cannot write to the file and get an error telling me I do not have the
proper permissions to do so.  The log file is in my web's directory, but
using the shared cert. requires a path like so:

https://secure.hostname.com/mydomain/cgi-bin/logs/logfile.log
rather than:
https://www.mydomain.com/cgi-bin/logs/logfile.log

Is there any way to overcome this short of owning the server or my own
certificate?

Thank you in advance -
Ron Goral



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




Re: ${DBI::errstr} vs $DBI::errstr

2004-07-08 Thread Peter Scott
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Perl.Org) writes:
>If my Perl contains ${DBI::errstr} I get warnings like this:
>
>Ambiguous use of ${DBI::errstr} resolved to $DBI::errstr at (eval 20) line 284.
>
>If my Perl contains $DBI::errstr (without the braces) I don't get these
>warnings.  Is there an explanation for this?

This is because there is a routine DBI::errstr() and therefore it is
possible that you meant to call it and take its return value as the
name of a scalar variable.

Yuk.  Fortunately Perl made the right call.

There's no reason to put braces in like that except when necessary to
isolate a variable name in interpolation.

Also, look at the RaiseError property of DBI connections.  I gave up
referring to DBI::errstr some years ago.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/

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




Re: Write to file with shared server certificate

2004-07-08 Thread Gunnar Hjalmarsson
Ron Goral wrote:
I need to write to a log file to record things happening in a cgi
script. The environment is secured using a server-wide, shared
certificate.  I cannot write to the file and get an error telling
me I do not have the proper permissions to do so.
So, why don't you change the file permissions? Maybe it's 644 right
now, and it's likely that 666 is needed since it's a CGI script.
The log file is in my web's directory, but using the shared cert.
requires a path like so:
https://secure.hostname.com/mydomain/cgi-bin/logs/logfile.log 
rather than:
https://www.mydomain.com/cgi-bin/logs/logfile.log
Those are not paths on the file system, they are two different URLs
that happen to be mapped to the same file. It has nothing to do with
the problem to write to the log file.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Determine if sub exists in module

2004-07-08 Thread perl.org
I can probably figure this out if I spend some time but as I was going through
it more questions were raised.

Is it possible for a Perl script to check if a subroutine exists in a module
without actually invoking that subroutine?  

I have a Perl module that contains a bunch of subroutines.  I need to pass the
name of one or more subroutines on the command line to another Perl script.  I
would like to avoid hard-coding the subroutine names on the command line and
at the same time automatically ensure I never pass the name of a subroutine
that does not exist.  I guess I need to abstract the subroutine names somehow
and I'm wondering what my options are.  I was thinking of having constants in
the module, one for each subroutine name, but there seems to be a little
duplication there.  When I'm composing the command line (in Perl), is there
some way I can check if a subroutine of a given name exists in the module?  I
would like to die under such conditions.

I know there is some way to get a reference to a subroutine.  If I can figure
out how to get this reference (which I assume would be undef or something if I
try to get a reference to a subroutine that does not exist) that would
probably help, but I am not sure of the syntax or if that's the right approach.

Are there reflection classes for dealing with things like this?

I did search the web (a little) but wasn't sure where to start in the perldocs.



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




Re: Determine if sub exists in module

2004-07-08 Thread Wiggins d Anconia
> I can probably figure this out if I spend some time but as I was going
through
> it more questions were raised.
>

Some time, or some more time.  Some time is usually expected
 
> Is it possible for a Perl script to check if a subroutine exists in a
module
> without actually invoking that subroutine?  
> 

perldoc UNIVERSAL specifically the 'can' function.

> I have a Perl module that contains a bunch of subroutines.  I need to
pass the
> name of one or more subroutines on the command line to another Perl
script.  I
> would like to avoid hard-coding the subroutine names on the command
line and
> at the same time automatically ensure I never pass the name of a
subroutine
> that does not exist.  I guess I need to abstract the subroutine names
somehow
> and I'm wondering what my options are.  I was thinking of having
constants in
> the module, one for each subroutine name, but there seems to be a little
> duplication there.  When I'm composing the command line (in Perl), is
there
> some way I can check if a subroutine of a given name exists in the
module?  I
> would like to die under such conditions.
> 
> I know there is some way to get a reference to a subroutine.  If I can
figure
> out how to get this reference (which I assume would be undef or
something if I
> try to get a reference to a subroutine that does not exist) that would
> probably help, but I am not sure of the syntax or if that's the right
approach.
> 
> Are there reflection classes for dealing with things like this?
> 
> I did search the web (a little) but wasn't sure where to start in the
perldocs.
> 
> 

See if the above helps.  All of this seems a little fishy, what is the
overall goal and why do you need to pass sub names to a separate script?

http://danconia.org


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




Re: Determine if sub exists in module

2004-07-08 Thread perl.org
On Thu, 8 Jul 2004 08:51:08 -0600, Wiggins d Anconia wrote
>
> All of this seems a little fishy, what is 
> the overall goal and why do you need to pass sub names to a separate 
> script?

I am assembling the command line under the Interwoven CMS workflow engine,
which is basically Perl.  Each automated task in the workflow calls a perl
script which basically calls one or more of the subroutines in this module.  I
need to indicate to each call to the script which subroutines to invoke rather
than having multiple scripts, one for each possible combination of
subroutines.  If there's a better solution I am very open to it.

Thanks again,

   -John

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




Re: ${DBI::errstr} vs $DBI::errstr

2004-07-08 Thread perl.org
On 8 Jul 2004 13:41:28 -, Peter Scott wrote
> Also, look at the RaiseError property of DBI connections.  I gave up
> referring to DBI::errstr some years ago.

Looks good, except I think I noticed yesterday that if the error is actually
connecting to the database, errstr may contain the username and password,
which may then be visible to the user.  Since RaiseError seems to always die
with errstr, I guess I can put eval around that, or is there a best practice
in that area?

Thanks,

   -John

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




Re: Creating or renaming a file with the creation date included (Impossible?)

2004-07-08 Thread jason corbett
So I guess to automate a script daily, and save it under a name that includes the date 
can only be done with "rename()" function? Or is there a work around that includes a 
module? If so, please let me know.
 
Regards.
JC

"Randal L. Schwartz" <[EMAIL PROTECTED]> wrote:
> "Jason" == Jason Corbett writes:

Jason> How can i rename a file or create a file with the date
Jason> included? For example, I want to automate and run reports and
Jason> save the reports under the date of when they were created
Jason> i.e. JC07082004. Whats the easiest way to do this? Thanks, JC

If you're on Unix, it's impossible. Creation dates/times are not
recorded.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

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





Re: Determine if sub exists in module

2004-07-08 Thread perl.org
On Thu, 8 Jul 2004 08:51:08 -0600, Wiggins d Anconia wrote
> 
> perldoc UNIVERSAL specifically the 'can' function.

That's the one.  But who's it calling "DUMMY"?  That's not my code...

C:\temp>type test.pl
use CGI;
use Data::Dumper;

my ${ref} = CGI->can( 'param' );

print Dumper( ${ref} );

${ref} = CGI->can( 'goober' );

print Dumper( ${ref} );

exit( 0 );

C:\temp>test.pl
$VAR1 = sub { "DUMMY" };
$VAR1 = undef;


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




RE: Determine if sub exists in module

2004-07-08 Thread Bob Showalter
perl.org wrote:
> I can probably figure this out if I spend some time but as I was
> going through it more questions were raised.
> 
> Is it possible for a Perl script to check if a subroutine exists in a
> module without actually invoking that subroutine?

Not really, because of autoloading. See perldoc perlsub under the heading
"Autoloading".

> 
> I know there is some way to get a reference to a subroutine.  If I
> can figure out how to get this reference (which I assume would be
> undef or something if I try to get a reference to a subroutine that
> does not exist) that would probably help, but I am not sure of the
> syntax or if that's the right approach. 

You can take a reference to a subroutine that doesn't yet exist! Consider:

  $x = \&foo; # reference to non-existant sub

  print "\$x is a reference to ", ref($x), "\n";
  eval { &$x };   # try to call the sub
  warn $@ if $@;

  eval qq[sub foo { print "Foo is here now!\n" }];   # define the sub
  &$x;# you can call it now

Outputs:

  $x is a reference to CODE
  Undefined subroutine &main::foo called at foo.pl line 4.
  Foo is here now!

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




Re: Determine if sub exists in module

2004-07-08 Thread Wiggins d Anconia
> On Thu, 8 Jul 2004 08:51:08 -0600, Wiggins d Anconia wrote
> > 
> > perldoc UNIVERSAL specifically the 'can' function.
> 
> That's the one.  But who's it calling "DUMMY"?  That's not my code...
> 
> C:\temp>type test.pl
> use CGI;
> use Data::Dumper;
> 
> my ${ref} = CGI->can( 'param' );
> 
> print Dumper( ${ref} );
> 
> ${ref} = CGI->can( 'goober' );
> 
> print Dumper( ${ref} );
> 
> exit( 0 );
> 
> C:\temp>test.pl
> $VAR1 = sub { "DUMMY" };
> $VAR1 = undef;
> 

See Bob's e-mail and the docs for 'can' in Universal, both talk about
Autoloading, which you have just found.  CGI uses autoloading for tag
generation when a method isn't recognized. (At least that is my
understanding of it).

http://danconia.org


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




Re: GnuPG::Interface hangs while decrypting files over 61068 bytes

2004-07-08 Thread Joshua Colson
On Wed, 2004-07-07 at 09:34, Wiggins d Anconia wrote:

> Don't seem to have it archived at work. I will check at home or see if I
> can whip up something or do some more testing.   What versions of Perl,
> GnuPG, and the module are you using?  I wonder if there might be
> something in there
> 
> http://danconia.org

Debian Machine:

jcolson:/tmp$ perl -v
 
This is perl, v5.8.3 built for i386-linux-thread-multi
 
Copyright 1987-2003, Larry Wall


GnuPG-Interface version 0.33

MethodMaker version 1.12

GnuPG version 1.2.4

***

RedHat Box:

jcolson:/tmp$ perl -v
 
This is perl, v5.8.0 built for i386-linux-thread-multi
(with 1 registered patch, see perl -V for more detail)
 
Copyright 1987-2002, Larry Wall
 
GnuPG-Interface version 0.33

MethodMaker version 2.02

GnuPG version 1.2.1



Thanks again for all the help.

Joshua Colson


signature.asc
Description: This is a digitally signed message part


Re: Mail App

2004-07-08 Thread Brian McGraw

Mail::Box is your friend !
I'm using it with a lot of success for needs similar to yours.
Here some references:
http://perl.overmeer.net/mailbox/
http://search.cpan.org/~markov/Mail-Box-2.055/lib/Mail/Box.pod
http://marc.theaimsgroup.com/?l=perl-mailbox
I'd like to add an article that Simon Cozens recently posted to 
perl.com.  It's got a nice overview of Perl's email handling modules, 
and what they can do for you.

http://www.perl.com/pub/a/2004/06/10/email.html
Brian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



trim

2004-07-08 Thread John
Is there any trim function that trims the spaces before and the end of the string?

Re: trim

2004-07-08 Thread Wiggins d Anconia
> 
> Is there any trim function that trims the spaces before and the end of
the string?
> 

 perldoc -q 'strip blank space'

http://danconia.org

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




RE: trim

2004-07-08 Thread Bob Showalter
John wrote:
> Is there any trim function that trims the spaces before and the end
> of the string? 

There's probably a module somewhere with such a function. You can also write
one simply.

I usually use the following:

   s/^\s+//, s/\s+$// for $variable;

I like that form because you can list a bunch of variables and trim them
all.

A more traditional trim() function could be:

   sub trim { local $_ = shift; s/^\s+//, s/\s+$//; $_ }

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




Re: trim

2004-07-08 Thread Gunnar Hjalmarsson
John wrote:
Is there any trim function that trims the spaces before and the end
of the string?
Not built-in in the Perl compiler. But you can use your own; I'm using
this for instance:
sub trim{
for ( grep defined, @_ ){
s/^\s+//;
s/\s+$//;
}
@_ > 1 ? @_ : $_[0]
}
Assuming you have
my $string = '   some text  ';
it allows you to just say:
trim($string);
to remove the whitespace at the beginning and the end. You can also do
my $trimmedstring = trim('   some text   ');
If you pass a variable to the function like this:
my $trimmedstring = trim($string);
both the variables get trimmed. That's how I like it, you may prefer
it some other way.
The function can also handle multiple strings:
my @array = ('   some text   ', '   some more text   ');
trim(@array);
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



$^T inconsistant?

2004-07-08 Thread perl.org


I am doing something like:

( $data{sec}, $data{min}, $data{hour}, $data{day}, $data{mon}, $data{year},
$data{wday}, $data{yday}, $data{isdst} ) = localtime( $^T );

If I do this repeatedly on Windows for one invocation of a Perl script, the
value of $data{sec} can vary by 1.  Is there an explanation for this?



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




Re: trim

2004-07-08 Thread John
Thanks a lot! It worked!



- Original Message - 
From: "Bob Showalter" <[EMAIL PROTECTED]>
To: "'John'" <[EMAIL PROTECTED]>; "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Thursday, July 08, 2004 7:07 PM
Subject: RE: trim


> John wrote:
> > Is there any trim function that trims the spaces before and the end
> > of the string?
>
> There's probably a module somewhere with such a function. You can also
write
> one simply.
>
> I usually use the following:
>
>s/^\s+//, s/\s+$// for $variable;
>
> I like that form because you can list a bunch of variables and trim them
> all.
>
> A more traditional trim() function could be:
>
>sub trim { local $_ = shift; s/^\s+//, s/\s+$//; $_ }
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>



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




Cron Tab Implementation

2004-07-08 Thread NandKishore.Sagi
Hi All ,
 
I want to implement the functionality of crontab in Perl. Which
module do you guys suggest can be used. The only consideration is it
should be simple to use. That is I should be able to say execute this
job at this given time say 1:00 AM . After that I can just go home and
have a nice sleep assured that the job would be kicked off at exactly
1:00 AM . I also want this to be executed at every saturday of the week
or everyday depending on my requirement.
 
Thanks a lot for your help.
 
Thanks and Regards
Nand Kishore S
 
Nand Kishore Sagi
ART Support Team
(612)-304-BART


Could anyone please answer a simple PERL question.

2004-07-08 Thread Marco
Hi, I always used PERL in UNIX environment, so it's my
first time trying to run a PERL script in Windows env
and I have a simple question to ask,
(I know how to do this in UNIX but not in windows).

I installed PERL for Windows under:
C:\Z_Perl_584\Perl\bin
my below simple PERL script is called "simple.PL".

#!C:\Z_Perl_584\Perl\bin
sub first() ;
sub first()
{
   print( "Hello World\n" ) ;
}

1- is my !# correct?
2- what command do I use to run the simple.pl?
3- is Win-DOS prompt the only place to run it from?
thanks so much,
Zapa.



__
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 

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




Re: Cron Tab Implementation

2004-07-08 Thread Wiggins d Anconia
> 
> Hi All ,
>  
> I want to implement the functionality of crontab in Perl. Which
> module do you guys suggest can be used. The only consideration is it
> should be simple to use. That is I should be able to say execute this
> job at this given time say 1:00 AM . After that I can just go home and
> have a nice sleep assured that the job would be kicked off at exactly
> 1:00 AM . I also want this to be executed at every saturday of the week
> or everyday depending on my requirement.
>  

Something wrong with the base cron?  

You might consider:
http://search.cpan.org/~roland/Schedule-Cron-0.05/Cron.pm

perldoc -f alarm
perldoc perlipc

http://danconia.org


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




Re: Cron Tab Implementation

2004-07-08 Thread Mandar Rahurkar
I am not sure why you need perl for this. Just write a perl script which 
does the job and put the file in crontab. 

-Mandar

On Thu, 8 Jul 2004, NandKishore.Sagi wrote:

> Hi All ,
>  
> I want to implement the functionality of crontab in Perl. Which
> module do you guys suggest can be used. The only consideration is it
> should be simple to use. That is I should be able to say execute this
> job at this given time say 1:00 AM . After that I can just go home and
> have a nice sleep assured that the job would be kicked off at exactly
> 1:00 AM . I also want this to be executed at every saturday of the week
> or everyday depending on my requirement.
>  
> Thanks a lot for your help.
>  
> Thanks and Regards
> Nand Kishore S
>  
> Nand Kishore Sagi
> ART Support Team
> (612)-304-BART
> 


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




RE: Cron Tab Implementation

2004-07-08 Thread NandKishore.Sagi
Actually I had a lot of time right now at hand and I was trying to spend
littile time more effectively ;). Anyway I checked that module. It uses
the basic cron file. This job has to be run on multiple boxes and hence
rather than depending upon the Cron tab functionality I wanted to
implement (that is use some existing module :) ) to achieve this. I need
which would take in time parameters and do the job for me.

Thanks for the quick reply though. Appreciate that.

-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 08, 2004 11:45 AM
To: NandKishore.Sagi; [EMAIL PROTECTED]
Subject: Re: Cron Tab Implementation


> 
> Hi All ,
>  
> I want to implement the functionality of crontab in Perl. Which 
> module do you guys suggest can be used. The only consideration is it 
> should be simple to use. That is I should be able to say execute this 
> job at this given time say 1:00 AM . After that I can just go home and

> have a nice sleep assured that the job would be kicked off at exactly 
> 1:00 AM . I also want this to be executed at every saturday of the 
> week or everyday depending on my requirement.
>  

Something wrong with the base cron?  

You might consider:
http://search.cpan.org/~roland/Schedule-Cron-0.05/Cron.pm

perldoc -f alarm
perldoc perlipc

http://danconia.org


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




Re: Could anyone please answer a simple PERL question.

2004-07-08 Thread JupiterHost.Net
Marco wrote:
Hi, I always used PERL in UNIX environment, so it's my
Hello
first time trying to run a PERL script in Windows env
and I have a simple question to ask,
(I know how to do this in UNIX but not in windows).
I installed PERL for Windows under:
C:\Z_Perl_584\Perl\bin
my below simple PERL script is called "simple.PL".
#!C:\Z_Perl_584\Perl\bin
sub first() ;
sub first()
{
   print( "Hello World\n" ) ;
}
1- is my !# correct?
Winders uses file extension association, so you don't even need a she 
bang tachnically

2- what command do I use to run the simple.pl?
perl simple.pl
3- is Win-DOS prompt the only place to run it from?
No, you can double click the file and it will execute as long as the 
file extention is associated

thanks so much,
No problem,
HTH - Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: Cron Tab Implementation

2004-07-08 Thread Jose Alves de Castro
You should take a look at:

Config::Crontab (I found this to be helpful, in the past) and
http://www.webmin.com/ (if memory doesn't fail me, it is written in
Perl, and it may suffice your needs...)

HTH,

jac (back again)

On Thu, 2004-07-08 at 17:53, NandKishore.Sagi wrote:
> Actually I had a lot of time right now at hand and I was trying to spend
> littile time more effectively ;). Anyway I checked that module. It uses
> the basic cron file. This job has to be run on multiple boxes and hence
> rather than depending upon the Cron tab functionality I wanted to
> implement (that is use some existing module :) ) to achieve this. I need
> which would take in time parameters and do the job for me.
> 
> Thanks for the quick reply though. Appreciate that.
> 
> -Original Message-
> From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, July 08, 2004 11:45 AM
> To: NandKishore.Sagi; [EMAIL PROTECTED]
> Subject: Re: Cron Tab Implementation
> 
> 
> > 
> > Hi All ,
> >  
> > I want to implement the functionality of crontab in Perl. Which 
> > module do you guys suggest can be used. The only consideration is it 
> > should be simple to use. That is I should be able to say execute this 
> > job at this given time say 1:00 AM . After that I can just go home and
> 
> > have a nice sleep assured that the job would be kicked off at exactly 
> > 1:00 AM . I also want this to be executed at every saturday of the 
> > week or everyday depending on my requirement.
> >  
> 
> Something wrong with the base cron?  
> 
> You might consider:
> http://search.cpan.org/~roland/Schedule-Cron-0.05/Cron.pm
> 
> perldoc -f alarm
> perldoc perlipc
> 
> http://danconia.org
-- 
José Alves de Castro <[EMAIL PROTECTED]>
Telbit - Tecnologias de Informação


signature.asc
Description: This is a digitally signed message part


Re: $^T inconsistant?

2004-07-08 Thread Jose Alves de Castro
Does it vary randomly, or does it just change after a while and stick
with the new value?

I've tried in on my RH and it works fine... :-|

Thoughts, anyone?

jac

On Thu, 2004-07-08 at 17:25, perl.org wrote:
> I am doing something like:
> 
> ( $data{sec}, $data{min}, $data{hour}, $data{day}, $data{mon}, $data{year},
> $data{wday}, $data{yday}, $data{isdst} ) = localtime( $^T );
> 
> If I do this repeatedly on Windows for one invocation of a Perl script, the
> value of $data{sec} can vary by 1.  Is there an explanation for this?
-- 
José Alves de Castro <[EMAIL PROTECTED]>
Telbit - Tecnologias de Informação


signature.asc
Description: This is a digitally signed message part


RE: Cron Tab Implementation

2004-07-08 Thread Wiggins d Anconia
Please bottom post...

> Actually I had a lot of time right now at hand and I was trying to spend
> littile time more effectively ;). Anyway I checked that module. It uses
> the basic cron file. This job has to be run on multiple boxes and hence
> rather than depending upon the Cron tab functionality I wanted to
> implement (that is use some existing module :) ) to achieve this. I need
> which would take in time parameters and do the job for me.
> 

The module doesn't need the cron file, check the docs more carefully. 
While it can use a cron-like file it does not have to, the 'add_entry'
method can be used to set the schedule without the use of an external
file.  Don't see how this would not be sufficient...

http://danconia.org





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




Excel format from a PERL script

2004-07-08 Thread jason corbett
I know this may sound crazy (I have asked crazy question before here so I hope this 
doesn't get me banned!!) but I have this client who receives automated reports from me 
every day from a PERL script. The script comes in a .csv format (changed from .txt 
format) and now they are asking me if I can send it in Excel format.
 
The reason? I had a problem with the server that runs the script, so I used an 
application to query the database and retrieve the data and it just so happens that 
the app. exports the data into Excel, whereas my script doesn't. Now they want it in 
Excel (i guess the few conversion steps cost them too much to hire some one who knows 
Excel other than "save" , "delete", "open", "exit"). 
 
So can Perl save me a mouthful of curse words by doing this "SMALL" task?
 
Humbly at your mercy,
JC


Re: Excel format from a PERL script

2004-07-08 Thread jeffrey_n_Dyke


they want it in Excel (i guess the few conversion steps cost them too much
to hire some one who knows Excel other than "save" , "delete", "open",
"exit").

So can Perl save me a mouthful of curse words by doing this "SMALL" task?
___
There is an excellent module by John Macnamara called SpreadsheetWriteExcel
(or something like that).  i've used both the Perl version and the port to
PHP...very easy to work with, and has tons of features.

HTH
jeff
_

Humbly at your mercy,
JC






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




RE: Cron Tab Implementation

2004-07-08 Thread NandKishore.Sagi
Ok. Would persons not having access to crontab use this method. If that
can be done then this should be sufficient for me.

-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 08, 2004 12:05 PM
To: NandKishore.Sagi; [EMAIL PROTECTED]
Subject: RE: Cron Tab Implementation


Please bottom post...

> Actually I had a lot of time right now at hand and I was trying to 
> spend littile time more effectively ;). Anyway I checked that module. 
> It uses the basic cron file. This job has to be run on multiple boxes 
> and hence rather than depending upon the Cron tab functionality I 
> wanted to implement (that is use some existing module :) ) to achieve 
> this. I need which would take in time parameters and do the job for 
> me.
> 

The module doesn't need the cron file, check the docs more carefully. 
While it can use a cron-like file it does not have to, the 'add_entry'
method can be used to set the schedule without the use of an external
file.  Don't see how this would not be sufficient...

http://danconia.org





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



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




Re: Excel format from a PERL script

2004-07-08 Thread jason corbett
SPER!! Thanks!!


[EMAIL PROTECTED] wrote:

they want it in Excel (i guess the few conversion steps cost them too much
to hire some one who knows Excel other than "save" , "delete", "open",
"exit").

So can Perl save me a mouthful of curse words by doing this "SMALL" task?
___
There is an excellent module by John Macnamara called SpreadsheetWriteExcel
(or something like that). i've used both the Perl version and the port to
PHP...very easy to work with, and has tons of features.

HTH
jeff
_

Humbly at your mercy,
JC








Re: $^T inconsistant?

2004-07-08 Thread perl.org
On 08 Jul 2004 17:59:26 +0100, Jose Alves de Castro wrote
> Does it vary randomly, or does it just change after a while and stick
> with the new value?

It seems random - most of the time it gets one number, but just once in a
while it gets that number plus one.  I can't prove it (it's difficult to
track) but it seems like I can get the original value after I've gotten the
incremented value.  I will run some tests if I have time.

> I've tried in on my RH and it works fine... :-|

This is perl, version 5.005_03 built for MSWin32-x86

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




RE: Cron Tab Implementation

2004-07-08 Thread Wiggins d Anconia
Please bottom post...

> Ok. Would persons not having access to crontab use this method. If that
> can be done then this should be sufficient for me.
> 

cron doesn't even have to be installed. the point of the module is to
write a very simple script that acts as a scheduler.  Within that script
the scheduler can set its events, then you start the event loop. When
the scheduler sees that it is time to fire an event that event occurs. 
No access to cron, crontab, etc. is needed. The only consideration is
bullet-proofing the app such that it starts, stops, crashes, etc.
somewhat safely.  cron has been around a while (shall we say), so it is
very robust, where your implementation may not be as much, but then
apparently there is access privileges yours would have that cron won't.

At least that is my understanding of the module, write a quick sample
script see if it will do what you want.

http://danconia.org

> -Original Message-
> From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, July 08, 2004 12:05 PM
> To: NandKishore.Sagi; [EMAIL PROTECTED]
> Subject: RE: Cron Tab Implementation
> 
> 
> Please bottom post...
> 
> > Actually I had a lot of time right now at hand and I was trying to 
> > spend littile time more effectively ;). Anyway I checked that module. 
> > It uses the basic cron file. This job has to be run on multiple boxes 
> > and hence rather than depending upon the Cron tab functionality I 
> > wanted to implement (that is use some existing module :) ) to achieve 
> > this. I need which would take in time parameters and do the job for 
> > me.
> > 
> 
> The module doesn't need the cron file, check the docs more carefully. 
> While it can use a cron-like file it does not have to, the 'add_entry'
> method can be used to set the schedule without the use of an external
> file.  Don't see how this would not be sufficient...
> 
> http://danconia.org
> 
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 
> 



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




Re: Cron Tab Implementation

2004-07-08 Thread William . Ampeh




I think you are experiencing some of my headaches here.  Why recreate a
fully functional and extensively tested utility?

My solution, when pressed, simply create an input to the utility and fire
up the utility.

That is, if you still want to use Perl for this, simply generate your
crontab file in using a Perl script, and with command ticks, file up cron
from within your Perl program.

Cron is cron and all it needs if a file and a kick start.

__

William Ampeh (x3939)
Federal Reserve Board


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




@ARGV - override

2004-07-08 Thread Brian Volk
Hi All,

I have a directory full of .txt files that I need to send to
Regexp::Common...  I want to over ride the diamond operator by defining the
directory using @ARGV .  I'm not sure how I define it..  Please help,
w/o too much laughing! :-) 

-  the start

#!/usr/bin/perl -w 

use Regexp::Common qw /URI/;

$dir = "/Program Files/OptiPerl/test_files";
   opendir (BIN, $dir) or die "Can't open $dir: $!";
   while ( defined ($file = readdir BIN) ) {
 #
do something with "$dirname/$file"

@ARGV = qw# $file # ;   # <-- this
is not right ? 

while (<>) {

 /$RE{URI}{HTTP}/   and  print "Contains an HTTP URI.\n";
  }

 closedir (BIN);

}

- the end ---

Thank you!

Brian Volk
[EMAIL PROTECTED]


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




Re: @ARGV - override

2004-07-08 Thread Gunnar Hjalmarsson
Brian Volk wrote:
I have a directory full of .txt files that I need to send to 
Regexp::Common...  I want to over ride the diamond operator by
defining the directory using @ARGV .
@ARGV = readdir BIN;
Just a thought.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: @ARGV - override

2004-07-08 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote:

@ARGV = readdir BIN;
OTOH, you probably want to exclude at least the '.' and '..' 
directories, so maybe

@ARGV = grep { !/^\./ } readdir BIN;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Excel format from a PERL script

2004-07-08 Thread William . Ampeh




If I understand your question correctly, then all you is
Spreadsheet::WriteExcel
It comes with an example which is very easy to follow.  I have used this
quite a bit and like I said, it is very easy to follow.

__

William Ampeh (x3939)
Federal Reserve Board


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




RE: @ARGV - override

2004-07-08 Thread Bob Showalter
Brian Volk wrote:
> Hi All,
> 
> I have a directory full of .txt files that I need to send to
> Regexp::Common...  I want to over ride the diamond operator by
> defining the directory using @ARGV .  I'm not sure how I define
> it..  Please help, w/o too much laughing! :-)
> 
> -  the start
> 
> #!/usr/bin/perl -w
> 
> use Regexp::Common qw /URI/;
> 
> $dir = "/Program Files/OptiPerl/test_files";
>opendir (BIN, $dir) or die "Can't open $dir: $!";
>while ( defined ($file = readdir BIN) ) {
>  
> # do something with "$dirname/$file"
> 
> @ARGV = qw# $file # ;   # <--
> this is not right ?
> 
> while (<>) {
> 
>  /$RE{URI}{HTTP}/   and  print "Contains an HTTP URI.\n";
>   }
> 
>  closedir (BIN);
> 
> }


To load @ARGV, you can use:

   @ARGV = grep -f, map "$dir/$_", readdir BIN;

or use glob():

   @ARGV = grep -f, glob '/Program\ Files/OptiPerl/test_files/*';

The grep is to include only plain files and not directories.

Your loop can be something like:

   while (<>) {
   print "$ARGV contains an HTTP URI\n" and close(ARGV) and next
   if /$RE{URI}{HTTP}/;
   }


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




where to put modules?

2004-07-08 Thread Christopher J. Bottaro
lets say i made a module called cjb::string.  where would i put
cjb/string.pm?  i'm using fedora core 1 and the default perl installation. 
i've read in my book about modules and a little bit about them on
perldoc.com, but i couldn't find the answer to this.

thanks.


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




Re: Could anyone please answer a simple PERL question.

2004-07-08 Thread JupiterHost.Net
Windows automatically associates a .pl file with the Perl interpreter, so
simply clicking on the "yellow icon" associated with the file (assuming you
have not changed it", should do the job.  The down side of this is that the
resulting DOS window disappears as soon at the program terminates.  A
solution is to bundle it around a batch file.
Another solution is to add this to the end:
print 'Press [enter] to continue...'
my $end = ;
print 'See ya later!';
That keeps the window open until you hit enter.
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: where to put modules?

2004-07-08 Thread Gunnar Hjalmarsson
Christopher J. Bottaro wrote:
lets say i made a module called cjb::string.  where would i put 
cjb/string.pm?  i'm using fedora core 1 and the default perl
installation. i've read in my book about modules and a little bit
about them on perldoc.com, but i couldn't find the answer to this.
Based on my own server structure, something like
/usr/lib/perl5/site_perl/5.8.1/cjb/string.pm
would do it. You'd better examine what your @INC contains, of course.
One of the paths in my @INC is, consequently,
/usr/lib/perl5/site_perl/5.8.1
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Excel format from a PERL script

2004-07-08 Thread jason corbett
Cool! I appreaciate that!

[EMAIL PROTECTED] wrote:



If I understand your question correctly, then all you is
Spreadsheet::WriteExcel
It comes with an example which is very easy to follow. I have used this
quite a bit and like I said, it is very easy to follow.

__

William Ampeh (x3939)
Federal Reserve Board




Re: Could anyone please answer a simple PERL question.

2004-07-08 Thread JupiterHost.Net
Marco wrote:
Hi Lee,
Hello,
I appreciate your help.
No problem, just don't forget to reply to the list so everyone can 
learn/help :)

I double click on it but it opens the file with Notes,
because that's how I created it.
Then you probably don't have .pl associated with perl or its not a .pl file.
and on DOS prompt when I say, perl simple.pl
it says:
'perl' is not recognized as an internal or external
command,
what am I missing? an execution path or something?
Not sure, you may need to ask ann Active Staelist if noone else knows.
I'm not really a Windows guy so my knowlefge is limited :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: where to put modules?

2004-07-08 Thread Wiggins d Anconia
> lets say i made a module called cjb::string.  where would i put
> cjb/string.pm?  i'm using fedora core 1 and the default perl
installation. 
> i've read in my book about modules and a little bit about them on
> perldoc.com, but i couldn't find the answer to this.
> 
> thanks.
> 

Generally lower case module names are reserved for pragmata, with all
upper case reserved for internals provided by the Perl distro, so you
might want to consider CJB::String or the like.  Additionally, I would
be extra careful with a module name as basic as 'String'.

Specifically to your question, you can place them anywhere that is
included in Perl's @INC, which is updateable at compile time with the
'lib' pragma,

perldoc lib
perldoc FindBin (for a useful tool, when messing with @INC)

And for more on writing your own modules, check out,

perldoc perlmodstyle

Excellent tips in there. Of course there is also the Learning Perl Objs,
Refs, and Mods from O'Reilly.

HTH,

http://danconia.org


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




RE: Write to file with shared server certificate

2004-07-08 Thread Ron Goral
> -Original Message-
> From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED]
> Sent: Thursday, July 08, 2004 9:19 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Write to file with shared server certificate
>
>
> Ron Goral wrote:
> > I need to write to a log file to record things happening in a cgi
> > script. The environment is secured using a server-wide, shared
> > certificate.  I cannot write to the file and get an error telling
> > me I do not have the proper permissions to do so.
>
> So, why don't you change the file permissions? Maybe it's 644 right
> now, and it's likely that 666 is needed since it's a CGI script.
>
> > The log file is in my web's directory, but using the shared cert.
> > requires a path like so:
> >
> > https://secure.hostname.com/mydomain/cgi-bin/logs/logfile.log
> > rather than:
> > https://www.mydomain.com/cgi-bin/logs/logfile.log
>
> Those are not paths on the file system, they are two different URLs
> that happen to be mapped to the same file. It has nothing to do with
> the problem to write to the log file.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>

Gunnar -

chmod 0666 is the right thing.  Thank you.  However, I am not able to do
that programmatically when the script is running in secure mode. The
following dies:

$file_path = qq[/usr/wwws/htdocs/mydomain/cgi-bin/logs/errs.log];
chmod 0666,$file_path or die "Cannot chmod $file_path - $!";

However, in "unsecure" mode, this succeeds:

$file_path = qq[/home/username/mydomain-www/cgi-bin/logs/errs.log];
chmod 0666,$file_path or die "Cannot chmod $file_path - $!";

Thanks for the help -
Ron Goral



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




Re: Could anyone please answer a simple PERL question.

2004-07-08 Thread Philipp Traeder
On Thursday 08 July 2004 HH:18:19, JupiterHost.Net wrote:
> Marco wrote:

Hi Marco,

> > and on DOS prompt when I say, perl simple.pl
> > it says:
> > 'perl' is not recognized as an internal or external
> > command,
> >
> > what am I missing? an execution path or something?
>
> Not sure, you may need to ask ann Active Staelist if noone else knows.
>
> I'm not really a Windows guy so my knowlefge is limited :)
>

I'm not sure if I got the full thread of your question, but the error message 
you posted above normally indicates that "perl" is not part of your "path" 
environment variable. you can try this by calling perl using it's full path:


C:\Path\to\your\perl\scripts> C:\Z_Perl_584\Perl\bin\perl simple.pl

If this works, you might want to include the path to perl into your path 
variable - you can do this for one process with a command like

  SET PATH=%PATH%;C:\Z_PERL_584\Perl\bin

or generally in the Settings (I believe it's in Settings | Control Panel | 
Advanced | Environment Variables, but I'm not sure). If you change it 
permanently, reboot Windows, because otherwise the changed environment 
variable won't be available to all processes.

HTH,

Philipp

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




Use of uninitialized value in string eq

2004-07-08 Thread FyD
Hi,

Here is a short perl script:

   open (FILE, "<$START");
   $nbc=0;
   foreach(){
if (/^XXX/ig)   { $atmnb[$nbc]++;}
if (/^YYY/ig)   { $atmnb1=$atmnb[0];}
if (/^ZZZ/ig)   { $nbc++;}
   }
   if ($atmnb1 eq "")   { $atmnb1=$atmnb[0];}
   close(FILE);
   $nbc++;

When I try to execute it using the '-w' option, I get the following warning:
"Use of uninitialized value in string eq at RED-II.pl line 8"

I do not understand as for me ($atmnb1 eq "") is needed for uninitialized
values.

How can avoid such warnings ?

Thanks, Francois

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




RE: Use of uninitialized value in string eq

2004-07-08 Thread Hanson, Rob
> "Use of uninitialized value"

This just means that you haven't given a value to $atmnb yet (which will
happen unless /^XXX/ matches in your loop).

To get rid of the warning you should initialize the variable when you create
it.

Instead of:
my $atmnb;

Use this:
my $atmnb = '';

Rob


-Original Message-
From: FyD [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 08, 2004 3:50 PM
To: [EMAIL PROTECTED]
Subject: Use of uninitialized value in string eq


Hi,

Here is a short perl script:

   open (FILE, "<$START");
   $nbc=0;
   foreach(){
if (/^XXX/ig)   { $atmnb[$nbc]++;}
if (/^YYY/ig)   { $atmnb1=$atmnb[0];}
if (/^ZZZ/ig)   { $nbc++;}
   }
   if ($atmnb1 eq "")   { $atmnb1=$atmnb[0];}
   close(FILE);
   $nbc++;

When I try to execute it using the '-w' option, I get the following warning:
"Use of uninitialized value in string eq at RED-II.pl line 8"

I do not understand as for me ($atmnb1 eq "") is needed for uninitialized
values.

How can avoid such warnings ?

Thanks, Francois

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


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




Re: $^T inconsistant?

2004-07-08 Thread John W . Krahn
On Thursday 08 July 2004 09:25, perl.org wrote:
>
> I am doing something like:
>
> ( $data{sec}, $data{min}, $data{hour}, $data{day}, $data{mon},
> $data{year}, $data{wday}, $data{yday}, $data{isdst} ) = localtime(
> $^T );

You like typing a lot?  :-)  You could use a hash slice.

@data{ qw[sec min hour day mon year wday yday isdst] } = localtime $^T;


> If I do this repeatedly on Windows for one invocation of a Perl
> script, the value of $data{sec} can vary by 1.  Is there an
> explanation for this?

Leap second?  :-)  Just kidding.  I don't know why it is changing, (I 
can't see your entire program) but perhaps you should just store the 
current time in a scalar and see if that helps.

my $current_time = $^T;

Or:

my $current_time = time;


John
-- 
use Perl;
program
fulfillment


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




RE: where to put modules?

2004-07-08 Thread Hanson, Rob

To see what directories are in your Perl's path, you can run this at the
command line.  It should work on Win or *nix.

perl -e "print join(qq[\n], @INC)"

You might instead want to create your own "private" library by setting the
PERL5LIB environment variable.  It will add a directory to the beginning of
your @INC path.

So, for example, on Unix you might create a directory called ~/my_modules/.
You would place the module in ~/my_modules/CJB/String.pm.  ...And in your
environment you would set PERL5LIB to ~/my_modules/.  On *nix (with bash)
add to your .bashrc "export PERL5LIB=~/my_modules/.

Rob

-Original Message-
From: Christopher J. Bottaro [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 08, 2004 2:40 PM
To: [EMAIL PROTECTED]
Subject: where to put modules?


lets say i made a module called cjb::string.  where would i put
cjb/string.pm?  i'm using fedora core 1 and the default perl installation. 
i've read in my book about modules and a little bit about them on
perldoc.com, but i couldn't find the answer to this.

thanks.


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


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




Re: Write to file with shared server certificate

2004-07-08 Thread Gunnar Hjalmarsson
Ron Goral wrote:
chmod 0666 is the right thing.  Thank you.  However, I am not able
to do that programmatically when the script is running in secure
mode. The following dies:
$file_path = qq[/usr/wwws/htdocs/mydomain/cgi-bin/logs/errs.log];
chmod 0666,$file_path or die "Cannot chmod $file_path - $!";
However, in "unsecure" mode, this succeeds:
$file_path = qq[/home/username/mydomain-www/cgi-bin/logs/errs.log];
chmod 0666,$file_path or die "Cannot chmod $file_path - $!";
That's another problem. Note that this is getting rather off topic for
a Perl list.
I was assuming that you simply could change the permissions when
logged in via FTP or SSH. To do it via a CGI script, the file must be
owned by the user CGI is run as, i.e. the file typically needs to have
been created by the script. Is that the case?
Still assuming that we are talking about 'physically' the same file,
i.e. that /usr/wwws/htdocs/mydomain is a symlink to
/home/username/mydomain-www, I really don't know why the first example
above dies. What does the error log say?
Can it possibly be that CGI is running as a different user under HTTPS
compared to HTTP?
But again, this is *very* off topic here.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Could anyone please answer a simple PERL question.

2004-07-08 Thread William . Ampeh




A sure kill is to search for "perl*" and take note of the path.  Then you
can do one of the following:

1./ update your path variable, verify that you have really done that with
the set command.

OR

2./  call up the perl interpreter using the absolute path.


I think he probabily have not installed Perl.

__

William Ampeh (x3939)
Federal Reserve Board


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




Mail::Internet Mime::Entity object $part

2004-07-08 Thread JupiterHost.Net
Howdy group.
In a recent post someone mentioned this url:
http://www.perl.com/pub/a/2004/06/10/email.html
My question is about the Mail::Internet Mime::Entity object and example 
 mentioned at that url:

my $num_parts = $obj->parts;
for (0..$num_parts) {
   my $part = $obj->parts($_);
   ...
}
1) $obj is the Mail::Internet object created above that example correct?
2) I can't seem to find out how to use $part to examine the part, and 
the docs don't seem to helpful, so how do you use the object that is $part?

Say to get the content, encoding, ctype, etc...
Somethgin like this perhaps:
 my $desc = $part->description();
 my $ctype = $part->ctype();
IE I'd like to ultimately get the attachment information seperated...
but anystart on what Ii can do with $part would be greatly appreciated.
Thanks
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: $^T inconsistant?

2004-07-08 Thread perl.org
On Thu, 8 Jul 2004 13:01:07 -0700, John W. Krahn wrote
> 
> You like typing a lot?  :-)  You could use a hash slice.

I'm not really a Perl programmer so I try to make the code clear to people
coming from Java, C#, etc. (no remarks on my relative success are needed). 
This kind of construct seems foreign to most other languages.  In fact I wish
localtime would return an associative array instead of a positional array (I
basically wrap localtime with a sub that converts the data to a hash).

> I don't know why it is changing, 
> (I can't see your entire program) but perhaps you should just store 
> the current time in a scalar and see if that helps.

It would have to be a global or environment variable, which I am hoping to
avoid (especially since this one should already contain the value).

Thanks,

   -John

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




Re: Mail::Internet Mime::Entity object $part

2004-07-08 Thread Wiggins d Anconia
> Howdy group.
> 
> In a recent post someone mentioned this url:
> http://www.perl.com/pub/a/2004/06/10/email.html
>

The key to understanding that snippet is the line: 

"Thankfully, MIME::Entity is a MIME-aware subclass of Mail::Internet;"

and specifically that little word in the middle, 'subclass'. 
MIME::Entity objects are subclasses of Mail::Internet objects, so my
understanding would be that anywhere in the article above the parts
accessing lines, you should switch Mail::Internet to MIME::Entity and it
should just work.  Therefore, for more information about the 'parts'
method you should check the docs for MIME::Entity as that is what
provides the method.  (Though I certainly agree that the author should
have made his transition a bit more clear.)
 
> 
> My question is about the Mail::Internet Mime::Entity object and example 
>   mentioned at that url:
> 
> 
> my $num_parts = $obj->parts;
> for (0..$num_parts) {
> my $part = $obj->parts($_);
> ...
> }
> 
> 
> 1) $obj is the Mail::Internet object created above that example correct?
>

Yes, sort of. I believe to make it work you are going to have
instantiate MIME::Entity on the original string rather than
Mail::Internet.  For future reference if you are ever wondering what
type of object a variable is holding just print the reference, 

print "$obj";

In most cases will show you, in the other cases, when $obj can be
stringified, use the 'ref' built-in,

print ref($obj);

Will tell you what kind of object you are accessing, which will then
tell you what docs to look at first, making sure to check the docs for
anything that that object subclasses/inherits.
 
> 2) I can't seem to find out how to use $part to examine the part, and 
> the docs don't seem to helpful, so how do you use the object that is
$part?
> 
> Say to get the content, encoding, ctype, etc...
> 
> Somethgin like this perhaps:
>   my $desc = $part->description();
>   my $ctype = $part->ctype();
> 
> IE I'd like to ultimately get the attachment information seperated...
> 

To get this information, you go through the same steps as any other
header, aka request a head object from the part, and then access into it
to get the various header's values.  The mime/content-type is provided
free of charge using either the 'mime_type' or 'effective_type' methods.

> but anystart on what Ii can do with $part would be greatly appreciated.
> 

Check the docs of MIME::Entity for more,

http://danconia.org

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




Re: Use of uninitialized value in string eq

2004-07-08 Thread John W . Krahn
On Thursday 08 July 2004 12:49, FyD wrote:
>
> Hi,

Hello,

> Here is a short perl script:
>
>open (FILE, "<$START");

You should *ALWAYS* verify that the file opened correctly:

open FILE, "<$START" or die "Cannot open $START: $!";


>$nbc=0;

You should use lexically scoped variables instead of package variables.

my $nbc = 0;


>foreach(){

Reading a filehandle in a foreach loop means that the whole file has to 
be converted to a list before the loop starts.  It is more efficient to 
use a while loop instead.

while (  ) {


>   if (/^XXX/ig)   { $atmnb[$nbc]++;}
>   if (/^YYY/ig)   { $atmnb1=$atmnb[0];}
>   if (/^ZZZ/ig)   { $nbc++;}

The /g option is used to find multiple matches in the string (globally) 
but you have anchored the match at the beginning of the string so it 
can only match once at the beginning of the string.  But even if it 
wasn't anchored, you are using the match as an if condition so matching 
multiple times is superfluous as one match is just as true as two or 
more matches.

if ( /^XXX/i ) { $atmnb[ $nbc ]++ }
if ( /^YYY/i ) { $atmnb1 = $atmnb[ 0 ] }
if ( /^ZZZ/i ) { $nbc++ }

Of course you could do that without using regular expressions.

if ( 'XXX' eq uc substr $_, 0, 3 ) { $atmnb[ $nbc ]++ }
if ( 'YYY' eq uc substr $_, 0, 3 ) { $atmnb1 = $atmnb[ 0 ] }
if ( 'ZZZ' eq uc substr $_, 0, 3 ) { $nbc++ }


>}
>if ($atmnb1 eq "") { $atmnb1=$atmnb[0];}

It could be that the value of $atmnb1 is undef.  You have to use the 
defined function to test for this.

$atmnb1 = $atmnb[ 0 ] if not defined $atmnb1 or not length $atmnb1;

But this should also work (unless the value in $atmnb1 is 0):

$atmnb1 ||= $atmnb[ 0 ];


>close(FILE);
>$nbc++;


John
-- 
use Perl;
program
fulfillment


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




Re: $^T inconsistant?

2004-07-08 Thread perl.org
On Thu, 8 Jul 2004 14:05:59 -0400, perl.org wrote
> It seems random - most of the time it gets one number, but just once 
> in a while it gets that number plus one.  I can't prove it (it's 
> difficult to track) but it seems like I can get the original value 
> after I've gotten the incremented value.  I will run some tests if I 
> have time.

I have not been able to reproduce this in my drastically simplified test case;
it must be a bug in my code (while I've written my share of bugs I honestly
don't see how this could be one), a side effect of more complex interaction or
some other issue.

use strict;

my %data = getDateTime();
my $orig = $data{sec};
print 'Original seconds : ', $orig, ${/};

for( my $i = 0 ; ${i} < 500 ; $i++ )
{
  %data = getDateTime();
  my $sec = $data{sec};

  if ( $sec != $orig )
  {
print $sec, ' does not match original value ', $orig, ' : iteration : ',
${i}, $/;
  }
}

sub getDateTime
{
  ( $data{sec}, $data{min}, $data{hour}, $data{day}, $data{mon}, $data{year},
$data{wday}, $data{yday}, $data{isdst} ) = localtime( $^T );
  $data{year} += 1900;
  $data{mon}++;
  return( %{data} );
}

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




RE: printing 10 scalers/elements

2004-07-08 Thread DBSMITH
All, 

Could you please explain line by line what this code is doing below from 
Charles?  I think I understand most of it but just to make sure. 
All I want to do is set up a maximum 40 element array with each element as 
an E string.  From there only print 5 elements per line then "\n" then 
elements 6-10... etc.  This would be 5 lines of 8 never more, always less  
 Here is my visual:

1   2   3   4   5
6   7   8   9   10
11  12

element 1 and all others would be Ex.  This cannot be that hard,  but 
since I am new to the code it is hard.  KSH is much easier, but I want to 
learn PERL !  :)
Here is my current code.  I attempted to use Tie::File and Array::Dissect 
but was getting bad results.  My FileHandle FILE has the E strings in it with newlines 
and FILEOUT has the data from FILE with eject 0,0,0 in front like so: eject 0,0,0 
E E E etc. 
 with no new lines thanks to chomp. 


use strict;
use warnings;
use MIME::Lite;

## Declare variables, set scaler ^I(rw to same file), init array, create 
filehandles

local $ENV{'PATH'} = "/usr/epoch/bin:/usr/epoch/EB/bin:/bin:/usr/bin";
my @ejectapes = "/usr/local/bin/perld/derektapes";
($^I, @ARGV) = ('.bak', $ejectapes);
open (FILE, "<@ejectapes") or die "cannot open file: $!\n";
open (FILEOUT, ">/tmp/ejects.out$$") or die "failed to open eject.out: 
$!\n";
my @ejects = "/tmp/ejects.out$$";
print FILEOUT "eject 0,0,0 ";
my $count = `wc -l <@ejectapes`;

if ($count <= 40 ) {
 
while() {
chomp $_;
print FILEOUT "$_ "; 
}
close (FILEOUT);
print "\n";
print "Number of lines are: $count \n";

# application calls as below
#`evmeject -r $_`;
#`evmeject -l offsite_0 -b$_`;
} else {
my $msg = MIME::Lite->new(
From=> 'EDM01 <[EMAIL PROTECTED]>',
To  => 'Derek Smith <[EMAIL PROTECTED]>',
Subject => "Eject list is greater than 40",
Data=> "@ejectapes" );
$msg->send;
}
close (FILE);

Thank you, 

derek





"Charles K. Clarkson" <[EMAIL PROTECTED]>
07/01/2004 05:12 PM

 
To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
cc: 
Subject:RE: printing 10 scalers/elements


[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

: I am trying to figure out how to print 8 scalers/elements
: then \n,  then 5 more lines of 8 or less for a max total
: of 40  Here is my code:
: 
: print FILEOUT "eject 0,0,0 ";
: my $count = `wc -l <$ejectapes`;
[snip]


How about:

use strict;
use warnings;

use Tie::File;
use Array::Dissect qw( reform );

tie my @content, 'Tie::File', 'eject 0,0,0 '
or die qw(Cannot open "eject 0,0,0 ": $!);

my $last_index = @content > 40 ? 39 : $#content;

print join( ' ', @$_ ), "\n"
foreach reform( 8, @content[ 0 .. $last_index ] );


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328





RE: printing 10 scalers/elements PLEASE DISREGARD and IGNORE. My Apologies. I have to redo my code.

2004-07-08 Thread DBSMITH
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
614-566-4145


Re: $^T inconsistant?

2004-07-08 Thread John W . Krahn
On Thursday 08 July 2004 13:51, perl.org wrote:
>
> On Thu, 8 Jul 2004 13:01:07 -0700, John W. Krahn wrote
> >
> > You like typing a lot?  :-)  You could use a hash slice.
>
> I'm not really a Perl programmer so I try to make the code clear to
> people coming from Java, C#, etc.

Ah, then why are you using $/ instead of "\n" in your example?

> (no remarks on my relative success are needed).

Sorry, I just had to.  :-)

> This kind of construct seems foreign to most other
> languages.  In fact I wish localtime would return an associative
> array instead of a positional array (I basically wrap localtime with
> a sub that converts the data to a hash).

localtime(), like many of Perl's builtin functions, is just a wrapper 
around the C library function of the same name.

man 3 localtime

> > I don't know why it is changing,
> > (I can't see your entire program) but perhaps you should just store
> > the current time in a scalar and see if that helps.
>
> It would have to be a global or environment variable, which I am
> hoping to avoid (especially since this one should already contain the
> value).

The value in $^T should remain the same for the duration of the 
program.  When it changes does it stay at the new value or does it 
switch back to the old value?


John
-- 
use Perl;
program
fulfillment


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




[Solved] Could anyone please answer a simple PERL question.

2004-07-08 Thread Philipp Traeder
On Thursday 08 July 2004 HH:31:20, [EMAIL PROTECTED] wrote:
> A sure kill is to search for "perl*" and take note of the path.  Then you
> can do one of the following:
>

Just to let you know: The "path" variable has been the problem (as Marco wrote 
me off-list).

Another happy customer ;-)

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




Re: $^T inconsistant?

2004-07-08 Thread perl.org
On Thu, 8 Jul 2004 15:06:49 -0700, John W. Krahn wrote
> 
> then why are you using $/ instead of "\n" in your example?

I used to use \n but have converted to $/.  I thought I was doing this to be
less platform-specific and that's more important to me than readability.  I
could be just making things harder for everyone - let me know if that's the case.

> The value in $^T should remain the same for the duration of the 
> program.  When it changes does it stay at the new value or does it 
> switch back to the old value?

I agree that it should remain the same, but it seems not to.  Basically I have
a logging function that can be called from anywhere in my code.  It determines
the log file name based on $0, $$, $^T, etc.  Every once in a while I see one
line written to a log that is very close to the right log file.  For instance,
 most of the data goes to:

jwest.CMIInstall.ipl.08-07-2004_09-00-02.2304.log

but a little is written to:

jwest.CMIInstall.ipl.08-07-2004_09-00-03.2304.log

As I was unable to reproduce the issue with the simplified test case I am
assuming that I've just lost more of my mind.  I think I remember seeing this
issue a few years ago (I wouldn't have posted if I wasn't pretty sure I had
seen a valid case).  Anyway if I can prove it I will summarize to the list.

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




MIME coding & flags for sending a .csv or Excel file

2004-07-08 Thread jason corbett
I am sending Excel and .csv files via MIME and it appears that the file is created on 
the server with the needed data, but when the script is supposed to email a copy, I am 
getting blank .csv files. 
 
My question:
 
Do I need to identify the file in MIME as a .csv or Excel?
Are there flags that I need to set?
 
Thanks,
JC


Re: ${DBI::errstr} vs $DBI::errstr

2004-07-08 Thread perl.org
On Thu, 8 Jul 2004 10:57:28 -0400, perl.org wrote
> 
> Looks good, except I think I noticed yesterday that if the error is actually
> connecting to the database, errstr may contain the username and 
> password, which may then be visible to the user.  Since RaiseError 
> seems to always die with errstr, I guess I can put eval around that, 
> or is there a best practice in that area?

Looks like in some contexts there should be an eval block around connect() to
ensure the password is not shown.  The pun in the output here was actually an
accident...

C:\temp>type db.pl
use strict;

use DBI;

my ${dbh} = DBI->connect( 'this', 'is', 'bad', { RaiseError => 1 } );

C:\temp>db.pl
Can't connect(this is bad HASH(0x1abf084)), no database driver specified and DBI
_DSN env var not set at C:\temp\db.pl line 5


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




Re: $^T inconsistant?

2004-07-08 Thread Randal L. Schwartz
> "Perl" == Perl Org <[EMAIL PROTECTED]> writes:

Perl> In fact I wish localtime would return an associative array
Perl> instead of a positional array (I basically wrap localtime with a
Perl> sub that converts the data to a hash).

Maybe you'd be happier with:

use Time::localtime;
printf "Year is %d\n", localtime->year + 1900;

core module, for a LONG time now.

print "Just another Perl hacker,"; # the original

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

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




Re: $^T inconsistant?

2004-07-08 Thread perl.org
On 08 Jul 2004 16:36:59 -0700, Randal L. Schwartz wrote
> Maybe you'd be happier with:
> 
> use Time::localtime;
> printf "Year is %d\n", localtime->year + 1900;

Nope - I don't feel that year logic should be in every piece of code that
needs to know the date (so I would still have to wrap it, which means parsing
an extra module, which may have an insignificant effect on performance).

Thanks though,

   -John

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




Name "main::file" used only once:

2004-07-08 Thread Brian Volk
Hi All, 

Below is the program I'm using... It works but I'm getting an error
message... Can you please tell me what I'm doing wrong?  I listed the error
below... Thanks so much for all your help.  PS:  The program will not fun if
I use strict;

-- start
---
1   #!/usr/bin/perl -w
2 
3   use Regexp::Common qw /URI/;
4 
5   $dir = "/Program Files/OptiPerl/test_files";
6   opendir (BIN, $dir) or die "Can't open $dir: $!";
7   while ( defined ($file = readdir BIN) ) {
8 
9   # ---  load @ARGV for <> operator 
10
11 @ARGV = grep { !/^\./ } readdir BIN;
12
13  while (<>) {
14  print "$ARGV contains an HTTP URI\n" and close(ARGV) and next
15   if /$RE{URI}{HTTP}/;
16
17  }
18
19   closedir (BIN);
20 }

 error I'm getting / program works  

Name "main::file" used only once: possible typo at C:\Program
Files\OptiPerl\test_web_7.pl line 7.
70072.TXT contains an HTTP URI
70071.TXT contains an HTTP URI
70070.TXT contains an HTTP URI


Thanks!

Brian Volk
[EMAIL PROTECTED]


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




RE: Need to see the http://

2004-07-08 Thread Brian Volk
I did some research and figured it out...  :-) 

 if /$RE{URI}{HTTP}{-keep}/; 

Thanks!

Brian 

>  -Original Message-
> From: Brian Volk  
> Sent: Thursday, July 08, 2004 3:48 PM
> To:   Brian Volk
> Subject:  Need to see the http://
> 
> Hi All,
> 
> One more for ya...  I have the program below working... some what ;-) but
> I need the module to return the actual URL, not just tell me it the is one
> in the file.  Eventually I'm going to have LWP::Simple inform me if the
> links are active.   Any idea how to extract the actual link from the file?
> 
> 
> Thanks! 
> 
> B
> [EMAIL PROTECTED] 
> 
> 
>   -- start
> ---
>   1   #!/usr/bin/perl -w
>   2 
>   3   use Regexp::Common qw /URI/;
>   4 
>   5   $dir = "/Program Files/OptiPerl/test_files";
>   6   opendir (BIN, $dir) or die "Can't open $dir: $!";
>   7   while ( defined ($file = readdir BIN) ) {
>   8 
>   9   # ---  load @ARGV for <> operator 
>   10
>   11 @ARGV = grep { !/^\./ } readdir BIN;
>   12
>   13  while (<>) {
>   14  print "$ARGV contains an HTTP URI\n" and close(ARGV) and
> next
>   15   if /$RE{URI}{HTTP}/;
>   16
>   17  }
>   18
>   19   closedir (BIN);
>   20 }
> 
>    error I'm getting / program works  
> 
>   Name "main::file" used only once: possible typo at C:\Program
> Files\OptiPerl\test_web_7.pl line 7.
>   70072.TXT contains an HTTP URI
>   70071.TXT contains an HTTP URI
>   70070.TXT contains an HTTP URI
> 
> 
>   Thanks!
> 
>   Brian Volk
>   [EMAIL PROTECTED]
> 

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




Re: Name "main::file" used only once:

2004-07-08 Thread Brian Eable
On Thu, 8 Jul 2004 15:17:55 -0500 , Brian Volk <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> Below is the program I'm using... It works but I'm getting an error
> message... Can you please tell me what I'm doing wrong?  I listed the error
> below... Thanks so much for all your help.  PS:  The program will not fun if
> I use strict;
> 
> -- start
> ---
> 1   #!/usr/bin/perl -w
> 2
> 3   use Regexp::Common qw /URI/;
> 4
> 5   $dir = "/Program Files/OptiPerl/test_files";
> 6   opendir (BIN, $dir) or die "Can't open $dir: $!";
> 7   while ( defined ($file = readdir BIN) ) {
> 8
> 9   # ---  load @ARGV for <> operator 
> 10
> 11 @ARGV = grep { !/^\./ } readdir BIN;
> 12
> 13  while (<>) {
> 14  print "$ARGV contains an HTTP URI\n" and close(ARGV) and next
> 15   if /$RE{URI}{HTTP}/;
> 16
> 17  }
> 18
> 19   closedir (BIN);
> 20 }
> 
>  error I'm getting / program works 
> 
> Name "main::file" used only once: possible typo at C:\Program

That means that you've only used the variable $file once. Why are you assigning
to a variable and never using the variable for anything else? The compiler is
warning you that you might have a typo, because it's not normal to assign to
a variable and never use it.

You say that the program will not run if you use strict. If you
declare your variables
using "my", like "my $dir = ...", then the program should run using
strict. This will
help you to find errors, so you should consider doing it.

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




Re: Name "main::file" used only once:

2004-07-08 Thread Gunnar Hjalmarsson
Brian Volk wrote:
Below is the program I'm using... It works but I'm getting an error
message...
"Name ... used only once: possible typo ..." is not an error message,
it's a warning message.
Can you please tell me what I'm doing wrong?
You are not using strict.
PS:  The program will not fun if I use strict;
Yes it will, provided that you my() declare $dir and get rid of the
redundant outer while loop.
11 @ARGV = grep { !/^\./ } readdir BIN;
Hmm.. Since it was me who suggested that (in another thread), I'd
better mention that readdir() only returns the actual file names, so
it only works either if the directory you want to explore happens to
be the working directory or if you set the working directory using
chdir().
Bob's suggestions would populate @ARGV with the full paths to the files.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: Write to file with shared server certificate

2004-07-08 Thread Ron Goral

> -Original Message-
> From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED]
> Sent: Thursday, July 08, 2004 3:25 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Write to file with shared server certificate
>
>
> Ron Goral wrote:
> > chmod 0666 is the right thing.  Thank you.  However, I am not able
> > to do that programmatically when the script is running in secure
> > mode. The following dies:
> >
> > $file_path = qq[/usr/wwws/htdocs/mydomain/cgi-bin/logs/errs.log];
> > chmod 0666,$file_path or die "Cannot chmod $file_path - $!";
> >
> > However, in "unsecure" mode, this succeeds:
> >
> > $file_path = qq[/home/username/mydomain-www/cgi-bin/logs/errs.log];
> > chmod 0666,$file_path or die "Cannot chmod $file_path - $!";
>
> That's another problem. Note that this is getting rather off topic for
> a Perl list.
>
> I was assuming that you simply could change the permissions when
> logged in via FTP or SSH. To do it via a CGI script, the file must be
> owned by the user CGI is run as, i.e. the file typically needs to have
> been created by the script. Is that the case?
>
> Still assuming that we are talking about 'physically' the same file,
> i.e. that /usr/wwws/htdocs/mydomain is a symlink to
> /home/username/mydomain-www, I really don't know why the first example
> above dies. What does the error log say?
>
> Can it possibly be that CGI is running as a different user under HTTPS
> compared to HTTP?
>
> But again, this is *very* off topic here.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>

Sorry for the off-topic.  I had not meant to do that.  But.

When trying to chmod, the error message is:

Operation not permitted at /usr/wwws/htdocs/mydomain/cgi-bin/test.cgi line
34.

If I try to create the file using open(LOG,"+>>$logfile), the error is:

No such file or directory at /usr/wwws/htdocs/mydomain/cgi-bin/test.cgi line
35.

I am unable to raise the $ENV{USER_NAME} in this environment.  However,
given that this is a shared server certificate and mine is not the only
website on the server, it probably is the case that it is a different user.
I will have to contact my host and determine what, if anything, I can do
about that.

Again, I apologize for posting off topic.

Ron Goral





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




Re: Write to file with shared server certificate

2004-07-08 Thread Gunnar Hjalmarsson
Ron Goral wrote:
If I try to create the file using open(LOG,"+>>$logfile), the error
is:
No such file or directory at
/usr/wwws/htdocs/mydomain/cgi-bin/test.cgi line 35.
You must not include the '+' character when creating a file.
perldoc perlopentut
Try:
open LOG, ">> $logfile" or die $!;
That presupposes of course that you remove the existing log file first.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: Could anyone please answer a simple PERL question.

2004-07-08 Thread Carol Stone
Just for this thread, I have gone to ActiveState and learned how to use
their search facility to find my email address to copy and update my
response to someone way back on August 31, 2000 - this was my very
first perl success ;-D

I have added a note regarding Windows XP at the end of it.

You're probably already all set by now, but if not, this solution has worked
well for me.

I have assumed that you have installed the Active State perl with all the
defaults and that you have done nothing special with your windows
installation.

-carol
===
, but when I double-click on the Perl icon, all
>  I get is an
>  MS-DOS box that apparently doesn't allow me to do anything.

When you edit a "perl program" in something like, oh, notepad, and save it
to type .pl in Windows 98, in order to "test" the program,  you need to be
able to double-click on the SCRIPT - "whatever.pl" - and have it run your
perl script for you.

What it does is pop up a command.com window, run your script in perl, and
close.  Unless you set up your command window to NOT close until you close
it manually.

One way to get around this is to open a command window.  Then your call to
perl might look like this:

c:\active state\perl\>  perl c:\testing\myscript.pl
However, I can give you instructions to be able to double click on the perl
script, since I generally type something wrong when I use a command line.

/* my original post didn't note that my solution will leave your command
window open at the end*/

You need to get to the "file types" section of windows - I'm in NT right
now, so I might not be sending you to the right place to find it, but it's
going to be called "file types" and you can surely find it through Windows
Help. My instructions on this computer say to open My Computer, open the
View menu, click Options, then click the File Types tab.

Once you get there, scroll down until you find an entry for the extension
PL. Edit the entry. If an action "OPEN" exists, select it and edit it to
have the line (just paste it in there).

command.com /k C:\Perl\bin\Perl.exe "%1" %*

/* NT4,Win2K,WinXP use cmd.exe - see notes at end of post */

for the "application used to perform action" (or whatever it's called in
98).

If no action "open" exists, create one.  While you're at it, you can set up
your right click menu to allow you to edit any .pl file using notepad by
adding an edit action. To find the correct code to put there, look for .txt
in your file types and copy the action commands to open something in notepad
from there.

Hope this helps, especially since it's the *only* perl trick I've got!

-carol

Oh, by the way, if anyone needs this same information for NT4, the line is a
little different (how irritating, I know):
C:\WINNT\System32\cmd.exe /K "C:\Perl\bin\Perl.exe %1 %*"

Win2K
I don't know if it's at c:\WINNT or c:\WINDOWS, - search for cmd.exe to find
out.

Win XP
C:\WINDOWS\System32\cmd.exe /K "C:\Perl\bin\Perl.exe %1 %*"
There's an Advanced button under FileTypes - go ahead and look there


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




Executing scripts from different directories

2004-07-08 Thread sudhindra k s
  
Hi

I have two scripts abc.pl and xyz.pl. Now abc.pl uses xyz.pl. i have implemented this 
as below.

abc.pl
{


system("perl xyz.pl arg1 arg2"); 
...
}

Now both abc.pl and xyz.pl are in the same directory c:\test\script. But now i want 
abc.pl in some different directory, but xyz.pl remains in c:\test\script. And the 
location of abc.pl need not be fixed. So how do i implement this requirement?

Regards
Sudhindra