[11541] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5141 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 15 18:07:37 1999

Date: Mon, 15 Mar 99 15:00:32 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 15 Mar 1999     Volume: 8 Number: 5141

Today's topics:
    Re: CGI form that calcs order form totals? <redbug@hyperarts.com>
    Re: Datastream API Problem Help! (Sam Holden)
        Detecting a whitespace at the end of a string kate_stafford@my-dejanews.com
    Re: Detecting a whitespace at the end of a string <dean2@mail.biol.sc.edu>
    Re: does perl discourage obfuscated code? (was Re: Perl (Craig Berry)
    Re: does perl discourage obfuscated code? (was Re: Perl (Craig Berry)
    Re: FAQ 8.31: Can I use perl to run a telnet or ftp ses rob_liberti@my-dejanews.com
    Re: FAQ 8.31: Can I use perl to run a telnet or ftp ses rob_liberti@my-dejanews.com
    Re: Help: Conditional use of packages in Perl <ebohlman@netcom.com>
    Re: How can I send variable to FORM CGI that using meth ("Adrian Fiorinni")
        How do you create an mSQL database... <swett@ncats.net>
    Re: How do you create an mSQL database... <alex@kawo2.rwth-aachen.de>
    Re: Learn the truth - In Dear Recruiter we establish ex <john@dhh.gt.org>
    Re: Learn the truth - In Dear Recruiter we establish ex <flavell@mail.cern.ch>
    Re: need better way to print external file withen perl  (Sami Rosenblad)
    Re: need better way to print external file withen perl  <syt@email*@sp\am|@|spa/m@*.com>
    Re: need better way to print external file withen perl  <jglascoe@giss.nasa.gov>
        Need Faster Approach frogsmock@my-dejanews.com
    Re: newbie needs help nel_o@my-dejanews.com
        NewbieQ: if ($dbhost && $dbname !~ m%[/@]%); <hattons@cpkwebser5.ncr.disa.mil>
    Re: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%); <jbc@shell2.la.best.com>
        NewbieQ: obscure code <hattons@cpkwebser5.ncr.disa.mil>
    Re: NewbieQ: obscure code <jeromeo@atrieva.com>
        Newby question.. <rcj@lucent.com>
    Re: Newby question.. <che@debian.org>
        Pushing current line back onto <FILE> (Jete Software Inc.)
    Re: Regex $1 behavior <aqumsieh@matrox.com>
    Re: Scalar/array question kkostenbader@my-dejanews.com
        Sendmail question, and LWP question (George)
        Sorting Problem <debot@xs4all.nl>
    Re: Sorting Problem <dean2@mail.biol.sc.edu>
        SSL Support is in a bad state! chris@ixlabs.com
        test pleas ignore <hattons@cpkwebser5.ncr.disa.mil>
        user.dat file problem.. <horizon@internetexpress.com.au>
    Re: user.dat file problem.. (Alastair)
        Web Programming <korak@intersurf.com>
    Re: Where is Perl 5.004 ? <msholund@bigfoot.com>
    Re: Why are unresolved refs not reported? (Tramm Hudson)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 15 Mar 1999 14:18:24 -0800
From: Tim Ware <redbug@hyperarts.com>
To: Meh <aghaeim@genesis.co.nz>
Subject: Re: CGI form that calcs order form totals?
Message-Id: <Pine.BSF.4.05.9903151417040.8379-100000@shell3.ba.best.com>


Hello,

Thanks for your reply. I thought there was most likely a Perl script out
there for this. My hesitation in using Javascript is that not all folks'
browsers support it, or they turn it off. CGIs don't allow for that sort
of disabling.

Tim Ware


===============<<<<< h y p e r a r t s . c o m >>>>>===============

        Tim Ware ::: tel 510.530.2847 ::: fax 510.530.1466

On Tue, 16 Mar 1999, Meh wrote:

> Tim Ware wrote:
> > 
> > Hello,
> > 
> > Does anyone know of a script that will handle the simple math of an online
> > order form? The form is located at:
> > 
> > www.metronomeballroom.com/registration2.html
> > 
> > Please copy response to: tim@hyperarts.com
> > 
> > Thanks.
> > 
> > Tim Ware
> 
> The easiest way is to use a piece of Javascript code to calculate what
> you want and add a calculate button to your web page.
> 
> 
> 
> ---------------------------------------------------------------------
> Protect privacy, boycott Intel PIII: http://www.bigbrotherinside.org
> ---------------------------------------------------------------------
> 



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

Date: 15 Mar 1999 22:39:25 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Datastream API Problem Help!
Message-Id: <slrn7er30t.eum.sholden@pgrad.cs.usyd.edu.au>

On Mon, 15 Mar 1999 19:47:18 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
>Dimensions wrote:
>
>>Unfortunately, I do not have rights to install perl libraries on the server
>>that is hosting my site, only access to my CGI-BIN.
>>
>>Any other suggestion?
>
>I think this is a FAQ. Check your documentation, or the docs on
><www.perl.com>. (perlfaq8)
>
>Create a subdirectory "lib" in your cgi-bin, and add this to the front
>of all of your scripts:
>
>	use lib "./lib";

Except of course that you have no idea what the current directory the
script is executing in. The web server could decide to put you in
/tmp/you/would/never/suspect/this one day and /etc the next.

Of course every server I've used seems to run cgi scripts with the cwd 
as the directory containing the script. If you want to write non-portable
code and help bring forward the end of civilisation then that's your choice
I guess.

-- 
Sam

It has been discovered that C++ provides a remarkable facility for
concealing the trival details of a program--such as where its bugs are.
	--David Keppel


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

Date: Mon, 15 Mar 1999 21:03:19 GMT
From: kate_stafford@my-dejanews.com
Subject: Detecting a whitespace at the end of a string
Message-Id: <7cjsif$h43$1@nnrp1.dejanews.com>

I am writing a script using Activestate build 509. I am reading in a list of
NT user groups that sometimes have a whitespace inside of them (i.e. "Domain
Users"). The program that is generating the group names sticks a whitespace
or sometimes 2 at the end of the string that I wish to chop. I came up with
the following until loop:

until ($group =~ /^[A-Za-z][_0=9a-zA-Z]*$\b/)
{
   chop $group;
}

This just keeps chopping. I tried the same loop without the \b, but this
doesn't work on a string that has a whitespace in the middle of the string.
I'm sure I'm missing something completly obvious, but I haven't been able to
catch it yet.

Thanks in advance for any help you can give me.
Kate

*********************
 Kate Stafford, MCSE
 Network Engineer
*********************

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 15 Mar 1999 16:34:40 -0500
From: Dean Pentcheff <dean2@mail.biol.sc.edu>
Subject: Re: Detecting a whitespace at the end of a string
Message-Id: <m3ogluzbbj.fsf@mail.biol.sc.edu>

kate_stafford@my-dejanews.com writes:
> I am writing a script using Activestate build 509. I am reading in a list of
> NT user groups that sometimes have a whitespace inside of them (i.e. "Domain
> Users"). The program that is generating the group names sticks a whitespace
> or sometimes 2 at the end of the string that I wish to chop. I came up with
> the following until loop:
> 
> until ($group =~ /^[A-Za-z][_0=9a-zA-Z]*$\b/)
> {
>    chop $group;
> }

$group =~ s/\s*$//;

-Dean
-- 
N. Dean Pentcheff                                     <dean2@mail.biol.sc.edu>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)


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

Date: Mon, 15 Mar 1999 22:34:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: does perl discourage obfuscated code? (was Re: Perl evangelism)
Message-Id: <wVfH2.73$AY3.254@newsfeed.slurp.net>

Matthew O. Persico (mpersico@bestweb.net) wrote:
: Perl (the language definition) and perl (the executable) do not
: discourage or encourage anything. They merely provide the MEANS by which
: you or I can write whatever we damn well please. The results depend
: entirely on the skill of the operator. You can write crap or gold just
: as easily in ANY language you please.

The last statement is true only if you mean "crap or gold relative to the
efforts of other authors using the same language."  Different languages
have different strengths and weaknesses, and indeed some are simply
all-around better tools for expressing algorithms than others, within
broad problem domains.  Nobody would blame a programmer for writing a
'crappy' (hard to understand, hard to maintain, painfully complex) text
formatting tool in Fortran.  A good programmer might minimize the crap
quotient, but never get close to the gold-osity achievable on the same
task in Perl (for example) by a merely competent programmer.

(And yes, I know you went on to say almost this in the material I've
snipped, but I thought it needed to be brought out separately and
directly.)

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "It's not an optical illusion; it just looks like one."


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

Date: Mon, 15 Mar 1999 22:43:06 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: does perl discourage obfuscated code? (was Re: Perl evangelism)
Message-Id: <_1gH2.78$AY3.254@newsfeed.slurp.net>

Eric The Read (emschwar@mail.uccs.edu) wrote:
: Mark <admin@asarian-host.org> writes:
: > But I think there are two scales here that we should consider: "useless to
: > powerful" vs. "terse and legible". 
: 
: A scale that runs from "terse" to "legible" is worthless.  Consider my
: current favourite bit of perl (don't ask me why, it's just come up a lot
: lately): foreach.  
: 
: foreach(@array) {
:   print;
: }

Which, it should be noted, is a less-terse version of

  print @array;

which might be called the 'natural' Perl WTDI.

: > For instance, very powerful instructions tend to be more terse than
: > easier ones. 
: 
: I'd like to see some evidence for this that's not APL.
: 
: This would also depend a lot on what you mean by "powerful".  I'm not
: sure it has any inherent meaning, as applied to programming languages, so 
: I'd like to understand what you mean by it.

I'll toss in a draft definition:  The 'power' of a programming language
construct is (bytes to implement in object code / bytes in source code).
Yes, it's stupid, but at least it provides a quantitative basis for
argument.  So, presuming a reasonably good C compiler, the power of

  i++;

might be around 0.25, while the power of

  print("%s", array[i]);

might well exceed 10,000 (leaving aside for a moment the question of power
measurements on shared function code, of course). 

: > Since Perl is extremely powerful, it can pack a multitude of operations
: > into a single line.
: 
: That doesn't follow.

It does if my definition is used;

  print @array;

expands to tons of 'object code' (machine-level instructions executed to
accomplish the task).

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "It's not an optical illusion; it just looks like one."


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

Date: Mon, 15 Mar 1999 20:53:55 GMT
From: rob_liberti@my-dejanews.com
Subject: Re: FAQ 8.31: Can I use perl to run a telnet or ftp session?
Message-Id: <7cjs0t$gge$1@nnrp1.dejanews.com>

In article <36ce3844@csnews>,
  perlfaq-suggestions@perl.com (Tom and Gnat) wrote:
> (This excerpt from perlfaq8 - System Interaction
>     ($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq8.html
> if your negligent system adminstrator has been remiss in his duties.)
>
>   Can I use perl to run a telnet or ftp session?
>
>     Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from
>     CPAN). http://www.perl.com/CPAN/scripts/netstuff/telnet.emul.shar will
>     also help for emulating the telnet protocol, but Net::Telnet is quite
>     probably easier to use..
>
>     If all you want to do is pretend to be telnet but don't need the initial
>     telnet handshaking, then the standard dual-process approach will
>     suffice:
>
>         use IO::Socket;             # new in 5.004
>         $handle = IO::Socket::INET->new('www.perl.com:80')
>                 || die "can't connect to port 80 on www.perl.com: $!";
>         $handle->autoflush(1);
>         if (fork()) {               # XXX: undef means failure
>             select($handle);
>             print while <STDIN>;    # everything from stdin to socket
>         } else {
>             print while <$handle>;  # everything from socket to stdout
>         }
>         close $handle;
>         exit;
>
> --
> "IMHO, CAPS LOCK should be somewhere more
> convenient; e.g., in another building."  --jgreely
>

Okay, I tried that, and as luck would have it, FORK is not supported on the
Windows NT version of Perl I'm using.  I know I can do it on a Unix box, but I
thought hey why can't I use the multiplexing io stuff from the select()
function?!  The problem is, that everything refers to the same FAQ which
doesn't supply a very easy to understand example:

    $nfound = select($rout=$rin, $wout=$win, $eout=$ein, undef);

So, for instance, I want to
(1) read from STDIN and send that to the client file descriptor
and at the same time
(2)read from the $handle file descriptor and write to STDOUT.

What do I assign to $rin? $win? and $ein?
How do I use $rout? $wout? and $eout?

I understand I have to start the $rin, $win, and $ein to ''. I also,
understand the fileno() and vec() functions. I just can't find an example of
anyone using the select fucntion for io multiplexing!  BTW I promise to do
this the easy way (with fork) on a Unix box, I just want to understand
select()

Thanks for any help,
Rob



-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 15 Mar 1999 21:11:12 GMT
From: rob_liberti@my-dejanews.com
Subject: Re: FAQ 8.31: Can I use perl to run a telnet or ftp session?
Message-Id: <7cjt16$hep$1@nnrp1.dejanews.com>

In article <36ce3844@csnews>,
  perlfaq-suggestions@perl.com (Tom and Gnat) wrote:
> (This excerpt from perlfaq8 - System Interaction
>     ($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq8.html
> if your negligent system adminstrator has been remiss in his duties.)
>
>   Can I use perl to run a telnet or ftp session?
>
>     Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from
>     CPAN). http://www.perl.com/CPAN/scripts/netstuff/telnet.emul.shar will
>     also help for emulating the telnet protocol, but Net::Telnet is quite
>     probably easier to use..
>
>     If all you want to do is pretend to be telnet but don't need the initial
>     telnet handshaking, then the standard dual-process approach will
>     suffice:
>
>         use IO::Socket;             # new in 5.004
>         $handle = IO::Socket::INET->new('www.perl.com:80')
>                 || die "can't connect to port 80 on www.perl.com: $!";
>         $handle->autoflush(1);
>         if (fork()) {               # XXX: undef means failure
>             select($handle);
>             print while <STDIN>;    # everything from stdin to socket
>         } else {
>             print while <$handle>;  # everything from socket to stdout
>         }
>         close $handle;
>         exit;
>
> --
> "IMHO, CAPS LOCK should be somewhere more
> convenient; e.g., in another building."  --jgreely
>

Not sure if my last message made it there due to having to subscribe AGAIN?!
Whatever, sorry if this is a repeat.
Can this be done without the fork statement?
I want to understand the select statement and everything references that page
with:

$nfound = select($rout=$rin, $wout=$win, $eout=$ein, undef);

I haven't found any good examples of how to use this.
I can set $rin:

$rin='';

and later do a:

vec($rin, fileno(Client), 1) = 1;

but I want to read from STDIN as well.  Is that another:

vec ($rin, fileno(STDIN), 1) = 1;

or does that go to $win?

How do I use $nfound?  Sorry if I'm missing the point on this one, but I can't
figure it out.  Thanks in advance,
Rob


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 15 Mar 1999 22:37:36 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Help: Conditional use of packages in Perl
Message-Id: <ebohlmanF8nqup.6y1@netcom.com>

edward@echarge.com wrote:
: I've got a strange problem that I hope somebody can help me with.  I'm trying
: to find some way to conditionally include particular packages in Perl.	I
: tried something like the following but it didn't work.

: if (condition is true)
:   use package1;
: else
:   use package2;

: It appears that Perl simply ignores the if statements and imports both
: packages regardless.  Please let me know if anyone has a solution.  Thanks in
: advance.

The problem you're running into is that "use" statements are executed at
compile time, whereas the rest of your code gets executed at run time.  
Depending on where in the flow of your code you need to do this, you 
might be able to put the conditional in a BEGIN {} block, so that the 
decision will be made at compile time.  Or you might have to replace 
"use" with a combination of "require" and "import."  A trip to perlmod 
would probably be helpful.




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

Date: Mon, 15 Mar 1999 14:19:01 -0800
From: grumetedapanair@hotmail.com ("Adrian Fiorinni")
Subject: Re: How can I send variable to FORM CGI that using method POST
Message-Id: <jHfH2.6951$EF1.32502629@WReNphoon1>

passme

easier, from scratch:
$your_data;
$encoded = &webfy_data($your_data);
$len = lenght($encoded);

print socket <<SEND;
POST /the_script_path/script.cgi HTTP/1.0
Content-type: application/x-www-form-urlencoded
Content-lenght: $len

$encoded
SEND



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: 15 Mar 1999 17:06:19 -0500
From: "Steve Swett" <swett@ncats.net>
Subject: How do you create an mSQL database...
Message-Id: <01be6f33$f69dbb20$51e5b0c7@bcs.newaygo.mi.us>

 ....for use with Perl CGI scripts and the DBI module on a Unix server?

I've seen lots of documentation on how to Connect to a database, how to
create/update table, how to Disconnect, etc. -- but how do you initially
create the database?

Can you do that outside of Perl with some kind of Unix command?  Do you
have to do it inside a CGI script?

(My web pages are on my ISP's Unix server and their Unix expert, who went
off to college, is no longer
available.)


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

Date: Mon, 15 Mar 1999 23:48:05 -0500
From: Alex Farber <alex@kawo2.rwth-aachen.de>
Subject: Re: How do you create an mSQL database...
Message-Id: <36EDE285.A5C0C2F9@kawo2.rwth-aachen.de>

Steve Swett wrote:
> ....for use with Perl CGI scripts and the DBI module on a Unix server?
> I've seen lots of documentation on how to Connect to a database, how to
> create/update table, how to Disconnect, etc. -- but how do you initially
> create the database?

Well, I don't have mSQL, but I have MySQL, and it comes
with a mysqladmin program. So if I call something like:

    system ( 'mysqladmin create test3' );

it wiil create database "test3". I have yet to see a program
that really needs to create a database (is table not enough?)
and think that DBI does not have a method for this, but maybe
I'm wrong.

/Alex

--
http://www.simplex.ru/pref.html


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

Date: Mon, 15 Mar 1999 20:01:45 GMT
From: John Hasler <john@dhh.gt.org>
Subject: Re: Learn the truth - In Dear Recruiter we establish exactly what a recruiter does.
Message-Id: <87hfrm7c9i.fsf@hasler.dhh>

Rufus V. Smith writes:
> A consultant is a person who:
>   a) calls himself,
> or
>   b) is called by someone else,
> a consultant.

