[17985] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 145 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 25 18:27:56 2001

Date: Thu, 25 Jan 2001 15:10:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980464217-v10-i145@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 25 Jan 2001     Volume: 10 Number: 145

Today's topics:
    Re: NET::TELNET <anonymous@anonymous.anonymous>
    Re: Perl and Java <jdf@pobox.com>
    Re: perl editors (Gregory Spath)
    Re: perl editors <mjcarman@home.com>
    Re: perl editors tebrusca@my-deja.com
    Re: perl editors <anonymous@anonymous.anonymous>
    Re: Perl is bad at (very) simple math! <juex@deja.com>
    Re: Perl is bad at (very) simple math! (Eric Bohlman)
    Re: Possible to UNset a Cookie? (Mark Jason Dominus)
        Problem with Tie::StdHash / FETCH ?? nexus6_kills@yahoo.com
        regex question <chrisw@ec2.edu>
    Re: regex question <sumus@aut.dk>
    Re: REQ: help about tainting in regex <joe+usenet@sunstarsys.com>
    Re: right place for a mod_perl question? (Villy Kruse)
    Re: right place for a mod_perl question? (Mark Jason Dominus)
    Re: right place for a mod_perl question? (Gary E. Ansok)
        simple question for probably all of you... about @ <verdien_guldens@hotmail.com>
    Re: Split string into two arrays <Kien_Ha@Mitel.COM>
    Re: Split string into two arrays (Craig Berry)
    Re: stock market simulator <vincentg@datashaping.com>
    Re: String comparing? <juex@deja.com>
    Re: Type globs <bart.lateur@skynet.be>
    Re: Very newbie question (Mark Jason Dominus)
    Re: What's wrong with this script? (Mark Jason Dominus)
    Re: What's wrong with this script? <kkk@elrancho.com>
    Re: What's wrong with this script? (Mark Jason Dominus)
    Re: What's wrong with this script? (Mark Jason Dominus)
    Re: What's wrong with this script? <kkk@elrancho.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 25 Jan 2001 17:59:40 -0500
From: Anonymous <anonymous@anonymous.anonymous>
Subject: Re: NET::TELNET
Message-Id: <6sb17tsrm9u38d13n0muln6a4fod4m8idj@4ax.com>

On Tue, 23 Jan 2001 17:32:41 -0500, a246456 <a246456@fmr.com> wrote:

>I am trying to do telnet to a list of servers from a file, if it fails
>to connect to server then it has to generate alert saying it cannot
>connect to that host and contiue. And also checks for valid username and
>password, else it prints saying invalid username/password.. Somehow i am
>not able to achieve this. I think i am doing some stupid thing inside
>the loop.
>Thanks inadvance..
>
>$username ="tng";
>$passwd ="c\@tng_98";
>
>open(FH, "host.txt") || die "File host.txt not found\n";
>
>while($host=<FH>){ #process list of servers from a file.
>use Net::Telnet ();
>chomp($host);
>$t = new Net::Telnet (Timeout => 300, Errmode => "return",
>                      Prompt => '/[\$%#>] $/');
>
> if($t->open($host))  #check for telnet connection
> {
>   if($t->login(Name => $username,
>           Password => $passwd))         #check username & password is
>valid
>    {
>     @lines = $t->cmd("uname -a");
>     print @lines;
>     print "\n\n";
>     @lines = $t->cmd("whoami");
>     print @lines;
>
>   else {
>     print "Unable to connect $host\n";   #print if it cannot connect to
>server.
>    }
> else{
> print "Invalid username/password $host\n"; #print if username/password
>is incorrect.
>       }
>      }
>}
>exit;
>close(FH);


Right off the top, I wouldn't put the "use" inside the loop - once at the start instead.

Also, what errors are you getting - its hard to diagnose w/o symptoms.

  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


------------------------------

Date: 25 Jan 2001 15:16:16 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Perl and Java
Message-Id: <hf2n5qwf.fsf@pobox.com>

"Géry" <ducateg@info.bt.co.uk> writes:

> I want to stream a perl hash to populate a hash table in a java
> piece of code.

You already said so four hours before this second posting.  I replied
to the first.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: Thu, 25 Jan 2001 20:51:56 -0000
From: gspath@freefall.homeip.net (Gregory Spath)
Subject: Re: perl editors
Message-Id: <slrn9714c0.2g5.gspath@freefall.homeip.net>

In <94pg91$578@fidoii.CC.Lehigh.EDU>, Phil R Lawrence (prlawrence@lehigh.edu) wrote:
>"hanja" <hanja@my-deja.com> wrote:
>> Out of curiousity, what editor do you use to write your scripts?
>TextPad
>
>Phil R Lawrence
>
>

vi & gvim

-- 
Gregory Spath              
gspath@freefall.homeip.net   http://freefall.homeip.net/
SCHeckler on IRC ----------> http://freefall.homeip.net/javairc/
Team YBR ------------------> http://www.yellowbreechesracing.org/


------------------------------

Date: Thu, 25 Jan 2001 12:44:48 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: perl editors
Message-Id: <3A707420.60CC1653@home.com>

hanja wrote:
> 
> Out of curiousity, what editor do you use to write your scripts?

UltraEdit on Win*, vi on *nix.

-mjc


------------------------------

Date: Thu, 25 Jan 2001 21:25:23 GMT
From: tebrusca@my-deja.com
Subject: Re: perl editors
Message-Id: <94q5jn$68g$1@nnrp1.deja.com>

In article <94np7f$483$1@nnrp1.deja.com>,
  hanja <hanja@my-deja.com> wrote:
> Out of curiousity, what editor do you use to write your scripts?

gvim on NT

I wrote several s/// type macros and it allows you to apply these
macros to highlighted sections.  Also lets you put your macros
in a menu.

vi on Unix



Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Thu, 25 Jan 2001 18:07:57 -0500
From: Anonymous <anonymous@anonymous.anonymous>
Subject: Re: perl editors
Message-Id: <fdc17t8hp5jsdushtotupqtaqtm4edjajj@4ax.com>

On Thu, 25 Jan 2001 02:42:29 +0100, Tore Aursand <tore@extend.no> wrote:

>In article <94np7f$483$1@nnrp1.deja.com>, hanja@my-deja.com says...
>> Out of curiousity, what editor do you use to write your scripts?
>
>Linux: fte
>Win32: fte
>
>:-)
>
>Search for it at www.sourceforge.net.  It haven't been updated for 
>ages, but works like a dream; small, fast and does what it should do.


Multi-Edit.  Great automatic language expansion.

  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


------------------------------

Date: Thu, 25 Jan 2001 13:07:16 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: Perl is bad at (very) simple math!
Message-Id: <3a709584$1@news.microsoft.com>

"Michael Stopp" <stopp@eye.ch> wrote in message
news:3A6EB808.D80DD247@unibas.ubaclu.ch...
> Can anybody explain why a perl script as simple as this can fail?
>
> $a = 5.1;
> $b = 5;
> print $a-$b, "\n";
>
> This produces:
> 0.0999999999999996

The script didn't fail at all.
I guess you missed the numerics class at university?

        Thou shalt not use floating point numbers if expecting accurate
results

This is one of the most basic rules of computing.

jue




------------------------------

Date: 25 Jan 2001 22:10:17 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Perl is bad at (very) simple math!
Message-Id: <94q889$3aq$1@bob.news.rcn.net>

"Jürgen Exner" <juex@deja.com> wrote:
> I guess you missed the numerics class at university?

>         Thou shalt not use floating point numbers if expecting accurate
> results

Er, that's the "freshman/sophomore" version of the rules.  The 
"junior/senior" version is full of details like "thou shalt arrange thy 
calculations so that thou never subtractest floating point numbers that 
are nearly identical."  It *is* possible to get accurate results from 
floating-point calculations, it's just not intuitive how to do it (for 
example, the textbook shortcut formula for computing a standard deviation 
in one pass is a classic example of a calculation that isn't accurate in 
floating point.  One of the accurate algorithms maintains a provisional 
mean and has a variable that accumulates signed deviations from it; this 
variable enters into the final calculation, even though mathematically it 
must be zero.  Numerically, though, it usually isn't).



