Re: beginner here - with basic cgi trouble

2001-05-08 Thread David A. Desrosiers


> [error](2)No such file or directory. exec of /usr/local/apache/cgi-bin/
>   formparser.cgi failed
> [error][192.168.1.8] Premature end of script headers: /usr/local/apache/
>   cgi-bin/formparser.cgi
> - I see the file DOES exist as formparser.cgi in the directory path shown
> in the errors.

> - I run perl -c formparser.cgi and get the response Syntax OK
> This is on my own web server here in my home, so I full access to everything
> on it and can change and mess around with everything on it.
> I have run other cgi scripts, just some little test scripts, just fine.
> If there is anything anyone can suggest for me to look at next I open to
> all suggestions.

How about making sure the path to the interpretor in the cgi is
pointing to the right location of perl on your system? Your tests exactly
point to this as the cause.


/d





Re: beginner here - with basic cgi trouble

2001-05-08 Thread Chip Wiegand

Okay, here is some more info on the error messeges: 
- the file, formparser.cgi, has 755 permissions
- the message - 

Internal Server Error

The server encountered an internal error or misconfiguration and was unable
to complete your request.

Please contact the server administrator, [EMAIL PROTECTED] and inform them of
the time the error occurred, and anything you might have done that may have 
caused the error.

More information about this error may be available in the server error log.

- server log - 
[error](2)No such file or directory. exec of /usr/local/apache/cgi-bin/
formparser.cgi failed
[error][192.168.1.8] Premature end of script headers: /usr/local/apache/
cgi-bin/formparser.cgi
- I see the file DOES exist as formparser.cgi in the directory path shown
in the errors.
- I run perl -c formparser.cgi and get the response Syntax OK
This is on my own web server here in my home, so I full access to everything
on it and can change and mess around with everything on it. 
I have run other cgi scripts, just some little test scripts, just fine. 
If there is anything anyone can suggest for me to look at next I open to 
all suggestions.
--
Chip



It appears "Brett W. McCoy" <[EMAIL PROTECTED]>, on Mon, 7 May 2001
22:59:20 -0400 (EDT) wrote something like:

> On Mon, 7 May 2001, Chip Wiegand wrote:
> 
> > Any suggestions as to what I should be changing so I can get some scripts
> > to run properly?
> 
> It's hard to say, not knowing what the scripts are, what modules or
> libraries they use, or what kinds of errors they are spewing out.
> 'Internal Server Error' can be a host of errors caused by a failed script,
> bad data, missing files, improper permissions, etc.  Did you take a look
> at the server logs to see what they have to say?  Can you run the scripts
> from the command-line?
> 
> The more details you give, the better your problems can be diagnosed.
> 
> -- Brett
>  http://www.chapelperilous.net/btfwk/
> 
> Facts are stubborn, but statistics are more pliable.
> 
> 


-- 
Regards,

--
Chip Wiegand
CRW Computer Services
www.wiegand.org
[EMAIL PROTECTED]
<-->
  Web page design
Consulting
 PC Repair
<-->



Re: Environment variable question

2001-05-08 Thread Matt Cauthorn

If you're using Unix (I think even a dos shell can do this sort of thing too), why
couldn't you just do a system call to the shell?

i.e. system(" export MY_Variable=whatever ");

I haven't tried this, but it sure seems like it would work -- provided you're
running and exiting the script as the same user. This is an interesting one; I'll be
interested to hear any and all feedback.

~Matt C.


--- Paul <[EMAIL PROTECTED]> wrote:
> 
> --- Hitesh Ray <[EMAIL PROTECTED]> wrote:
> > I am required to modify an Environment variable from one value to
> > another using perl script. I can access the env. variables in the
> perl
> > script using ENV. How can i modify so that when I exit my perl script
> > -- the env. variable has new value.
> 
> That's a tricky one.
> 
> I suppose you're in a shell that supports backticks?
> Have the script print the new, desired value to STDOUT.
> Then try something like 
>  VAR=`script.pl`
> 
> This has to be done in the environment where the variable resides.
> You can't have a process change the environment of its parent.
> 
> What's the context?
> I assume it's a command-line operation, but that the script has to
> figure out what the new value is to be. If that's not the case, what
> *are* you trying to do?
> 
> __
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/


__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



Re: Regexp: Grouping and replacing with an unknown number of groups

2001-05-08 Thread Matt Cauthorn

Not sure if this will help you at this point, but I strongly recommend the
Date::Manip module for anything involving parsing dates. It does everything you can
imagine with dates and more. Tell it to parse your dates, and boom you can print
them however you want, get differences, etc. There are plenty of other date mods on
CPAN as well, but I've used Date::Manip and can say that it is awesome. Check it
out.


--- Craig Moynes/Markham/IBM <[EMAIL PROTECTED]> wrote:
> Continuing with the problems for my 'date formatting' script.
> 
> I am reading in a complete record from a logfile.  I check to see if the
> regexp matches to something inside the record.
> Then I want to find the what each grouped mini-regexp matched up with in
> the monster one at the bottom of the email.
> 
> The number of mini-regexp differs depending on the date format line the
> user enters.  So i find out how make keys there are (thus the number of
> mini-regexps)
> and try to construct a string that will print out whatever the mini-regexp
> matched up with.  But of course it doesn't work ;)
> 
> 
> $completeRec = "[Wed Aug  2 16:00:02 2000] [notice] caught SIGTERM,
> shutting down";
>  my $numOfKeys = keys %{$self->{DF_TOKENS}};
> for ( $counter = 1; $counter < $numOfKeys; $counter++)
> {
>  $replaceString.="\$$counter ";
> }
> my $values = $completeRec;
> 
> $values =~ s/.*$self->{DF_REGEXP}.*/$replaceString/g;
> print "$values\n";
> 
> 
> 
> Where $self->{DF_REGEXP} = something like :
> (?-xism:((?-xism:Mon|Tue|Wed|Thu|Fri|Sat|Sun))) (?-xism:((?
> -xism:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))) (?-xism:((?-xism:
> [ ][1-9]|[1-2][0-9]|3[0-1]))) (?-xism:((?-xism:[01][0-9]|2[0-3]))):(?-xism:
> ((?-xism:[0-5][0-9]))):(?-xism:((?-xism:[0-5][0-9]))) (?-xism:((?
> -xism:[0-9]{4})))
> 
> 
> This prints out something like:
> $1 $2 $3 $4 $5
> 
> for each record.  Which is not to useful ;)
> 
> However if I change the "$replaceString" to $1 $2 $3 etc it works
> perfectly.
> So what are my options guys and gals ?
> 
> 
> -
> Craig Moynes
> Internship Student
> netCC Development
> IBM Global Services, Canada
> Tel: (905) 316-3486
> [EMAIL PROTECTED]
> 
> 


__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



RE: html files in MAIL

2001-05-08 Thread King, Jason

[EMAIL PROTECTED] writes ..

>Please how do i (the actual commands) send an file (html) as 
>an attachment using sendmail in pelr with no MIME intalled?


I can't remember what options you need to give to sendmail .. and I don't
have sendmail here to test .. but you'll get the idea

  open MAIL, '|/usr/ucb/sendmail' or die "Bad pipe: $!";

  print MAIL <

EOF

  close MAIL or die "Bad pipe close: $!";

  __END__


hope that helps

-- 
  jason king

  In Hibbing, Minnesota, it shall be the duty of all policemen to kill
  all cats running at large. - http://dumblaws.com/



RE: Perl and WindowsNT

2001-05-08 Thread King, Jason