or
 c) Borrows your watch to tell you what time it is.
-- 
John Hasler
john@dhh.gt.org (John Hasler)
Dancing Horse Hill
Elmwood, WI


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

Date: Mon, 15 Mar 1999 22:27:12 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Learn the truth - In Dear Recruiter we establish exactly what a recruiter does.
Message-Id: <Pine.HPP.3.95a.990315222637.24854W-100000@hpplus01.cern.ch>

On Mon, 15 Mar 1999, John Hasler wrote:

> > A consultant is a person who:

>  c) Borrows your watch to tell you what time it is.

And then charges you for the privilege?




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

Date: Mon, 15 Mar 1999 23:26:52 +0200
From: blade@leela.janton.fi (Sami Rosenblad)
Subject: Re: need better way to print external file withen perl file
Message-Id: <blade-1503992326520001@durandal.janton.fi>

In article <7cjmlb$tlp$1@news3.infoave.net>, "Jim"
<jim@*nospam*network-2001.com> wrote:

> Thanks much, but the
> only problem with that is that I have multiple $blah's .. $blah1 $blah2
> etc and I dont want to have to manually add each one into that. it
> actually reads those from a separate "configuration" file, I need to be
> able to change and add there.
> 
> I am just starting with perl, I cant find any good resources on the net
> and I'm still waiting on my perl/cgi cookbook from amazon so I'm just
> stumbling in the dark here, sorry to ask so easy/stupid questions.
> 
> Thanks for any help..

