Re: Questions about CGI

2018-06-06 Thread Jim Gibson



> On Jun 6, 2018, at 2:16 PM, Ahmad Bilal  wrote:
> 
> Ok, I went over to previously answered questions under the cgi tag here on 
> stackoverflow.

This message was posted to the Perl Beginners list, so you are not at 
Stackoverflow any more.
> 
> This seems to be the most voted one: What is Common Gateway Interface (CGI)?
> 
> But it still doesn't clear a few things, which I'm asking here.
> 
> Since RFC3875 is only a informational doc, and there is no finalized standard.
> 
>   • Who implements CGI protocol? Who defines its "standard behavior" on 
> servers such as Apache.

The CGI protocol is implemented by web servers and web browsers. It is a way 
for browsers to query a server and get dynamic information, rather than a 
static web page. The CGI request is part of the Hypertext Transfer Protocol 
(HTTP). It allows parameters to be sent by the browser to the server, which 
then uses the values of these parameters to generate a dynamic web page that it 
sends back to the browser.

> 
>   • How does C files work with CGI in modern environment. Please 
> elaborate using a "Hello World!" as a response to a form submission.

You can write a CGI program in just about any language. Since this is a Perl 
list, maybe you should be asking about CGI programming in Perl. I have written 
CGI programs in Perl, but now use PHP (for compatibility with existing CGI 
scripts).

Perl has modules to assist in CGI program development. The oldest of these is 
the CGI.pm module, but it has now fallen out of favor, and other modules are 
now recommended. I haven’t used any (or done any CGI programming in Perl for a 
long time), so I can’t recommend any from personal experience.

Check out these pages:





> 
> 
> 
> -- 
> Ahmad Bilal
> 



Jim Gibson

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Questions about optmodel constraints

2010-11-21 Thread Uri Guttman
 a == ayaa  ayaafa...@gmail.com writes:

  a I have three questions:
  a 1. If I have a variable that is stored in a data set and I want to
  a formulate only one constraint (under optmodel) that is a function of
  a all the data set's observations of this variable and a decision
  a variable. Suppose the
  a variable is  a  and x is the decision variable. My
  a constraint is: [(maximum value of a) +x ] / [(minimum value of a) +x ]
  a  maximum value of (a)  / minimum value of (a), can you
  a help me to include this constraint under optmodel?

  a 2. If there is one scalar number that is a result of certain
  a calculations and the it is stored in a dataset and I want to equate a
  a constraint with this scalar,  can you help me to do this?

  a 3.  If there is one scalar number that is a result of certain
  a calculations and it is stored in a dataset and I want to include this
  a scalar in sum operator. Suppose there are also two stored variables
  a that are a and b, and x is a decision variable and the scalar is c, I
  a want c to appear as in the following constraint:
  a  sum over i for  [  c*(ai)^2 * bi/ (ai+x)] = 0.5  ,  can you help me
  a to do this under optmodel?

and your perl question is? even if optmodel is some perl package (which
i never have heard of), this would be beyond the level for a beginner's
list. please find an optmodel list/forum to ask this.

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Questions on perl?

2008-08-29 Thread Rob Dixon
moijes12 wrote:
 Hello friends,
 
 I have a few questions about perl,whose answers i am finding difficult
 to find.They are as below:
 
 1)What type of language is perl?
a)Functional Oriented
b)Object Oriented
c)Process Oriented

Those are programming styles, rather than language types. You can write both
function- and object-oriented programs in perl. Process-oriented programming is
possible to a limited extent, but it is not automated in the way you would
expect for a language intended for that style.

 2)What is the use of '===' operator in perl?

  It has no function in Perl 5. In perl 6 it compares to see if two items refer
  to the same object, so for instance

  @list === @[EMAIL PROTECTED]

  is true.

 3)In URL encoding,what is the use of the '=' operator?

  By convention it separates a key from a value in the query part of a URL

And I really really hope this isn't homework. If it is then you must tell us and
 also give me credit for your answers when you turn it in.

Rob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: questions from Learning Perl

2008-04-14 Thread Randal L. Schwartz
 Chas == Chas Owens [EMAIL PROTECTED] writes:

Chas I remember in Learning Perl 2nd edition

AKA the version that never existed.  In other words, please consider
anything in that book non-canonical, as the SciFi geeks say.  Long story.

-- 
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]
http://learn.perl.org/




Re: questions from Learning Perl

2008-04-13 Thread brian d foy
In article [EMAIL PROTECTED], Gunnar
Hjalmarsson [EMAIL PROTECTED] wrote:

 I don't understand what you mean. However, the code below confuses me 
 for another reason.
 
  use strict;
  use warnings;
  my @fred = qw/1 3 5 7 9/;
  my $fred_total = total(@fred);
  print The total of [EMAIL PROTECTED] is $fred_total.\n;
  print Enter some numbers on separate line: ; ## line 6
  my $user_total = total(STDIN);
 
 When I tried the program, that line didn't work for me. Shouldn't it 
 rather be for instance:
 
  my $user_total = total( split ' ', STDIN );
 
 so that STDIN gets evaluated in scalar context?

No, it should be as posted. Remember, this is _Learning Perl_, and it's
only up to Chapter 4 so far. We haven't talked about string processing
yet, so everything is line oriented, as noted in the prompt text. :)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: questions from Learning Perl

2008-04-13 Thread brian d foy
In article
[EMAIL PROTECTED], Chas.
Owens [EMAIL PROTECTED] wrote:

 On Sun, Apr 6, 2008 at 5:36 AM,  [EMAIL PROTECTED] wrote:
 snip
   my $user_total = total(STDIN);
 snip
 
 First off, don't call functions with *.  

The is _Learning Perl_, and he hasn't got to the point where we tell
the reader they don't need the  in front of subroutine calls. Most of
the progression goes from the general rule to the usual case.

 The problem here is that you
 are evaluating STDIN in list context. 

It's supposed to be in list context. That's how you get multiple lines
containing one number per line, as noted in the prompt string. :)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: questions from Learning Perl

2008-04-13 Thread Chas. Owens
On Sun, Apr 13, 2008 at 11:58 AM, brian d foy [EMAIL PROTECTED] wrote:
snip
   First off, don't call functions with *.

  The is _Learning Perl_, and he hasn't got to the point where we tell
  the reader they don't need the  in front of subroutine calls. Most of
  the progression goes from the general rule to the usual case.
snip

I remember in Learning Perl 2nd edition it never calling functions
with  (it had a footnote stating something to the effect that func's
name was really func, but that you normally didn't need to spell it
that way).  Is this some error that has crept into later editions?  Do
you have a rationale for confusing the reader by first telling him/her
to call function with  and then later telling him/her not to because
it breaks prototypes and passes the calling functions @_ if no
arguments are supplied?  Adding the  adds magic, I wouldn't call that
the general case.  It seems like handing a someone a loaded gun and
teaching him/her about proper gun safety an hour later.

snip
   The problem here is that you
   are evaluating STDIN in list context.

  It's supposed to be in list context. That's how you get multiple lines
  containing one number per line, as noted in the prompt string. :)
snip

Reread the rest of that paragraph; the problem the user is seeing is
that the input phase never ends.  This is because he/she is evaluating
STDIN in list context and STDIN does not have an end (if it where
normal file handle it wouldn't be a problem because the file has an
end).  So he/she must give the program an end by typing control-d on
UNIX or control-z on Win32.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: questions from Learning Perl