Carl Rogers writes ..

>I used the opendir() function in my Perl script to point to a folder
>with 200+ text files for the purpose of extracting data from each file.
>
>If I run the script with opendir/readdir pointing to a directory on a
>shared drive, I'll get to a point where Perl tells me "Can't open file-
>no such file or directory"

possibly - this is because of network instability .. ie. the network is not
available for that file .. you could try putting the open attempt in a loop
so that it tries a few times before giving up

  my $attempts = 100;

  until( open FILE, "$filename")
  {
die qq(Could not open "$filename": $!) unless $attempts--;
  }


>If I copy the "bad" file to my home directory, run the same script with
>opendir/readdir pointing to my home directory now- it can be opened and
>read.

smells of something caused by the share


>The weird part: If I go back and opendir/readdir to the shared
>directory, the "bad" file is all of a sudden working and another
>file later in the directory becomes the "bad" file. As the steps are
>repeated, more files in the shared directory are able to be read.

can't explain that other than by saying "Windows is weird"


>Question: Is there a "feature" in WindowsNT that would cause Perl to
>behave this way? I've tried by changing the properties on the files,
>and that doesn't seem to help. (BTW: I'm using Perl 5.001running on NT
>4.0 SP 6)


have you tried upgrading your Perl .. 5.001 - are you sure ??? .. the above
code snippet might not work in 5.001 - I don't know when they introduced the
post-conditional syntax

in any case you should not be running such an old version of Perl .. it is a
possible cause of this weird problem

you should upgrade to at least 5.005_03 .. but why not 5.6.0 or 5.6.1 .. get
the latest version from ActiveState

  http://www.activestate.com/

-- 
  jason king

  In Hibbing, Minnesota, it shall be the duty of all policemen to kill
  all cats running at large. - http://dumblaws.com/



RE: what's wrong in systax

2001-05-08 Thread King, Jason

either that or the "if (/$TYPETAG/i)" is not matching - so the block isn't
even being entered .. this would be most likely because even if the match on
line 29 doesn't match .. line 30 should still initialise $jobtype to (at the
very least) '::'

so my guess is that $TYPETAG doesn't appear on the line .. taking a look at
its contents - and using my Psi::ESP module .. I'm guessing that it's
because its value is

  

where it should be

  

but that's just a guess

-- 
  jason king

  In Hibbing, Minnesota, it shall be the duty of all policemen to kill
  all cats running at large. - http://dumblaws.com/


>-Original Message-
>From: Jos I Boumans [mailto:[EMAIL PROTECTED]]
>Sent: Wed 9 May 2001 09:05
>To: Anshu Anshu; [EMAIL PROTECTED]
>Cc: [EMAIL PROTECTED]
>Subject: Re: what's wrong in systax
>
>
>from the error msg i conclude that line 29 is not producing a 
>match. You
>might want to add some print statements to see whats going on there.
>if it holds meta chars like japhy said, you might also want to try
>"quotemeta $_;" so you can be sure all 'special characters' 
>are escaped for
>the regex.
>
>Regards,
>
>Jos Bouamns
>
>- Original Message -
>From: "Anshu Anshu" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Cc: <[EMAIL PROTECTED]>
>Sent: Tuesday, May 08, 2001 11:36 PM
>Subject: Re: what's wrong in systax
>
>
>> Thanks for reply. below is the varibales as defined -
>>
>> $LOCTAG = "";
>> $TYPETAG = "";
>>
>> and error message was
>>
>> Name "main::JOBDATA" used only once: possible typo at 
>gen_job.pl line 14.
>> Name "main::CP" used only once: possible typo at gen_job.pl line 13.
>> Use of uninitialized value in substitution (s///) at 
>gen_job.pl line 35.
>>
>> Thanks
>> AS
>> - Original Message -
>> From: "Jeff Pinyan" <[EMAIL PROTECTED]>
>> To: "Anshu Anshu" <[EMAIL PROTECTED]>
>> Cc: <[EMAIL PROTECTED]>
>> Sent: Tuesday, May 08, 2001 5:28 PM
>> Subject: Re: what's wrong in systax
>>
>>
>> > On May 8, Anshu Anshu said:
>> >
>> > > 22  while () {
>> > >23  if (/$LOCTAG/i) {
>> > >24  ($curloc) = /VALUE="([^"]+)"\s*\w*>/i;
>> > >25  $location .= "${curloc}::";
>> > >26  }
>> > >27
>> > >28  if (/$TYPETAG/i) {
>> > >29  ($curtype) = /VALUE="([^"]+)">/i;
>> > >30  $jobtype .= "${curtype}::";
>> > >31  }
>> > >32  }
>> > >33  close(IF);
>> > >34  $location =~ s/::$//;
>> > >35  $jobtype =~ s/::$//;
>> >
>> > It would be much appreciated if you gave us an error 
>message.  My guess
>is
>> > that there are characters in $LOCTAG and $TYPETAG that 
>Perl is using as
>> > regex characters.  Try:
>> >
>> >   if (/\Q$LOCTAG\E/i) { ... }
>> >   if (/\Q$TYPETAG\E/i) { ... }
>> >
>> > instead.  Or, consider using index() instead:
>> >
>> >   if (index(lc, lc($LOCTAG)) > -1) { ... }
>> >
>> > --
>> > Jeff "japhy" Pinyan  [EMAIL PROTECTED]
>http://www.pobox.com/~japhy/
>> > Are you a Monk?  http://www.perlmonks.com/
>http://forums.perlguru.com/
>> > Perl Programmer at RiskMetrics Group, Inc.
>http://www.riskmetrics.com/
>> > Acacia Fraternity, Rensselaer Chapter. Brother #734
>> >
>> >
>>
>



RE: Session Variables

2001-05-08 Thread Andy Sharp

There are many ways to do it, here's mine:

I wanted to semi-securely identify users to my site, having them log in
once, and then never have the need to login again (as long as they're at the
same computer)

So, I used cookies (perldoc CGI)  to set a unique session ID, once a user
had logged in.

When a user enters a username and a password, the username is looked up and
if the MD5 hash of the password matches the one stored in the Database, a
sessionID is created.  In order to generate a SessionID which is reasonably
tamper proof, I concatenated the IP address the person was connecting from
($ENV{REMOTE_ADDR}) with the username they had, and tacked on a 10 Digit
random number.

I then used Digest::MD5 to create an MD5 base 64 hash of this value, which
was set as a cookie on the visitors computer.  The random number, the IP
address, the numeric ID of the user, and the Session key were stored in a
sessions table.

now when a user visits the site, most of the time I just lookup the
sessionID returned by CGI->cookie('SessionID') and assume that they're
logged in correctly.  In cases of high security (admin functions) I can
regenerate the MD5 hash from the table to ensure it matches.

here's the code to store a cookie.

use CGI;
my $q = new CGI;

my $cookie = $q->cookie(-name=> 'Name of Cookie',
-value=> 'Value of Cookie',
-expires=> '+1y' ,  # cookie lasts a year
-domain=> '.allakhazam.com');  #
print $q->header(-cookie=> $cookie,
   -content-type=> 'text/html');

To get a cookie:

use CGI;
my $q = new CGI;
my $cookie_value = $q->cookie('Name of Cookie');
# $cookie_value is now 'Value of Cookie'