Ok, multiple $blah's...

#!/usr/bin/perl -w

$foo1 = "string";
$bar2 = "another string";
$baz3 = "yet another string";

print "Content-type: text/html\n\n";
open FILE, "testfile" or die "open: $!";
while (<FILE>) {
        s/(\$\S+)/eval $1/eg;
        print;
}
close FILE;

-- 
Sami Rosenblad | blade@leela.janton.fi | running Linux since 1999


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

Date: Mon, 15 Mar 1999 16:26:12 -0600
From: "Jim" <syt@email*@sp\am|@|spa/m@*.com>
Subject: Re: need better way to print external file withen perl file
Message-Id: <7ck1e1$eld$1@news3.infoave.net>

exactly what I needed, thanks very much

--
Jim

Sami Rosenblad <blade@leela.janton.fi> wrote in message
news:blade-1503992326520001@durandal.janton.fi...
>In article <7cjmlb$tlp$1@news3.infoave.net>, "Jim"
><jim@*nospam*network-2001.com> wrote:
>
>> Thanks much, but the
>> only problem with that is that I have multiple $blah's .. $blah1 $blah2
>> etc and I dont want to have to manually add each one into that. it
>> actually reads those from a separate "configuration" file, I need to be
>> able to change and add there.
>>
>> I am just starting with perl, I cant find any good resources on the net
>> and I'm still waiting on my perl/cgi cookbook from amazon so I'm just
>> stumbling in the dark here, sorry to ask so easy/stupid questions.
>>
>> Thanks for any help..
>
>Ok, multiple $blah's...
>
>#!/usr/bin/perl -w
>
>$foo1 = "string";
>$bar2 = "another string";
>$baz3 = "yet another string";
>
>print "Content-type: text/html\n\n";
>open FILE, "testfile" or die "open: $!";
>while (<FILE>) {
>        s/(\$\S+)/eval $1/eg;
>        print;
>}
>close FILE;
>
>--
>Sami Rosenblad | blade@leela.janton.fi | running Linux since 1999




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