2008-04-07 Thread Jay Savage
On Sun, Apr 6, 2008 at 5:36 AM,  [EMAIL PROTECTED] wrote:
 Hi,
  I am doing some homework from the book Learning Perl chapter 4 excercise 1,
  Looking at the script below, I wonder why line 6 (print Enter some numbers 
 on separate line: ;) is not printed immediately after the previous print.
  Thanks


  use strict;
  use warnings;
  my @fred = qw/1 3 5 7 9/;
  my $fred_total = total(@fred);
  print The total of [EMAIL PROTECTED] is $fred_total.\n;
  print Enter some numbers on separate line: ; ## line 6

Your system is buffering the output. See perldoc -q How do I
flush/unbuffer an output filehandle

  my $user_total = total(STDIN);
  print the total of those numbers is $user_total.\n;

  sub total {
   my $sum;
   foreach (@_){
   $sum += $_;
   }
   $sum;
  }



-- 
--
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org

values of β will give rise to dom!


Re: questions from Learning Perl

2008-04-06 Thread Chas. Owens
On Sun, Apr 6, 2008 at 5:36 AM,  [EMAIL PROTECTED] wrote:
snip
  my $user_total = total(STDIN);
snip

First off, don't call functions with *.  The problem here is that you
are evaluating STDIN in list context.  That means it will read from
STDIN until it is closed.  To close a STDIN on UNIX use control-d,
under Win32 I believe it is control-z.

* unless you know exactly when you should.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: questions from Learning Perl

2008-04-06 Thread Gunnar Hjalmarsson

[EMAIL PROTECTED] wrote:
I am doing some homework from the book Learning Perl chapter 4 
excercise 1,
Looking at the script below, I wonder why line 6 (print Enter some 
numbers on separate line: ;) is not printed immediately after the 
previous print.


I don't understand what you mean. However, the code below confuses me 
for another reason.



use strict;
use warnings;
my @fred = qw/1 3 5 7 9/;
my $fred_total = total(@fred);
print The total of [EMAIL PROTECTED] is $fred_total.\n;
print Enter some numbers on separate line: ; ## line 6
my $user_total = total(STDIN);


When I tried the program, that line didn't work for me. Shouldn't it 
rather be for instance:


my $user_total = total( split ' ', STDIN );

so that STDIN gets evaluated in scalar context?


print the total of those numbers is $user_total.\n;
  
sub total {  
 my $sum;

 foreach (@_){
  $sum += $_;
 }
 $sum;
}


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: questions

2004-10-26 Thread M. Ilyas Hassan
hi Chris,
Thanks for the responses.
Q1: Your suggestion would work without the date module for now :-)
Q2: The input file is a flat file (.txt) parsed by ~ with 40 columns. 
Columns 2-40 has numbers (all integers, +ve and -ve numbers). Column 0 has 
items in alphanumeric and column 1 has labels in text. I would like to find 
the minimum value for numbers in columns 2-40 and write out an output in the 
form of a flat file with 2 columns (col. 0 = item, col. 1 =min value).

Please see the code I wrote. I does NOT work. Thanks for your input and 
help,
=
$i=0;
open INV_RPT, $_inventory_rpt or die Can't open file handler;
open (INV_RPT_MIN, $_inventory_rpt_min);
{
  chop($Ctmp1);
  @Ctmp2=split(/~/,$Ctmp1);
  $items{$Ctmp2[0]}=$Ctmp2[0];
}