For excellent reading on different ways to use SessionIDs, consult the
"Writing Apache Modules in Perl and C" from O'Reily's.  Also consult the
cookie spec at Netscape.com
(http://www.netscape.com/newsref/std/cookie_spec.html)

For more info on controlling cookies from CGI.pm, consult it's
documentation.

Hope that helps,

--A

-Original Message-
From: Brian Shoemaker [mailto:[EMAIL PROTECTED]]
Sent: May 8, 2001 4:59 PM
To: [EMAIL PROTECTED]
Subject: Session Variables


Hello.

I am attempting to find some information on using session variables in
Perl/CGI.

When someone logs into my site, the script will check a flat-text database
and if the user has entered a correct username and password, the user will
be validated. At this point, a session variable will be set so the user will
not have to login again.

Unfortunately, I can't seem to find any information about how to do this.
Any info would be appreciated.

Brian Shoemaker





Re: microsoft sql2000

2001-05-08 Thread Jos I Boumans

Judging from the modules it should be able too...
what you need is the DBD module, as well as a driver.. which in your case
would be
DBIx-MSSQLReporter [1.00 ] An module to connect Perl to MS SQL Server and MS
if i'm not mistaken.

if you use ActiveState Perl, it shouldnt be hard to install them.

just run the PPM from your perl/bin directory and do a search for both dbd
as well as dbi and you're bound to find the right modules.

Regards,

Jos Boumans


- Original Message -
From: "Matthew, Marlon B." <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 09, 2001 1:46 AM
Subject: microsoft sql2000


> Hello perl friends. I need to know if perl works with microsoft sql2000.
if
> it does, which module do i need to get? thanks
>
> Marlon
>




microsoft sql2000

2001-05-08 Thread Matthew, Marlon B.

Hello perl friends. I need to know if perl works with microsoft sql2000. if
it does, which module do i need to get? thanks

Marlon



Re: Session Variables

2001-05-08 Thread Dan Brown

If you're using Apache, I highly recommend the O'Reilly book "Writing
Apache Modules with Perl and C" by Lincoln Stein and Doug MacEachern
(ISBN: 1-56592-567-X).  A section of the book starts with a simple
authentication example and builds on it (including a couple of different
way to store session information).  One of the best things I got out of
this book is learning how to set the session id in cookies and, in the
event that the user does not have cookies enabled, set the session id in
the URL.

Dan

Brian Shoemaker wrote:
> 
> Hello.
> 
> I am attempting to find some information on using session variables in
> Perl/CGI.
> 
> When someone logs into my site, the script will check a flat-text database
> and if the user has entered a correct username and password, the user will
> be validated. At this point, a session variable will be set so the user will
> not have to login again.
> 
> Unfortunately, I can't seem to find any information about how to do this.
> Any info would be appreciated.
> 
> Brian Shoemaker



Re: what's wrong in systax

2001-05-08 Thread Jos I Boumans

from the error msg i conclude that line 29 is not producing a match. You
might want to add some print statements to see whats going on there.
if it holds meta chars like japhy said, you might also want to try
"quotemeta $_;" so you can be sure all 'special characters' are escaped for
the regex.

Regards,

Jos Bouamns

- Original Message -
From: "Anshu Anshu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, May 08, 2001 11:36 PM
Subject: Re: what's wrong in systax


> Thanks for reply. below is the varibales as defined -
>
> $LOCTAG = "";
> $TYPETAG = "";
>
> and error message was
>
> Name "main::JOBDATA" used only once: possible typo at gen_job.pl line 14.
> Name "main::CP" used only once: possible typo at gen_job.pl line 13.
> Use of uninitialized value in substitution (s///) at gen_job.pl line 35.
>
> Thanks
> AS
> - Original Message -
> From: "Jeff Pinyan" <[EMAIL PROTECTED]>
> To: "Anshu Anshu" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Tuesday, May 08, 2001 5:28 PM
> Subject: Re: what's wrong in systax
>
>
> > On May 8, Anshu Anshu said:
> >
> > > 22  while () {
> > >23  if (/$LOCTAG/i) {
> > >24  ($curloc) = /VALUE="([^"]+)"\s*\w*>/i;
> > >25  $location .= "${curloc}::";
> > >26  }
> > >27
> > >28  if (/$TYPETAG/i) {
> > >29  ($curtype) = /VALUE="([^"]+)">/i;
> > >30  $jobtype .= "${curtype}::";
> > >31  }
> > >32  }
> > >33  close(IF);
> > >34  $location =~ s/::$//;
> > >35  $jobtype =~ s/::$//;
> >
> > It would be much appreciated if you gave us an error message.  My guess
is
> > that there are characters in $LOCTAG and $TYPETAG that Perl is using as
> > regex characters.  Try:
> >
> >   if (/\Q$LOCTAG\E/i) { ... }
> >   if (/\Q$TYPETAG\E/i) { ... }
> >
> > instead.  Or, consider using index() instead:
> >
> >   if (index(lc, lc($LOCTAG)) > -1) { ... }
> >
> > --
> > Jeff "japhy" Pinyan  [EMAIL PROTECTED]
http://www.pobox.com/~japhy/
> > Are you a Monk?  http://www.perlmonks.com/
http://forums.perlguru.com/
> > Perl Programmer at RiskMetrics Group, Inc.
http://www.riskmetrics.com/
> > Acacia Fraternity, Rensselaer Chapter. Brother #734
> >
> >
>




Re: Session Variables

2001-05-08 Thread Peter Scott

At 04:00 PM 5/8/01 -0700, I wrote:
>At 06:59 PM 5/8/01 -0400, Brian Shoemaker wrote:
>>Hello.
>>
>>I am attempting to find some information on using session variables in
>>Perl/CGI.
>>
>>When someone logs into my site, the script will check a flat-text database
>>and if the user has entered a correct username and password, the user will
>>be validated. At this point, a session variable will be set so the user will
>>not have to login again.
>>
>>Unfortunately, I can't seem to find any information about how to do this.
>>Any info would be appreciated.
>
>If the user logs in via http basic-auth, this happens automatically - 
>until they quit their browser, whenever they talk to your site, the 
>username/password will be sent transparently.
>
>This is by far the simplest solution to your problem.  More complicated 
>ones involve Apache modules of some kind.

Or (duh) cookies, of course.  Although basic-auth is still simpler.  Only 
disadvantage is that it gives you no choice about the user interface for 
logging in.

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Re: Session Variables

2001-05-08 Thread Casey West

On Tue, May 08, 2001 at 06:59:07PM -0400, Brian Shoemaker wrote:
: Hello.
: 
: I am attempting to find some information on using session variables in
: Perl/CGI.

In a CGI environment, you might want to take a look at the CGI::Cookie
module, which comes standard with all modern versions of Perl.

You can accept the form variables and, if the user is authenticated,
set a cookie stating so and check it on all your pages.  Of course,
this is kind of a pain.

If you are looking for real sessions I would suggest using mod_perl
for your web site development architecture and the Apache::Session
module for handling sessions.

perldoc CGI::Cookie# for basic cookie info
http://perl.apache.org # for mod_perl info
http://search.cpan.org # to check out Apache::Session

: When someone logs into my site, the script will check a flat-text database
: and if the user has entered a correct username and password, the user will
: be validated. At this point, a session variable will be set so the user will
: not have to login again.
: 
: Unfortunately, I can't seem to find any information about how to do this.
: Any info would be appreciated.

  Casey West

-- 
Shooting yourself in the foot with C++ 
You accidently create a dozen instances of yourself and shoot them all
in the foot. Providing emergency medical assistance is impossible
since you can't tell which are bitwise copies and which are just
pointing at others and saying "That's me, over there." 



Re: Session Variables

2001-05-08 Thread Jos I Boumans