Date: Mon, 15 Mar 1999 17:24:02 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Jim <jim@network-2001.com>
Subject: Re: need better way to print external file withen perl file
Message-Id: <36ED8882.AFDA1492@giss.nasa.gov>

[courtesy copy of post sent to cited author]

Jim wrote:
<snip>
> [...] Is there a better way to do this
> similar to this:
> 
> print <<__END__ ;
> contents of text file recognized like they are here
> __END__

here's a possible solution, building on Sami's suggestion:

no strict 'refs';  # turn off strict references
while (<FILE>) {
    s/(^|[^\\])\$(\w+)/$1 . ${$2}/ge;
    s'\\\$'$';
    print;
}
use strict 'refs'; # turn 'em back on


Or, you can do a "use/require/do" type thing:


--- file "foo.pm" --------
package foo;

sub the_string {
    package main;
my $string =<< "FOOZBALL";
the value of \$biz is "$biz"
and \@foo is "@foo"
FOOZBALL
    return $string;
}

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

use strict;
use vars qw(@foo $biz);

@foo = qw(1 2 buckle my shoe);
$biz = "3 4 close the door";

use foo;

print foo::the_string();
--------------------------

	Jay Glascoe
-- 
"Just say 'Poit!'"
  --Pinky


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

Date: Mon, 15 Mar 1999 22:11:02 GMT
From: frogsmock@my-dejanews.com
Subject: Need Faster Approach
Message-Id: <7ck0hd$krn$1@nnrp1.dejanews.com>