------------------------------

Date: Thu, 25 Jan 2001 19:18:06 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Possible to UNset a Cookie?
Message-Id: <3a707bed.1999$3bd@news.op.net>
Keywords: Rotarian, chair, ease, sore


In article <t70olbbc8dq275@corp.supernews.com>,
Stuart Carroll  <scarroll@sci-design.com> wrote:
>I've figured out how to set a cookie, and retreive it - but is it possible 
>to UNset the cookie?

Yes.  When you sent a cookie, you may specify an expire time.  If the
expire time is in the past, the browser is supposed to forget the
cookie. 

The easy way to do this is to use the CGI module that comes with Perl:

        use CGI;
        my $cookie = CGI->cookie(-name => 'userid',
                                 -value => $userid,
                                 -expires => '-1d',  # "yesterday"
                                );

then

        print "Set-Cookie: $cookie\n";

Hope this helps.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: Thu, 25 Jan 2001 21:36:53 GMT
From: nexus6_kills@yahoo.com
Subject: Problem with Tie::StdHash / FETCH ??
Message-Id: <94q69k$6ru$1@nnrp1.deja.com>

Hi Folks,

I posted the following problem a few days ago but did not
get any response, so I am posting it again. I have also
pursued other channels (to have the problem fixed) with
out and feedback. I would appreciate if anyone has any
idea about the misbehavior of the program.

Thanks in advance.

------------------------------------

The problem that I am encountering is shown in the example
file below (sorry for the length, but it is as short as I
could make it). In "package main", I have listed the seven
cases which I would like to make work. The last two cases
do not work. I would like to know why they don't work. I
understand that it has something to do with copy, but some
help would be appreciated.

The code below can be executed as is; you will get the
message:

"Can't use an undefined value as an ARRAY reference ..."


#!/usr/local/bin/perl -w

#===============================================================================
package MyPackage_1;

use Tie::Hash;

@ISA = (Tie::StdHash);

sub new
{
    my ($className) = shift;
    my $self = {};

    bless ($self, $className);
    $self->{key_1} = "val_1";
    $self->{key_2} = "val_2";

    my %retHash;
    tie %retHash, $className, $self;
    return bless \%retHash, $className;
}

sub TIEHASH
{
    my ($className, $obj) = @_;
    return bless $obj, $className;
}

sub FETCH
{
    my ($self, $key) = @_;
    my ($rhs) = $self->{$key};
    $rhs = &$rhs if (ref($rhs) eq "CODE");
    return $rhs;
}

#===============================================================================
package MyPackage_2;

use Tie::Hash;

@ISA = (Tie::StdHash);

sub new
{
    my ($className, $pkg_1) = @_;

    my $self = {};
    bless ($self, $className);

    $self->{DEPS}->{pkg_1} = $pkg_1;
    $self->{the_keys} = sub { return [$self->{DEPS}->{pkg_1}->{key_1},
                                      $self->{DEPS}->{pkg_1}->{key_2}];
};
    $self->{the_keys_2} = sub { return ["foo", "bar"]; };

    my %retHash;
    tie %retHash, $className, $self;
    return bless \%retHash, $className;
}

sub TIEHASH
{
    my ($className, $obj) = @_;
    return bless $obj, $className;
}

sub FETCH
{
    my ($self, $key) = @_;
    my ($rhs) = $self->{$key};
    $rhs = &$rhs if (ref($rhs) eq "CODE");
    return $rhs;
}

#===============================================================================
use strict;

package main;

sub printArray
{
    my (@arr) = @_;

    foreach my $m (@arr) {
        print "+ ", $m;
    }
    print "\n";
}

my $pkg_1 = new MyPackage_1 ();
my $pkg_2 = new MyPackage_2 ($pkg_1);

my ($n);