I take it you have the CGI module installed... all you need to do is read up
on CGI::Cookies which will show you exactly how to store and retrieve
cookies. The docs can be foudn on CPAN or in your perl/html/site/lib/CGI dir

regards,

Jos Boumans


- Original Message -
From: "Brian Shoemaker" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 09, 2001 12:59 AM
Subject: Session Variables


> Hello.
>
> I am attempting to find some information on using session variables in
> Perl/CGI.
>
> When someone logs into my site, the script will check a flat-text database
> and if the user has entered a correct username and password, the user will
> be validated. At this point, a session variable will be set so the user
will
> not have to login again.
>
> Unfortunately, I can't seem to find any information about how to do this.
> Any info would be appreciated.
>
> Brian Shoemaker
>
>




Re: Session Variables

2001-05-08 Thread Peter Scott

At 06:59 PM 5/8/01 -0400, Brian Shoemaker wrote:
>Hello.
>
>I am attempting to find some information on using session variables in
>Perl/CGI.
>
>When someone logs into my site, the script will check a flat-text database
>and if the user has entered a correct username and password, the user will
>be validated. At this point, a session variable will be set so the user will
>not have to login again.
>
>Unfortunately, I can't seem to find any information about how to do this.
>Any info would be appreciated.

If the user logs in via http basic-auth, this happens automatically - until 
they quit their browser, whenever they talk to your site, the 
username/password will be sent transparently.

This is by far the simplest solution to your problem.  More complicated 
ones involve Apache modules of some kind.

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Session Variables

2001-05-08 Thread Brian Shoemaker

Hello.

I am attempting to find some information on using session variables in
Perl/CGI.

When someone logs into my site, the script will check a flat-text database
and if the user has entered a correct username and password, the user will
be validated. At this point, a session variable will be set so the user will
not have to login again.

Unfortunately, I can't seem to find any information about how to do this.
Any info would be appreciated.

Brian Shoemaker




Re: what's wrong in systax

2001-05-08 Thread Anshu Anshu

Thanks for reply. below is the varibales as defined -

$LOCTAG = "";
$TYPETAG = "";

and error message was

Name "main::JOBDATA" used only once: possible typo at gen_job.pl line 14.
Name "main::CP" used only once: possible typo at gen_job.pl line 13.
Use of uninitialized value in substitution (s///) at gen_job.pl line 35.

Thanks
AS
- Original Message -
From: "Jeff Pinyan" <[EMAIL PROTECTED]>
To: "Anshu Anshu" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, May 08, 2001 5:28 PM
Subject: Re: what's wrong in systax


> On May 8, Anshu Anshu said:
>
> > 22  while () {
> >23  if (/$LOCTAG/i) {
> >24  ($curloc) = /VALUE="([^"]+)"\s*\w*>/i;
> >25  $location .= "${curloc}::";
> >26  }
> >27
> >28  if (/$TYPETAG/i) {
> >29  ($curtype) = /VALUE="([^"]+)">/i;
> >30  $jobtype .= "${curtype}::";
> >31  }
> >32  }
> >33  close(IF);
> >34  $location =~ s/::$//;
> >35  $jobtype =~ s/::$//;
>
> It would be much appreciated if you gave us an error message.  My guess is
> that there are characters in $LOCTAG and $TYPETAG that Perl is using as
> regex characters.  Try:
>
>   if (/\Q$LOCTAG\E/i) { ... }
>   if (/\Q$TYPETAG\E/i) { ... }
>
> instead.  Or, consider using index() instead:
>
>   if (index(lc, lc($LOCTAG)) > -1) { ... }
>
> --
> Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
> Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
> Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
> Acacia Fraternity, Rensselaer Chapter. Brother #734
>
>



Re: what's wrong in systax

2001-05-08 Thread Jeff Pinyan

On May 8, John Joseph Trammell said:

>On Tue, May 08, 2001 at 05:24:10PM -0400, Anshu Anshu wrote:
>>  22  while () {
>> 23  if (/$LOCTAG/i) {
>> 24  ($curloc) = /VALUE="([^"]+)"\s*\w*>/i;
>> 25  $location .= "${curloc}::";
>> 26  }
>> 27
>> 28  if (/$TYPETAG/i) {
>> 29  ($curtype) = /VALUE="([^"]+)">/i;
>> 30  $jobtype .= "${curtype}::";
>> 31  }
>> 32  }
>> 33  close(IF);
>> 34  $location =~ s/::$//;
>> 35  $jobtype =~ s/::$//;
>
>Lines 24, 29; perhaps you mean "=~" ?

No.  Doing:

  ($foo) = /pattern/;

is the same as:

  ($foo) = $_ =~ /pattern/;

What he's doing is getting the ()'d part of the regex, and storing it in
$curloc.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734




Re: what's wrong in systax

2001-05-08 Thread Jeff Pinyan

On May 8, Anshu Anshu said:

> 22  while () {
>23  if (/$LOCTAG/i) {
>24  ($curloc) = /VALUE="([^"]+)"\s*\w*>/i;
>25  $location .= "${curloc}::";
>26  }
>27
>28  if (/$TYPETAG/i) {
>29  ($curtype) = /VALUE="([^"]+)">/i;
>30  $jobtype .= "${curtype}::";
>31  }
>32  }
>33  close(IF);
>34  $location =~ s/::$//;
>35  $jobtype =~ s/::$//;

It would be much appreciated if you gave us an error message.  My guess is
that there are characters in $LOCTAG and $TYPETAG that Perl is using as
regex characters.  Try:

  if (/\Q$LOCTAG\E/i) { ... }
  if (/\Q$TYPETAG\E/i) { ... }

instead.  Or, consider using index() instead:

  if (index(lc, lc($LOCTAG)) > -1) { ... }

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734




Re: what's wrong in systax

2001-05-08 Thread John Joseph Trammell

On Tue, May 08, 2001 at 05:24:10PM -0400, Anshu Anshu wrote:
>  22  while () {
> 23  if (/$LOCTAG/i) {
> 24  ($curloc) = /VALUE="([^"]+)"\s*\w*>/i;
> 25  $location .= "${curloc}::";
> 26  }
> 27
> 28  if (/$TYPETAG/i) {
> 29  ($curtype) = /VALUE="([^"]+)">/i;
> 30  $jobtype .= "${curtype}::";
> 31  }
> 32  }
> 33  close(IF);
> 34  $location =~ s/::$//;
> 35  $jobtype =~ s/::$//;

Lines 24, 29; perhaps you mean "=~" ?

-- 
I don't know what the hell is going on dude, but this suspension gives
me more time for fraggin'.  Yee haw!



what's wrong in systax

2001-05-08 Thread Anshu Anshu

 22  while () {
23  if (/$LOCTAG/i) {
24  ($curloc) = /VALUE="([^"]+)"\s*\w*>/i;
25  $location .= "${curloc}::";
26  }
27
28  if (/$TYPETAG/i) {
29  ($curtype) = /VALUE="([^"]+)">/i;
30  $jobtype .= "${curtype}::";
31  }
32  }
33  close(IF);
34  $location =~ s/::$//;
35  $jobtype =~ s/::$//;

with Perl 5.6.1

Thanks



Re: Regexp: Grouping and replacing with an unknown number of groups-- SOLVED

2001-05-08 Thread Craig Moynes/Markham/IBM

Perfect, thanks.  I think I saw that earlier ...stupid brain :)

-
Craig Moynes
Internship Student
netCC Development
IBM Global Services, Canada
Tel: (905) 316-3486
[EMAIL PROTECTED]



   
   