Folks,

Suppose a long comma-delimited string (say 100,000 items for the sake of
argument).  Now suppose you want to grab 50 items from the middle of this
string (like if you're displaying search results 50 at a time).  Does anyone
out there have a particularly speedy approach to this problem?	Right now I
am reading all 100,000 items into an array by using 'split' on the comma
delimiter, then I'm using 'splice' to grab my 50 result items into a
"results" array.

Here's the way I see it:  if I want, for example, records 75,000 - 75,050 out
of 100,000, one obvious place to save time is by ignoring everything after
75,050 (but I don't know how to do that using my 'split' approach).  However,
what I'm hoping for is a faster way (impossible?) to get to the 75,000th item
instead of splitting off each preceding item.

Thanks!

Jim

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 15 Mar 1999 21:17:28 GMT
From: nel_o@my-dejanews.com
Subject: Re: newbie needs help
Message-Id: <7cjtcs$hs7$1@nnrp1.dejanews.com>

Hi,

Posted this on another group. Hoping to get answer soon.
TIA.

> Greetings!
>
> Need to transform contents of 50 text files from...
>
> #Santa Clara
> ALMANOR
> <about 100 similar lines follows>
>
> to...
> #<Some text needed to be added here. >
> #Santa Clara
> ALMANOR		|Almanor	|50	|Male
>
> TIA
> ~nel_o
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>

~nel_o

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 15 Mar 1999 15:04:46 -0500
From: "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil>
Subject: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%);
Message-Id: <36ED67DE.63406D31@cpkwebser5.ncr.disa.mil>

Hi,

I'm trying to lean DBD::Informix and perl the hard way.  I am trying to
read the test scripts that came with the package.  The one I am
currently concerned with is InformixTest.pm, v 58.1 by Johnathan
Leffler.   From that script I found a line that doesn't make a lot of
sense to me:

$dbname = $dbname . '@' . $dbhost if ($dbhost && $dbname !~ m%[/@]%);

Obviously this is an assignment of a concatonated string to $dbname.
This assignment only works if ($dbhost && $dbname !~ m%[/@]%) evalueates
to true.  I assume that  $dbhost evaluates to true if it is declared(?)
and non-zero.  Is this right?  I also assume $dbname !~ m%[/@]%
evaluates to true if $dbname does not match  m%[/@]%.  What I completely
don't understand is " m%[/@]% "   What the heck does this mean?

TIA,

Steve




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

Date: 15 Mar 1999 22:04:46 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%);
Message-Id: <36ed83fe$0$215@nntp1.ba.best.com>

Steven T. Hatton <hattons@cpkwebser5.ncr.disa.mil> wrote:
>  What I completely
> don't understand is " m%[/@]% "   What the heck does this mean?

