[8717] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2334 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 16 03:07:23 1998

Date: Thu, 16 Apr 98 00:00:45 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 16 Apr 1998     Volume: 8 Number: 2334

Today's topics:
    Re: avoid double-click on submit button <grinch@whoville.com>
    Re: avoid double-click on submit button (brian d foy)
    Re: avoid double-click on submit button (Abigail)
    Re: Content-Length with mailx <grinch@whoville.com>
    Re: environnemt variables (Martien Verbruggen)
        Farnham's Freehold <rdsteph@ibm.net>
    Re: FileHandle woes: can't use indirect object method i (Andrew M. Langmead)
        hash/complex data structure problem <mika@wcug.wwu.edu>
    Re: Help: to eliminate eval() on a HTML Filling script. (Abigail)
    Re: How to insert a \n each... greene@gucc.org
        Incrementing counter <travisj@earthlink.net>
    Re: info on cookies (brian d foy)
    Re: info on cookies (brian d foy)
    Re: info on cookies (Abigail)
    Re: info on cookies <glchy@csah.com>
    Re: Match \/ ? <justin@nectar.com.au>
        Need simple way to define numerical output accuracy? (Mike)
    Re: Need simple way to define numerical output accuracy <grinch@whoville.com>
    Re: Need simple way to define numerical output accuracy (Abigail)
    Re: Obfusticator <justin@nectar.com.au>
    Re: open telnet <justin@nectar.com.au>
        Opening a filehandle for input amd output. <dstanawa@ug.cs.usyd.edu.au>
        Perl Module or Script for difference of two files <burkhard.kiesel@med.siemens.de>
    Re: Regex problem: match maximal substring (Abigail)
        Viewing perl abstract data structures no_spam@winzig.com
    Re: Viewing perl abstract data structures <grinch@whoville.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 15 Apr 1998 23:55:49 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: avoid double-click on submit button
Message-Id: <6h3umc$arr@fridge.shore.net>

Daryl Nguyen wrote in message <3534D9A6.321A50D7@utoronto.ca>...

>The problem is if one double clicks on the submit button, the perl
>script will run twice, if n-click on the submit button, then the script
>will run n-times.


<rant class="flame">
First of all people, this "unlink" stuff is stupid and destructive. If the
web server will allow it, it would delete the script! That's not too far
fetched a scenario, when you consider the number of people using a
lightweight server and win32 Perl on Windows 95 machines. Did it occur to
anyone that he may not have another copy of his script? Your so-called
"help" may cost him hours of work, if he's new and inexperienced enough to
take it at face value.

The incessant griping and moaning about posting to the wrong group is
irritating, but tolerable. Thin-skinned people shouldn't be on usenet
anyway. Posting suggestions that attempt to deliberately sabatoge the
newbie's work is...well, I'm at a loss for words. Words appropriate for a
public forum, anyway. You people have hit a new low.

Actually, I'm not at a loss for words. Here's one that's very appropriate:
PLONK.
</rant>

>I just want to have a script run just ONCE regardless of how many
>clicks.


You'll need to use a flag or indicator on the server, to indicate that the
form has been submitted. You can identify the user by a number of means,
such as password authentication or a cookie. Once the user is identified,
check that user's flag to see if he's submitted the form previously. If not,
set the flag and continue. If so, ignore the extra submission and return a
"204 No Response" header instead of the usual response. The flag can be
stored in a file, or a database, or maintained by a server daemon, whatever
best fits the needs of your script.

That's a description of one way to do it. It's not perfect; for example when
the form is submitted a second time it interrupts the browser, causing it to
stop waiting for output from the first. It should be used as a starting
point for your own efforts, and would probably be best used in conjunction
with a client-side technique in JavaScript or VBScript. You'll need to ask
in a group dedicated to those languages for advice on them, however.

For a good general reference for doing CGI stuff in Perl, that covers the
techniques I've mentioned and much more, see the following URL:

<URL: http://reference.perl.com/query.cgi?cgi>

HTH!

-grinch