"Brett W. McCoy"   
   
  cc: <[EMAIL PROTECTED]>   
   
Subject: Re: Regexp: Grouping and 
replacing with an unknown number of 
05/08/01 04:09 PMgroups
   
   
   
   
   
   
   



On Tue, 8 May 2001, Craig Moynes/Markham/IBM wrote:

> $values =~ s/.*$self->{DF_REGEXP}.*/$replaceString/g;

Perhaps you actually want:

@values_arr = $values =~ /.*$self->{DF_REGEXP}.*/

This will give you an array of the atomized matches in your regexp, and
you don't need to fool around with those backreferences.  If you're not
really doing anything with those backreferences, you are just making busy
work for yourself trying to format that output.

-- Brett

http://www.chapelperilous.net/btfwk/

I came, I saw, I deleted all your files.









Re: Perl and WindowsNT

2001-05-08 Thread Mike Lacey

Carl,

Have you tried to use the globbing function rather than readdir?

my $file;
while(<*.txt>){
$file=$_;  # not strictly needed, I know, but makes it clear
open(F,$file) || die "with a nice error message\n$!\n";
while(){
# do something useful with the file
}
close F;
}

Mike Lacey

www.tek-tips.com -- a friendly, flame free, environment for computer
professionals and students
Perl forum at:
http://www.tek-tips.com/gthreadminder.cfm/lev2/4/lev3/32/pid/219

- Original Message -
From: "Carl Rogers" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 08, 2001 5:42 PM
Subject: Perl and WindowsNT


> Sorry if this is a dumb question.. (I know, there is no such thing as a
> dumb question- only questions asked by dumb people:)
>
> I used the opendir() function in my Perl script to point to a folder with
> 200+ text files for the purpose of extracting data from each file.
>
> If I run the script with opendir/readdir pointing to a directory on a
> shared drive, I'll get to a point where Perl tells me "Can't open file- no
> such file or directory"
>
> If I copy the "bad" file to my home directory, run the same script with
> opendir/readdir pointing to my home directory now- it can be opened and
read.
>
> The weird part: If I go back and opendir/readdir to the shared directory,
> the "bad" file is all of a sudden working and another file later in the
> directory becomes the "bad" file. As the steps are repeated, more files in
> the shared directory are able to be read.
>
> Question: Is there a "feature" in WindowsNT that would cause Perl to
behave
> this way? I've tried by changing the properties on the files, and that
> doesn't seem to help. (BTW: I'm using Perl 5.001running on NT 4.0 SP 6)
>
> I'm hoping there is a more efficient way of solving this "hiccup".
>
> Thank you in advance for all of your time & help.
> Carl
>




Re: Regexp: Grouping and replacing with an unknown number of groups

2001-05-08 Thread Me

Tip for those posting (or even just creating)
long regexes:

If you stick a /x on the end of a regex,
whitespace in the regex is ignored, so
you can break it up into multiple lines,
indent lines as appropriate, add spaces
where nice, and comments, etc. One
thing to remember if you do this: white
space is ignored! so you have to use
\S and its cousins to actually specify
a space.




Re: Regexp: Grouping and replacing with an unknown number of groups

2001-05-08 Thread Brett W. McCoy

On Tue, 8 May 2001, Craig Moynes/Markham/IBM wrote:

> $values =~ s/.*$self->{DF_REGEXP}.*/$replaceString/g;

Perhaps you actually want:

@values_arr = $values =~ /.*$self->{DF_REGEXP}.*/

This will give you an array of the atomized matches in your regexp, and
you don't need to fool around with those backreferences.  If you're not
really doing anything with those backreferences, you are just making busy
work for yourself trying to format that output.

-- Brett
   http://www.chapelperilous.net/btfwk/

I came, I saw, I deleted all your files.





Regexp: Grouping and replacing with an unknown number of groups

2001-05-08 Thread Craig Moynes/Markham/IBM

Continuing with the problems for my 'date formatting' script.

I am reading in a complete record from a logfile.  I check to see if the
regexp matches to something inside the record.
Then I want to find the what each grouped mini-regexp matched up with in
the monster one at the bottom of the email.

The number of mini-regexp differs depending on the date format line the
user enters.  So i find out how make keys there are (thus the number of
mini-regexps)
and try to construct a string that will print out whatever the mini-regexp
matched up with.  But of course it doesn't work ;)


$completeRec = "[Wed Aug  2 16:00:02 2000] [notice] caught SIGTERM,
shutting down";
 my $numOfKeys = keys %{$self->{DF_TOKENS}};
for ( $counter = 1; $counter < $numOfKeys; $counter++)
{
 $replaceString.="\$$counter ";
}
my $values = $completeRec;

$values =~ s/.*$self->{DF_REGEXP}.*/$replaceString/g;
print "$values\n";



Where $self->{DF_REGEXP} = something like :
(?-xism:((?-xism:Mon|Tue|Wed|Thu|Fri|Sat|Sun))) (?-xism:((?
-xism:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec))) (?-xism:((?-xism:
[ ][1-9]|[1-2][0-9]|3[0-1]))) (?-xism:((?-xism:[01][0-9]|2[0-3]))):(?-xism:
((?-xism:[0-5][0-9]))):(?-xism:((?-xism:[0-5][0-9]))) (?-xism:((?
-xism:[0-9]{4})))


This prints out something like:
$1 $2 $3 $4 $5

for each record.  Which is not to useful ;)

However if I change the "$replaceString" to $1 $2 $3 etc it works
perfectly.
So what are my options guys and gals ?


-
Craig Moynes
Internship Student
netCC Development
IBM Global Services, Canada
Tel: (905) 316-3486
[EMAIL PROTECTED]





Re: getting values from a called subroutine

2001-05-08 Thread Me

> [returning values from a sub?]

As other posters have said, just return a list
of some sort. Note that stuff gets flattened.
So if you do:

sub flat {
$foo = '1';
@bar = (2, 3);
$baz['4'} = 5;
return $foo, @bar, %baz, ['qux', 'waldo']
}

@list = flat;

@list should contain 6 entries, effectively:

('1', 2, 3, '4', 5, ['qux', 'waldo'])

If you want to create some data structure and
maintain its structure on returning it, then return
a reference to the structure instead. As you can
see, that's what happened with the anonymous
array at the end (the qux waldo thing).



Sometimes "auto flattening" or whatever you want
to call it is wonderful, other times its inconvenient.

It looks like when auto flattening applies may
change in perl6, but that's a couple years off.




Re: ppm error

2001-05-08 Thread M.W. Koskamp


- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 08, 2001 7:54 PM
Subject: ppm error


> when i use Active Perl on Win98 PPm i get the following error when i try
to use the search command:
>
> ---
> PPM> search
>
> not well-formed at line 1, column 17, byte 17 at
C:/Perl/site/lib/SOAP/Parser.pm line 73

Thought i already answered this one.
It seems that your ppm.xml file is not ok.




ppm error

2001-05-08 Thread gerry

when i use Active Perl on Win98 PPm i get the following error when i try to use the 
search command:

---
PPM> search

not well-formed at line 1, column 17, byte 17 at C:/Perl/site/lib/SOAP/Parser.pm line 
73
---

what does the message "not well-formed mean" and any ideas about how to fix this??

May Thanks...gerry

-

Be passionate about your email
Just click here: http://another.com

Show off your email or web address on a figure hugging skinny t-shirt. Only 15.00:
http://www.clickandbuild.com/cnb/shop/another



Perl and WindowsNT

2001-05-08 Thread Carl Rogers