It's using the percent sign as the delimiter to the match operation.
Inside the regular expression you've got a character class consisting
of the "slash" character and the "at" sign. Thus, this will match any
line that contains either of those two characters ('/' or '@').

I think.

More details via:

perldoc perlre

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Mon, 15 Mar 1999 15:11:00 -0500
From: "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil>
Subject: NewbieQ: obscure code
Message-Id: <36ED6954.9EEBE5B5@cpkwebser5.ncr.disa.mil>

Sorry if this message shows up more than once.  I tried to send it with
a different subject, but I never saw it on the NG.  Perhaps all the perl
code in the subject caused the nntp server to reject it.???  

Hi,

I'm trying to lean DBD::Informix and perl the hard way.  I am trying to
read the test scripts that came with the package.  The one I am
currently concerned with is InformixTest.pm, v 58.1 by Johnathan
Leffler.   From that script I found a line that doesn't make a lot of
sense to me:

$dbname = $dbname . '@' . $dbhost if ($dbhost && $dbname !~ m%[/@]%);

Obviously this is an assignment of a concatonated string to $dbname.
This assignment only works if ($dbhost && $dbname !~ m%[/@]%) evalueates
to true.  I assume that  $dbhost evaluates to true if it is declared(?)
and non-zero.  Is this right?  I also assume $dbname !~ m%[/@]%
evaluates to true if $dbname does not match  m%[/@]%.  What I completely
don't understand is " m%[/@]% "  What the heck does this mean?

TIA,

Steve

--
http://counter.li.org -User # 79059 | I think.
http://www.suse.com                 | I think I am.
http://www.kde.org                  | Therefore I am.
http://samba.anu.edu.au             | I think? - Moody Blues



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

Date: Mon, 15 Mar 1999 14:13:12 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
To: "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil>
Subject: Re: NewbieQ: obscure code
Message-Id: <36ED85F8.39278B15@atrieva.com>

Steven T. Hatton wrote:
> What I completely
> don't understand is " m%[/@]% "  What the heck does this mean?

It's a regular expression.  The m% merely says we are using the % as the
delineator of the pattern.  m! and m{ are also popular choices.  This is
useful if you have slashes in your pattern,  or lots of escaped
characters.

For all the exciting detail on regular expressions, see the perlre
manpage.  For all the exciting detail on quote and quote-like operators,
see the perlop man page.

Good Luck!

Jerome

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Mon, 15 Mar 1999 16:42:00 -0600
From: "Raymond C. Jender" <rcj@lucent.com>
Subject: Newby question..
Message-Id: <36ED8CB8.9FA1A8C@lucent.com>


OK, all I'm trying to do is take a number: 12345.6789 (notice the
decimal point)
I want to set a variable to the number left of the decimal point.
(12345)
I've tried split, but apparently I'm having trouble reading the many
tutorials and Perl
books I've looked in. The use of split below comes right out of one of
them. 
 (I'm sure there are a bunch of bugs in these few lines)


Here is the code:

#!/usr/bin/perl           
$temp=2264996672;         
$temp1=($temp/256);       
print "\n";               
print "Temp = $temp\n"; # looks good  
print "\n";               
print "Temp1 = $temp1\n"; # looks good too
@quot = split(/./,$temp1);
print $quot[0]; # Not good          

Thanks.


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

Date: 15 Mar 1999 14:57:34 -0800
From: Ben Gertzfield <che@debian.org>
Subject: Re: Newby question..
Message-Id: <yttsob65pk1.fsf@gilgamesh.cse.ucsc.edu>

>>>>> "Raymond" == Raymond C Jender <rcj@lucent.com> writes:

    Raymond> OK, all I'm trying to do is take a number: 12345.6789
    Raymond> (notice the decimal point) I want to set a variable to
    Raymond> the number left of the decimal point. 

How about:

$number   = 12345.6789;
$int_part = int $number;

    Raymond> Here is the code:

*snip*

    Raymond> split(/./,$temp1);

Your problem here is that the character '.' is special in a regular
expression (think of it as a way of describing a string), which is the
second argument to split(). The '.'  character means "exactly one
character which is anything except newline".

So, your split call is splitting $temp1 on *every* character, not just
a literal '.' .

Either use int $number as above, or escape the . in your split() call
above with a \, like:

$number = 12345.6789;
($int_part, $decimal_part) = split /\./, $number;

Ben

-- 
Brought to you by the letters X and R and the number 4.
"Hoosh is a kind of soup."
Debian GNU/Linux maintainer of Gimp and GTK+ -- http://www.debian.org/
I'm on FurryMUCK as Che, and EFNet/Open Projects IRC as Che_Fox.


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

Date: 15 Mar 1999 17:00:25 -0500
From: jete@dgs.dgsys.com (Jete Software Inc.)
Subject: Pushing current line back onto <FILE>
Message-Id: <7cjvtp$lvu@dgs.dgsys.com>

I need to push the current line back onto the <FILE> file handle

open(FILE, "/tmp/junk") || die "Can't open /tmp/junk";

while <<FILE>) {

	if (something) {
		push $_ back onto <FILE>;
		last;
	}
}

I need to learn to write this down, because I have figured this out 3 or 4 times
in the last year, but I keep forgetting the solution and waste lots of time trying
to work it out. Then when I see how simple the solution is, I get pissed at myself. 