----
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: Thu, 16 Apr 1998 00:11:37 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: avoid double-click on submit button
Message-Id: <comdog-ya02408000R1604980011370001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6h3qqu$q4q$2@comdyn.comdyn.com.au>, mgjv@comdyn.com.au (Martien Verbruggen) posted:

>In article <3534D9A6.321A50D7@utoronto.ca>,
>        Daryl Nguyen <daryl.nguyen@utoronto.ca> writes:
>> The problem is if one double clicks on the submit button, the perl
>> script will run twice, if n-click on the submit button, then the script
>> will run n-times.
>
>submit button? Does perl have submit buttons? Since when?

since Perl/Tk obviously.  tell a script to do something twice and it
will. :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
just don't accept submissions from browsers not running on a PlayStation


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

Date: 16 Apr 1998 06:07:18 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: avoid double-click on submit button
Message-Id: <6h476m$4tq$2@client3.news.psi.net>

Grinch (grinch@whoville.com) wrote on MDCLXXXIX September MCMXCIII in
<URL: news:6h3umc$arr@fridge.shore.net>:
++ 
++ The incessant griping and moaning about posting to the wrong group is
++ irritating, but tolerable. Thin-skinned people shouldn't be on usenet
++ anyway. Posting suggestions that attempt to deliberately sabatoge the
++ newbie's work is...well, I'm at a loss for words. Words appropriate for a
++ public forum, anyway. You people have hit a new low.
++ 
++ Actually, I'm not at a loss for words. Here's one that's very appropriate:
++ PLONK.

What did you say again about thin-skinned people? 

++ You'll need to use a flag or indicator on the server, to indicate that the
++ form has been submitted. You can identify the user by a number of means,
++ such as password authentication or a cookie. Once the user is identified,
                                                         ^^^^^^^^^^^^^^^^^^

                                                Using a stateless protocol?

++ check that user's flag to see if he's submitted the form previously. If not,
++ set the flag and continue. If so, ignore the extra submission and return a
++ "204 No Response" header instead of the usual response. The flag can be
++ stored in a file, or a database, or maintained by a server daemon, whatever
++ best fits the needs of your script.

So, what's the Perl aspect of this discussion?



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: Thu, 16 Apr 1998 00:06:09 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Content-Length with mailx
Message-Id: <6h3v9n$be0@fridge.shore.net>

Database Coder wrote in message <6h382h$49p$1@news.scruz.net>...

>I wrote a small perl script that uses mailx to send email. The body of the
>message is read from a text file. When the message is received the first
>line of the body contains "Content-Length:  805" even thought the string
>that contains the body text at the time it is sent to mailx does not
contain
>that line. Is there a way to get rid of it?


If mailx has an option that will cause it to omit that line, you should have
your Perl script use that option when it calls mailx. You need to consult
the documentation for mailx to find whether such an option exists and if so
how to use it. Most UNIX utilities respond to either environment variables
or command-line switches to set optional parameters.

If you already know of such an option, and you need help on passing it to
mailx via command-line switches, see the Perl docs on the "system" and
"open" functions. For help on doing so via environment variables, see the
Perl docs on the %ENV hash.

As an alternative, you may want to look into using the Mail::Send module,
which wraps the process up into a neat package that works on a number of
platforms, using a number of mailers. If it works on your system, it's a
heck of a lot easier than writing your own.

HTH!

-grinch

-----
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: 16 Apr 1998 06:06:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: environnemt variables
Message-Id: <6h475c$r9a$1@comdyn.comdyn.com.au>

In article <6h3tcj$343$1@ndnws01.ne.highway1.com>,
	"Dick Elkin" <eelkin@mediaone.net> writes:

> I say this because that is exactly the question and answer I have been
> reading this newsgroup for.

I hope you're also reading some of the groups in the
comp.infosystems.www.* hierarchy, if these are the sort of questions
and answers you are mainly interested in. After all, this is a group
that normally would talk about perl, not about CGI/HTTP/SSI/HTML and
other things like that.

Yes, questions about those subject will come up here. Yes, sometimes
someone will answer them, instead of referring the poster to a better
suited group. But, if you are interested in those subjects, you
really are better off in one of the groups devoted to them. You should
be reading c.l.p.m for perl discussions.