Sorry if this is a dumb question.. (I know, there is no such thing as a 
dumb question- only questions asked by dumb people:)

I used the opendir() function in my Perl script to point to a folder with 
200+ text files for the purpose of extracting data from each file.

If I run the script with opendir/readdir pointing to a directory on a 
shared drive, I'll get to a point where Perl tells me "Can't open file- no 
such file or directory"

If I copy the "bad" file to my home directory, run the same script with 
opendir/readdir pointing to my home directory now- it can be opened and read.

The weird part: If I go back and opendir/readdir to the shared directory, 
the "bad" file is all of a sudden working and another file later in the 
directory becomes the "bad" file. As the steps are repeated, more files in 
the shared directory are able to be read.

Question: Is there a "feature" in WindowsNT that would cause Perl to behave 
this way? I've tried by changing the properties on the files, and that 
doesn't seem to help. (BTW: I'm using Perl 5.001running on NT 4.0 SP 6)

I'm hoping there is a more efficient way of solving this "hiccup".

Thank you in advance for all of your time & help.
Carl




Re: regexp and Multiple lines{SOLVED}

2001-05-08 Thread Ga Bu

Thanks for your help, 

Changing the $/ variable from "/n" to "!" for the
seperator worked great!

It reading in the lines and I am able to search that
with no problems know. 

I just found that in the perl cookbook also. 


Good luck everyone...

__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



Re: getting values from a called subroutine

2001-05-08 Thread Brett W. McCoy

On Tue, 8 May 2001, Adam Theo wrote:

> so, in short, any way i can get a subroutine to send *back* arguments
> to the piece of code that called it? all of this will be within the
> same program, i just am hoping there is a way to do this.

The last expression evaluated in a subroutine is returned, but you can
explicitly return a value by doing:

return $some_value;

If you have multiple values to return, put the return values into a list
context and grab it back that way:

sub some_sub {
#do stuff
return @vals;
}

my (val1, val2) = some_sub;