foreach $item (keys %items)
{
 while($Ctmp1 = INV_RPT)
  {
   chop($Ctmp1);
   @Ctmp2=split(/~/,$Ctmp1);
   $START_MIN{$ctmp2[0]}=$ctmp2[2];
   for $i (0..40)  { if(defined($Ctmp2[$i]))  { $Ctmp2[$i] =~ s/\s*//; }   
else { $Ctmp2[$i] = ; } }
	if($START_MIN{$ctmp2[0]}  $Ctmp2[$i])
	{
	 $END_MIN{$Ctmp2[0]}=$Ctmp2[$i];
	 print INV_RPT_MIN $item~$END_MIN{$Ctmp2[0]}\n;
	}
  }
}
close(INV_RPT);
close(INV_RPT_MIN);
===

sample input file content:
==
col0~col1~col2...
AI6CQ7~Finishing Onhand~48.0~42.0~   134.0~   124.0~   120.0~   
120.0~   120.0~   110.0~   108.0~   102.0~96.0~94.0~94.0~
94.0~90.0~88.0~88.0~60.0~60.0~60.0~60.0~
60.0~   - 48.0~   -34.0~24.0~18.0~18.0~18.0~14.0~
98.0~88.0~88.0~88.0~88.0~   -88.0~82.0~78.0~
68.0~62.0~58.0~58.0~58.0~56.0~50.0~44.0~
42.0~40.0~   140.0~   140.0~96.0~96.0~96.0~96.0~
96.0~-96.0~-96.0~56.0~56.0~56.0~56.0~56.0~
56.0~56.0~56.0~56.0~56.0~56.0~


I appreciate your help.
From: Chris Devers [EMAIL PROTECTED]
Reply-To: Perl Beginners List [EMAIL PROTECTED]
To: M. Ilyas Hassan [EMAIL PROTECTED]
CC: Perl Beginners List [EMAIL PROTECTED]
Subject: Re: questions
Date: Mon, 25 Oct 2004 19:28:38 -0400 (EDT)
On Mon, 25 Oct 2004, M. Ilyas Hassan wrote:
 #1 - Is there a way to add days to a date?
The modules that the other two respondants pointed you to are the right
way to do this, but it's good to know that the way to do this by hand --
which you won't want to do, but it's good to see why not -- is to only
deal with times represented as seconds.
So, for example, 90 days works out to 7776000 seconds (60 secs/min * 60
mins/hour * 24 hours/day * 90 days).
So you look up the Unix timestamp for the starting date. For this, let's
use the time as I type this, 1098746228:
$ perl -le 'print scalar localtime 1098746228'
Mon Oct 25 19:17:08 2004
$
You add 90 days worth of seconds to that to get the future date:
$ perl -le 'print 1098746228 + 7776000'
110658
$
And then you convert that back to a more conventional format:
$ perl -le 'print scalar localtime( 1098746228 + 7776000 )'
Sun Jan 23 18:17:08 2005
$
Or, putting it all together:
$ perl -le '$now = 1098746228; $ninety_days = 7776000; $then = $now + 
$ninety_days; print scalar localtime $then'
Sun Jan 23 18:17:08 2005
$

This isn't *that* bad, but the math gets annoying to manage manually.
Using a module like Date::Calc saves a lot of effort  reduces errors.
Look up the documentation for Date::Calc for usage detals.
 #2 - How could I find the minimum value from table with say 80columns.
How is this table represented? Is it in a database? Is it in a flat file
of some kind? Do you already have it in memory in some kind of data
structure?
The approach to this problem depends a lot on what tools you have to
work with.
For this, you need to describe where this data is coming from, how you
are thinking of representing it in variables, and (most important) you
need to show us what code you've written to solve the problem.
The date problem was a gimme, but this is a larger task with many ways
it could be solved. You have to show us where you're starting from
before  you can expect people to fill in the blanks for you.
 Please email your feedback to [EMAIL PROTECTED] I will truly
 appreciate any help that you could offer.
This seems to be a typo -- all discussion should stay on the list where
it can be of use to everyone that is trying to learn this stuff. If you
have not already done so, please subscribe to the list so that we can
have the conversation on the list.
--
Chris Devers

-
Muhammed I. Hassan
1030 Baytowne Drive, #24
Champaign, IL 61822
217-353-0075 (Home)
630-267-2494 (Mobile)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: questions

2004-10-26 Thread Bob Showalter
M. Ilyas Hassan wrote:
 hi,
 Could someone please help me with the following perl questions.
 
 #1 - Is there a way to add days to a date? I want
 end_date=start_date+90days; where start_date is in the format
 10/25/04; the output end_date should be in the same format as well. I
 was not successful loading the Date::Calc module from CSPAN on
 ActivePerl 5 (Revision 5, version 6, Subrevision 1, - 5.006001). Can
 some suggest some input.

The command:

   ppm install Date-Calc 

should work for you with ActiveState's Perl.

But see also http://datetime.perl.org for the newfangled modules for doing
date stuff.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: questions

2004-10-26 Thread Charles K. Clarkson
M. Ilyas Hassan [EMAIL PROTECTED] wrote:

: The input file is a flat file (.txt) parsed by ~ with 40
: columns. Columns 2-40 has numbers (all integers, +ve and -ve
: numbers). Column 0 has items in alphanumeric and column 1 has
: labels in text. I would like to find the minimum value for
: numbers in columns 2-40 and write out an output in the form of
: a flat file with 2 columns (col. 0 = item, col. 1 =min value).

That's 41 columns (0 - 40). 40 columns would be numbered
0 - 39.


: Please see the code I wrote. I does NOT work. Thanks for your
: input and help,

Always begin your code with these modules. They will help you
to use better programming habits.

use strict;
use warnings;


: $i=0;

Too early. Declare your variables when you use them.


: open INV_RPT, $_inventory_rpt or die Can't open file handler;
: open (INV_RPT_MIN, $_inventory_rpt_min);

$_inventory_rpt and $_inventory_rpt_min have not been defined.


The first 'open' checks for errors and the second does not.
Why? Be consistent. If you do error checking the first time, do
it the last and every time in between.

As long as you use perl you will be opening files. Create a
macro for opening files in your code editor. Try to use the same
open idiom each time. Including the $! variable will help you
track down where errors came from. Here's mine.

my $file = '';
open FH, $file or die qq(Cannot open $file: $!);

close FH;

Whatever you choose, use the same thing for each 'open'
statement.


: {
:chop($Ctmp1);
:@Ctmp2=split(/~/,$Ctmp1);
:$items{$Ctmp2[0]}=$Ctmp2[0];
: }

Too early. $Ctmp1 (horrible name for a variable) has not been
defined yet. The hash doesn't hold what you expect. Learn how to
test.

use Data::Dumper 'Dumper';

{
chop($temp);
@fields=split(/~/,$temp);
$items{$fields[0]}=$fields[0];
}
print Dumper \%items;

__END__

I get:

$VAR1 = {
  '' = undef
};

   So %items has one key with an undefined value. I am not sure
what you intended to do here, but that wasn't it.


: foreach $item (keys %items)
: {

The hash has one element. We can skip the loop and just write
this. That doesn't look right, does it?

my $item = '';


:   while($Ctmp1 = INV_RPT)
:{

Under strict, that would be written like this. (Read perlfunc
'my') I used $record instead of $Ctmp1 because it is more
descriptive of what the variable holds. Use meaningful variable
names.

while( my $record = INV_RPT )
{


: chop($Ctmp1);

chop is deprecated. Throw away whatever tool (book,
tutorial, outdated program, etc,) you are using to learn perl. Go
to learn.perl.org for books and online support for writing good
perl scripts.

chomp $record;


: @Ctmp2=split(/~/,$Ctmp1);

@Ctmp2 as used here has file scope. Let's scope it to this
code block  (using 'my') and let's use a meaningful name for it.

my @fields = split /~/, $line;

: $START_MIN{$ctmp2[0]}=$ctmp2[2];

Why does this hash (%START_MIN) use all caps for the the
variable name? Other variables are mixed case (which I personally
despise). What is so special about this hash that it should
deserve all caps?

According to your description we are attempting to find the
minimum value in this array. We can do that by importing a
function from List::Util. To import this function we need to use
this module (at the beginning of the script). The function we need
is named 'min'.

use List::Util 'min';


: for $i (0..40) {

Forty fields, not forty-one.

foreach my $i ( 0 .. 39 ) {


: if ( defined $fields[$i] ) {

Every field in @fields will be defined. split cannot return
undefined fields as it is used here. It *can* return empty fields
(''). The only undefined fields are the fields added for columns
with less than 40 columns.


: $fields[$i] =~ s/\s*//;
: } else {
: $fields[$i] = ;
: }
: }

We could use this to eliminate the space between some negative
numbers and the value.

s/\s+//g foreach @fields;


:   if($START_MIN{$ctmp2[0]}  $Ctmp2[$i])
:   {
:$END_MIN{$Ctmp2[0]}=$Ctmp2[$i];
:print INV_RPT_MIN $item~$END_MIN{$Ctmp2[0]}\n;   }
:}

You did say this code didn't work. Finding a minimum value
in an array would require iterating over each element, not just
these.

We don't need any of that to get a minimum value with the
imported min() function.

my $item = shift @fields;

s/\s+//g foreach @fields;

my $minimum = min( @fields );

print INV_RPT_MIN $item~$minimum\n;

: }
: close(INV_RPT);
: close(INV_RPT_MIN);
: ===

As tested:


use strict;
use warnings;

use List::Util 'min';

while ( DATA ) {

my @fields  = split /~\s*/;
my $item= shift @fields;

s/\s+//g foreach @fields;

my $minimum = min( 

Re: questions

2004-10-25 Thread Gunnar Hjalmarsson
M. Ilyas Hassan wrote:
#1 - Is there a way to add days to a date? I want 
end_date=start_date+90days; where start_date is in the format
10/25/04; the output end_date should be in the same format as well. I
was not successful loading the Date::Calc module from CSPAN on
ActivePerl 5 (Revision 5, version 6, Subrevision 1, - 5.006001). Can
some suggest some input.
The standard module Time::Local and the core function localtime() should
be sufficient. The solution at
http://groups.google.com/groups?selm=2pcclbFj9gkjU1%40uni-berlin.de
may give you some ideas.
#2 - How could I find the minimum value from table with say
80columns. The numbers are stored in columns across (from column 2 to
column 6). The output from the input table should retrieve the
minimum value for each unique item in column 0. Does Perl have
aggregate function to get minimum/average and other statistical
values? How should the array/hash be structured.
I pass that one. But I think you need to provide some sample data, and a
serious attempt to solve the problem.
Please email your feedback to [EMAIL PROTECTED]
This is a public mailing list, not a private helpdesk. (I sent you a
copy, but you should really subscribe to the list if you haven't already.)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: questions

2004-10-25 Thread JupiterHost.Net
hi,
Hello,
Could someone please help me with the following perl questions.

#1 - Is there a way to add days to a date? I want 
end_date=start_date+90days; where start_date is in the format 10/25/04; 
the output end_date should be in the same format as well. I was not 
successful loading the Date::Calc module from CSPAN on ActivePerl 5 
(Revision 5, version 6, Subrevision 1, - 5.006001). Can some suggest 
some input.
search.cpan.org
Date::Calc
#2 - How could I find the minimum value from table with say 80columns. 
The numbers are stored in columns across (from column 2 to column 6). 
The output from the input table should retrieve the minimum value for 
each unique item in column 0. Does Perl have aggregate function to get 
minimum/average and other statistical values? How should the array/hash 
be structured.
search.cpan.org
DBI

Please email your feedback to [EMAIL PROTECTED] I will truly 
We will post back to the list so everyone can share. If want personal 
consulting and development feel free to contact me offlist for a quote ;p

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: questions

2004-10-25 Thread Chris Devers
On Mon, 25 Oct 2004, M. Ilyas Hassan wrote:

 #1 - Is there a way to add days to a date?

The modules that the other two respondants pointed you to are the right 
way to do this, but it's good to know that the way to do this by hand -- 
which you won't want to do, but it's good to see why not -- is to only 
deal with times represented as seconds. 

So, for example, 90 days works out to 7776000 seconds (60 secs/min * 60 
mins/hour * 24 hours/day * 90 days).

So you look up the Unix timestamp for the starting date. For this, let's 
use the time as I type this, 1098746228:

$ perl -le 'print scalar localtime 1098746228'
Mon Oct 25 19:17:08 2004
$

You add 90 days worth of seconds to that to get the future date:

$ perl -le 'print 1098746228 + 7776000'
110658
$

And then you convert that back to a more conventional format:

$ perl -le 'print scalar localtime( 1098746228 + 7776000 )'
Sun Jan 23 18:17:08 2005
$

Or, putting it all together:

$ perl -le '$now = 1098746228; $ninety_days = 7776000; $then = $now + 
$ninety_days; print scalar localtime $then'
Sun Jan 23 18:17:08 2005
$

This isn't *that* bad, but the math gets annoying to manage manually. 
Using a module like Date::Calc saves a lot of effort  reduces errors. 

Look up the documentation for Date::Calc for usage detals.

 #2 - How could I find the minimum value from table with say 80columns. 

How is this table represented? Is it in a database? Is it in a flat file 
of some kind? Do you already have it in memory in some kind of data 
structure? 

The approach to this problem depends a lot on what tools you have to 
work with. 

For this, you need to describe where this data is coming from, how you 
are thinking of representing it in variables, and (most important) you 
need to show us what code you've written to solve the problem.

The date problem was a gimme, but this is a larger task with many ways 
it could be solved. You have to show us where you're starting from 
before  you can expect people to fill in the blanks for you.

 Please email your feedback to [EMAIL PROTECTED] I will truly 
 appreciate any help that you could offer.

This seems to be a typo -- all discussion should stay on the list where 
it can be of use to everyone that is trying to learn this stuff. If you 
have not already done so, please subscribe to the list so that we can 
have the conversation on the list.
 

-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Questions related to draw graphy using perl

2004-10-15 Thread Chris Devers
On Fri, 15 Oct 2004, Li, Aiguo (NIH/NCI) wrote:

 Is it possible to create graphs like this using perl?
 
 The graph in my mind should look like this and it will be better to 
 use histogram bar for meta p-values.
  
  
 ---|
  --|
|
   -|
  
Interesting -- that's not one of the typical data visualization 
techniques that most canned tools (from Perl's GD::Graph to, say, 
Excel's chart abilities) usually provide, as far as I know. :-)

Usually on this list, it's expected that people give an overview of what 
they've tried so far, including modules used and code written. In this 
case though, you're asking an interesting but advanced question, and you 
would probably be better off by taking this to the bioperl list:

  Overview:
http://lists.perl.org/showlist.cgi?name=bioperl-l

  Homepage:
http://bioperl.org/mailman/listinfo/bioperl-l

  Archives:
http://bioperl.org/pipermail/bioperl-l/

  Subscribe / Unsubscribe:
http://bioperl.org/mailman/listinfo/bioperl-l

But that said, if you get no help over there, by all means ask away on 
this list. I'm certainly not trying to drive away interesting questions. 

:-)



-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Questions regarding use: optional modules, and refreshing modules

2004-08-31 Thread Wiggins d Anconia
 Folks,
 
 I've run into a couple of issues with use and was hoping someone could
 help me come up with a solution.
 
 First, I use a specific module in a work environment to set some global
 variables. I want to re-use my code in another environment which doesn't
 have the specific configuration module. I don't want to have to keep two
 separate copies of the code. What I currently use in the work
 environment is of the format:
 
 use lib '/path/to/work/modules';
 use Prefs;
 
 my $config = Prefs-new();
 my $param1 = $config-get(PARAM1);
 
 I'd like to something of the format:
 
 my $param1;
 if (-f '/path/to/work/modules/Prefs.pm') {
   use lib '/path/to/work/modules';
   use Prefs;
 
   my $config = Prefs-new();
   $param1 = $config-get(PARAM1);
 }
 else {
   $param1 = default value here;
 }
 
 Is something like this possible?


perldoc -f eval  (2nd form)

Generally you use 'eval' to wrap a segment of code that can die, then
just catch the error and set your default when an error occurs. So in
this case if the module isn't available, can't be loaded (think syntax
error in it), or causes some other error, then the failure will be
caught and you can move on gracefully.

If the examples in the doc aren't sufficient, come back and someone will
provide a good example.
 
 Also, some of the config-style modules I use store their configuration
 values with the module itself. Using the above example Prefs.pm, the
 function $config-get(PARAM1) might look like: 
 
 my $self = shift;
 my $val = shift;
 return $self-{DATA}{$val};
 
 I have code which runs daemonized (using Proc::Daemon) that begins by
 using the Prefs config module. It's quite possible that the parameters
 in the Prefs config module get modified. I may need my daemonized code
 to refresh its copy of the Prefs config module to pull in the new
 parameters. Can this be done, or do I have to stop the daemon and
 restart it?
 
 Thanks all!
 - Ed
 

perldoc -f do

There is an example of this very thing in that doc. In the case of your
daemon, usually you would set up a signal handler, catch the signal
(usually HUP) and re-init the config information when that signal is
received.

perldoc perlipc (for more about signal handling)

There is excellent information about daemons in the Network Programming
with Perl book, I highly recommend it if you have the resources and will
be writing code of this nature.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Questions regarding use: optional modules, and refreshing modules

2004-08-31 Thread Ed Christian
Wiggins d Anconia wrote:
 Folks,
 
 I've run into a couple of issues with use and was hoping someone
 could help me come up with a solution.
 
 First, I use a specific module in a work environment to set some
 global variables. I want to re-use my code in another environment
 which doesn't have the specific configuration module. I don't want to
 have to keep two separate copies of the code. What I currently use in
 the work environment is of the format:
 
 use lib '/path/to/work/modules';
 use Prefs;
 
 my $config = Prefs-new();
 my $param1 = $config-get(PARAM1);
 
 I'd like to something of the format:
 
 my $param1;
 if (-f '/path/to/work/modules/Prefs.pm') {
  use lib '/path/to/work/modules';
  use Prefs;
 
  my $config = Prefs-new();
  $param1 = $config-get(PARAM1);
 }
 else {
  $param1 = default value here;
 }
 
 Is something like this possible?
 
 
 perldoc -f eval  (2nd form)
 
 Generally you use 'eval' to wrap a segment of code that can die, then
 just catch the error and set your default when an error occurs. So in
 this case if the module isn't available, can't be loaded (think
 syntax error in it), or causes some other error, then the failure
 will be caught and you can move on gracefully.
 
 If the examples in the doc aren't sufficient, come back and someone
 will provide a good example. 
 
 Also, some of the config-style modules I use store their
 configuration values with the module itself. Using the above example
 Prefs.pm, the function $config-get(PARAM1) might look like:
 
 my $self = shift;
 my $val = shift;
 return $self-{DATA}{$val};
 
 I have code which runs daemonized (using Proc::Daemon) that begins by
 using the Prefs config module. It's quite possible that the
 parameters in the Prefs config module get modified. I may need my
 daemonized code to refresh its copy of the Prefs config module to
 pull in the new parameters. Can this be done, or do I have to stop
 the daemon and restart it? 
 
 Thanks all!
 - Ed
 
 
 perldoc -f do
 
 There is an example of this very thing in that doc. In the case of
 your daemon, usually you would set up a signal handler, catch the
 signal (usually HUP) and re-init the config information when that
 signal is received.   
 
 perldoc perlipc (for more about signal handling)
 
 There is excellent information about daemons in the Network
 Programming with Perl book, I highly recommend it if you have the
 resources and will be writing code of this nature.  
 
 http://danconia.org

Wiggins,

Thanks for the help! I was hung-up on the notion that every module I
loaded had to be loaded at compile-time. By using the do function, I
can optionally load and/or reload my modules at run-time. My code now
looks like:

my $setting = 'localhost';

if (-f '/usr/local/PerlModules/Prefs.pm') {
do '/usr/local/PerlModules/Prefs.pm';
my $config = Prefs-new();
$setting = $config-read('DB_SERVER');
}

print $setting\n;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: questions about heredocs

2004-07-17 Thread Randy W. Sims
On 7/17/2004 2:08 AM, gohaku wrote:
Hello everyone,
After months of searching perl documentation and books,
I finally found out what those  are called.
What's strange is that I found my answer in a PHP book!
Having seen heredocs in a php script first,
I find Perl's syntax very confusing.
The following works as a php script but not as a perl script (removed 
?php  and ?):

print HTML
head
titleheredoc demo/title
/head
HTML;
 From the sparse examples that I could find with heredocs and perl, the 
former php script
finally becomes a perl script:

print HTML;
head
titleheredoc demo/title
/head
HTML
...onto the questions:
1.)  What's up with the semicolon at the end of the first delimiter?  I 
find that confusing.
statement terminator. It ends the statement. A more obvious example 
would be somthing like:

sub myfunc {
  my $str = shift;
  # do something with $str;
  return str;
}
print myfunc(HTML);
head
titleheredoc demo/title
/head
HTML
Above you can see that the semicolon is only there to end the statement 
that contains the here-document.

2.)  No documentation was found for [perldoc heredoc] and [perldoc 
heredocs],
where is the documentation or examples that illustrate how to use 
heredocs in perl?
perldoc perldata
perldoc perlop
search for 'here-doc'
3.)  How are heredocs stored in variables?
here-documents just provide a simple way of representing strings. there 
is nothing special about them.

Thanks in advance.
-gohaku
Regards,
Randy.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: questions about heredocs

2004-07-17 Thread Gunnar Hjalmarsson
Gohaku wrote:
1.)  What's up with the semicolon at the end of the first
delimiter?  I find that confusing.
If you prefer, you can put the semicolon after the terminator in Perl
as well, as long as you don't put it at the same line as the
terminating string. By doing so, it's easier to preserve indenting:
my $html =html\n;
$html .= HTML
head
titleheredoc demo/title
/head
HTML
;
print $html;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: questions and understanding

2004-06-30 Thread Randy W. Sims
[EMAIL PROTECTED] wrote:
All, 

I was playing with my code and after re-reading perdoc perlre, I still do 
not understand the items in yellow and their need.
items in yellow???
here is my code.
open(F,$ARGV[0]) || die dick face: $!\n;
$i=0;
print -w ';
#print $i;
while (F) {
chomp($_); 
if ($i  0) {
print  or ;
} 
$i++; 
print barcode=\$_\ ;
}
print \'\n;

I will start from the bottom up:
Why do I need or what is the significance of  print \ ' \n;  I really do 
not need the first \ !
You're correct. The backslash is not needed to escape single quotes 
within double quotes.

At line print barcode it seems that  do need the \ $_\ ; as when I take 
the \'s away I get these errors which I am not understanding:
Double quotes must be quoted within double quotes. Otherwise, perl will 
think the string has ended. In the above example it would be translated as:

print barcode= $_  ;
And as the error below says, if this is your intention, their should be 
an operator before and after the $_ in order for it to be a valid 
instruction.

If you want to use the double quotes in a string without the esapes, you 
can use a differnet quote character for your string:

print qq{barcode=$_ };
Read the section Quote and Quote-like operators in `perldoc perlop`
Scalar found where operator expected at parse_for_ejects.pl line 11, near 
barcode=$_
(Missing operator before $_?)
String found where operator expected at parse_for_ejects.pl line 11, near 
$_ 
(Missing operator before  ?)
syntax error at parse_for_ejects.pl line 11, near barcode=$_
parse_for_ejects.pl had compilation errors.

Randy.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: questions about bind_param and mysql trace data included

2004-05-11 Thread Brad Lhotsky
Try this:

On Tue, May 11, 2004 at 12:51:28PM -0700, [EMAIL PROTECTED] wrote:
 
 
 below I have a snippet from a trace file read out for a section of code below. The 
 problem seems to be with '$sth-bind_param (2,$rh_row-{prop_str_addr});' The first 
 Bind works fine however the next one in the line listed produces a null entry per 
 the trace file. I have verified that the data is correct in 
 '$rh_row-{prop_str_addr}' and that it is quoted but for some reason myql isn't 
 recieving the data any help would be appreciated.
 
 - dbd_st_execute 0 rows
 - execute= '0E0' at db_load_1-2.pl line 128
 - bind_param for DBD::mysql::st (DBI::st=HASH(0x8104f14)~0x8104e3c 1 
 ''310-673-5515'')
 - bind_param= 1 at db_load_1-2.pl line 122
 - execute for DBD::mysql::st (DBI::st=HASH(0x8104f14)~0x8104e3c)
 - dbd_st_execute for 08104e48
   Binding parameters: UPDATE own_info
SET own_phone_home = '\'310-673-5515\''
WHERE own_str_addr = NULL
 
 
 
 ###CODE SNIPPETTE
 $dbh = connect_try(**,**);
 foreach $k (keys (%{$ar_info-[1]})){ # retrieves a generic set of fields and 
 uses them to assign values for each row.
 if ($table eq prop_info){ # checks which table is being used and assigns 
 the correct SQL statement
 $sth = $dbh-prepare (UPDATE prop_info
SET $k = ?
WHERE prop_str_addr = ?) or
err_trap(failed to prepare statement\n);
 }elsif ($table eq own_info){
 $sth = $dbh-prepare (UPDATE own_info
SET $k = ?
WHERE own_str_addr = ?) or
err_trap(failed to prepare statement\n);
 
 
 }
 $sth-trace(2, ./trace_data.txt);
 foreach $rh_row (@$ar_info) { # iterates through the list of rows and 
 assigns the correct value to the field
 print ::$k=$rh_row-{$k}; # this is an internal check to verify what 
 values are being inserted
 $sth-bind_param (1,$rh_row-{$k});

  if($table eq 'prop_info') {

 if ($table eq prop_str_addr) {
 $sth-bind_param (2,$rh_row-{prop_str_addr});
 }elsif  ($table eq own_str_addr) {
 $sth-bind_param (2,$rh_row-{own_str_addr});
 }
 $sth-execute() or
 err_trap(failed to execute statement\n);
 
 }
 print \n===\n;
 
 }
 $sth-finish();
 $dbh-disconnect or
 err_trap(failed to disconnect statement\n);
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 

-- 
Brad Lhotsky [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Questions about game design in perl

2004-04-07 Thread R. Joseph Newton
Morbus Iff wrote:

  I am trying to build a game in perl. I have questions.
  This is a story book game... here is the story, make a choice
  next page..here is the story, make a choice

 I'd love to see what you come up with.
 Games and Perl is close to my heart.

WTF does this have to do with the confusion between NULL and Perl's udef [New To
Perl], the thread on which you replied?

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Questions about game design in perl

2004-04-07 Thread Morbus Iff
 I'd love to see what you come up with.
 Games and Perl is close to my heart.

WTF does this have to do with the confusion
between NULL and Perl's udef [New To
Perl], the thread on which you replied?
I suspect a good amount of people have no clue
the purpose of a Message-ID/References, much less how
replying to the wrong one (ie. I don't feel like typing
the To: address myself) and then rewriting the subject
line can cause havoc with archivers and threaders.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions about game design in perl

2004-04-07 Thread R. Joseph Newton
R. Joseph Newton wrote:

 Morbus Iff wrote:

   I am trying to build a game in perl. I have questions.
   This is a story book game... here is the story, make a choice
   next page..here is the story, make a choice
 
  I'd love to see what you come up with.
  Games and Perl is close to my heart.

 WTF does this have to do with the confusion between NULL and Perl's udef [New To
 Perl], the thread on which you replied?

 Joseph

Sorry, I sanpped at the wrong post.  Still I wish those replying had redirected this
back to the main index [by start a new message using the title line] before replying

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Questions about game design in perl

2004-04-07 Thread WC -Sx- Jones
Morbus Iff wrote:
I suspect a good amount of people have no clue
the purpose of a Message-ID/References, much less how
replying to the wrong one (ie. I don't feel like typing
the To: address myself) and then rewriting the subject
line can cause havoc with archivers and threaders.


Just as bad are MUAs which do not honor
the Message-ID/References and start a new
thread EVEN when they actually do reply to
a post in a proper manner...
SUN's dtmail - even within Solaris 9 -
is guilty of this...  You listening SUN?
--
http://www.usenix.org/publications/perl/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions about game design in perl

2004-04-07 Thread Luinrandir Hernsen
Hey
What ever I did I'm sorry. Obvisious ly it upset someone...
I'm gone.. you guys are way to uptight about little shit

L Hernsen

- Original Message - 
From: WC -Sx- Jones [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, April 07, 2004 12:00 PM
Subject: Re: Questions about game design in perl


 Morbus Iff wrote:
  I suspect a good amount of people have no clue
  the purpose of a Message-ID/References, much less how
  replying to the wrong one (ie. I don't feel like typing
  the To: address myself) and then rewriting the subject
  line can cause havoc with archivers and threaders.
 
 
 Just as bad are MUAs which do not honor
 the Message-ID/References and start a new
 thread EVEN when they actually do reply to
 a post in a proper manner...
 
 SUN's dtmail - even within Solaris 9 -
 is guilty of this...  You listening SUN?
 
 -- 
 http://www.usenix.org/publications/perl/
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Questions about game design in perl

2004-04-07 Thread Ned Cunningham
Hey don't go.  Some times people get cranky.
There are still a lot of smart people that are willing to help here.

Just ignore the not so smart ones ;) 



Ned Cunningham
POS Systems Development
Monro Muffler Brake
200 Holleder Parkway
Rochester, NY 14615
(585) 647-6400 ext. 310
[EMAIL PROTECTED]

There are two ways of constructing a software design; one way is to make it so simple 
that there are obviously no deficiencies, and the other way is to make it so 
complicated that there are no obvious deficiencies. The first method is far more 
difficult. 

-Original Message-
From:   Luinrandir Hernsen [mailto:[EMAIL PROTECTED]
Sent:   Wednesday, April 07, 2004 12:30 PM
To: [EMAIL PROTECTED]
Subject:Re: Questions about game design in perl

Hey
What ever I did I'm sorry. Obvisious ly it upset someone...
I'm gone.. you guys are way to uptight about little shit

L Hernsen

- Original Message - 
From: WC -Sx- Jones [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, April 07, 2004 12:00 PM
Subject: Re: Questions about game design in perl


 Morbus Iff wrote:
  I suspect a good amount of people have no clue
  the purpose of a Message-ID/References, much less how
  replying to the wrong one (ie. I don't feel like typing
  the To: address myself) and then rewriting the subject
  line can cause havoc with archivers and threaders.
 
 
 Just as bad are MUAs which do not honor
 the Message-ID/References and start a new
 thread EVEN when they actually do reply to
 a post in a proper manner...
 
 SUN's dtmail - even within Solaris 9 -
 is guilty of this...  You listening SUN?
 
 -- 
 http://www.usenix.org/publications/perl/
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Questions about game design in perl

2004-04-07 Thread WC -Sx- Jones
Luinrandir Hernsen wrote:
Hey
What ever I did I'm sorry. Obvisious ly it upset someone...
I'm gone.. you guys are way to uptight about little shit


Well, I wasn't speaking about you - only
to Sun Microsystems...
Give us another chance...
--
http://www.usenix.org/publications/perl/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions about game design in perl

2004-04-07 Thread WC -Sx- Jones
Ned Cunningham wrote:
Hey don't go.  Some times people get cranky.
There are still a lot of smart people that are willing to help here.
Just ignore the not so smart ones ;) 

...

And especially those MUAs which refuse to chop off the
freaking LONG footers...  Oh well... I am not even gonna
start about all the CC'ing people even though the list is
here - public - for al (peggy, bud, and kelly) to read.
-Sx-

[EMAIL PROTECTED]

There are two ways of constructing a software design; one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult. 

...
These footers here ...
		 -- 
		 To unsubscribe, e-mail: [EMAIL PROTECTED]
		 For additional commands, e-mail: [EMAIL PROTECTED]
		 http://learn.perl.org/ http://learn.perl.org/first-response
		 

		-- 
		To unsubscribe, e-mail: [EMAIL PROTECTED]
		For additional commands, e-mail: [EMAIL PROTECTED]
		http://learn.perl.org/ http://learn.perl.org/first-response

		



--
http://www.usenix.org/publications/perl/
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



[OT] Re: Questions about game design in perl

2004-04-07 Thread Morbus Iff
Give us another chance...

For what it's worth, giving up on the list this early in the
game doesn't impress me very much. If someone wants to be that
close-minded [1] without further investigation [2], then good
riddance - they're not gonna make good programmers, so why waste
our time [3] trying to dissect their lack of language and grammar?
I, personally, have never killfiled or filtered anyone - I
have yet to meet someone that doesn't entertain me with
mirth or intelligence at least once in their life. I'm
always ready for a second helping.
[1] abrupt, assumptionary, out to get me, etc.
[2] mailing list archives, assuming only you and I speak, etc.
[3] Use MySQL! five minutes later I installed it. Now what?
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions about game design in perl

2004-04-06 Thread Morbus Iff
I am trying to build a game in perl. I have questions.
This is a story book game... here is the story, make a choice
next page..here is the story, make a choice
I'd love to see what you come up with.
Games and Perl is close to my heart.
1-Do I set up the login file (password name and your game details)
in one big file, or in many files, one file per player?
Depends - if you expect the game to get any substantial amount
of hits, you'd really want it in a MySQL database. Likewise, if
you plan on getting zillions of users, managing them in a single
file is going to get rather slow and cumbersome rather quickly.
Likewise, one little bug is gonna wipe out your entire userbase.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture: http://www.disobey.com/ and http://www.gamegrene.com/
Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom
icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions about game design in perl

2004-04-06 Thread James Edward Gray II
On Apr 6, 2004, at 2:11 PM, Luinrandir Hernsen wrote:

Hallo
Howdy.

I am trying to build a game in perl. I have questions.
This is a story book game... here is the story, make a choice
next page..here is the story, make a choice
Are we talking Interactive Fiction, or where you referring to actual 
audio files?  Sounded like a Choose your own Adventure Audio Book, am I 
right?

Is this online, or an actual executable?

1-Do I set up the login file (password name and your game details)
in one big file, or in many files, one file per player?
How many users are we talking about here?  How much information is 
included in game details?

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions about game design in perl

2004-04-06 Thread WC -Sx- Jones
Luinrandir Hernsen wrote:
1-Do I set up the login file (password name and your game details)
in one big file, or in many files, one file per player?


Have you seen PostgresSQL and Bricolage?
Maybe at least a good templatingsystem?
I would only use one file per play for config data
on each player -- but the core data and interaction
will likely need to be database-centric and driven.
-Sx-

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: More Details --- Re: Questions about game design in perl

2004-04-06 Thread James Edward Gray II
Let's keep this discussion on the list so all can learn and help.

On Apr 6, 2004, at 3:08 PM, Luinrandir Hernsen wrote:

This will be a multi player game

Interactive fiction-yes
No audio files
Have you ever heard of Zork Books?
No, but I believe I'm getting the idea now.

Basically, you get a piece of the story, make a decision, and click on 
the
link to that decision.
more story, more choices... but in a large , multi city setting.

many players
I agree with what others have said.  A database backend is probably the 
way to go.

James

The players file will be reffereenced to see what tools you have, and 
allow
for movement options accordingly.

I am working on a simple sample game to show you

Thanks
Lou
- Original Message -
From: James Edward Gray II [EMAIL PROTECTED]
To: Luinrandir Hernsen [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 3:26 PM
Subject: Re: Questions about game design in perl

On Apr 6, 2004, at 2:11 PM, Luinrandir Hernsen wrote:

Hallo
Howdy.

I am trying to build a game in perl. I have questions.
This is a story book game... here is the story, make a choice
next page..here is the story, make a choice
Are we talking Interactive Fiction, or where you referring to actual
audio files?  Sounded like a Choose your own Adventure Audio Book, am 
I
right?

Is this online, or an actual executable?

1-Do I set up the login file (password name and your game details)
in one big file, or in many files, one file per player?
How many users are we talking about here?  How much information is
included in game details?
James




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions about game design in perl

2004-04-06 Thread JupiterHost.Net
Hallo
Hello

I am trying to build a game in perl. I have questions.
This is a story book game... here is the story, make a choice
next page..here is the story, make a choice
cool

1-Do I set up the login file (password name and your game details)
in one big file, or in many files, one file per player?


That's really up to your wants/needs. I'd use a MySQL db if I were doing 
 it.

Lee.M - JupiterHost.Net

Thanks
Lou
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: More Details --- Re: Questions about game design in perl

2004-04-06 Thread Luinrandir Hernsen
I went to www.MySQL.com
Do I download for windows and DBI for perl
do I need

Contributed APIs:
DBI -- for connecting to MySQL from Perl

I downloaded MySQL 4.0

I have OptiPerl, which I use top write perl
I have windows 98.
My Web Host has Unix.

I kow how to parse a variable... but still need to know how to pass
variables with the HIDDEN INPUT command from web page to web page that perl
generates.

Thanks for your help again
Lou




- Original Message - 
From: James Edward Gray II [EMAIL PROTECTED]
To: Luinrandir Hernsen [EMAIL PROTECTED]
Cc: Perl Beginners [EMAIL PROTECTED]
Sent: Tuesday, April 06, 2004 4:48 PM
Subject: Re: More Details --- Re: Questions about game design in perl


 Let's keep this discussion on the list so all can learn and help.

 On Apr 6, 2004, at 3:08 PM, Luinrandir Hernsen wrote:

  This will be a multi player game
 
  Interactive fiction-yes
  No audio files
  Have you ever heard of Zork Books?

 No, but I believe I'm getting the idea now.

  Basically, you get a piece of the story, make a decision, and click on
  the
  link to that decision.
  more story, more choices... but in a large , multi city setting.
 
  many players

 I agree with what others have said.  A database backend is probably the
 way to go.

 James

  The players file will be reffereenced to see what tools you have, and
  allow
  for movement options accordingly.
 
  I am working on a simple sample game to show you
 
  Thanks
  Lou
 
 
  - Original Message -
  From: James Edward Gray II [EMAIL PROTECTED]
  To: Luinrandir Hernsen [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Sent: Tuesday, April 06, 2004 3:26 PM
  Subject: Re: Questions about game design in perl
 
 
  On Apr 6, 2004, at 2:11 PM, Luinrandir Hernsen wrote:
 
  Hallo
 
  Howdy.
 
  I am trying to build a game in perl. I have questions.
  This is a story book game... here is the story, make a choice
  next page..here is the story, make a choice
 
  Are we talking Interactive Fiction, or where you referring to actual
  audio files?  Sounded like a Choose your own Adventure Audio Book, am
  I
  right?
 
  Is this online, or an actual executable?
 
  1-Do I set up the login file (password name and your game details)
  in one big file, or in many files, one file per player?
 
  How many users are we talking about here?  How much information is
  included in game details?
 
  James
 
 


 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: More Details --- Re: Questions about game design in perl

2004-04-06 Thread WC -Sx- Jones
Luinrandir Hernsen wrote:
I went to www.MySQL.com
Do I download for windows and DBI for perl
do I need
Contributed APIs:
DBI -- for connecting to MySQL from Perl
I downloaded MySQL 4.0

Your MySQL database should be installed and
functioning on Unix then.

I have OptiPerl, which I use top write perl
I have windows 98.
My Web Host has Unix.
I kow how to parse a variable... but still need to know how to pass
variables with the HIDDEN INPUT command from web page to web page that perl
generates.


That is an HTML question...  You would use the HTML input
hidden attribute. http://htmlref.com/reference/appa/tag_input.htm
Here is a very OLD and Generic example CGI; please ask further
Perl CGI on the Beginners CGI Perl list.  I read that list as
well and can continue helping you there with other CGI programmers...
http://www.cpan.org/authors/id/S/SN/SNEEX/WebPass.perl-Sx

-Sx-

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Questions of OOP in Perl

2003-08-14 Thread James Edward Gray II
On Wednesday, August 13, 2003, at 12:34  AM, R. Joseph Newton wrote:

Pablo Fischer wrote:

Thanks!

After sending my question I found in a website the topic of 'private' 
methods,
and shows code like this:

my $method_name = sub {
my $this = shift;
_blablabla_
};
And to access it :

$this-$method_name(Arg1);

Now, this it really works for 'private' methods?
This is the standard Perl way to create private methods, yes.  The 
subroutine is only available within the scope of the my variable, 
generally your module.

Perl has no private methods.  Only polite conventions concerning which 
methods
should be called from outside the pm file.
Uh, did you read the question?  :)  That looks like a pretty text book 
perfect private method to me, but please correct me if I'm wrong.

I believe what Joseph meant to say is the Perl doesn't have a 'private' 
keyword, like many OO languages.  However, Perl generally gives you the 
tools to do what needs to be done, just as you show above.  I disagree 
that Perl doesn't have private methods.

The real meat of Joseph's message is that most OO Perl programmers feel 
that what you show above is seldom called for.  While most languages 
give you the tools to lock things down as tight as possible, Perl 
prefers the If you push the big red button marked 'Do Not Touch!', 
don't come crying to us philosophy.  Generally, saying 'Hands Off' 
works in Perl land.  If they mess with it after that, they knew what 
they were getting into and deserve whatever pain they get.

There are even some instances where security hurts users.  By way of 
example, Perl's OO system is known to have a good bit of overhead and 
thus be a little on the slow side of execution.  Accessors, while a 
great OO principal, generally show off this slowdown, in a bad light.  
In Perl though, what you usually have as your object reference is a 
blessed hash.  Is there really a good reason you can do your own hash 
lookup?  For some objects, sure there is, but a lot of the time I think 
read-only hash access of an object's data is fine, especially when 
speed really counts.  Heck, document this in your module and list is as 
a feature, when you can.  Instead of straight jacketing Perl into Good 
OO Behavior, use Perlisms to your advantage.

Of course, just to be thorough I need to say, there are definitely 
times when security IS called for.  Most Perl guys don't think they're 
as often as the Encapsulation Fanatics would have you believe, but they 
definitely exist.  As the programmer, it's your job to determine when 
those situations arise and employ the proper amount of paranoia.  With 
great power comes great responsibility, as they say.  Make good choices.

One way to communicate this is simply to document only public methods 
using the emedded donumentation format, and use standard comments for 
any necessary explanation of internal methods.
Another popular convention is to start any Perl identifier (variable 
name, subroutine name, etc.) with a _ when you want to tell users it's 
important stuff only you need to handle.  Many modules follow this and 
some will even help you enforce it, when you do need the security.

James Gray

Joseph

--
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: Questions of OOP in Perl

2003-08-14 Thread Tassilo von Parseval
On Fri, Aug 08, 2003 at 12:05:47AM + Pablo Fischer wrote:

 I have some questions about OOP in Perl.
 
 1. In my class I have lot of methods, but some of them just parse a file or 
 pass a string to a different format (like in C, Im thinking that they are 
 private), In perl, whats the better way to call a private method:
 
 $state = $this-city2state(Arg1);
 
 and in the citystate have
 
 sub city2state {
   my $this = shift;
   my $city = $_[0];
 
 ...MoreCode..
 }

That's an ordinary method call. Nothing wrong with that. Nonetheless I'd
write

my ($this, $city) = @_;

inside the method.

 Or this way
 
 $state = city2state(Arg1);
 
 and in citystate have
 
 sub citystate {
   my $city = $_[0];
 
 MoreCode..
 }

No. This is a plain function call. city2state() is now no longer a
method and wouldn't obey to inheritance either, for example.

With 'private', do you perhaps really mean 'static'? That is, the object
on which the method was called, isn't actually used? If so, call it as a
class method:

Your::Class-city2state(Arg1);

sub city2state {
my ($class, $city) = @_;
# $class is now Your::Class and can be ignored if you want
}

 Which is the correct way? Im confused if I need to use $this for public and 
 private methods or no..

If you really mean private versus public this is a different story.
Whatever you call the object inside your methods should be of no concern
for the interface. If you call it $this or $self or $mona_lisa is up to
you.

There is however a certain convention in Perl to make private methods
look private by prepending an underscore:

$obj-_private;

Of course, perl just doesn't care and _private() can still be accessed
by anyone who gets hold of it. 

 2. Exists an special nomenclature, like Arrays need to be in capital letters 
 and scalar variables not.

Not in this way. The nomenclature is to use lowercase names for lexical
variables (so it's $this, not $This and certainly not $THIS). Globals
should be all uppercased ($GLOBAL). As for things like $Variable, I am
not sure. I haven't often seen them so it is usually either only
lowercase or uppercase.

One final thing about method names: make them lowercase and use
underscores to separate words. This looks Perl-ish:

$obj-get_attribute;

while this looks Java-ish and is harder to read:

$obj-getAttribute;

Tassilo
-- 
$_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval


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



Re: Questions of OOP in Perl

2003-08-14 Thread R. Joseph Newton
Pablo Fischer wrote:

 Thanks!

 After sending my question I found in a website the topic of 'private' methods,
 and shows code like this:

 my $method_name = sub {
 my $this = shift;

 _blablabla_
 };

 And to access it :

 $this-$method_name(Arg1);

 Now, this it really works for 'private' methods?


Perl has no private methods.  Only polite conventions concerning which methods
should be called from outside the pm file.  One way to communicate this is simply
to document only public methods using the emedded donumentation format, and use
standard comments for any necessary explanation of internal methods.

Joseph


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



Re: Questions of OOP in Perl

2003-08-09 Thread Pablo Fischer
Thanks!

After sending my question I found in a website the topic of 'private' methods, 
and shows code like this:


my $method_name = sub {
my $this = shift;

_blablabla_
};


And to access it :

$this-$method_name(Arg1);

Now, this it really works for 'private' methods?

Thanks!
-- 
Pablo Fischer Sandoval ([EMAIL PROTECTED])
http://www.pablo.com.mx
http://www.debianmexico.org
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131  AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt

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



Re: questions

2001-10-25 Thread Mark Bergeron

I know this is a beginner's list. And, we have all been at the point of starting out 
but, you've get to explain your situation a bit better than this. What window?, do you 
want to collapse a window during a process and have it post something on after the 
completion of another process. In front?, behind?. this kind of info would help 
evaluate your situation and advise you of what path to take.

P.S. take your time. no one will poke fun. and if they do, shame on THEM.

-Original Message-
From: Gary M Rocco[EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Date: Thu Oct 25 07:37:53 PDT 2001
Subject: questions

hi!

please consider the following:

i downloaded the perl source from active state. is there an index of 
commands/instructions with syntax rules included in the download?  if not, where 
might i find one?

i am using windows 98.  must i run scripts from the dos prompt?

how can perl be used to make a minimized window active again(i am not asking for 
someone to write a program for me, just to point me in the right direction--what 
instructions to look at, etc.)

thank you!

gary rocco

____ 
| _ ) ___  ___ | |
| _ \/ _ \/ _ \|_|
|___/\___/\___/(_)
___
GO.com Mail
Get Your Free, Private E-mail at http://mail.go.com



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