Reading c.l.p.m for web related subjects is like reading a book about
insects while you are really interested in grasshoppers. It would
make more sense to read a book about grasshoppers. The chance of
actually seeing something about grasshoppers are just a lot higher.

Oh well.
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd.       | why kamikaze pilots wore helmets - Dave
NSW, Australia                      | Edison 


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

Date: Thu, 16 Apr 1998 00:57:52 -0400
From: Ronald Stephens <rdsteph@ibm.net>
Subject: Farnham's Freehold
Message-Id: <35358FD0.D1A6AFFF@ibm.net>

Announcing Farnham's Freehold, a new web site dedicated to PERL advocacy
and freeware advocacy in general. While we are just beginning, any help
and support will be appreciated. We hope to add our voice to the
freeware cause and to collect as many freeware resources and articles as
possible under one roof. See http://www.awaretek.com

    Also, we are interested in an app for collaborative poetry on the
web, also collaborative graphics and possibly music. Does any one know
if any similar PERL program exists? I would like to find a good place to
start. BTW, I am a newcomer to PERL programming, previously being
primarily Java and before that Visual Basic. I was attracted by artilces
written by Todd Christianson and larry Wall, which I bumped into
originally via a refernce from Nick Petreley.
Ron Stephens
rdsteph@ibm.net
http://www.awaretek.com



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

Date: Thu, 16 Apr 1998 05:57:30 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: FileHandle woes: can't use indirect object method invocation?
Message-Id: <ErHsJu.4vs@world.std.com>

Martin Gregory <mgregory@asc.sps.mot.com> writes:

>The problem now seems to be that I can't use indirect object method 
>invocation for methods who's names clash with perl functions.  This is 
>unexpectedly obstructive for perl....

>I wanted to create my own 'NamedFile' object, and delegate most of the 
>method calls to FileHandle.  Unfortunately, this causes perl to barf: 
[stuff deleted] 
>#Since perl won't let us subclass FileHandle, lets use AUTOLOAD to delegate...

The problem with delagating is the same as subclassing, for perl's
built in I/O operators, it will allow an IO::File or FileHandle object
in place of a filehandle, but nothing  else.

You can get a little bit closer to what you want by using tied
filehandles. If you use tie(), you have to pass it a typeglob, you can
use it as a regular filehandle, but you can't use method calls on
it. If you use the object, then you can use the method calls, but you
can't use it in the builtin I/O routines.

package NamedHandle;

use IO::File;

use strict;
use vars qw(@ISA @EXPORT $AUTOLOAD);

require Exporter;

@ISA = qw(Exporter);
@EXPORT = qw(name);

my %tie_mapping = ( PRINT => 'print' , PRINTF => 'printf',
		   READLINE => 'getline', GETC => 'getc', READ => 'read');

# new named handles can be created with either the tie() interface,
# or by calling the contructor. 
sub new {
    my $self = shift;
    my @args = @_;
    my $obj = {};
    bless $obj, $self;
    return $obj->init(@args);
}

sub TIEHANDLE {
     new(@_);
}

# create our IO::File object and pass whatever arguments we got.
# return undef on error.
sub init {
    my $self = shift; 
    my @args = @_;

    $self->{args} = \@args;
    $self->{fh} = new IO::File @args;
    $self->{fh} or return;
    return $self;
}

# update our args whenever we open a file.
sub open {
    my $self = shift;
    my @args = @_;
    @{$self->{args}} = @args;
    $self->{fh}->open(@args);
}

# return the filename we passed to IO::File->open()
sub name {
    # we we got passed a typeglob as the first argument, get
    # the tied object it is associated with.
    my $self = tied $_[0] || shift;
    return $self->{args}->[0];
}

# create the implicit Tied handle methods or delegates for the IO::File
# objects as needed.
sub AUTOLOAD {
  my $call = $AUTOLOAD;
  $call =~ s/.*:://;

  # if it is a Tied handle method, 
  # substitute the appropriate IO::File method.
  my $sub = $tie_mapping{$call} || $call;

  # alias the anonymous subroutine to the name of the sub we want.
  no strict 'refs';
  *{$call} = sub { my $self = shift; $self->{fh}->$sub(@_)};
  # and go to it.
  goto &$call;
}