Also I don't want nor need to do the following:

	@lines = <FILE>;

Although it is a workaround.

-- Norman


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

Date: Mon, 15 Mar 1999 22:10:08 GMT
From: @l@ <aqumsieh@matrox.com>
Subject: Re: Regex $1 behavior
Message-Id: <7ck0fm$koh$1@nnrp1.dejanews.com>

In article <slrn7elm01.sjm.hdiwan@diwanh.stu.rpi.edu>,
  hdiwan@diwanh.stu.rpi.edu (the jackal) wrote:
> In article <slrn7ej4n4.cbq.jalovel@dogbert.orl.ilstu.edu>, Jeff Lovell wrote:
>
> >Ok, I'm sure I must be missing something fairly obvious here, but I can't
> >seem to find it.  When I use the $1 backreference in s/// it doesn't seem
>                                   ^ <------- inside a regexp, this needs to be
> a '\'

It depends on what you mean by "in the regexp". In the regular expression
part, you must use \1, \2 etc .. but in the replacement string, you should
use $1, $2, etc .. or else '-w' will complain.

[snip]

> >print $address, "\n";  # eq "127.0.0.1" <- I don't want this.
>
> Variable interpolation is performed inside double quotes [this is not C(++)]
> >$address =~ s/((\d+\.)*)/$1/;
>
> $address =~ s/((\d+\.)*)/\1/; # ****!!!!
>

Currently, there is absolutely no difference between the above two lines,
except that the second one will give you a warning under '-w'. The original
line is cleaner.

> You may want to check out Jeffrey Freidl's Mastering Regular Expressions for a
> section on matching IP Addresses. In short, this regular expression states.
> look for any number of numbers followed by a period [something like
> 276.276.265.256 would match].
>
> >print $1, "\n";        # eq "127.0.0."  <- I want this.
>
> Make the change marked with a '# ****!!!!' above and you will get the result
> you seek.

Those changes don't do anything. They are not changes really.


--Ala

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 15 Mar 1999 21:51:35 GMT
From: kkostenbader@my-dejanews.com
Subject: Re: Scalar/array question
Message-Id: <7cjvd2$ju5$1@nnrp1.dejanews.com>

Try this:

open (INF, "YOURFILE")||die $!;
while(<INF>){
  /(.*)/;
  push (@arr, "\"".$1."\"");
  }
foreach $item(@arr){print $item."\n"}


In article <36ecef46.11096488@news.freeserve.net>,
  John@melon17.freeserve.co.uk wrote:
> Just wondered if anyone knows
> how after i read a file into an
> array and then modify the elements
> so they are in double quotes?
>
> Example :
>
> line 1 of file is :
> Hello world
> Line 2:
> Hello again
> etc...
>
> But i want then in the array as "Hello  world"
> and "Hello again" respectively.
>
> John
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 15 Mar 1999 16:16:18 -0500
From: fred222@mauimail.com (George)
Subject: Sendmail question, and LWP question
Message-Id: <fred222-ya023580001503991616180001@news.bellatlantic.net>

First of all, I was curious if anyone know either some sendmail command, or
command for the mail proggies in Linux, so that I do not get complains back
if the recipient is unavailable.  This is because I'm setting up an
account-base website, and I need to email people confirmation info... and a
lot of the time the emails are asdf@asdf.com, which doesn't help me very
much so I end up having to delete lots of dead messages from my email box
every day... while I'm on the subject of that site, I might as well mention
that I've found Perl to be GREAT in its creation!  It's a jokes site, and
I've set it up so each user can choose graphical preferences, font size,
whether they get random jokes emailed to them daily, user statistics,
parental controls like the censoring of categories or 'bad' words, and so
forth.  Fun stuff, love it - thanks to everyone involved in the creation of
perl! >:)

Secondly, if there is anyone out there who would be so kind as to point me
towards the Linux 'packages' which contain the standard C/C++ compilers (I
forgot to install them!) I'd be forever greatful.  I really want to install
LWP, and I believe a compiler is pretty necessary unless I get someone else
to compile it for me (?).

Alternatively, if some kind soul would lend me the brief use of his server
with LWP installed so I can quickly test a 10-line program I wrote (its
just for pulling in and displaying a webpage), if I can't get LWP working
on mine, again, I would be very appreciative.

Thanks again,
George Henry

-- 
Just another hacking head >l-d


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

Date: Mon, 15 Mar 1999 21:08:48 +0100
From: Frank de Bot <debot@xs4all.nl>
Subject: Sorting Problem
Message-Id: <36ED68D0.8D14D81D@xs4all.nl>

I have an array:

$ar[0] = "14 || Some Text here";
$ar[1] = "4 || Lalalala";
$ar[2] = "7 || Hello World";

How can I sort that the array is this:

$ar[0] = "4 || Lalalala";
$ar[1] = "7 || Hello World";
$ar[2] = "14 || Some Text here";

I've tried everything, but nothing worked.




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

Date: 15 Mar 1999 16:41:14 -0500
From: Dean Pentcheff <dean2@mail.biol.sc.edu>
Subject: Re: Sorting Problem
Message-Id: <m3n21ezb0l.fsf@mail.biol.sc.edu>

