Re: Clearing a Form

2003-07-22 Thread drieux
On Monday, Jul 21, 2003, at 15:05 US/Pacific, Peter Fleck wrote:

I have a cgi that creates a form and then receives the output of the 
form and sends it to a mysql database. It also displays the form 
information as a preview of what is getting sent to the database.

You can return to the original form with data if you need to correct 
something via an 'Edit' button. This button also makes sure that 
nothing gets stored in the database (by deleting the data that was 
just sent and I know there must be a better way to do that part but 
it's not my current question).
[..]
I'm wondering if javascript is the answer?
[..]

Let me try to underscore wiggins basic idea.

Javascript can help a part of this, in that
it can do basic checking on the browser side.
If fields foo|bar|baz have to be filled in,
then a quick Java Script
alert(Must have value in field foo);
return false;
is a quick way to prevent some of those problems.
The bad news is that with some of the 'pop-up blocker'
software - those alerts will be dumped and the user
will not see them.
SO you need to always write your CGI code as IF
the javascript TOTALLY FAILED. Hence that you
check that the values returned from the form
are kosher and sane.
What I do, is then present a 'verification page'
where they have the option to 'commit' or 'go edit'.
On the 'commit' we actually execute on the DB transaction.

This is where you also need to work out your basic DB transaction model.

I have mine happily say 'yes' to any 'add' for something
that is already there - since, well, yes, it is already there.
I also generically say 'ok' to any 'delete' of things that
do not exist, since, well, they are no longer there.
This way, if the person does use the 'back button' on you,
the worst case is that they will niggle the front end of
your DB transaction system - by trying to delete a deleted record,
or add an already existing record.
What you can then deal with is a 'confirmation' process
if they send you what would be a 'modify' - in which
the record exists, but there are differences between
what is in the current record and the new information.
This too can be caught at the 'validation' stage, with
a 'warning' message - that says something like 'foo already
exists on bar - go to bar?'
So rather than doing an 'update' and recycle, make sure
that they REALLY want to go there before you even talk
to the database
Other strategies are to do the no-cache pragma, and hope
that the browser honors that. Other tricks are to run
SID's - and to have a table of active SID's - session id's,
and to delete a sid from the table if
a. the commit occurs
b. the transaction is older than time allowed
This way if you get a SID for a transaction on a back button
event, that is for something that has already been committed,
then you warn about that if the SID is 'aged out' then
you warn about that... Or you take the alternative strategy
that since you can not find the SID in the active sid table,
then you whine that the SID is not there.
You get the sid into the form as a 'hidden' - and you can
then think about dealing with a journaling database model
that will allow you full rollback, etc, etc, etc...
But basically what I would argue is that you get a better back
end model for dealing with the real back end issues.


ciao
drieux
---

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


urgent help needed!

2003-07-22 Thread S. Naqashzade
Dear Friends,
I need to trnaslate thid code to PHP.
Can any one help me?
Tnx

use constant MD5_CRYPT_MAGIC_STRING = '$1$';
use constant I_TO_A64 =
'./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';

sub _to_yahoo_base64
{
 pos($_[0]) = 0;

 my $res = join '', map( pack('u',$_)=~ /^.(\S*)/, ($_[0]=~/(.{1,45})/gs));
 $res =~ tr{` -_}{AA-Za-z0-9\._};

 my $padding = (3 - length($_[0]) % 3) % 3;
 $res =~ s/.{$padding}$/'-' x $padding/e if $padding;
 return $res;
}


sub _to64
{
 my ($v, $n) = @_;
 my $ret = '';
 while (--$n = 0) {
  $ret .= substr(I_TO_A64, $v  0x3f, 1);
  $v = 6;
 }
 $ret;
}

 my $Magic = MD5_CRYPT_MAGIC_STRING;
 $salt =~ s/^\Q$Magic//;
 $salt =~ s/^(.*)\$.*$/$1/;
 $salt = substr $salt, 0, 8;




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



RE: urgent help needed! (PHP translation)

2003-07-22 Thread wiggins


On Tue, 22 Jul 2003 17:10:36 +0430, S. Naqashzade [EMAIL PROTECTED] wrote:

 Dear Friends,
 I need to trnaslate thid code to PHP.
 Can any one help me?

This is a Perl list. You might try a PHP list for PHP help, even if it is coming from 
Perl code. Most people here would prefer to help you with finding a way to keep this 
being done in Perl, but that is a philosophical discussion.

http://danconia.org

 
 use constant MD5_CRYPT_MAGIC_STRING = '$1$';
 use constant I_TO_A64 =
 './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
 
 sub _to_yahoo_base64
 {
  pos($_[0]) = 0;
 
  my $res = join '', map( pack('u',$_)=~ /^.(\S*)/, ($_[0]=~/(.{1,45})/gs));
  $res =~ tr{` -_}{AA-Za-z0-9\._};
 
  my $padding = (3 - length($_[0]) % 3) % 3;
  $res =~ s/.{$padding}$/'-' x $padding/e if $padding;
  return $res;
 }
 
 
 sub _to64
 {
  my ($v, $n) = @_;
  my $ret = '';
  while (--$n = 0) {
   $ret .= substr(I_TO_A64, $v  0x3f, 1);
   $v = 6;
  }
  $ret;
 }
 
  my $Magic = MD5_CRYPT_MAGIC_STRING;
  $salt =~ s/^\Q$Magic//;
  $salt =~ s/^(.*)\$.*$/$1/;
  $salt = substr $salt, 0, 8;
 
 

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



RE: Clearing a Form

2003-07-22 Thread Peter Fleck
Thanks to all for the help on 'clearing the form' and for forcing me 
to face the design limitations.

I would prefer to preview the data before storing in the DB and had 
hoped to get this in place but ran into a problem on the way which 
led to my workaround which and the STORE-PREVIEW-DELETE ENTRY-EDIT 
sequence. I don't like it either.

The problem is that I am storing a series of entries to a table in a 
hash with values that reference arrays.  I don't think I can store 
something like that in a hidden form field so I have to 
rethink/redesign that whole data storage process. Would it be safe to 
say that only scalar values can really be hidden away in fields on a 
form? (I also have some values in an array that would have to be 
taken care of.)

I'm starting to conceive as to how it can be done but I'm also way 
behind schedule on this project. So the 'good' design will have to be 
implemented in the next rev of my ap.

Just to provide a bit more entertainment for you experienced perlers, 
my intermim/ugly hack solution to the back button problem is to add a 
field in the DB that must be true for the data to display on a Web 
page. The default value is 'false'. After previewing the data, the 
user clicks an button which simply sets the display column value to 
true. So if user uses back button, an extra record will exist in the 
database but that record will not show up in public display.

Background: This is a data entry system for one person/editor that 
will then result in dynamic display of information for the public on 
our Web site. Right now the person is maintaining the page in HTML 
Netscape Composer so it's hard for anything scripted not to be an 
improvement. You can check the current site at:

http://www.cancer.umn.edu/page/aboutus/grantopp.html

At 5:27 PM -0500 7/21/03, [EMAIL PROTECTED] wrote:

On Mon, 21 Jul 2003 17:05:57 -0500, Peter Fleck [EMAIL PROTECTED] wrote:
 I have a cgi that creates a form and then receives the output of the
 form and sends it to a mysql database. It also displays the form
 information as a preview of what is getting sent to the database.
 You can return to the original form with data if you need to correct
 something via an 'Edit' button. This button also makes sure that
 nothing gets stored in the database (by deleting the data that was
 just sent and I know there must be a better way to do that part but
 it's not my current question).
 If the visitor uses the browser 'Back' button to return to the form,
 their data will be there but the record won't get deleted from the
 database.
 How do I erase all the data from the form if the visitor chooses to
 use the Back button? I tried the CGI.pm method mentioned in
 O'Reilly's CGI Programming:
 print $dataIn-header( -type = text/html, -expires = now);

 but that doesn't do it.

 I'm wondering if javascript is the answer?

I think the difficulty you are experiencing in your implementation 
is a direct result and indicator of a design that needs to be 
re-examined.  You are running into the standard problem with a 
protocol that is stateless (aka HTTP). Rather than switching to use 
Javascript to handle the abnormal use of the browser's back 
button, you would be better off assuming that 50% of the time that 
is how a person is going to navigate and do something like store the 
values as hidden fields in a form on the preview page, then when 
they use the back button make some edits and resubmit, your script 
need only re-display the preview page, which makes the 
implementation easier. Then the data is *only* stored to the DB once 
the final version is submitted from the preview page. To implement 
your edit feature you need only return them to the original form 
and pre-fill the fields based on the values submitted in your 
preview form (which is also your Edit form).

Sorry if this is confusing, I would re-examine why and when you 
store data to the DB in your design rather than the implementation 
details.
--
Peter Fleck
Webmaster | University of Minnesota Cancer Center
Dinnaken Office Bldg.
925 Delaware St. SE
Minneapolis, MN  55414
612-625-8668 | [EMAIL PROTECTED] | www.cancer.umn.edu
Campus Mail: MMC 806
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: urgent help needed!

2003-07-22 Thread Randal L. Schwartz
 S == S Naqashzade [EMAIL PROTECTED] writes:

S Dear Friends,
S I need to trnaslate thid code to PHP.
S Can any one help me?

This is the *perl* beginners list.  Not the PHP help desk.
You must've pushed some buttons by mistake.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL: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: Clearing a Form

2003-07-22 Thread wiggins


On Tue, 22 Jul 2003 09:33:28 -0500, Peter Fleck [EMAIL PROTECTED] wrote:

 Thanks to all for the help on 'clearing the form' and for forcing me 
 to face the design limitations.
 

As long as you realize them then that is most of the battle, all of us have to face 
hacking around them because outside factors (like budget and schedule) have caused the 
need.

 I would prefer to preview the data before storing in the DB and had 
 hoped to get this in place but ran into a problem on the way which 
 led to my workaround which and the STORE-PREVIEW-DELETE ENTRY-EDIT 
 sequence. I don't like it either.
 
 The problem is that I am storing a series of entries to a table in a 
 hash with values that reference arrays.  I don't think I can store 
 something like that in a hidden form field so I have to 
 rethink/redesign that whole data storage process. Would it be safe to 
 say that only scalar values can really be hidden away in fields on a 
 form? (I also have some values in an array that would have to be 
 taken care of.)
 

Well storing complex data structures is possible, you just have to serialize them 
first, then on the other end reload them. Granted this can get ugly depending on how 
complex the structure is, especially since you have to store it into HTML which means 
you need to account for special characters, etc..  There are numerous CPAN modules 
that provide this type of functionality if doing conversions on your own isn't 
possible. Because a hidden field can really contain any amount of data (though I 
wouldn't use a GET) you should be able to serialize the data into a single string and 
store it in a hidden field.

 I'm starting to conceive as to how it can be done but I'm also way 
 behind schedule on this project. So the 'good' design will have to be 
 implemented in the next rev of my ap.
 

Understood.

 Just to provide a bit more entertainment for you experienced perlers, 
 my intermim/ugly hack solution to the back button problem is to add a 
 field in the DB that must be true for the data to display on a Web 
 page. The default value is 'false'. After previewing the data, the 
 user clicks an button which simply sets the display column value to 
 true. So if user uses back button, an extra record will exist in the 
 database but that record will not show up in public display.
 

Actually I like this, the only thing I would add would be a revision identifier. Make 
it a two step process, aka a new revision must be added then it must be committed or 
the like, not unlike a version control system, I am working on implementing this on 
all components of my new site. Then you end up selecting the most recent (greatest) 
revision that is active for display, but can always roll back to a previous revision, 
simply by deactivating the most recent addition.

Of course there are other issues with this technique, aka storage space, do you store 
the complete entry or just a diff, locking, etc.

 Background: This is a data entry system for one person/editor that 
 will then result in dynamic display of information for the public on 
 our Web site. Right now the person is maintaining the page in HTML 
 Netscape Composer so it's hard for anything scripted not to be an 
 improvement. You can check the current site at:
 
 http://www.cancer.umn.edu/page/aboutus/grantopp.html


Sounds like it is definitely an improvement. I would say the issues you have 
encountered are fairly regular and can't really be taught around, in most cases the 
only way to avoid them is to have already experienced them (and trust me I have).

http://danconia.org
 
-- snip old messages --

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



RE: urgent help needed! (PHP translation)

2003-07-22 Thread Andrew Brosnan
On 7/22/03 at 9:16 AM, [EMAIL PROTECTED] wrote:

 
 
 On Tue, 22 Jul 2003 17:10:36 +0430, S. Naqashzade
[EMAIL PROTECTED] 
 wrote:
 
  Dear Friends,
  I need to trnaslate thid code to PHP.
  Can any one help me?
 
 This is a Perl list. You might try a PHP list for PHP help, even if
 it is coming from Perl code. Most people here would prefer to help
 you with finding a way to keep this being done in Perl, but that is a
 philosophical discussion.
 
 http://danconia.org

I was recently hired to write some PHP. The client had a mix of Perl and
PHP scripts. I ended up writing some PHP scripts that simply called Perl
scripts. Is that cheating? ;-)

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



RE: PHP vs Perl

2003-07-22 Thread wiggins


On Wed, 23 Jul 2003 00:39:30 +0300, Octavian Rasnita [EMAIL PROTECTED] wrote:

 Hi all,
 
 Talking about PHP, someone asked me to tell him why is PHP better and why it
 is used more than Perl.
 I don't know what to tell him because I don't know PHP, but I've seen that
 it is used more and more and I guess that there are more PHP scripts than
 Perl scripts now, so I think he could be right.
 
 Of course, he was talking about CGI programming, because I know that Perl
 can do much more than CGI programming like PHP.
 

Can you say hello to Pandora for me...

The only sure answer to this is that Vim is better than Emacs.

Let the flaming begin!

http://danconia.org

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



Re: PHP vs Perl

2003-07-22 Thread drieux
[..]
Talking about PHP, someone asked me to tell him why is PHP better
and why it is used more than Perl.
[..]

This might be a good time to point people towards the

	MVC - Model, View, Controller

approach for doing software development.
{ just google search on Model, View, Controller for fun }
Web-browsers are a way of presenting a 'view' of
the 'model' - and the web-browser dialogs with
the web-server to 'get stuff done' - this may
mean using the 'common gateway interface' (CGI)
to pass stuff back to a 'controller'
That controller may be written in perl, it may
actually invoke code that is NOT written in perl.
It might be written in PHP, that understands how
to invoke things written in perl and other languages.
As we have discussed in terms of 'using java scripting'
there is actually a level of 'MVC' that is strictly at
the browser side - and that the server side needs to be
able to deal with the 'failures' that occurred because
the 'java scripting' was ignored, and 'stuff' came
back to the server side - and needs to be managed
by either the CGI code itself - or by the underlying
stuff that it rests upon
So a part of the problem is

how tightly wrapped is your 'web-browser side'
MVC to the 'server-side' MVC(s); and how tightly
coupled is your 'server-side' MVC's to each other...
At which point we start noticing that there are
'design sillies' in which we forget that the
'server side' is laying on top of other MVC's,
such as database queries, CLI invokations, proxy-ing
through other web-services
IF one started with a clean, clear and consistent
interface for each MVC on MVC, on MVC, then of
course those will all align correctly and all
will be fine, at least in theory
Allow me to offer an actual case study. I started with
a general 'abstraction layer' that said
I need a database thingie, somewhere,
and I will make my queries to it using a
CGI based solution.
This way, all of the 'cgi code' that is directly
invoked by the user - calls code that itself will
turn around and query some other web-server as if
we were a 'web-browser' doing a
	GET http://some_db_host:db_port/some/path/db_cgi.cgi?verb=doFooval=bob

get the answer back, stuff it into some html
wrappings, and push it out STDOUT to
the user's web-browser.
This allowed me to work out the basics of
what sort of DB I really wanted - so when I
decided what to use at the other end of that query,
I could swap it IN, without changing line one of
the 'cgi code' that the user will invoked.
{ as a general rule, I like to stuff the 'do the work'
side of the problem in a 'perl module' that is external
to the foo.cgi - so that modifications can be done external
to the 'foo.cgi' itself... }
We could of course go the other way with this,
and decide that for 'presentation purposes'
calling a PHP was 'much cooler' - then all I
need to do is teach the PHP to go fetch the
stuff from the DB by using a step in the process
that either knew how to invoke a CGI connection
with another web-server, or invoke some piece
of perl bridge code built with the lwp-useragent,
or roll up something that understood how to open
a socket, woof stuff down it, get a message back,
deconstruct it
Ok, I must complain here there is that other
part of the HORROR STORY - where your beautiful
web application gets 'attacked' because
	well it's just a 'check box'.

So now one has to 'just' add

trtdpbSysnames (-S):/b/p/tdtd\n .
'input type=text name=S value='.
' maxlength=256 onclick=return lineEater()/td/tr' . \n;
to the presentation layer, except of course that also means
updating the java-script to adjust for the shift in fields
of type foo, and then the back side of that cgi code has
to actually pick out the 'S' value, if it exists, then
of course one has to re-write the Freaking Controller,
to figure out how to pass that smack on through to
the CLI interface, so that it will be used, plus the
extension to that Module, to handle all of the new
classes of ERRORS that can occur, because one did
or did not pass that additional set(s) of argument(s),
with or without the newly restructured pre-ceeding Smack,
because the vendor's CLI MVC shifted more than the
	it is just a check box thingie widget...

Or should I just say, there are other more sinister
plots and conspiracies to really feast upon
than whether you want PHP or Perl to be the
primary source of the 'html like stuff' that
goes back to the user's browser...
ciao
drieux
---

ps: did I mention the part about having to shift
all of the 'online html based documentation' that
goes with the application that will also have to
be clarified where all of the previous illustrations
have been obsoleted by the addition of 'just a checkboxThingie'
not to mention the additional work of providing the primary
documentation about how the user should use it, plus
all of the new error/exceptions that can be thrown,
caught, missed, 

Re: Is there a better way?

2003-07-22 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Kevin Pfeiffer wrote:
[...]
   unless ($input =~ /^[^\D]+/ or $input eq '') {

While messing around with the valid '' input problem I see I obfuscated the 
regex. I think this will do just fine:

unless ($input =~ /^\d+/ or $input eq '') {


-- 
Kevin Pfeiffer
International University Bremen

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



News Group - Mailing List

2003-07-22 Thread Paul Kraus
I have switched from the mailing list to viewitg the list via NNTP on perls 
servers.
I notice my messages sometimes take 6 or more hours to appear. As well as 
everyone elses. Its as if I am a day behind all the time.

Is this just something I have to deal with if I want to use the newsgroup 
rather then pop/smtp.

Paul Kraus
=-=-=-=-=-=-=-=-=-=-=-
Network Administrator
PEL Supply Company
=-=-=-=-=-=-=-=-=-=-=-
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


passing a var to a sub

2003-07-22 Thread jdavis
hello,
  I would like to pass subs vars to work on. right now I,m
using globals to pass messages to the subs.Is this the right 
way to do this?

thanks,
-- 
jdavis [EMAIL PROTECTED]


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



Re: passing a var to a sub

2003-07-22 Thread Sudarshan Raghavan
jdavis wrote:

hello,
 I would like to pass subs vars to work on. right now I,m
using globals to pass messages to the subs.Is this the right 
way to do this?

Avoid global variables if possible, some of the issues are code 
maintenance, readability etc. Read through this doc to learn about perl 
subroutines
perldoc perlsub

thanks,
 



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


RE: Is $1 ever undefined or set to null?

2003-07-22 Thread Bob Showalter
Steve Grazzini wrote:
 On Mon, Jul 21, 2003 at 04:40:19PM -0400, Jeff 'japhy' Pinyan wrote:
  On Jul 21, Jeff 'japhy' Pinyan said:
  
   This is the issue.  Why are the $DIGIT variables bound to the
   block they're in IN TOTALITY, rather than for the life of the
   execution of the block?
 ...
 You're explaining this much more clearly than I had done, but let me
 jump in again -- 
 
 The magic regex variables *themselves* live forever and don't obey
 any scoping rules.  They don't have to worry about scope, since as
 you said, they don't contain any data.  Their values are fetched
 dynamically by looking at the last match (which is what I've been
 calling PL_curpm, which is the dynamically scoped PMOP pointer).
 
 PL_curpm behaves consistently, although the way it's dynamically
 scoped is slightly unusual, as you said.
 
 But the PMOP doesn't contain any data *either*.  It has a pointer
 to REGEXP structure, which contains, among other things, the compiled
 pattern and what I'll call the match data.  The match data might
 include a copy of the target string and offsets for each pair of
 capturing parens, and it can be used to calculate the value of $1
 or @- (or a host of other variables) dynamically.
 
 The problem with this set-up is that PL_curpm is dynamically
 scoped, but the REGEXP, which contains the data we're interested in,
 isn't.

Aha! (slaps forehead, finally understanding)
 
 
 Tying the match data to the compiled pattern (and thence to the
 PMOP, for pity's sake) is, arguably, bad design...
 
 You can also see it misbehaving here:
 
 my $rx = qr/(...)/;   # REGEXP 1
 
   foo =~ /$rx/; # PMOP 1 / REGEXP 1
 { bar =~ /$rx/; }   # PMOP 2 / REGEXP 1
 
 print $1;   # bar
 
 In this one there are two distinct PMOPs (the m// operations) but
 only one REGEXP, which is what we've stored in $rx.
 
 When we print $1 the chain of references looks something like
 
$1 - PL_curpm - PMOP #1 - $rx - match data
 
 [ Really the PMOP points directly to the REGEXP inside $rx. ]
 
 And the match data inside $rx comes from the time it matched bar,
 since there's no mechanism for saving and restoring that kind of
 thing. 
 
 Anyway, apologies for the blood and perlguts --

Steve and Jeff, thanks for the explanations. Obviously, I underestimated the
complexity of the underlying issues :~)

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



Re: Perl Security

2003-07-22 Thread Douglas Hunter
Jonathan wrote:
Hi, 

I am insterested in creating a reusable module that allows my scripts to have pretty good security. I just don't know how i would go about encrypting passwords. Please help

perldoc -q password has some advice for you (which includes looking at 
perldoc -f crypt).  You should also look at perldoc perlsec.

Thanks

You're welcome.

-- Douglas

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


Re: splitting an array into ???

2003-07-22 Thread Rob Dixon
Tim McGeary wrote:
 Hi...  I have an array of pipe delimited data from a file.  I need
 to go item by item of the array, splitting up the fields into
 separate variables so that I can insert other pre-determined fields
 into an SQL statement to load into a MySQL db.  I feel pretty
 confident about the SQL part, but I'm not sure the best way to
 split the fields of the array.  I have 4 pipe-delimited fields in
 each line of the array.

 is it as simple as doing:

 foreach $item (@array) {
 my ($key, $title, $url, $code) = split /\|/;
 do other stuff;
 }


Looks good to me, but always start with

  use strict;
  use warnings;

and remember the default operand for split is $_.

Also, you may want to think about whether yo may have
leading or trailing pipe characters which will result in
additional empty start and end fields. You also may
want to strip whitespace from each field before you use
it.

Cheers,

Rob




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



TK::HList

2003-07-22 Thread Marcos . Rebelo
I need to see what is writen in the display for a givem $path? 
How can I do it?

Thanks
MArcos

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



RE: Perl Security

2003-07-22 Thread Dan Muey
 Jonathan wrote:
  Hi,
  
  I am insterested in creating a reusable module that allows my 
  scripts to have pretty good security. I just don't know how 
 i would go 
  about encrypting passwords. Please help
  

I like to:
use Crypt::OpenPGP;

It's very handy at helping keep the goodies secret from prying eyes.
Check it out on search.cpan.org

HTH

DMuey

 
 perldoc -q password has some advice for you (which includes 
 looking at 
 perldoc -f crypt).  You should also look at perldoc perlsec.


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



Re: writing to file

2003-07-22 Thread wiggins

On Mon, 21 Jul 2003 21:55:03 -0600 (MDT), [EMAIL PROTECTED] wrote:

 open the file with 
 This will cause an overwrite..
 

Actually that is an append. Maybe there is a definition issue, aka I would think of 
an overwrite to be a  where the file already existed.

http://danconia.org

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



Re: Is there a better way?

2003-07-22 Thread Jeff 'japhy' Pinyan
On Jul 22, Kevin Pfeiffer said:

In article [EMAIL PROTECTED],
[EMAIL PROTECTED] wrote:


 I know I'm missing something here, but this code just looks to me like I
 shloud be doing it a better way..

 Any ideas?

my $intel_num_hosts = '';
my $num_hosts = get_input(Number of hosts? );
$intel_num_hosts = join ( , -N, $num_hosts) if $num_hosts;

That still seems long-winded to me.  I'd write:

  my $n_hosts = get_input(Number of hosts? );
  my $opt_hosts = $n_hosts ? -N $n_hosts : ;

  my $n_procs = get_input(Number of processes? );
  my $opt_procs = $n_procs ? -n $n_procs : ;

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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



RE: php mod perl 5.8 apache2 question

2003-07-22 Thread Dan Muey
 Hi all,

Howdy

 
 I have downloaded and installed perl with apache and php
 
 Here are the readme file folders for each part of the packaged file 
 Perl-5.8-win32-bin-0.1.exe
 
 openssl-0.9.6h
 php-4.23
 mod_perl-2.0
 httpd-2.0.43
 AP804_source
 
 I have apache running ok and perl,  but I can't get the hello 
 world file for 
 php to display Hello World
 
 htmlbody
 ?php
 $myvar = Hello World;
 echo $myvar;
 ?
 /body/html
 

Basically you'd probably have to ask a php list why it's not working or just not use 
php.
Php blows and when we upgraded to apache 2 php had a big prob;em running so we had to 
go back to the previouse apache version since we had 1 customer that used php for 
phpbb.
That's been a while ago though so I'm sure that bug has been squashed.

But I've my life asa sysadmin/ web developer to be so much easier to use Perl 
exclusively and avoid php all together.

Perl does everything it does plus about a zillion other things.

HTH

DMuey

 I've uncommented these lines in my Apache2 httpd.conf file
 # Uncomment the following for php
 LoadFile C:/Apache2/bin/php4ts.dll
 LoadModule php4_module modules/php4apache2.dll
 AddType application/x-httpd-php .php
 
 Also the Paths to Perl and Apache are in my autoexec.bat 
 file. The .dll files for php are in the apache2/bin folder.
 
 What else should I check for?  
 
 
 
 
 
 
 
 

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



Re: subroutines

2003-07-22 Thread Jeff 'japhy' Pinyan
On Jul 21, Stuart White said:

I tried reading the perldoc, but it came up all screwy
on my screen.  Lines ran over the end.  I'm having

Then you can read them online at http://www.perldoc.com/.

trouble passing variables into a subroutine.Also,
once I get it passed, I want to pass it from there
back to the main function.  Can someone help me figure
this out?  This is the code that I have:

sub FoulParser($$$);

You don't NEED function prototypes.  In fact, they're probably confusing
more than you need to be confused right now.  They're for very SPECIFIC
purposes, and I doubt you need them.

use warnings;
use strict;

open(STATS, stats.txt) or die statfile\n;

You might want to include $! in your error message.

my $foul;
my $foultype;
my $player;
my @stuff;

You might want to define these variables in the block at which they're
needed.  That is, I don't think you use them outside this while() loop, so
why not wait until you're inside that if block?

 while (STATS)
 {
   if ($_ =~ /(\w+) (Foul:) (\w+)/)
   {
$foul = $_;
$player = $1;
$foultype = $3;
print line to be passed: $foul;
   FoulParser($foul, $player, $foultype);
  }
   }

  while (STATS) {
if (/(\w+) Foul: (\w+)/) {
  my $foul = $_;  # why not just use $_ instead of $foul?
  my $player = $1;
  my $foultype = $2;  # notice I got rid of the ()'s around Foul:

  FoulParser($foul, $player, $foultype);
}
  }

sub FoulParser($$$)
{
 my ($foul, $typefoul, $player, @stuff);

Ok, the problem is that you don't ever give these variables values!  You
need to get them from @_, which is the array that function arguments are
placed into (automatically, by Perl).

  sub FoulParser {
my ($line, $who, $type) = @_;

Now, it looks like you wanted to do $fouls{$foultype}{$player}++.  That's
fine.  Just declare %fouls beforehand, outside the subroutine (if you want
it to exist outside the subroutine, which I think you do).

$fouls{$type}{$who}++;
  }

Please read the documentation, and RE-read the chapters of the book you're
using.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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



Re: passing a var to a sub

2003-07-22 Thread Jeff 'japhy' Pinyan
On Jul 22, jdavis said:

  I would like to pass subs vars to work on. right now I,m
using globals to pass messages to the subs.Is this the right
way to do this?

Globals are bad.

The main mechanism is:

  sub plus_minus {
my ($this, $that) = @_;  # arguments arrive in the @_ array
return ($this + $that, $this - $that);
  }

  my $x = 10;  # my() variables are NOT globals
  my $y = 14;  # globals are bad, these are lexicals
  my ($plus, $minus) = plus_minus($x, $y);

Notice that by passing values to a function, the FUNCTION can have its own
names for the things to work on?  So you don't need to worry about what
name the function's using, since they're my()d (so they're lexically
scoped), and you can name your variables whatever you want.

Contrast that to:

  sub ugly {
return ($x + $y, $x - $y);
  }

which requires you to call your variables $x and $y on the outside.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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



RE: Script's Name

2003-07-22 Thread Dan Muey
 
 --- Nigel Peck - MIS Web Design [EMAIL PROTECTED] wrote:
  Can someone please remind a forgetful idiot how to get the 
 name of the 
  script being run (the file itself)?

I alwayd use CGI:

use CGI qw(:standard);
my $self = url(relative = 1);

HTH 
Dan

  
  Cheers,
  Nigel
  
  MIS Web Design
  http://www.miswebdesign.com/
  
 print Full File name: $0\n;
 
 Forgetfulness does not automagically confer idiotism.
 
 Kristofer
 
 
 =
 -BEGIN GEEK CODE BLOCK-
 Version: 3.12
 GIT d s+:++ a C++ UL++ US+ P+++ L++ 
 W+++ w PS PE t++ b+ G e r+++ z
 --END GEEK CODE BLOCK--
 
 __
 Do you Yahoo!?
 SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
 
 -- 
 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: Is there a better way?

2003-07-22 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
 I know I'm missing something here, but this code just looks to me
 like I shloud be doing it a better way..

 Any ideas?


 # -N
 print Number of Hosts?  ;
 # get user input and strip off CR-LF
 chomp($n=);
 $intel_num_hosts = join ( , -N,$n);
 # if user did not enter a value, dont put the -N in
 if ($n eq ){ $intel_num_hosts = }

 # -n
 print Number of processes?  ;
 chomp($n=);
 $intel_num_procs = join ( , -n,$n);
 if ($n eq ){ $intel_num_procs = }


  use strict;
  use warnings;

  my $n;
  my $intel_num_hosts = '';
  my $intel_num_procs = '';

  {
print Number of Hosts?  ;
chomp ($n = );
redo if $n =~ /\D/;
  }
  $intel_num_hosts = -N $n if $n;

  {
print Number of processes?  ;
chomp ($n = );
redo if $n =~ /\D/;
  }
  $intel_num_procs = -n $n if $n;



HTH,

Rob





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



Re: writing to file

2003-07-22 Thread denis

I stand corrected.. It should be  not ..

Should stop reading the list late at night..

Thanks

On Tue, 22 Jul 2003 [EMAIL PROTECTED] wrote:

 
 On Mon, 21 Jul 2003 21:55:03 -0600 (MDT), [EMAIL PROTECTED] wrote:
 
  open the file with 
  This will cause an overwrite..
  
 
 Actually that is an append. Maybe there is a definition issue, aka I would think 
 of an overwrite to be a  where the file already existed.
 
 http://danconia.org
 


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



Comparing two files

2003-07-22 Thread Cynthia Xun Liu
Hi,

Could anybody help me with the code of comparing files? I have two files
:
File A: name, info1, info2...
FileB: name, info1, info2...
I want to print out all the lines in File A with the same names as in
File B.
Thanks.


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



Re: loading a module

2003-07-22 Thread Sri
Have you tried PERL5LIB enviroment variable that should take of handling .pm
not found.


Casey West [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 It was Monday, July 21, 2003 when Hemant Desai took the soap box, saying:
 : cant' locate loadable object from module Time::HiRes in @INC (@INC
 : contains...a list of paths which are present in @INC)
 :
 : this is the error I am getting while trying to use HiRes.pm (probably a
 : general error.
 :
 : have made copies of HiRes.pm in
 : /usr/perl5/
 : /usr/perl5/5.00503/
 : /usr/perl5/5.00503/Time
 :
 : please do let me know how a .pm can be loaded

 Hi there, you need to install the module.

 The short answer for installing a module is this (run from the command
 line):

   perl -MCPAN -e'install Time::HiRes'

 For more information, consult the documentation for CPAN.

   perldoc CPAN



   Casey West

 --
 Usenet is like a herd of performing elephants with diarrhea --
 massive, difficult to redirect, awe-inspiring, entertaining, and a
 source of mind-boggling amounts of excrement when you least expect
 it. -- Gene Spafford




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



ANNOUNCE: Ncurses programming examples

2003-07-22 Thread Anuradha Ratnaweera

Some examples from ncurses programming howto have been ported from C to
Perl.  Downloads are at http://www.linux.lk/anuradha/.

Anuradha

-- 

Debian GNU/Linux (kernel 2.4.21-preempt)


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



Re: ANNOUNCE: Ncurses programming examples

2003-07-22 Thread Gary Stainburn
On Tuesday 22 Jul 2003 3:35 pm, Anuradha Ratnaweera wrote:
 Some examples from ncurses programming howto have been ported from C to
 Perl.  Downloads are at http://www.linux.lk/anuradha/.

I get 404 not found for this URL.  Could you correct and repost as this is 
something I'd be interrested in.


   Anuradha

-- 
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 


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



uploading from network

2003-07-22 Thread Saurabh Singhvi
hi all
 i am in a local net and we use a netmon proxy , so if
i hav to upload someting to a site outside how do i
do?/
Thanks in advance
Saurabh

=

SAURABH SINGHVI
H-8,ROOM NO.291
IIT BOMBAY
POWAI
MUMBAI


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



Reg Exp Help...

2003-07-22 Thread James Kelty
I know that this is a common request, but I have a question about
parsing an email box. I have a UW IMAP box, and I am trying to extract
all the emails where the line starts with From: blah blah. Now, getting
those lines isn't the issue, but since each email is a little different,
I am having a problem. Given this list, how would I extract JUST the
email address?

From: James Kelty [EMAIL PROTECTED]
From: [EMAIL PROTECTED]
From: [EMAIL PROTECTED]

There are three types that I have seen, and I am having the worst time
trying to come up with a regex to extract just the address. Can someone
help with an idea or two? Thanks!

-James





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



Re: Comparing two files

2003-07-22 Thread LI NGOK LAM
First, I would ask, how many lines in each file ? under 100 ? above 1 ?
because that effect to choose the tatic for making things done.

Well, I assume there is reasonable to carry 1 names and each name not
longer then 20 character ( consumed about 200KB, still acceptable )
and I will do so :

use strict;
my (@names, @matches) ;

# Reading and record names into @names
open my $A, FileA;
while (my $line = $A)
{ my ($name, $waste ) = split /,/, $line, 2;
push (@names, $name)
}close $A;

# Find matching name in B and record them into @matches
open my $B, FileB;
while (my $line = $B)
{ my ($name, $waste )  = split /,/, $line, 2;
push (@matches, $name ) if ( grep /$name/, @names )
} close $B;

# Print results
print $_br\n for (@matches);
# Omit br if the printout is not returned as HTML format;

Remarks :
1. Code not been tested.
2. I suppose your line format is exactly same as you provided.

HTH






- Original Message - 
From: Cynthia Xun Liu [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 22, 2003 11:15 PM
Subject: Comparing two files


 Hi,

 Could anybody help me with the code of comparing files? I have two files
 :
 File A: name, info1, info2...
 FileB: name, info1, info2...
 I want to print out all the lines in File A with the same names as in
 File B.
 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: :HList

2003-07-22 Thread EUROSPACE SZARINDAR

Hi Marcos,

What you can do is to go to the perl/bin directory where you have installed
Tk and you will find a executable widget which show you the possibilities
of Tk, the code, the result.

It is a very good demo clear and usable to extract code.

Michel

-Message d'origine-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Date: mardi 22 juillet 2003 15:44
À: [EMAIL PROTECTED]
Objet: TK::HList


I need to see what is writen in the display for a givem $path? 
How can I do it?

Thanks
MArcos

-- 
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: Reg Exp Help...

2003-07-22 Thread wiggins


On 22 Jul 2003 09:15:29 -0700, James Kelty [EMAIL PROTECTED] wrote:

 I know that this is a common request, but I have a question about
 parsing an email box. I have a UW IMAP box, and I am trying to extract
 all the emails where the line starts with From: blah blah. Now, getting
 those lines isn't the issue, but since each email is a little different,
 I am having a problem. Given this list, how would I extract JUST the
 email address?
 
 From: James Kelty [EMAIL PROTECTED]
 From: [EMAIL PROTECTED]
 From: [EMAIL PROTECTED]
 
 There are three types that I have seen, and I am having the worst time
 trying to come up with a regex to extract just the address. Can someone
 help with an idea or two? Thanks!
 

This is a relatively complex task since e-mail addresses can come in so many different 
forms and contain so many different types of values. Your best bet may be to either 
use a module for parsing the whole message which is always advised, or look at the 
source for one of the better message header parsing modules to determine  how they are 
doing it.  Sorry this is such a non-specific answer, but rather than suggesting a way 
to poorly re-invent the wheel, I prefer suggesting that this should be avoided

http://danconia.org

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



To module or not to module that is the question

2003-07-22 Thread Dan Muey
Howdy List, 

Bit of a quandry here.

I have a script that does everything it's supposed to.

It's basically like this:
--
Configuration variables here:

Program flow here with a single print statement after 
it figures out what it's doing based on the configuration and user input.
--
Now I need to use this same script lots of times so I already have differen 
configurations saved as different modules then in the script all I have to do is:

In One.cgi:
 use Special::One;
# this brings in all the configuartion stuff for 'One'

Rest of script here that uses the variables set up in the module above

In Two.cgi:
 use Special::Two;
# this brings in all the configuartion stuff for 'Two'

Rest of script here that uses the variables set up in the module above

What I'd like to do is this:

 use Special::Blah; # set the configuration
 use Special; # imports one function, doscript(),which is basically the rest of the 
script
 print doscript();


Where doscript() basically contains the rest of the script mentioned above and 
replaces 
the print with return at the end.

That way I can do all the configs I want and if I change the script I only have to 
change it in one place instead of every script.

So my question for all you experienced module folks is this:

1) If I do it that way is there anythign special I need to do to get the 
variables and things imported by 
use Special::Blah; able to be used in the routine doscript(); ??

Does that make sense?

2) Am I thinking correctly about how doscript() would work?
IE
before in script: 
if($this =~ m/$that/) { 
elsif($the =~ m/$other/) { ...
else { ...

print $results;

after in script:
use Special; # imports doscript();

package Special;
...
sub doscript {
if($this =~ m/$that/) { $results = mysubhere(); }
elsif($the =~ m/$other/) { ...
else { ...

sub mysubhere {}

return $results;
}

3) Am I just crazy?

TIA

Dan






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



Embedding a while construct in a function call. (using CGI)

2003-07-22 Thread Jamie Risk
A few days back I decided that all the html formating I've been doing with
Perl had probably been done before; so now I'm reading 'perldoc CGI'.

Anyway, in my (newsgroup simplified) old code I had the following;
print  tbody\n;
while ($tabbed_text_fh) {
tabbed_text_2_html_table_row_normal($_);
}
print  /tbody\n;

Which I've successfully replaced with;

print  tbody\n;
while ($tabbed_text_fh) {
s/([^\n\r]+)[ \t\n\r]+$/$1/;
print Tr(td([split(/\t/)]));
}
print  /tbody\n;


My question is then:
 * is there a way to embedd the 'while' loop within the CGI function/method
call to 'tbody()'?

- Jamie




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



print command help

2003-07-22 Thread Josh Corbalis
I'm writing a webmin module and I'm trying to add a search function in right
now but after I search for it and try to display the output it has a problem
with the way the output is formatted.

print searchtestgimp10; will print searchtest10
print searchtest gimp10; will print searchtest gimp10

I don't understand why it will not print any of what is inside the  if what
is right next to the  is a letter. Numbers and spaces will print everything
on the line but a letter discards everything in the brackets. I've tried to
escape the special meaning of the  characters when used with a word but it
didn't work. Does anybody out there have any insight into this problem?

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



Re: Reg Exp Help...

2003-07-22 Thread LI NGOK LAM
- Original Message - 
From: [EMAIL PROTECTED]
To: James Kelty [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, July 23, 2003 1:21 AM
Subject: RE: Reg Exp Help...



 
 On 22 Jul 2003 09:15:29 -0700, James Kelty [EMAIL PROTECTED] wrote:

  I know that this is a common request, but I have a question about
  parsing an email box. I have a UW IMAP box, and I am trying to extract
  all the emails where the line starts with From: blah blah. Now, getting
  those lines isn't the issue, but since each email is a little different,
  I am having a problem. Given this list, how would I extract JUST the
  email address?
 
  From: James Kelty [EMAIL PROTECTED]
  From: [EMAIL PROTECTED]
  From: [EMAIL PROTECTED]
 

 snipped 

 

 This is a relatively complex task since e-mail addresses can come in so
many different forms and contain so many different types of values. Your
best bet may be to either use a module for parsing the whole message which
is always advised, or look at the source for one of the better message
header parsing modules to determine  how they are doing it.  Sorry this is
such a non-specific answer, but rather than suggesting a way to poorly
re-invent the wheel, I prefer suggesting that this should be avoided


Hmm The OP seems not trying to do somewhat Email::Valid,
but to fetch the mail address from a line only... ie, try to cut out
something not expect to left...  I hope I bet it correct..

sub filter
{my $line = shift; chomp ($line);
chop ($line) if ($line =~ /[^\w]$/; # mail must end with tld or
country code
my ($waste, $mailAd) = split / /, $line ; # So 'From: ' is kicked
out
$mailAd =~ s/^[^\w]//; # so '' or '' will be kicked out from head
too...
# Perhaps the regex above can be [^\w|\\] if [EMAIL PROTECTED] is
valid
# I am not sure
return $mailAd
}

Code not tested, but HTH



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



Re: Reg Exp Help...

2003-07-22 Thread John W. Krahn
James Kelty wrote:
 
 I know that this is a common request, but I have a question about
 parsing an email box. I have a UW IMAP box, and I am trying to extract
 all the emails where the line starts with From: blah blah. Now, getting
 those lines isn't the issue, but since each email is a little different,
 I am having a problem. Given this list, how would I extract JUST the
 email address?
 
 From: James Kelty [EMAIL PROTECTED]
 From: [EMAIL PROTECTED]
 From: [EMAIL PROTECTED]
 
 There are three types that I have seen, and I am having the worst time
 trying to come up with a regex to extract just the address. Can someone
 help with an idea or two? Thanks!

It looks like you could use one of these modules:
http://search.cpan.org/author/MARKOV/MailTools-1.58/Mail/Address.pm
http://search.cpan.org/author/PDWARREN/Mail-RFC822-Address-0.3/Address.pm
http://search.cpan.org/author/ABIGAIL/RFC_RFC822_Address-1.5/Address.pm


John
-- 
use Perl;
program
fulfillment

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



Re: print command help

2003-07-22 Thread LI NGOK LAM

- Original Message - 
From: Josh Corbalis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 23, 2003 2:24 AM
Subject: print command help


 I'm writing a webmin module and I'm trying to add a search function in
right
 now but after I search for it and try to display the output it has a
problem
 with the way the output is formatted.

 print searchtestgimp10; will print searchtest10
 print searchtest gimp10; will print searchtest gimp10

 I don't understand why it will not print any of what is inside the  if
what
 is right next to the  is a letter. Numbers and spaces will print
everything
 on the line but a letter discards everything in the brackets. I've tried
to
 escape the special meaning of the  characters when used with a word but
it
 didn't work. Does anybody out there have any insight into this problem?


In Perl,  means nothing in string, it only means :

open FH, file.txt; $line = FH; close FH;
it reads one line from the file.txt and give the value to $line.

or

open FH, file.txt; @lines = FH; close FH;
it reads all the context to array (@lines) from file.txt,
elems are splitted by each \n ( or \r\n ) from file.txt

So, what your trying to looking for might be :

print `searchtest gimp 10`; # exec a shell command
or
print searchtest $val1 $val2;

HTH




 -- 
 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: print command help

2003-07-22 Thread Josh Corbalis



-- Original Message ---
From: LI NGOK LAM [EMAIL PROTECTED]
To: Josh Corbalis [EMAIL PROTECTED], [EMAIL PROTECTED]
Sent: Wed, 23 Jul 2003 02:52:16 +0800
Subject: Re: print command help

 - Original Message - 
 From: Josh Corbalis [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, July 23, 2003 2:24 AM
 Subject: print command help
 
  I'm writing a webmin module and I'm trying to add a search function in
 right
  now but after I search for it and try to display the output it has a
 problem
  with the way the output is formatted.
 
  print searchtestgimp10; will print searchtest10
  print searchtest gimp10; will print searchtest gimp10
 
  I don't understand why it will not print any of what is inside the  if
 what
  is right next to the  is a letter. Numbers and spaces will print
 everything
  on the line but a letter discards everything in the brackets. I've tried
 to
  escape the special meaning of the  characters when used with a word but
 it
  didn't work. Does anybody out there have any insight into this problem?
 
 
 In Perl,  means nothing in string, it only means :
 
 open FH, file.txt; $line = FH; close FH;
 it reads one line from the file.txt and give the value to $line.
 
 or
 
 open FH, file.txt; @lines = FH; close FH;
 it reads all the context to array (@lines) from file.txt,
 elems are splitted by each \n ( or \r\n ) from file.txt
 
 So, what your trying to looking for might be :
 
 print `searchtest gimp 10`; # exec a shell command
 or
 print searchtest $val1 $val2;
 
 HTH

Actually the value 'searchtestgimp10' is all stored in one variable. It
prints the searchtest10 fine but ignores the gimp because ofthe 
surrounding it. The variable is printed in a double quoted string

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



Re: Reg Exp Help...

2003-07-22 Thread wiggins


On Wed, 23 Jul 2003 02:41:28 +0800, LI NGOK LAM [EMAIL PROTECTED] wrote:

 - Original Message - 
 From: [EMAIL PROTECTED]
 To: James Kelty [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Wednesday, July 23, 2003 1:21 AM
 Subject: RE: Reg Exp Help...
 
 
 
  
  On 22 Jul 2003 09:15:29 -0700, James Kelty [EMAIL PROTECTED] wrote:
 
   I know that this is a common request, but I have a question about
   parsing an email box. I have a UW IMAP box, and I am trying to extract
   all the emails where the line starts with From: blah blah. Now, getting
   those lines isn't the issue, but since each email is a little different,
   I am having a problem. Given this list, how would I extract JUST the
   email address?
  
   From: James Kelty [EMAIL PROTECTED]
   From: [EMAIL PROTECTED]
   From: [EMAIL PROTECTED]
  
 
  snipped 
 
  
 
  This is a relatively complex task since e-mail addresses can come in so
 many different forms and contain so many different types of values. Your
 best bet may be to either use a module for parsing the whole message which
 is always advised, or look at the source for one of the better message
 header parsing modules to determine  how they are doing it.  Sorry this is
 such a non-specific answer, but rather than suggesting a way to poorly
 re-invent the wheel, I prefer suggesting that this should be avoided
 
 
 Hmm The OP seems not trying to do somewhat Email::Valid,
 but to fetch the mail address from a line only... ie, try to cut out
 something not expect to left...  I hope I bet it correct..
 
 sub filter
 {my $line = shift; chomp ($line);
 chop ($line) if ($line =~ /[^\w]$/; # mail must end with tld or
 country code
 my ($waste, $mailAd) = split / /, $line ; # So 'From: ' is kicked
 out
 $mailAd =~ s/^[^\w]//; # so '' or '' will be kicked out from head
 too...
 # Perhaps the regex above can be [^\w|\\] if [EMAIL PROTECTED] is
 valid
 # I am not sure
 return $mailAd
 }
 
 Code not tested, but HTH
 

Thank you for illustrating my point. I understood that the OP was not trying to verify 
the validity of an address but to retrieve it, but your code snippet fails on the OPs 
first line of data, which was my point, parsing email addresses out of a line of data 
is a very difficult task that is easily botched.  (There is also a missing right paren 
for those that get caught by the syntax check.)

A true e-mail address is an incredibly complex and nasty little beast, so matching 
them while it may seem simple at first becomes a nightmare quickly.  

Possibly the OP would be satisfied with just stripping off the 'From:' if that is 
guaranteed...

if ($line =~ /^From:\s*(.*)/) {
   $address = $1;
}
else {
die Not a 'From' line;
}

I still hold that this is best handled by a module that is designed to parse a mail 
message, or at the very least a module designed to parse either a message header, or a 
single header line that contains e-mail addresses.

http://danconia.org

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



Deleting from a Has

2003-07-22 Thread bseel
I want to delete an entry from a hash when the value becomes Finished. What is the 
best way of doing this?

Brian



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



RE: Deleting from a Has

2003-07-22 Thread wiggins


On Tue, 22 Jul 2003 13:40:31 -0600, [EMAIL PROTECTED] wrote:

 I want to delete an entry from a hash when the value becomes Finished. What is the 
 best way of doing this?
 

Just 'delete' it. :-).

perldoc -f delete

http://danconia.org

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



Bug in Net::FTP?

2003-07-22 Thread Mike Bernhardt
I am seeing a bug or issue with Net::FTP and thought I would try this list
about what may be the cause. I wrote the following little script to push a
host file, concatenated with some scripting, to another server where the
file can be viewed.

The problem is when I send it via this script, the file is truncated when it
gets to the destination. If I ftp it manually, it's fine. I have tried this
from unix to unix, unix to pc (the desired situation) and pc to unix. Tried
it on Perl 5.005, 5.6 and ActivePerl on the PC.  I notice that the
destination file is the same size as ALLO says- which is smaller than the
actual file. Below are the directory listings, followed by my script and the
debug output. Any ideas? Is this a module bug? I've emailed the owner of
Net::FTP also...

If there's another list better suited to helping me, please advise. There
are so many!!

Thanks in advance,

Mike Bernhardt

Here's the directory listing at the source:
-rw-r--r--   1 username  other 210380 Jul 22 12:15 iphostlist.html
-rw-r--r--   1 username  other 51 Jul 21 16:13
post.host.list.template
-rw-r--r--   1 username  other   4996 Jul 21 16:57
pre.host.list.template

And at the destination:
-rw-r--r--   1 username staff 204800 Jul 22 12:19 iphostlist.html

The script:
use Net::FTP;
open (PRE,pre.host.list.template) or die Couldn't open PRE;
open (POST,post.host.list.template) or die Couldn't open POST;
open (HOSTS, /etc/hosts) or die Couldn't open /etc/hosts;
open (NEW,iphostlist.html) or die Couldn't write to new file;
@pre = PRE;
@post = POST;
@hosts = HOSTS;
print NEW foreach @pre;
print NEW foreach @hosts;
print NEW foreach @post;
close PRE;
close POST;
close HOSTS;
FTP;
#
sub FTP {
$ftp = Net::FTP-new(server,
Debug = 1,
Timeout = 10)
   or die Cannot connect to server: $@;

 $ftp-login(username,'password')
   or die Cannot login , $ftp-message;

 $ftp-ascii()
   or die ascii failed , $ftp-message;

 $ftp-put(iphostlist.html)
   or die put failed , $ftp-message;

 $ftp-quit;
}

Here's the CLI output:
# perl test
Net::FTP Net::FTP(2.71)
Net::FTP   Exporter(5.562)
Net::FTP   Net::Cmd(2.24)
Net::FTP   IO::Socket::INET(1.25)
Net::FTP IO::Socket(1.26)
Net::FTP   IO::Handle(1.21)
Net::FTP=GLOB(0x1c9e4c) 220 server FTP server (SunOS 5.8) ready.
Net::FTP=GLOB(0x1c9e4c) user username
Net::FTP=GLOB(0x1c9e4c) 331 Password required for username.
Net::FTP=GLOB(0x1c9e4c) PASS 
Net::FTP=GLOB(0x1c9e4c) 230 User username logged in.
Net::FTP=GLOB(0x1c9e4c) TYPE A
Net::FTP=GLOB(0x1c9e4c) 200 Type set to A.
Net::FTP=GLOB(0x1c9e4c) ALLO 204800
Net::FTP=GLOB(0x1c9e4c) 202 ALLO command ignored.
Net::FTP=GLOB(0x1c9e4c) PORT x.x.x.x,128,239
Net::FTP=GLOB(0x1c9e4c) 200 PORT command successful.
Net::FTP=GLOB(0x1c9e4c) STOR iphostlist.html
Net::FTP=GLOB(0x1c9e4c) 150 ASCII data connection for iphostlist.html
(x.x.x.x,33007).
Net::FTP=GLOB(0x1c9e4c) 226 Transfer complete.
Net::FTP=GLOB(0x1c9e4c) QUIT
Net::FTP=GLOB(0x1c9e4c) 221 Goodbye.
#


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



RE: Embedding a while construct in a function call. (using CGI )

2003-07-22 Thread Bob Showalter
Jamie Risk wrote:
 A few days back I decided that all the html formating I've been doing
 with Perl had probably been done before; so now I'm reading 'perldoc
 CGI'. 
 
 Anyway, in my (newsgroup simplified) old code I had the following;   
 print  tbody\n; while ($tabbed_text_fh) {
 tabbed_text_2_html_table_row_normal($_);
 }
 print  /tbody\n;
 
 Which I've successfully replaced with;
 
 print  tbody\n;
 while ($tabbed_text_fh) {
 s/([^\n\r]+)[ \t\n\r]+$/$1/;
 print Tr(td([split(/\t/)]));
 }
 print  /tbody\n;
 
 
 My question is then:
  * is there a way to embedd the 'while' loop within the CGI
 function/method call to 'tbody()'?

use CGI qw/:standard tbody/;

print tbody(
   Tr(
  [map { s/([^\n\r]+)[ \t\n\r]+$/$1/; td([split /\t/]) }
$tabbed_text_fh]
   )
);

I'm not sure what your regex is trying to do. Why not just s/\s+$//

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



RE: Bug in Net::FTP? D'oh!

2003-07-22 Thread Mike Bernhardt
I fixed the problem. I had closed all the files- except the one I was
ftping. Now it works! Sorry to bother you all.


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



Re: Embedding a while construct in a function call. (using CGI )

2003-07-22 Thread Jamie Risk

Bob Showalter [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 print tbody(
Tr(
   [map { s/([^\n\r]+)[ \t\n\r]+$/$1/; td([split /\t/]) }
 $tabbed_text_fh]
)
 );

Thanks, though as usual, I've got another perldoc reference to lookup
(map).


 I'm not sure what your regex is trying to do. Why not just s/\s+$//

It's meant to be a generic chomp() for handling EOL's created on different
systems.  It probably does the exact same thing as s/\s+$//, though I'm
only now aware of the shortcut.

Cheers.




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



Re: print command help

2003-07-22 Thread Josh Corbalis
 I'm writing a webmin module and I'm trying to add a search function 
 in right now but after I search for it and try to display the output 
 it has a problem with the way the output is formatted.
 
 print searchtestgimp10; will print searchtest10
 print searchtest gimp10; will print searchtest gimp10
 
 I don't understand why it will not print any of what is inside the 
  if what is right next to the  is a letter. Numbers and spaces 
 will print everything on the line but a letter discards everything 
 in the brackets. I've tried to escape the special meaning of the  
 characters when used with a word but it didn't work. Does anybody 
 out there have any insight into this problem?

OK I have some more information about the initial problem as described above.
The problem isn't really with perl at all but with HTML as this is printing to
a web page. HTML is taking the gimp to be a command for it to execute
instead of plain text in a string. Should I design a regexp to replace all 
and  with something else? If so how would I replace something using a regexp?
I've never used regexps before so some help on this would be great. 

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



Re: print command help

2003-07-22 Thread wiggins


On Tue, 22 Jul 2003 16:29:08 -0500, Josh Corbalis [EMAIL PROTECTED] wrote:

  I'm writing a webmin module and I'm trying to add a search function 
  in right now but after I search for it and try to display the output 
  it has a problem with the way the output is formatted.
  
  print searchtestgimp10; will print searchtest10
  print searchtest gimp10; will print searchtest gimp10
  
  I don't understand why it will not print any of what is inside the 
   if what is right next to the  is a letter. Numbers and spaces 
  will print everything on the line but a letter discards everything 
  in the brackets. I've tried to escape the special meaning of the  
  characters when used with a word but it didn't work. Does anybody 
  out there have any insight into this problem?
 
 OK I have some more information about the initial problem as described above.
 The problem isn't really with perl at all but with HTML as this is printing to
 a web page. HTML is taking the gimp to be a command for it to execute
 instead of plain text in a string. Should I design a regexp to replace all 
 and  with something else? If so how would I replace something using a regexp?
 I've never used regexps before so some help on this would be great. 
 

The client (browser) is assuming gimp is a tag which was my initial thought, because 
tags can't start with digits your numerical content was working ok.  Yes you can 
replace the  and  with the special HTML replacement characters, gt; and lt; and 
one easy method to do this is with a regexp. There are also modules that provide this 
type of functionality, in particular if you are already using the CGI module you 
should have a look at the escapeHTML function.  

The following substituitions are possibly an oversimplified way of handling this.

$string =~ s//gt;/g;
$string =~ s//lt;/g;

The using a module is still the better approach from a completeness standpoint.

http://danconia.org

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



Re: ANNOUNCE: Ncurses programming examples

2003-07-22 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Gary 
Stainburn wrote:

 On Tuesday 22 Jul 2003 3:35 pm, Anuradha Ratnaweera wrote:
 Some examples from ncurses programming howto have been ported from C to
 Perl.  Downloads are at http://www.linux.lk/anuradha/.
 
 I get 404 not found for this URL.  Could you correct and repost as this is
 something I'd be interrested in.

Try it with a tilde (he said): http://www.linux.lk/~anuradha/

http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

-- 
Kevin Pfeiffer
International University Bremen

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



Re: Deleting from a Has

2003-07-22 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
 I want to delete an entry from a hash when the value becomes
 Finished. What is the best way of doing this?


Don't forget that there is no implicit order to
hash elements.

  foreach (keys %hash) {
delete $hash{$_} if $hash{$_} eq 'Finished';
  }

will delete every element where the value is 'Finished',
which is what you say, but I'm not sure it's what you want.

Can you exemplify?

Rob




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



RE: Create Perl Menu

2003-07-22 Thread Dan Muey
 
 Hi, I am taking perl at school.

Good for you, I wish my school had it when I was there.

 
  
 
 I need help to create a simple menu with input of a( current 
 date), b(users currently log in), c(name of working 
 directory), and d(contents of the working directory).

Ummm, if we did your homework for you you wouldn't learn anything and 
then you'd be dumb when you graduated and live in a van down by the river.

You don't want that do you? :)

 

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



Re: subroutines

2003-07-22 Thread Stuart White
thanks for the help so far.  the program is much
closer to what I want it to be now.  the last thing is
to count the total number of fouls committed, send
them back to the 'main' program, and print them there.
I can do the sending back and printing, I'm not sure
how to do the counting.  Essentially, it would be
counting the number of instances of the $typefoul
variable in the FoulParser subroutine.  Can I get some
help?
You'll see in the code how I've attempted to put
$typefoul and $player into a @stuff array, return
that, and print the instances of $typefoul.  YOu'll
also notice that I tried a failed attempt at counting
with a $count variable, but that failed.  I only keep
those in to show I tried different things.

HEre is the code:

Note: Though I have been told twice, maybe 3x that I
do not need to declare the number of variables that I
am passing, my book, Perl for Beginners, says I do,
and, the program doesn't print anything when I leave
the declarations out.  This is in 5.8.0.  
Thanks in advance for your help. -stu


# Subroutine prototypes

sub FoulParser($$$);
#
# Main Program
#

use warnings;
use strict;
 
open(STATS, stats.txt) or die statfile\n;
my $foul; 
my $foultype;
my $player;
my $count;
my @stuff;
 while (STATS)
 {
if ($_ =~ /(\w+) (Foul:) (\w+)/)
{
 $foul = $_;
 $player = $1;
 $foultype = $3;
 print \nline to be passed: $foul; 

@stuff = FoulParser($foul, $player, $foultype);
my ($space1, $space2) = @stuff;
print space1: $space1\n;
print space2: $space2\n;
  }
}
print type of foul count: $count;

# Subroutine Definitions
###

sub FoulParser($$$)
{ 
 my ($line, $player, $typefoul) = @_;
 my $count;
 my @stuff;
 print selected line: $line;
 print Player's Name: $player\n;
 @stuff = $player;
 print Type of foul committed: $typefoul\n;
 @stuff = $typefoul;
 $count = $typefoul;
 $count++;
 return @stuff;
}

--- Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote:
 On Jul 21, Stuart White said:
 
 I tried reading the perldoc, but it came up all
 screwy
 on my screen.  Lines ran over the end.  I'm having
 
 Then you can read them online at
 http://www.perldoc.com/.
 
 trouble passing variables into a subroutine.   
 Also,
 once I get it passed, I want to pass it from there
 back to the main function.  Can someone help me
 figure
 this out?  This is the code that I have:
 
 sub FoulParser($$$);
 
 You don't NEED function prototypes.  In fact,
 they're probably confusing
 more than you need to be confused right now. 
 They're for very SPECIFIC
 purposes, and I doubt you need them.
 
 use warnings;
 use strict;
 
 open(STATS, stats.txt) or die statfile\n;
 
 You might want to include $! in your error message.
 
 my $foul;
 my $foultype;
 my $player;
 my @stuff;
 
 You might want to define these variables in the
 block at which they're
 needed.  That is, I don't think you use them outside
 this while() loop, so
 why not wait until you're inside that if block?
 
  while (STATS)
  {
  if ($_ =~ /(\w+) (Foul:) (\w+)/)
  {
   $foul = $_;
   $player = $1;
   $foultype = $3;
   print line to be passed: $foul;
  FoulParser($foul, $player, $foultype);
   }
  }
 
   while (STATS) {
 if (/(\w+) Foul: (\w+)/) {
   my $foul = $_;  # why not just use $_ instead
 of $foul?
   my $player = $1;
   my $foultype = $2;  # notice I got rid of the
 ()'s around Foul:
 
   FoulParser($foul, $player, $foultype);
 }
   }
 
 sub FoulParser($$$)
 {
  my ($foul, $typefoul, $player, @stuff);
 
 Ok, the problem is that you don't ever give these
 variables values!  You
 need to get them from @_, which is the array that
 function arguments are
 placed into (automatically, by Perl).
 
   sub FoulParser {
 my ($line, $who, $type) = @_;
 
 Now, it looks like you wanted to do
 $fouls{$foultype}{$player}++.  That's
 fine.  Just declare %fouls beforehand, outside the
 subroutine (if you want
 it to exist outside the subroutine, which I think
 you do).
 
 $fouls{$type}{$who}++;
   }
 
 Please read the documentation, and RE-read the
 chapters of the book you're
 using.
 
 -- 
 Jeff japhy Pinyan  [EMAIL PROTECTED] 
 http://www.pobox.com/~japhy/
 RPI Acacia brother #734   http://www.perlmonks.org/ 
  http://www.cpan.org/
 stu what does y/// stand for?  tenderpuss why,
 yansliterate of course.
 [  I'm looking for programming work.  If you like my
 work, let me know.  ]
 


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



Security Code Validation for Forms

2003-07-22 Thread Adam Gent
Hi All,

I am trying to find a way, to place a security code image on to a web form,
so that the user, has to copy the text from the image into a text field
before they can continue, similar to hotmail, paypal etc

I have been looking around the web and on CPAN for a solution to this, but
can not find anything, I was hopping that someone else may have already have
a solution to this, or have some thoughts on how it could be done.

Thanks,

Adam


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.502 / Virus Database: 300 - Release Date: 19/07/2003


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



RE: subroutines

2003-07-22 Thread Charles K. Clarkson
Stuart White [EMAIL PROTECTED] wrote:
: 
: 
: HEre is the code:
: 
: Note: Though I have been told twice, maybe 3x that I
: do not need to declare the number of variables that I
: am passing, my book, Perl for Beginners, says I do,
: and, the program doesn't print anything when I leave
: the declarations out.  This is in 5.8.0.  

Only $count is file scoped. The other variables can
be in the while, though they're not really needed.


: Thanks in advance for your help. -stu
: 
: 
: # Subroutine prototypes
: 
: sub FoulParser($$$);

   As Jeff mentioned, you really don't need prototypes
in this situation.


: #
: # Main Program
: #
: 
: use warnings;
: use strict;
:  
: open(STATS, stats.txt) or die statfile\n;

As mentioned before the most common idiom
includes the error generated by perl. Don't
put \n on the end. It suppresses need
information.

open STATS, stats.txt or die Cannot open 'stats.txt': $!;


: my $foul; 
: my $foultype;
: my $player;
: my $count;
: my @stuff;
:  while (STATS)
:  {
:   if ($_ =~ /(\w+) (Foul:) (\w+)/)
:   {


:$foul = $_;
:$player = $1;
:$foultype = $3;
:print \nline to be passed: $foul; 
: 
:   @stuff = FoulParser($foul, $player, $foultype);
:   my ($space1, $space2) = @stuff;
:   print space1: $space1\n;
:   print space2: $space2\n;


if ($_ =~ /(\w+) (Foul:) (\w+)/) {

print \nline to be passed: $_;

printf
space1: %s\nspace2: %s\n,
FoulParser( $_, $1, $2 );

:   }
:   }
:
: print type of foul count: $count;

Here $count is file scoped. In the subroutine
you are using a subroutine scoped $count, which is
different is a different variable.

 
: sub FoulParser($$$)

The name for this subroutine is misleading.
The parsing of $line was handled outside the
routine and its name does not indicate that it
is printing anything.

: { 
:  my ($line, $player, $typefoul) = @_;
:  my $count;

Since $count is not returned from the
subroutine, it is unnecessary.

:  my @stuff;
:  print selected line: $line;
:  print Player's Name: $player\n;
:  @stuff = $player;
:  print Type of foul committed: $typefoul\n;
:  @stuff = $typefoul;

@stuff will always $typefoul, so you may as
well return it and stop creating @stuff, which is
a really poor name for a variable anyway.


:  $count = $typefoul;
:  $count++;
:  return @stuff;

   The entire sub is equivalent to:

my( $line, $player, $foul_type ) = @_;

print Selected line: $line\n;
print Player's Name: $player\n;
print Type of foul committed: $foul_type\n;

return $foul_type;

: }

[snipped - completely unnecessary quoting]


What I think you wanted to return was this:

return ( $player, $foul_type );


But that doesn't make sense since you
didn't process them in any way. Why pass
back variables you just passed in. What
I really think you ultimately want is a
hash with foul type counts and a report
for each line.

I would recommend that a routine which
returns a report not actually do the
printing. The script might look like:

use Data::Dumper;

my %fouls_count;

open STATS, stats.txt or die statfile\n;
while ( STATS ) {
if ( /(\w+) Foul: (\w+)/ ) {

# $1 = player, $2 = foul type
print line_report( $1, $2 );

# count by foul type
$fouls_count{ $2 }++;
}
}
close STATS;

# This would need to be changed to a
#  full blown report
print Dumper \%fouls_count;

sub line_report {
return sprintf
Player's Name: %s\n .
\tType of foul committed: %s\n,
@_;
}


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328















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



meta refresh - PERL - IE

2003-07-22 Thread jdavis

hello,
  The code below is from a cgi scrip
this code makes a html page by calling FP
this works, i know this because i can see
Thinking.
printed in the browser right before redirect.
problem is i get the error...

Preamautre end of script headers

while trying to redirect... also..the redirect works just fine
for mozilla/Linux but fails on ie/windows. Any ideas


elsif($in{my_action} eq fp){
FP;
print htmlheadtitleAbqRlty/title\n;
print meta http-equiv=\Refresh\
content=\0,URL=http://www.mysite.com/feature.html\;\n;
print /headbodyOne Moment
Thinking../body/html\n;
}
thanks,
-- 
jdavis [EMAIL PROTECTED]


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



Create Perl Menu

2003-07-22 Thread Phan Ros
Hi, I am taking perl at school.

 

I need help to create a simple menu with input of a( current date), b(users
currently log in), c(name of working directory), and d(contents of the
working directory).

 

Thanks 

 

Angkor



Re: Security Code Validation for Forms

2003-07-22 Thread Wiggins d'Anconia
Adam Gent wrote:
Hi All,

I am trying to find a way, to place a security code image on to a web form,
so that the user, has to copy the text from the image into a text field
before they can continue, similar to hotmail, paypal etc
I have been looking around the web and on CPAN for a solution to this, but
can not find anything, I was hopping that someone else may have already have
a solution to this, or have some thoughts on how it could be done.
Not sure about pre-written examples, I imagine it is a pretty specific 
type of thing so a generic solution may end up being hard to come by. 
Theoretically all you need is some way to generate the text, a session 
ID hashed, or something, and allow it to be re-generated after 
submission, aka it can't just be random unless you store it somehow, but 
if that is done client side then it can be spoofed, obviously. Then you 
can use one of the standard on-the-fly image generation modules 
available on CPAN, such as Image::Magick or GD, to generate the image, 
you can even add speckles, etc. to make it harder to automate.

http://search.cpan.org/author/LDS/GD-2.07/GD.pm
http://search.cpan.org/author/JCRISTY/PerlMagick-5.57/Magick.pm
Then someway to re-generate the string to make sure the user entered the 
correct value.  That or you could pre-generate a series of images and 
choose one at random, but again you have to know how to verify the 
correct value and this is less secure than generating a unique image for 
every session

http://danconia.org

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


Re: Create Perl Menu

2003-07-22 Thread Oliver Schnarchendorf
On Tue, 22 Jul 2003 11:35:16 -0600, Phan Ros wrote:
 I need help to create a simple menu with input of a( current date), b(users
 currently log in), c(name of working directory), and d(contents of the
 working directory).
Good, we would love to help you... yet we are not here to do your 
homework for you.

You might want to read the material your teacher gave you... and maybe 
you will also find some modules on search.cpan.org.

Once you are in your project and need concrete help with a smaller part 
of your homework, we would love to help you as long as you provide an 
example of the problem and how you tried to solve it.

/oliver/


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



Re: Deleting from a Has

2003-07-22 Thread John W. Krahn
Rob Dixon wrote:
 
 [EMAIL PROTECTED] wrote:
  I want to delete an entry from a hash when the value becomes
  Finished. What is the best way of doing this?
 
 
 Don't forget that there is no implicit order to
 hash elements.
 
   foreach (keys %hash) {
 delete $hash{$_} if $hash{$_} eq 'Finished';
   }
 
 will delete every element where the value is 'Finished',
 which is what you say, but I'm not sure it's what you want.

Or without the loop:   :-)

delete @hash{ grep $hash{$_} eq 'Finished', keys %hash };


John
-- 
use Perl;
program
fulfillment

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



RE: subroutines

2003-07-22 Thread Charles K. Clarkson
Stuart White [EMAIL PROTECTED] wrote:
: 
: Couple things:
: 
: About declaring variables in while loops and if
: constructs.  I don't do that because it's messy and
: disorganized for me.  I prefer to declare all the
: variables I will use in a subroutine at the top of the
: subroutine, before I write any assignments or process
: any code.  It's just a style I prefer.

That's fine for a small program and for longer
ones I find objects and module eliminate many
variables. TIMTOWTDI. I do like to keep them in
the smallest scope possible though.


: What I want to return is the count of the number of
: fouls, nothing more.  However, I am a bit lost as to
: how to count them.  Can someone point me in the right
: direction to figure out how to count that?


my $fouls_count = 0;

open STATS, 'stats.txt' or die Cannot open 'stats.txt': $!;
while ( STATS ) {
if ( /(\w+) Foul: (\w+)/ ) {

# $1 = player, $2 = foul type
print line_report( $1, $2 );

# count fouls
$fouls_count++;
}
}
close STATS;

print \nTotal fouls: $fouls_count\n;


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


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