1;


#!/usr/bin/perl -w

use strict;

use NamedHandle;

# tie the filehandles to our objects, extra args get passed to IO::File
tie *IN, 'NamedHandle', '/etc/passwd';
tie *OUT, 'NamedHandle', ">/tmp/tiehandle.test.$$";
# or use the constructor
my $out2 = new NamedHandle "/tmp/tiehandle.test.$$.2","w";

# name() can be either a NamedHandle method or a normal subroutine.
print name(*IN), "\n";
print tied(*OUT)->name(), "\n"; 
print $out2->name(), "\n";


# and the tied ones act like normal filehandles.
while(<IN>) {
  print OUT;
  $out2->print($_);
}

-- 
Andrew Langmead


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

Date: Wed, 15 Apr 1998 22:44:00 -0700
From: Mika Koivisto <mika@wcug.wwu.edu>
Subject: hash/complex data structure problem
Message-Id: <Pine.LNX.3.96.980415222420.24530A-100000@sloth>

I have this problem with a complex structure which looks like this:

%virtual = (
 'plan1' => {
		'full' => {
			     '3' => {
					'price' = '22',
					'setup' = '0',
					'other'
				    },
			    '6' => {
					as above
				   }
			   },
		'quarter' => {
			        as above
			     }
	},
'plan2' => {
		well you get the picture
	}
);

Now the problem is that I need to walk trough each item on that structure
and crap the price, setup and other and then do something with them.

I know how to go trough them by hand
($virtual{'plan1'}{'full'}{'3'}{'price'} etc.) but I ideally would like to
use nested foreach or what ever does the job  shortest and not having to
modify that code if and when I add or remove items. The structure will
stay the same.

Could someone help me out with the traverse code.

Thanks

P.S. please e-mail replies to mika-perl@wcug.wwu.edu

#include <signature.h>
/*
* Mika Koivisto
* E-mail: mika-junk@wcug.wwu.edu
* WWW: http://www.msk-design.com
* PGP Public Key: http://www.msk-design.com/mika/pgp/
*/

Memory fault -- core...uh...um...core... Oh damnit, I foreget!




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

Date: 16 Apr 1998 04:37:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help: to eliminate eval() on a HTML Filling script.
Message-Id: <6h41um$m23$1@client2.news.psi.net>

Tommy (tkho@technologist.com) wrote on MDCLXXXVIII September MCMXCIII in
<URL: news:35352AF7.BD02EBC3@technologist.com>:
++ 
++ 
++ The major problem is the speed of eval() of the following lines:
++ 
++ if ($L=~ /\$/) {        # foreach chomp line
++   $L=~ s/\"/\\\"/g;     # replace " to \"
++   $L=~ s/\;/\\\;/g;     # replace ; to \;
++   $L=~ s/\@/\\\@/g;     # replace @ to \@
++   $L=~ s/\&/\\\&/g;     # replace & to \& because of "&nbsp;", etc.
++   $L= "\"$L\"\n";       # put quote on ends
++   print eval($L);       # print the eval()- slooooooooooow.
++ } else {
++   print "$L\n";         # print normal line
++ }
++ 
++ Is there a way to eliminate the eval()?

Well, there's an easy way to eliminate all but one of them:
eval the entire template at once, not line by line.



Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


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

Date: Thu, 16 Apr 1998 01:21:13 -0600
From: greene@gucc.org
Subject: Re: How to insert a \n each...
Message-Id: <6h480p$lfu$1@nnrp1.dejanews.com>

In article <6h31dt$b0o$1@marina.cinenet.net>,
  cberry@cinenet.net (Craig Berry) wrote:
>
> LE CORRE (lecorre@magic.fr) wrote:
> : I don't know how to insert a \n new line each x char eg:
> :
> : $line="031317212230333646490811162224293037404104050717293537414647";  (40
> : char)
>
> Actually, that's 60 chars.
>
> : I want to insert a \n each 10 char to display :
> : 03131721223033364649
> : 08111622242930374041
> : 04050717293537414647
>
> Actually, those are 20 char chunks.
>
> : I tried $line=~ s/.{10}/\n/g; but it doesn't work.
>
> A more efficient approach uses substr:
>
>   $line  = '031317212230333646490811162224293037404104050717293537414647';
>   $chunk = 10;
>
>   for ($ix = 0; $ix < length($line); $ix += $chunk) {
>     print substr($line, $ix, $chunk), "\n";
>   }
>
> : Please, answer by email.
>
> Sorry, private consulting costs extra.
>
> ---------------------------------------------------------------------
>    |   Craig Berry - cberry@cinenet.net
>  --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
>    |      Member of The HTML Writers Guild: http://www.hwg.org/
>        "Every man and every woman is a star."
>

Some people are determined to use regular expressions, even if it makes it
harder to read and understand what is happening. If this is the case here, I
would suggest

    $line =~ s/.{10}/$&\n/g ;

>From the perlre document:

    $& returns the entire matched string. ($0 used to return the same thing,
but not any more.)

# James Greene - Informatics Consulting - 79539 Loerrach, Germany
# www.gucc.org/greene/consult - greene (at) gucc (dot) org
perl -e "eval unpack
'u*',q/B<')I;G0@(DIU<W0@86YO=&AE<B!015),(&AA8VME<B$*(@``/"

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 14 Apr 1998 01:18:36 -0700
From: "TravisJ" <travisj@earthlink.net>
Subject: Incrementing counter
Message-Id: <6h47kq$5pe@argentina.earthlink.net>

Does anyone have any information that might assist me in creating a counter
that has a constant position (similar to RAM count off at boot up) in a
command window on WIn32. Thanks




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

Date: Thu, 16 Apr 1998 00:07:27 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: info on cookies
Message-Id: <comdog-ya02408000R1604980007270001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35356C88.DA3F5236@csah.com>, "Gilles L. Chong Hok Yuen" <glchy@csah.com> posted:

>Errrr ... hmmmmm
>ok guys fanx for the response n concern shown. I just hope tt it will not
>escalate into somefing other than a newsgroup response to a newbie.
>
>Im sorry but i didnt get any mail n cannot read from the newsgroup the detailed
>explanation n URLs cookie info by Lloyd Zusman. Can u pls resend them to me
>and/or repost them in the newsgroup.

everything you need to know is referenced in the CGI Meta FAQ, 
including Perl specific issues.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Thu, 16 Apr 1998 00:05:52 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: info on cookies
Message-Id: <comdog-ya02408000R1604980005520001@news.panix.com>
Keywords: from just another new york perl hacker

In article <ltyax6k2j8.fsf@asfast.com>, Lloyd Zusman <ljz@asfast.com> posted:

>Tom Phoenix <rootbeer@teleport.com> writes:

>> > or else Gilles Chong is unaware of the name of this variable and is
>> > trying to learn this in order to access cookies in Perl-based cgi
>> > scripts (my interpretation). 
>> 
>> Which is to say, not a Perl-specific problem...
>
>But there is an elegant, Perl-based solution to it.

oh really?  which one would that be?  you do it the same way in other
languages, so it's not Perl specific.  perhaps you haven't read the
cookie info referenced in the CGI Meta FAQ.

>will probably just have to deal with the fact that some of us would
>prefer to offer Perl-based and Perl-positive solutions in this current
>newsgroup, and leave the distasteful task of sending people to other
>newsgroups to those eager others who get more enjoyment out of doing
>so than we do.

dilemma - do you give the starving fish or do you teach them to fish?
if people knew how to find information on their own, they wouldn't
need to ask questions.  most of finding something is knowing where to
look.  

glad to hear that you are perpetuating people's dependent behaviour.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
just when you thought it was safe to come back...


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

Date: 16 Apr 1998 06:02:10 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: info on cookies
Message-Id: <6h46t2$4tq$1@client3.news.psi.net>