#--- Case 1 (works)
my ($theArrRef) = $pkg_2->{the_keys};
foreach $n (@{$theArrRef}) {
    print " ", $n;
}
print "\n";

#--- Case 2 (works)
print join (" : ", @{$pkg_2->{the_keys}}), "\n";

#--- Case 3 (works)
$theArrRef = $pkg_2->{the_keys};
printArray (@{$theArrRef});

#--- Case 4 (works)
printArray ((@{$theArrRef = $pkg_2->{the_keys}}));

#--- Case 5 (works)
printArray ((@{$pkg_2->{the_keys_2}}));

#--- Case 6 (DOES NOT work)
printArray ((@{$pkg_2->{the_keys}}));

#--- Case 7 (DOES NOT work)
foreach my $n (@{$pkg_2->{the_keys}}) {
    print " ", $n;
}
print "\n";


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Thu, 25 Jan 2001 14:53:40 -0800
From: "chris w." <chrisw@ec2.edu>
Subject: regex question
Message-Id: <Q72c6.97$fA1.80264@news.pacbell.net>

Hi,

I am trying to parse text using a regular expression, but can't find a
newsgroup specific to regular expressions...

Anyway, if anyone can offer an opinion on this problem, that would be great!

I'm to look through a file and remove duplicates of a particular string,
separated by whitespace. Here is an example of the file:

-----------------------------
<p>           <p>
     <p>    <p>Blah-blah-blah
 ------------------------------

I started out trying to use something like:

s/<p>\s+<p>/<p>/g;

Which everyone here will see that it only solves my problem half-way. I'm
not sure if there is a way to substitute one-or-more <p> with just one <p>
without going beyond a regular expression.

Anyone know if this is possible and/or how to do it?

Thanks for any help.




------------------------------

Date: 26 Jan 2001 00:03:00 +0100
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: regex question
Message-Id: <y9vzqlp7.fsf@macforce.sumus.dk>

"chris w." <chrisw@ec2.edu> writes:

> I am trying to parse text using a regular expression, but can't find a
> newsgroup specific to regular expressions...

If your're doing your regexes in perl this group is definately appropriate.

> I'm to look through a file and remove duplicates of a particular string,
> separated by whitespace. Here is an example of the file:
> 
> -----------------------------
> <p>           <p>
>      <p>    <p>Blah-blah-blah
> ------------------------------
> 
> I started out trying to use something like:
> 
> s/<p>\s+<p>/<p>/g;

s/<p>(\s+<p>)*/<p>/g;

should do

-- 
Jakob Schmidt
http://aut.dk/orqwood
etc.


------------------------------

Date: 25 Jan 2001 14:08:32 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: REQ: help about tainting in regex
Message-Id: <m3itn3phzj.fsf@mumonkan.sunstarsys.com>

Samuele Manfrin <samuele@null.net> writes:

> #!/usr/bin/perl -T
> # --- part 1 ---
> push(@in,@ARGV);
> foreach $i (0 .. $#in) {
>    ($key, $val) = split(/=/,$in[$i],2);
>    # <...snip...>
>    $in{$key} = $val;
>    }
> # --- end of part 1 ---
> # if you use the following line in place of "part 1" above, it works!
> # $in{area} = 'S::=A{emit(`ls -la`)} A::=b';
> # ----
> # but here this b...rd enters in an infinite loop if taint is on
> while( $in{area} =~ /([A-Z])::=(.+?)(?=([A-Z]::=|$))/sg ) {
>    $in{$1}="$2";
>    # print for debug
>    print "$1 is equal to $2\n"; }
> 
> Does someone knows what's wrong? 

Looks like a bug to me. I can reproduce it on linux 5.005_03 
and 5.6. I think the taint flag is causing the regexp to fail 
to set pos() for tainted hash and array elements.  Binding to 
a tainted scalar seems to work fine, though.

Try testing it with the following lines substituted for 
the while(...) line above:

OK:
        $_ = $in{area};
        while ( $_ =~ /([A-Z])::=(.+?)(?=([A-Z]::=|$))/sg ) {     


ALSO BAD:
        $_[0] = $in{area};
        while ( $_[0] =~ /([A-Z])::=(.+?)(?=([A-Z]::=|$))/sg ) {     


HTH        
-- 
Joe Schaefer


------------------------------

Date: 25 Jan 2001 19:11:36 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: right place for a mod_perl question?
Message-Id: <slrn970ui3.5o9.vek@pharmnl.ohout.pharmapartners.nl>

On Thu, 25 Jan 2001 13:58:00 GMT, Daniel W. Burke <dwb1@home.com> wrote:

>
>The kicker is, some functions it seems to happen 100% of the time...
>others, it only happens when the sub is used in some places, but
>not when it's used in others...
>
>I did discover that a fix is to call the sub like this:
>
>&SomeFunc(); # note the () added
>



That makes a difference.

&somefunc pases the existing @_ array to the called program 
&somefunc() will pass an empty array to the called program.


Villy


------------------------------

Date: Thu, 25 Jan 2001 19:31:38 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: right place for a mod_perl question?
Message-Id: <3a707f18.19dc$263@news.op.net>
Keywords: Charleston, conch, figure, propellant


In article <Pine.LNX.4.20.0101250858170.17416-100000@ethyl.addictmud.org>,
Daniel W. Burke <dwb1@home.com> wrote:
>I'm not sure if this is the right place for a mod_perl type
>question, 

Yes, but you might also have better luck on the modperl mailing list.

        modperl@apache.org

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: 25 Jan 2001 20:27:29 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: right place for a mod_perl question?
Message-Id: <94q27h$7cu@gap.cco.caltech.edu>

In article <Pine.LNX.4.20.0101250858170.17416-100000@ethyl.addictmud.org>,
Daniel W. Burke <dwb1@home.com> wrote:
>I'm not sure if this is the right place for a mod_perl type
>question, so if not, please let me know where the beast place
>would be :)

Since your question is about the Perl language, here is fine.
If your problem was with configuration or something specific to
mod_perl, that would be different.

>We're having trouble with some subs that take optional
>parameters... Typically we've always done something like :
>
># blah blah...
>
>&SomeFunc;
>
># blah blah...
>
>sub Somefunc
>{
>	my $var = shift;
>	if (defined($var)) {
>		# do something
>	}
>}

When you call a function using &SomeFunc, @_ is left alone.
In other words, &SomeFunc is equivalent to &SomeFunc(@_),
not &SomeFunc().  

Typically, this results in SomeFunc getting passed whatever 
arguments were passed to the function that called it.

From perlsub:

    To call subroutines:

        NAME(LIST);    # & is optional with parentheses.
        NAME LIST;     # Parentheses optional if predeclared/imported.
        &NAME(LIST);   # Circumvent prototypes.
        &NAME;         # Makes current @_ visible to called subroutine.

>What we're finding is, sometimes, (not always), when the script
>is run in mod_perl, it's passing a value to the sub that's a
>reference to a scalar in the Apache package.  I ran some tests,
>and the variable is set to "Apache=SCALAR(0x????????)"... I checked
>a value of it, and it's a number that doesn't make sense to me...
>The number is the same across all apache processes, but it tends
>to change every time apache is restarted...

Yup, the value you're seeing looks like a reference to an Apache object,
which is commonly passed as the first parameter to a method function.

>The kicker is, some functions it seems to happen 100% of the time...
>others, it only happens when the sub is used in some places, but
>not when it's used in others...
>
>I did discover that a fix is to call the sub like this:
>
>&SomeFunc(); # note the () added

That's the way to go.  Actually, you don't even need the "&" any more.

>But I'm hoping that's not the route we have to take... some of the
>subs causing trouble are called 100's of times, spread across 250
>files...

Unfortunately, I don't see any way to really fix the problem without
modifying every call to the function.  

If you were sure that every problem value was a reference like 
you describe, you could change Somefunc to use if (defined($var) 
and not ref($var)) -- but since the value you see is whatever 
happened to be in @_, I'd be hesitant to assume anything applies to
*all* the unwanted values you might see.

-- Gary Ansok


------------------------------

Date: Thu, 25 Jan 2001 23:56:09 +0100
From: "Mike" <verdien_guldens@hotmail.com>
Subject: simple question for probably all of you... about @
Message-Id: <3a70af16$0$29588@reader2>

Dear all

How do I write '@' on my screen between two fields..

as in name1.name2@site?

What is wrong here?
$link[$field_id{"name1"}].$link[$field_id{"name2"}]@$link[$field_id{"Server"
]

Thanks in advance
Mike




------------------------------

Date: Thu, 25 Jan 2001 19:57:00 GMT
From: Kien Ha <Kien_Ha@Mitel.COM>
Subject: Re: Split string into two arrays
Message-Id: <3A7084E5.E6809AF6@Mitel.COM>

scottpa@my-deja.com wrote:
> 
> I wonder if anyone could check my code and see if it could be more
> compact. I need to break the following string up into two arrays @parm
> and @type and I wondered if there was a tidier way of doing it?
> 
> $_='charparm string dateparm datetime intparm number';
> 
> $parm=1;
> foreach $item (@arguments)
> {
>         if ($parm)      {
>                 $parm=0;
>                 push (@parms, $item);
>         }
>         else    {
>                 $parm=1;
>                 push (@type, $item);
>         }
> }
> 
> OUTPUT:
> Parm: charparm dateparm intparm
> Type: string datetime number
>
 

 $_='charparm string dateparm datetime intparm number';
 @arguments = split ' ';
 push @{ $_ % 2 ? \@type : \@parms }, $arguments[$_] for 0 ..
$#arguments


-- 
kien


------------------------------

Date: Thu, 25 Jan 2001 22:17:21 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Split string into two arrays
Message-Id: <t719fh2arhbgf7@corp.supernews.com>

scottpa@my-deja.com wrote:
: I wonder if anyone could check my code and see if it could be more
: compact. I need to break the following string up into two arrays @parm
: and @type and I wondered if there was a tidier way of doing it?
: 
: $_='charparm string dateparm datetime intparm number';
[snip]
: OUTPUT:
: Parm: charparm dateparm intparm
: Type: string datetime number

  my @pieces = split;

  while (@pieces);
    push @parm, shift @pieces;
    push @type, shift @pieces if @pieces;
  }

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


------------------------------

Date: Thu, 25 Jan 2001 13:21:43 -0600
From: Vincent Granville <vincentg@datashaping.com>
Subject: Re: stock market simulator
Message-Id: <3A707CC7.30DB88C4@datashaping.com>

Yes, the code is available. I'll post a link on the site as soon as it is
uploaded. It should be in the section
http://www.datashaping.com/finance_virtual.shtml (the data generated with
the program is not free, but the source code will be available for free). At
this stage it's written in C and I doubt I'll find time to rewrite in Perl,
although it's a small program.