This is also a good way to return errors, failure of an algorithm (by
returning a false value, etc:

if(!some_sub()) {
# do something
}

-- Brett
   http://www.chapelperilous.net/btfwk/

... the flaw that makes perfection perfect.




Re: getting values from a called subroutine

2001-05-08 Thread Kevin Meltzer

Hi Adam,

Are you talking about doing:

sub foo {
my $arg1 = 1;
my $arg2 = 2;
my ($one, $two) = bar($arg1, $arg2);
print qq{$one and $two};
}

sub bar {
my $arg1 = shift;
my $arg2 = shift;

return ++$arg1, ++$arg2;
}


Cheers,
Kevin

On Tue, May 08, 2001 at 11:58:06AM -0400, Adam Theo ([EMAIL PROTECTED]) spew-ed 
forth:
> hello, all. i just signed onto this list, and i have to say *wow, it's active!*. 
>just got my first digest version, and it has over 1,400 lines in it!
> 
> well, anyway, while i hope to be able to help out and give advice and answers to 
>many people on this list, i have a question of my own right now.
> 
> i am making a perl program (using Tk for a GUI), and it makes frequent use of my() 
>and many subroutines. up till now, i've just been having the program work by passing 
>scalarref's from one my'ed sub to the next using &this_sub(\$ref1, \$ref2);, etc.
> 
> but, now that i'm near the end of completing this program, i have found a spot where 
>i will basically need to do the opposite. i will need to have one subroutine that 
>generates the values formerly passed along as arguments to the many other subs, and 
>now have these many other subs be bale to calkl this new subroutine, and get *back* 
>info, instead of just sending it.
> 
> so, in short, any way i can get a subroutine to send *back* arguments to the piece 
>of code that called it? all of this will be within the same program, i just am hoping 
>there is a way to do this.
> 
> thanks all.
> 
> -- 
>/\--- Adam Theo ---
>   //\\   Theoretic Solutions (www.Theoretic.com)
>  /\ Software, Politics, and Advocacy
> /--||--\ email: [EMAIL PROTECTED]   AIM: Adam Theo 2000
>||jabber: [EMAIL PROTECTED]   ICQ: 3617306
>||  "Did you ever get the feeling the world was a tuxedo,
>|| and you were a pair of brown shoes?"
> 

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
There ain't nothin' in this world that's worth being a snot over.
--Larry Wall in <[EMAIL PROTECTED]>



getting values from a called subroutine

2001-05-08 Thread Adam Theo

hello, all. i just signed onto this list, and i have to say *wow, it's active!*. just 
got my first digest version, and it has over 1,400 lines in it!

well, anyway, while i hope to be able to help out and give advice and answers to many 
people on this list, i have a question of my own right now.

i am making a perl program (using Tk for a GUI), and it makes frequent use of my() and 
many subroutines. up till now, i've just been having the program work by passing 
scalarref's from one my'ed sub to the next using &this_sub(\$ref1, \$ref2);, etc.

but, now that i'm near the end of completing this program, i have found a spot where i 
will basically need to do the opposite. i will need to have one subroutine that 
generates the values formerly passed along as arguments to the many other subs, and 
now have these many other subs be bale to calkl this new subroutine, and get *back* 
info, instead of just sending it.

so, in short, any way i can get a subroutine to send *back* arguments to the piece of 
code that called it? all of this will be within the same program, i just am hoping 
there is a way to do this.

thanks all.

-- 
   /\--- Adam Theo ---
  //\\   Theoretic Solutions (www.Theoretic.com)
 /\ Software, Politics, and Advocacy
/--||--\ email: [EMAIL PROTECTED]   AIM: Adam Theo 2000
   ||jabber: [EMAIL PROTECTED]   ICQ: 3617306
   ||  "Did you ever get the feeling the world was a tuxedo,
   || and you were a pair of brown shoes?"



Checking available bytes in socket

2001-05-08 Thread Robin Lavallee (LMC)


Hi,

What's the easy, portable way, to check the number
of bytes available in a socket ? (IO::Socket::INET).

-Robin



Re: Need help on Unicode Programming...

2001-05-08 Thread M.W. Koskamp


- Original Message -
From: Ang Sei Heng <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 09, 2001 1:27 AM
Subject: Need help on Unicode Programming...



> This is what I did:
> -- BEGIN -
> #!/usr/bin/perl -w
>
> use Unicode::Map8;
> use Unicode::String;
>
> MAIN:
> {
> my $m = Unicode::String->new;
I dont see a 'new' constructor mentioned in the documentation

Here's a part of the fine manual on UTF...:

SYNOPSIS
 use Unicode::String qw(utf8 latin1 utf16);
 $u = utf8("The Unicode Standard is a fixed-width, uniform ");
 $u .= utf8("encoding scheme for written characters and text");
 # convert to various external formats
 print $u->ucs4;  # 4 byte characters
 print $u->utf16; # 2 byte characters + surrogates
 print $u->utf8;  # 1-4 byte characters
 print $u->utf7;  # 7-bit clean format
 print $u->latin1;# lossy
 print $u->hex;   # a hexadecimal string
 # all these can be used to set string value or as constructor
 $u->latin1("Å være eller å ikke være");
 $u = utf16("\0Å\0 \0v\0æ\0r\0e");
 # string operations
 $u2 = $u->copy;
 $u->append($u2);
 $u->repeat(2);
 $u->chop;
 $u->length;
 $u->index($other);
 $u->index($other, $pos);
 $u->substr($offset);
 $u->substr($offset, $length);
 $u->substr($offset, $length, $substitute);
 # overloading
 $u .= "more";
 $u = $u x 100;
 print "$u\n";
 # string <--> array of numbers
 @array = $u->unpack;
 $u->pack(@array);
 # misc
 $u->ord;
 $u = uchr($num);





Re: nested each(%hash) question

2001-05-08 Thread Timothy Kimball


: > I have 2 hashes, %one and %two.
: >
: > the ($key, $value) of %one is a span of time.
: >
: > I need to compare this span of time over every $key of %two.
: 
: ...
: 
: Look at the replies given here earlier.
: I ran some benchmarks with while and grep, and your while loop didnt look
: less efficient.
: I think the timeout has another reason.
: Try putting some warns in your code and check the webserver's logfile.

If you *really* want to know what's going on, a profiler will tell
you.  There are plenty of them around. Devel::DProf comes with Perl
(5.6.0, anyway); I like Devel::SmallProf myself. Either one will tell
you where your program is *really* spending its time- which often is
not where you thought it was. Learned a valuable lesson about CGI.pm's
html "shortcuts" that way.

-- tdk



Need help on Unicode Programming...

2001-05-08 Thread Ang Sei Heng

Hello,

Anyone out there actually play with Unicode::Map8,
Unicode::String or Unicode::Map?

I don't seem to be make my code working. I am trying
to convert from a utf8 => utf16. Reading from the 
document seems to imply one of the above module
should be able to help me. But, I don't understand
how to use these modules. (I know this is embarrassing, 
this mean I cannot understand what the doc at all).

This is what I did:
-- BEGIN -
#!/usr/bin/perl -w

use Unicode::Map8;
use Unicode::String;

MAIN:
{
my $m = Unicode::String->new;
while ( <> ){

my $line = $_;

chomp($line);

## Is the below tow line make sense??
$m->utf8($line);
print $m->utf16, "\n";

}
}

sub Build_HexString
{
my $raw = shift;

my $len = length($raw);
my $i = 0;
my $process_code = "";

while( $i < $len ){

my $c = substr $raw, $i, 1;

my $hex_num = sprintf("%.2x", ord($c) );

$process_code .= $hex_num;

$i++;
}

return $process_code;
}

- END -

Basically, I want to convert utf-8 to utf-16 first, 
then display the result in Hex string. 

But, I get a lot of warnning mesasge, and the Hex
string is not what I expected. 

Anyone can explain I mistake I did...

Thanks,
Sei Heng


-- 
Cybersource Pte Ltd
745 Toa Payoh Lorong 5 #03-02
HBM Building Singapore 319455
Tel: (65) 3580575

>> I rather be free in Hell then a slave in Heaven <<



Re: nested each(%hash) question

2001-05-08 Thread M.W. Koskamp



> I have 2 hashes, %one and %two.
>
> the ($key, $value) of %one is a span of time.
>
> I need to compare this span of time over every $key of %two.
>
> Here's what I have:
>
> while (($key1, $val1) = each (%one)) {
>
> while (($key2, $val2) = each (%two)) {
>
> if (($key2 >= $key1) && ($key2 < $val1)) {
>
> push @match, $val2;
> }
> }
> }
>

Look at the replies given here earlier.
I ran some benchmarks with while and grep, and your while loop didnt look
less efficient.
I think the timeout has another reason.
Try putting some warns in your code and check the webserver's logfile.

Maarten.




Re: regexp?? Reading in multiple lines to search??

2001-05-08 Thread Jeff Pinyan

On May 8, Ga Bu said:

>I am fairly new to perl and having problems with
>pulling in multiple lines from a file so I can search
>those lines and if it has the expression I am looking
>for then I want to return to that file and search
>again for the same pattern of lines again and then
>search again for the pattern in those line and save it
>to a file. 
> 
>Between each group of text is a "!" exclamation point.

Then just tell Perl that a "line" is really just a series of characters
that ends with "\n!\n".  To do this, change the value of the $/ variable.

The $/ variable (as described in perlvar) is the input-record-separator,
which means that it holds the string that comes at the end of every record
or "line" that you read.  It defaults to "\n", meaning that "lines" end in
a newline.

  {
local $/ = "\n!\n";  # so that $/ gets its normal value afterward
while () {
  # do something with $_
}
  }

You might want to know about the /m modifier for regexes, which makes ^
and $ not match beginning and end of a STRING, but rather, beginning and
end of a \n-line.

  my @parts = "abc\ndef\n" =~ /^(.*)$/mg;
  print "@parts";  # "abc def"

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734




Re: nested each(%hash) question

2001-05-08 Thread Timothy Kimball


: I have 2 hashes, %one and %two.
: 
: the ($key, $value) of %one is a span of time.
: 
: I need to compare this span of time over every $key of %two.
: 
: Here's what I have:
: 
: while (($key1, $val1) = each (%one)) {
: 
:   while (($key2, $val2) = each (%two)) {
: 
:   if (($key2 >= $key1) && ($key2 < $val1)) {
:   
:   push @match, $val2;
:   }
:   }
: }
: 
: There are 10,000 , 5,000 records in %one and %two, and it keeps timing out.
: ( this is an http-request )
: 
: Is there a more efficient way?

Just off the top of my head, I know that looping over the keys
of a hash is faster than looping over the key/val pairs:

foreach my $key1 ( keys %one ) {
foreach my $key2 ( keys %two ) {
if ($key2 >= $key1 and $key2 < $one{$key1}) {
push @match, $two{$key2};
}
}
}

Also, sorting the keys of %two can give the inner loop an opportunity
place to break off the search early:

foreach my $key1 ( keys %one ) {
foreach my $key2 ( sort {$a<=>$b} keys %two ) {
next unless $key2 >= $key1;
last if $key2 >= $one{$key1};
push @match, $two{$key2};
}
}

"last if" will prevent the code from doing any more comparisons
than are necessary.

N.B. This isn't benchmarked, so I don't know how much time it will save,
especially netted against the sort. I'm sure people who actually took an
algorithms class will come up with something better. ;)

-- tdk



Re: regexp?? Reading in multiple lines to search??

2001-05-08 Thread Carl Rogers

Being a beginner myself, this might work, but someone else may have a 
better solution...

$INFILE = "Your_Input_File.txt" ;
open (OUTFILE, ">Your_Output_File.txt";) or die;
open (INFILE) or die;

while ($line  = )
{
chomp ($line);
if ($line =~ /(whatever expression you're looking for)/)
{
 print OUTFILE $1;
}
}
close (INFILE);
close (OUTFILE);

Hope this helps.

At 06:31 AM 5/8/01 -0700, Ga Bu wrote:
>Hi everyone,
>
>I am fairly new to perl and having problems with
>pulling in multiple lines from a file so I can search
>those lines and if it has the expression I am looking
>for then I want to return to that file and search
>again for the same pattern of lines again and then
>search again for the pattern in those line and save it
>to a file.
>
>Between each group of text is a "!" exclamation point.
>
>
>!
>line of text 1
>line of text 2
>line of text 3
>!
>line of text 4
>line of text 5
>!
>
>and so on.
>
>
>
>Thanks in advance everyone.
>
>Gary Butler
>
>
>
>__
>Do You Yahoo!?
>Yahoo! Auctions - buy the things you want at great prices
>http://auctions.yahoo.com/




Re: html files in MAIL

2001-05-08 Thread Gary Stainburn

If you have Mail::Sender already installed then there is a specific 
example showing sending a HTML attachment.  If not, then I suggest that 
you install it - it does a hell of a lot of the work for you.

You can get it from 

http://search.cpan.org/search?mode=module&query=mail%3A%3Asender

Gary
On Saturday 05 May 2001  3:55 pm, [EMAIL PROTECTED] wrote:

> > Hi,
> Please how do i (the actual commands) send an file (html) as an
> attachment using sendmail in pelr with no MIME intalled? Thanks in
> advance

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 




Re: XML -- SOLVED

2001-05-08 Thread Stephen E. Hargrove

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Mon, 7 May 2001, David Monarres wrote:
>
>   I will qualifythis by saying that I am not an expert on MCPAN but
> it would appear that you probably do not have the module XML::Parser
> installed. Which doesn't make that much sence considering that I thought
> that MCPAN checks dependencies, and that XML::Parser would look like it
> should be included in the package that you rquested. I would try to install
> XML::Parser.

MCPAN, depending upon how it's configured, should follow dependencies.
However, in this instance, it didn't.  The XML package needed expat
(sourceforge.net/projects/expat).  Once I downloaded and installed that,
XML::Parser installed without a hitch.  The hard part was not getting the
dependencies installed . . . it was figuring out where the point of
failure was.

Thanks for assist.
- -- 
 ) ,_)
(-(__ -|- __
 ) | (/_\/(/_
(
 ___
| mailto : [EMAIL PROTECTED]  |
| linux  : http://exitwound.org |
| mozart : http://mozart.sourceforge.net|
| buck   : http://www.BuckOwensFan.com  |
 ___
| The human brain is a wonderful thing. It  |
| starts working the moment you are born, and   |
| never stops until you stand up to speak in|
| public. -- Sir George Jessel  |
 ___
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE69/vTr9c0KwefYXMRAtwVAJ4mx0OlWZlj9CmjgjEjpvu2BsNEiwCfb7Sx
T28cNr0bjuTTyXQ5uPiF9W8=
=5Naw
-END PGP SIGNATURE-




html files in MAIL

2001-05-08 Thread a

Hi,
Please how do i (the actual commands) send an file (html) as an attachment using 
sendmail in pelr with no MIME intalled?
Thanks in advance




regexp?? Reading in multiple lines to search??

2001-05-08 Thread Ga Bu

Hi everyone, 

I am fairly new to perl and having problems with
pulling in multiple lines from a file so I can search
those lines and if it has the expression I am looking
for then I want to return to that file and search
again for the same pattern of lines again and then
search again for the pattern in those line and save it
to a file. 
 
Between each group of text is a "!" exclamation point.


!
line of text 1
line of text 2 
line of text 3
!
line of text 4
line of text 5
!

and so on. 
 
   

Thanks in advance everyone. 

Gary Butler



__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



nested each(%hash) question

2001-05-08 Thread Jim Conte

I have 2 hashes, %one and %two.

the ($key, $value) of %one is a span of time.

I need to compare this span of time over every $key of %two.

Here's what I have:

while (($key1, $val1) = each (%one)) {

while (($key2, $val2) = each (%two)) {

if (($key2 >= $key1) && ($key2 < $val1)) {

push @match, $val2;
}
}
}

There are 10,000 , 5,000 records in %one and %two, and it keeps timing out.
( this is an http-request )

Is there a more efficient way?

Thanks.

-Jim Conte
http://www.jimconte.com



Re: help..too many emails!

2001-05-08 Thread Kevin Meltzer

These questions are answered in  the FAQ:
http://beginners.perl.org/beginners-faq

Cheers,
Kevin

On Tue, May 08, 2001 at 02:05:26PM +0100, [EMAIL PROTECTED] 
([EMAIL PROTECTED]) spew-ed forth:
> 
> heysince i been subscribed to this PERL mailing list i've been seeing the 
>message: INBOX - 130 new messages rather too often.
> 
> I've lost the original email telling me how to unsubscribe...can somebody please 
>tell me how to stop italso, is there perhaps a better way of accessing this..like 
>a newsgroup etc. or can you recomend any newsgroups?
> 
> Many Thanks..Gerry.
> 
> 
> 
> -
> 
> 20 email addresses from 15,000 domain names - free at http://www.another.com
> 
> Wear a designer label -- your own!  Your email or web address on a t-shirt for only 
>9.99:
> http://www.clickandbuild.com/cnb/shop/another


-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"I know the human being and fish can coexist peacefully."
-- G.W. Bush, Saginaw, MI 09/29/2000



help..too many emails!

2001-05-08 Thread gerry


heysince i been subscribed to this PERL mailing list i've been seeing the message: 
INBOX - 130 new messages rather too often.

I've lost the original email telling me how to unsubscribe...can somebody please 
tell me how to stop italso, is there perhaps a better way of accessing this..like 
a newsgroup etc. or can you recomend any newsgroups?

Many Thanks..Gerry.



-

20 email addresses from 15,000 domain names - free at http://www.another.com

Wear a designer label -- your own!  Your email or web address on a t-shirt for only 
9.99:
http://www.clickandbuild.com/cnb/shop/another



Re: send variable

2001-05-08 Thread Tony Cook

On Tue, 8 May 2001, nakosu-budi wrote:

> i have try from john lee mail. but i got problem
> the message syntax error at ./test.pl line 2, near "use
> CGI."
> Execution of ./test.pl aborted due to compilation errors.
> 
> --
> this nextPage.pl
> #!/usr/bin/perl -w
> use CGI.pm

This should be:

  use CGI;

-- 
Tony




Re: send variable

2001-05-08 Thread Johan Groth

nakosu-budi wrote:
> 
> i have try from john lee mail. but i got problem
> the message syntax error at ./test.pl line 2, near "use
> CGI."

> #!/usr/bin/perl -w
> use CGI.pm

This row should end with a ';'.
thus

use CGI.pm;

/Johan

--
Johan Groth (xghjn) ! Tel. mobil: 0703 - 24 25 27
Cell Network!   Kontoret:  054 - 14 25 27
[EMAIL PROTECTED] ! Bofors: 0586 - 820 14
[EMAIL PROTECTED]




send variable

2001-05-08 Thread nakosu-budi

i have try from john lee mail. but i got problem
the message syntax error at ./test.pl line 2, near "use
CGI."
Execution of ./test.pl aborted due to compilation errors.

this mainPage (include form and variable)

#!/usr/bin/perl -w

print "Content-type: text/html\n\n";

print "


New Page 1






  
  


--
this nextPage.pl
#!/usr/bin/perl -w
use CGI.pm

$rCGI = new CGI;
$id =  $rCGI->param('id');

print "Content-type: text/html\n\n";

print $id;
if ($id==1){
print "satu";
}else{
print "Bukan satu";
}


maybe there's mistake on my programs.
thank you




RE: Refresh Button

2001-05-08 Thread King, Jason

Helio S. Junior writes ..

>I would like to know if it's possible to do the
>following:
>
>When the user clicks on the Refresh Button of
>Internet Explorer and my WebPage refreshes, i
>also have to 'insert' some information on the
> inside the Page. Is it possible to do
>it?
>If so, how?
>Any Sample code?


everytime someone refreshes your page your script will be executed again -
so you can insert whatever you want .. here's an example that outputs the
time on the server in a table...

  #!perl -w
  use strict;

  use CGI;
  $CGI::POST_MAX = 0;

  my $q = new CGI;

  print $q->header,
$q->start_html('My test table page'),
$q->start_table( { -border => 0 } ),
$q->Tr( $q->td( scalar localtime )),
$q->end_table,
$q->end_html;

  __END__

-- 
  jason king

  In Nevada, it is still legal for a person to hang another for killing
  their dog on their own property. - http://dumblaws.com/