Gilles L. Chong Hok Yuen (glchy@csah.com) wrote on MDCLXXXIX September
MCMXCIII in <URL: news:35356C88.DA3F5236@csah.com>:
++ Errrr ... hmmmmm
++ ok guys fanx for the response n concern shown. I just hope tt it will not
++ escalate into somefing other than a newsgroup response to a newbie.
++ 
++ Im sorry but i didnt get any mail n cannot read from the newsgroup the detail
++ explanation n URLs cookie info by Lloyd Zusman. Can u pls resend them to me
++ and/or repost them in the newsgroup. Yesterday, our mailserver went down real
++ bad n i guess some mails got lost in the cyber black hole! The only messages 
++ my newsgroup are from (i)Tom Phoenix - Toyotas, SF (!) n (ii)Lloyd Zusman -
++ replying to Tom.

Then use dejanews and/or altavista.

++ #Testing cookies
++ $cookie = $ENV{'HTTP_COOKIE'};
++ print "<br><blink>cookie: $cookie </blink><br> \n";
++ 
++ I.e the perl script is NOT able to get the cookie and read it!

As I explained in a previous post, that's not a Perl problem.

Take it up with your server. In a server group.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Thu, 16 Apr 1998 14:16:00 +0800
From: "Gilles L. Chong Hok Yuen" <glchy@csah.com>
Subject: Re: info on cookies
Message-Id: <3535A21F.740FC1AB@csah.com>

> >will probably just have to deal with the fact that some of us would
> >prefer to offer Perl-based and Perl-positive solutions in this current
> >newsgroup, and leave the distasteful task of sending people to other
> >newsgroups to those eager others who get more enjoyment out of doing
> >so than we do.
>
> dilemma - do you give the starving fish or do you teach them to fish?
> if people knew how to find information on their own, they wouldn't
> need to ask questions.  most of finding something is knowing where to
> look.
>
> glad to hear that you are perpetuating people's dependent behaviour.