Vincent

brian d foy wrote:

> In article <3A6F29DC.5A7EFEDC@datashaping.com>, Vincent Granville
> <vincentg@datashaping.com> wrote:
>
> > I have it written in C. Anyone interested in a Perl version. I plan to
> > distribute it free from my website (http://www.datashaping.com ), and
> > will put a Perl version if enough people are interested.
>
> i'm interested.  my new purpose in life is stock market data.
>
> is code available?
>
> --
> brian d foy <comdog@panix.com>
> no longer for hire ;)



------------------------------

Date: Thu, 25 Jan 2001 13:13:25 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: String comparing?
Message-Id: <3a7096f5@news.microsoft.com>

"wavetable" <wavetable@birdmail.com> wrote in message
news:94pbc5$poi$1@news.kolumbus.fi...
> Is it possible to compare two strings with functions like "contains",
In Perl the function "contains" is know as the operator "m".

> "starts with", "ends with"?
For this you can use "m", too. Just indicate in the expression that it
should match only at the beginning "^" or end "$" of the string.

> As I don't know how to compare a whole line read
For comparison Perl uses "eq".

> from a file with a string (the line contains the line change character,
What's a line change character?

jue




------------------------------

Date: Thu, 25 Jan 2001 20:11:54 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Type globs
Message-Id: <hq117tc43lk9vvje1kfl6o0ddts7mi4994@4ax.com>

CM wrote:

>While aliasing a list into a subroutine I get problems when I use 'my'
>but works allright with 'local'

>@foo = ("here's", "a", "list");
>&testsub (*foo);
>
>sub testsub
> {
>   local (*printarray) = @_;

The only lexical kind of variables are plain scalars, arrays and hashes.
Nothing else.

What's more, only global variables are stored in a typeglob, which is a
record strure containing one field for every kind of variable, i.e. *foo
contains a field for the scalar $foo, the array @foo, the hash %foo, and
lots more, including filehandles, subroutines and formats.

BTW I which there was a better aliasing mechaism than assigning to a
typeglob. Something like 

	sub testsub {
	    my \@printarray = shift;
	}

would be very nice. But, it doesn't work. For those who don't get it:
this would create a lexical @printarray, which is nothing but an alias
to the array that got referenced, i.e. @foo. That's what the typeglob
assignment does.

-- 
	Bart.


------------------------------

Date: Thu, 25 Jan 2001 20:55:39 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Very newbie question
Message-Id: <3a7092ca.1bcd$f9@news.op.net>

In article <94mvlp$ok5$1@kermit.esat.net>,
Ross McLoughlin <ross@technipoint.ie> wrote:
>Apologies if this sounds stupid!

It didn't.


>I want to install ActivePerl on Windows98, and run them locally before
>adding them to the website.  For example, is it possible to run a form
>validation script separate from the web server?

If your form validation script has been written with the standard
Perl 'CGI' module, you should be able to run it from the DOS shell.
For example, consider the following extremely simple CGI program,
which we will call 'agecheck.cgi':

        use CGI ':standard';

        my $age = param('age');
        if ($age =~ /\D/) {
          print "Your age should be a number.\n";
        } elsif ($age eq '') {
          print "Your did not enter your age.\n";
        } 


If you run this from the shell, you should see the following prompt:

        (offline mode: enter name=value pairs on standard input)

Enter 
        age=17y

and then type control-Z.  The program responds:

        Your age should be a number.

(If you don't get the prompt, change the 

        use CGI ':standard';

to say

        use CGI ':standard', '-debug';

instead.)

You may also run the program like this:

        agecheck.cgi age=17y

in which case the value of 'age' is still taken to be '17y' but you
won't be prompted for additional data.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: Thu, 25 Jan 2001 19:26:24 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: What's wrong with this script?
Message-Id: <3a707de0.19c0$29b@news.op.net>
Keywords: accession, caustic, past, permutation


In article <94pq50$a5e$1@news.kolumbus.fi>, Dan <kkk@elrancho.com> wrote:
>After that it only adds the popup menu's value.
>print OUT "$id\n", param('ratenr'), "\n";

What is in $id?

>$id = $c->param('i');

$id comes from form input item named 'i'.

What is form input item named 'i'?

>print (start_form,
>"Rating: ",
>popup_menu(-name=>'ratenr',
>-values=>['5','4','3','2','1']),
>
>submit,
>end_form);

There isn't one, so $id is undefined.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: Thu, 25 Jan 2001 21:42:05 +0200
From: "Dan" <kkk@elrancho.com>
Subject: Re: What's wrong with this script?
Message-Id: <94pvdj$f76$1@news.kolumbus.fi>

"Mark Jason Dominus" <mjd@plover.com> wrote in message
news:3a707de0.19c0$29b@news.op.net...
>
> In article <94pq50$a5e$1@news.kolumbus.fi>, Dan <kkk@elrancho.com> wrote:
> >After that it only adds the popup menu's value.
> >print OUT "$id\n", param('ratenr'), "\n";
>
> What is in $id?
>
> >$id = $c->param('i');
>
> $id comes from form input item named 'i'.
>
> What is form input item named 'i'?
>
> >print (start_form,
> >"Rating: ",
> >popup_menu(-name=>'ratenr',
> >-values=>['5','4','3','2','1']),
> >
> >submit,
> >end_form);
>
> There isn't one, so $id is undefined.
>

$id is a parameter passed to the script (it's a cgi script) in the form of
script.cgi?i=something. Thanks for any help..




------------------------------

Date: Thu, 25 Jan 2001 20:11:26 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: What's wrong with this script?
Message-Id: <3a70886c.1ac8$e4@news.op.net>

In article <94pvdj$f76$1@news.kolumbus.fi>, Dan <kkk@elrancho.com> wrote:
>> >$id = $c->param('i');
>> There isn't one, so $id is undefined.
>>
>
>$id is a parameter passed to the script (it's a cgi script) in the form of
>script.cgi?i=something. 

For that, you use ->url_param instead of ->param:

        if($c->url_param())
        {
          $id = $c->url_param('i');
        }

Note that many browsers won't handle the submission correctly if you
have some parameters in the form and some in the URL.  It is more
reliable to put all the parameters into the form:

        show_form();
        if ($c->param('form_submitted')) {
          # process the form submission
          # write the data to the file
          # use ->param('i') and ->param('ratenr').
        }

        sub show_form {
          print (start_form,
                 "Rating: ",
                 popup_menu(-name=>'ratenr',
                            -values=>['5','4','3','2','1']),

                 submit,
                 hidden('i'), 
                 hidden('form_submitted', 'yes'),
                 end_form
                );
        }


If the form is retrieved via a GET request, the first 'hidden' field
here will automatically pick up the value of 'i' from the URL.  The
second hiddden field lets you distinguish whether the form is being
retrieved via a regular link ('GET') or a click on the 'submit' button
('POST').



-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: Thu, 25 Jan 2001 20:16:12 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: What's wrong with this script?
Message-Id: <3a70898b.1adf$224@news.op.net>
Keywords: Copperfield, acre, mongoose, stagnate


Note that if you go visit your program at a URL like 

        .../my-rating-prog.cgi?i=57790

then the ->param() test will be true even *before* you submit the
form.  This block:

>if($c->param())
>{
>$id = $c->param('i');
>}

will retreive the value of 'i', and then this block:

>if (param()) {
>open(OUT,">>ratings.dbn") || die "cannot open ratings.dbn";
>print OUT "$id\n", param('ratenr'), "\n";
>}

will store the $id in the file with an empty 'ratenr'.

See my other post on how to fix this: Put a hidden field in the form,
and use this hidden data as an indicator of whether the form was
submitted or not.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: Thu, 25 Jan 2001 22:29:56 +0200
From: "Dan" <kkk@elrancho.com>
Subject: Re: What's wrong with this script?
Message-Id: <94q276$ii7$1@news.kolumbus.fi>

Thanks alot for the help! I will try getting deeper into the examples you
have posted... -d

"Mark Jason Dominus" <mjd@plover.com> wrote in message
news:3a70898b.1adf$224@news.op.net...
>
> Note that if you go visit your program at a URL like
>
>         .../my-rating-prog.cgi?i=57790
>
> then the ->param() test will be true even *before* you submit the
> form.  This block:
>
> >if($c->param())
> >{
> >$id = $c->param('i');
> >}
>
> will retreive the value of 'i', and then this block:
>
> >if (param()) {
> >open(OUT,">>ratings.dbn") || die "cannot open ratings.dbn";
> >print OUT "$id\n", param('ratenr'), "\n";
> >}
>
> will store the $id in the file with an empty 'ratenr'.
>
> See my other post on how to fix this: Put a hidden field in the form,
> and use this hidden data as an indicator of whether the form was
> submitted or not.
>
> --
> @P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub
p{
>
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^or
d
> ($p{$_})&6];$p{$_}=/
^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
> close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep
rand(2)if/\S/;print




------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 145
**************************************


home help back first fref pref prev next nref lref last post