Frank de Bot <debot@xs4all.nl> writes:
> I have an array:
> 
> $ar[0] = "14 || Some Text here";
> $ar[1] = "4 || Lalalala";
> $ar[2] = "7 || Hello World";
> 
> How can I sort that the array is this:
> 
> $ar[0] = "4 || Lalalala";
> $ar[1] = "7 || Hello World";
> $ar[2] = "14 || Some Text here";
> 
> I've tried everything, but nothing worked.

Somehow, I suspect that you haven't tried everything.  For example,
you didn't check the FAQ list, where you'd have found:

http://language.perl.com/newdocs/pod/perlfaq4.html#How_do_I_sort_an_array_by_anyth

among lots of other interesting and useful information.

Hope that helps!

-Dean
-- 
N. Dean Pentcheff                                     <dean2@mail.biol.sc.edu>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)


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

Date: Mon, 15 Mar 1999 21:58:45 GMT
From: chris@ixlabs.com
Subject: SSL Support is in a bad state!
Message-Id: <7cjvqf$k5f$1@nnrp1.dejanews.com>

Anyone skilled enough/interested in re-unifying LWP and SSLeay?

Right now this support has fallen into a really messy state, as Crypt::SSLeay
was dropped in expectation of Eric's implementation, which still isn't done.

Right now, for example, one cannot get LWP https-enabled on a FreeBSD box.

That really sucks, because this is the kind of thing Perl is supposed to kick
ass at.

Also - anyone know if there is a commercial implementation/Python solution?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 15 Mar 1999 14:53:30 -0500
From: "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil>
Subject: test pleas ignore
Message-Id: <36ED653A.64C7A417@cpkwebser5.ncr.disa.mil>

test




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

Date: Tue, 16 Mar 1999 08:58:11 +1100
From: Mick <horizon@internetexpress.com.au>
Subject: user.dat file problem..
Message-Id: <36ED8273.F4782A04@internetexpress.com.au>

Hi....Under NT, I can't seem to open a .dat file (Does Perl see it as an
executable and therefore not open it?)

The other problem is the contents is totally unformatted...I need to get
user/password pairs,  but it contains alot of garbage characters?.

Hope someone can help,
Mick
--
----------------------------------------------------------------
HORIZON Software Solutions

Visit Site - http:www.deakin.edu.au/~bellears/horizon/index.html
e-mail     - mailto:horizon@internetexpress.com.au

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




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

Date: Mon, 15 Mar 1999 22:19:02 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: user.dat file problem..
Message-Id: <slrn7er1ue.62.alastair@calliope.demon.co.uk>

Mick <horizon@internetexpress.com.au> wrote:
>Hi....Under NT, I can't seem to open a .dat file (Does Perl see it as an
>executable and therefore not open it?)

I'd suspect Perl can open it - if you have permission to that is. What what the
error message? A file's a 'file' isn't it?

>The other problem is the contents is totally unformatted...I need to get
>user/password pairs,  but it contains alot of garbage characters?.

Maybe it's a binary file? Maybe you have a virus?

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Mon, 15 Mar 1999 16:27:18 -0600
From: "Travis Leuthauser" <korak@intersurf.com>
Subject: Web Programming
Message-Id: <QLfH2.1$85.137707520@news.intersurf.com>

    I am trying to write a perl script which will display a dislaimer, have
the web user agree to the terms of the agreement, then call itself again and
bring up a simple form for the user to fill out.  The reason I would like
everything in the same script is to force every user to read the disclaimer
first.  If there is a better way, I am certainly open to suggestions.  This
is being written for an Apache web server.  Any help would be greatly
appreciated.

Thanks,
    Travis Leuthauser




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

Date: Mon, 15 Mar 1999 17:46:30 -0500
From: Mark Sholund <msholund@bigfoot.com>
Subject: Re: Where is Perl 5.004 ?
Message-Id: <36ED8DC6.D0E9BDBF@bigfoot.com>

Here's 5.005

 http://www.ActiveState.com/ActivePerl

Jens Engelbrecht wrote:

> Hello,
> I'm running Perl (v5.003_07) under win98. My Problem is to use the modul
> LWP::UserAgent. The modul requires version 5.004. I've tried to get the
> latest version of Perl under www.activestate.com but I couldnt find it
> there.
> Where can I get Version 5.004?
>
> Thanks for your answer !
>
> Jens Engelbrecht



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

Date: 15 Mar 1999 14:04:11 -0700
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Why are unresolved refs not reported?
Message-Id: <7cjskb$9md@llama.swcp.com>

In article <comdog-ya02408000R1503991548090001@news.panix.com>,
brian d foy <comdog@computerdog.com> wrote:
>
>would you rather predeclare all of your subroutines?

Another problem comes from AUTOLOAD routines.  By their very
nature they can not predeclare the subroutines that they will
handle.

I'm still bugged that:

	&{"foo"}

is a strict error ("Can't use string as a subroutine reference"), but

	&{\&{"foo"}}

is valid.  And that:

	my $ref = \&{"foo"}

produces a CODE reference, even if foo does not exist.  I complained
about this at length in <7929mc$9s5@boofura.swcp.com>, but no one
responded as to why function references were exempt from use strict
under 5.004 or if this is no longer acceptable in 5.005.

Tramm
-- 
  o   hudson@swcp.com                 tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.266.59.96   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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