First of all, i appreciate ur help. N nope, i didnt know tt a CGI MetaFAQ
existed. As i said (n im not ashamed of saying it cos it's true), im a newbie.I
turn to u guys in the newsgroup to get some help or some direction of where the
help is.
I dont understand what is ur problem if someone wants to help in a more explicit
n detailed way. Doesnt cost u anyfing, does it?
Putting it in a 'starving-fish' context, if u help the starving by pointing out
the direction of the nearest river (even tho it can be 50 miles away!), fine. But
wat's the problem if someone ELSE gives some food n then teach the starving how
to fish?

True tt some questions may seem insignificant n almost irritating to some gurus
but then u do have to start somewhere! Phaps there should be a specific newsgroup
like 'comp.lang.perl.only_for_gurus.misc'!

G.

p.s i thought tt it was a Perl computer programming language newsgroup. N im
getting stuff like "Toyotas, Golden Gate, starving, fish ......"!
--
Gilles Chong (glchy@csah.com, glchy@csa.com.sg)
Systems Engineer, Internet Division
CSA Holdings Ltd, Singapore.




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

Date: Thu, 16 Apr 1998 15:23:30 +1000
From: Justin Wills <justin@nectar.com.au>
Subject: Re: Match \/ ?
Message-Id: <353595D2.9916EB6C@nectar.com.au>

cotal@delphi.com wrote:

> What syntax would you use to match \/, as in abc\/def
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading


try:

$var=~/\\\//



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

Date: Thu, 16 Apr 1998 04:07:35 GMT
From: info@mikeschoice.com (Mike)
Subject: Need simple way to define numerical output accuracy?
Message-Id: <353583b9.529912405@news.net-link.net>

Topic: 
      Need simple way to define numerical output accuracy? (1 of 1), 
From: 
      Adam Stubbs (astubbs@advantagecommunication.com) 



I am using a CGI script to calculate product pricing. When using
standard variables $quantity, $unit_price, and $total the output
removes the trailing 0's. 

e.g. 
via user input $quantity="4"
via db $unit_price="27.95"
therefore $total="111.8" (not 111.80)

I have been able to ascertain this happens since $quantity is "4" and
not "4.00". Unfortunately, this is via user input and the conversion
code would seem extensive and unnecessary. Is there a simple way to
define numerical output accuracy?

Adam Stubbs
astubbs@advantagecommunication.com


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

Date: Thu, 16 Apr 1998 00:51:38 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Need simple way to define numerical output accuracy?
Message-Id: <6h41uu$ckn@fridge.shore.net>

Mike wrote in message <353583b9.529912405@news.net-link.net>...

>I have been able to ascertain this happens since $quantity is "4" and
>not "4.00". Unfortunately, this is via user input and the conversion
>code would seem extensive and unnecessary. Is there a simple way to
>define numerical output accuracy?


The sprintf function can be used.

For example:

#!/usr/bin/perl
$total = 5;
$format_total = sprintf "\$%2.2f", $total;
print "$format_total\n";

print the total as "$5.00".

HTH!

-grinch

----
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: 16 Apr 1998 06:10:16 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Need simple way to define numerical output accuracy?
Message-Id: <6h47c8$4tq$3@client3.news.psi.net>

Mike (info@mikeschoice.com) wrote on MDCLXXXIX September MCMXCIII in
<URL: news:353583b9.529912405@news.net-link.net>:
++ 
++ 
++                                            Is there a simple way to
++ define numerical output accuracy?


perldoc -f sprintf



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Thu, 16 Apr 1998 15:25:28 +1000
From: Justin Wills <justin@nectar.com.au>
Subject: Re: Obfusticator
Message-Id: <35359648.9B77BC31@nectar.com.au>

Dave Cross wrote:

> abigail@fnx.com (Abigail) writes:
>
> >
> > tory1 (tory1@mail.idt.net) wrote on MDCLXXVII September MCMXCIII in
> > <URL: news:3525CDB2.B45589D6@mail.idt.net>:
> > ++ Hi All,
> > ++ I have some perl programs I would like to distribute but
> > ++ I would like the perl code to be "hidden". It strikes me
> > ++ that a "random" obfusticator would shroud the code sufficiently.
> > ++
> > ++ Does anyone know of any code I could use to effectively
> > ++ use for this purpose.
> >
> > Just write bad code, and noone will attempt to "steal" it.
>
> Abigail,
>
> You seem to be assuming that anyone who 'steals' code would know
> the difference between good and bad code. I'm not sure that this
> assumption is warrented, I have seen many examples of bad code
> propageted across the internet...
>
> Dave...
>
> --
> If I wasn't so busy writing status reports,
> my status report might just become a progress report.
>
> Dave.Cross@gb.swissbank.com


and how do you get your code back out again ???? with a random
unobfuscator ????





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

Date: Thu, 16 Apr 1998 15:22:45 +1000
From: Justin Wills <justin@nectar.com.au>
Subject: Re: open telnet
Message-Id: <353595A5.449273DA@nectar.com.au>

Loren Schooley wrote:

> Hi.
> This group his huge. I wonder if I'll even be seen in here!
> What I am trying to do is open two telnet sessions at once with an
> icon using perl.
> Do I have to put it between brackets like
> #!/usr/local/bin/perl
> {
> exec telnet [address]
> exec telnet [address2]
> }
>

the second telet will never run.  hint... exec




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

Date: Thu, 16 Apr 1998 01:15:05 +1000
From: David Stanaway <dstanawa@ug.cs.usyd.edu.au>
Subject: Opening a filehandle for input amd output.
Message-Id: <3534CEF9.795EAAD7@ug.cs.usyd.edu.au>

#!/gnu/usr/bin/perl
open (www,"|telnet www-personal.usyd.edu.au 80|");
write(www,"GET http://www-personal.usyd.edu.au:80/~dstanawa/");
while(read(www,$buff,36)) {
        print $buff;
}

Am I doing something wrong?
Please email a reply ...
Thanks.

David Stanaway.



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

Date: Thu, 16 Apr 1998 08:07:17 +0200
From: "Burkhard Kiesel" <burkhard.kiesel@med.siemens.de>
Subject: Perl Module or Script for difference of two files
Message-Id: <6h470b$1vf$1@med-iss3.med.siemens.de>

Hi out there,

I already asked this question before, but I didn't get an answer.
Is there a unix-like "diff" command available as a Perl-Module or is there
a Perl-Script available, which does the same.

Unfortunatly I was forced to move from SUN's to Windows-NT 4.0, and there is
really no adequate system command like the "unix - diff".

Help is appreciated


Burkhard




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

Date: 16 Apr 1998 06:20:32 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Regex problem: match maximal substring
Message-Id: <6h47vg$4tq$4@client3.news.psi.net>

Peter J. Scott (psf@euclid.jpl.nasa.gov) wrote on MDCLXXXIX September
MCMXCIII in <URL: news:6h3qap$h7e@netline.jpl.nasa.gov>:
++ It seemed like a simple problem at the time I thought of it:
++ given a string $s and some text $t, find the longest substring of $s
++ in $t.  But a simple solution eluded me.  After reading Jeffrey Friedl's
++ regex book (which I will reread as soon as my head stops spinning - if
++ anyone knows of medication which will cure the "asterisks flashing before
++ the eyes" syndrome, please advise), I crafted the below, which appears to
++ work but I would not want at this point to advertise it as a testimonial
++ to the book's powers :-)

Uhm, finding longest subsequences is a well known problem in
combinatorics. You might want to dive into the literature to find
a suitable algorithm. (No doubt will Sharir have written about
subsequences).

My intuition says that the Perl regex machine isn't going to help much.



Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


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

Date: Wed, 15 Apr 1998 23:24:04 -0600
From: no_spam@winzig.com
Subject: Viewing perl abstract data structures
Message-Id: <6h4154$6ju$1@nnrp1.dejanews.com>

I was working on a script that uses some abstract data structures (like hashes
of hashes of arrays of hashes, etc...) and I needed a way to debug the script
and view my structures. I wrote this perl library (yeah, not a module) that
works pretty well, so I thought someone else out there might want to use it:

http://www.winzig.com/snippets/lib_ads.pl

It's probably a horrible hack of a script, but it worked for me!

Here's a snippet from the comments in the code:

########################################################################
# An example program is below. It's a contrived example, because
# normally this lib comes in handy when you are using whacky loops
# and such to create your ADS's. The example below just shows that
# the output structure resembles your input pretty closely
# (considering all we have to work with is a reference to your ADS!).
#
#    require "lib_ads.pl";
#
#    %myhash = (
#        h1 => {
#            a2      =>    [aa, bb, cc, dd, ee, ff],
#            h2      =>    {1=>"2", 2=>"4", 3=>"6", 4=>"8"},
#            this    =>    "that"
#        },
#        a1 => ["jane", "harriet", "ozzy"]
#    );
#
#    &ads_write(\*STDOUT, \%myhash);
#
#
# THE TEXT WRITTEN TO <STDOUT> IS THEN:
#
#    %START = {
#        %h1 = {
#            this => that
#            %h2 = {
#                1 => 2
#                2 => 4
#                3 => 6
#                4 => 8
#            };
#            @a2 = [
#                aa
#                bb
#                cc
#                dd
#                ee
#                ff
#            ];
#        };
#        @a1 = [
#            jane
#            harriet
#            ozzy
#        ];
#    };
#
##########################################################################

-thomas

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 16 Apr 1998 00:54:02 -0400
From: "Grinch" <grinch@whoville.com>
Subject: Re: Viewing perl abstract data structures
Message-Id: <6h423e$cn3@fridge.shore.net>

no_spam@winzig.com wrote in message <6h4154$6ju$1@nnrp1.dejanews.com>...

>I was working on a script that uses some abstract data structures (like
hashes
>of hashes of arrays of hashes, etc...) and I needed a way to debug the
script
>and view my structures.

You may want to take a look at the Data::Dumper module... Using it would
save you the effort of writing your own.

-grinch

-----
"Of course coffee doesn't make the world go around. It
just makes it go faster." - me

Sherm Pendley
grinch@whoville.com
http://www.whoville.com





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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2334
**************************************

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