[8277] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1894 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 13 21:07:13 1998

Date: Fri, 13 Feb 98 18:00:25 -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           Fri, 13 Feb 1998     Volume: 8 Number: 1894

Today's topics:
    Re: ? Regular Expressions ? (Jonathan Stowe)
    Re: An aside.. <rra@stanford.edu>
    Re: Basic File Manipulation <ebohlman@netcom.com>
    Re: Basic File Manipulation <rra@stanford.edu>
        Beauty jnorman2@usit.net
    Re: Clearing all variables <friedman@uci.edu>
    Re: combine lines(swap 2)for novice user (Craig Berry)
    Re: Creating Arrays from a file of names <beans@bedford.net>
        DBM Authorization <kelby@mplx.com>
    Re: Decryptable crypt? (Stephen P. Clouse)
    Re: Decryptable crypt? <rra@stanford.edu>
    Re: foreach and my() [GUTS; LONG] <chris@ixlabs.com>
    Re: garbage collection in perl <chris@ixlabs.com>
    Re: getting strings (Craig Berry)
    Re: Help: "use strict" & passing variables to subroutin <tkho@technologist.com>
        help: Question on hash ref <tkho@technologist.com>
    Re: Learning Perl (Jonathan Stowe)
    Re: on reading FAQs and gurus answering questions (Nathan V. Patwardhan)
    Re: on reading FAQs and gurus answering questions <rra@stanford.edu>
    Re: on reading FAQs and gurus answering questions <ebohlman@netcom.com>
    Re: Open Remore File <ebohlman@netcom.com>
    Re: Passing values into a subroutine from an array... <rra@stanford.edu>
    Re: perl -e in Win95? <ebohlman@netcom.com>
    Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ <ebohlman@netcom.com>
    Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ <danboo@negia.net>
    Re: retrieving html files (David Waring)
    Re: sending files with email <chris@ixlabs.com>
    Re: Stupid problem that got me stumped <rra@stanford.edu>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Feb 1998 20:23:17 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: ? Regular Expressions ?
Message-Id: <34e479a0.9534375@news.btinternet.com>

On 12 Feb 1998 14:45:54 -0500, Myles Barrett Williams <a@b.c.d> wrote:


>I downloaded and installed the djgpp build of Perl.  I don't have the
>manuals on my machine.  Go figure.
> 

So did I but have the docs in $libpth/pod.

/J\



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

Date: 13 Feb 1998 16:56:14 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: An aside..
Message-Id: <m3yazfxavl.fsf@windlord.Stanford.EDU>

StarScream <hallm4@cortez.sss.rpi.edu> writes:

>> /(foo) (bar)/ = ("xyzzy", "plugh")

> I've always felt it a shame that most people younger 
> than me will never get/understand these references. :-)

May the Great Bird of the Galaxy rest on your home planet.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Fri, 13 Feb 1998 23:28:24 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Basic File Manipulation
Message-Id: <ebohlmanEoCBvD.BJJ@netcom.com>

KHeise <kheise@aol.com> wrote:
: Background:  I am dealing with very large, fixed length data files (500M+ -
: 1,000,000+ records (lines)). 

: Question 1: Luckily our company appends a CRLF (carriage-return line-feed) at
: the end of each record (line) even though we don't really need it, so it has
: been easy for me to isolate records (lines), but there are times when I wont
: want to use the CRLF as a record delimiter. I will want to define the records
: according to x number of bytes (i.e.record1 = byte 0 - 199, record2 = 200-399,
: etc.). It seems like an easy problem, but I can't figure out a clean,
: efficient, and **fast** to deal with a file in this manner.

But Larry Wall did, and "perldoc -f read" will tell you how he did it.

: Question 2: I want to reverse the lines in a large file.
: (i.e. File = "AA""AB""AC""AD"- Reversed File = "AD""AC""AB""AA"). Is there an
: easy way to do this? Remember, these files are pretty huge, so I can't simply
: reverse the contents of a list(I think).

With a combination of seek() and read() and some tricky buffering that 
you'll have to implement yourself, this is possible.

: Question 3: How do you return the number of bytes in a file?

Using the -s test, of course (take a look at perlop).


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

Date: 13 Feb 1998 17:01:21 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Basic File Manipulation
Message-Id: <m3vhujxan2.fsf@windlord.Stanford.EDU>

KHeise <kheise@aol.com> writes:

> Question 1: Luckily our company appends a CRLF (carriage-return
> line-feed) at the end of each record (line) even though we don't really
> need it, so it has been easy for me to isolate records (lines), but
> there are times when I wont want to use the CRLF as a record
> delimiter. I will want to define the records according to x number of
> bytes (i.e.record1 = byte 0 - 199, record2 = 200-399, etc.). It seems
> like an easy problem, but I can't figure out a clean, efficient, and
> **fast** to deal with a file in this manner.

Have you looked at the seek(), read(), write(), pack() and unpack()
functions?  They would seem to do exactly what you're looking for.

> Question 2: I want to reverse the lines in a large file.  (i.e. File =
> "AA""AB""AC""AD"- Reversed File = "AD""AC""AB""AA"). Is there an easy
> way to do this? Remember, these files are pretty huge, so I can't simply
> reverse the contents of a list(I think).

Are these also fixed-length lines?  If so, you open the original file,
seek to the end, seek backwards the length of the line, read in the line
and write it out to the new file, seek backwards two lines, read in a line
and write it out, and repeat.

If not, you may have to do several seeks and reads to find the line
terminators.

> Question 3: How do you return the number of bytes in a file?

-s or stat().

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 14 Feb 1998 01:04:17 GMT
From: jnorman2@usit.net
Subject: Beauty
Message-Id: <34e4ec3a.361799583@nntp.usit.net>

In a Interview with Larry Wall in DDJ the interviewer asked Mr. Wall a
very interesting question. I would like to start a thread of opinions
on this matter.


The interviewer asked where Mr. Wall believed a programs beauty
existed. In the algorithm, or the syntax?



I personally feel like a program is not beautiful without a beautifull
unless its algorithm is beautiful. I believe that the logic and
cunning that is put into a clever algorithm are what is artistic.



Please post your opinions, especially if you have an opinion that is
contrary to either of the above choices.



                           		See you in the thread


				Regards,
				   JCN


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

Date: 14 Feb 1998 01:09:46 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Clearing all variables
Message-Id: <6c2qsq$1ko@news.service.uci.edu>

[mailed, posted]

I'm looking for the "rudeness" in Martien's message, and I don't see  it.
Curt maybe, but he explained your error & suggested a source for
further reading.  At these prices, do you really have the right to
ask for more?

-edf

In article <34e496d3.0@myth.vianet.on.ca>, Lainer <elaine@lainer.com> wrote:
<Someone else was KIND enough to point me in the right direction politely and
<I have subsequently learned a great deal from his willingness to help.
<
<Why are some people so damned rude to others in here?  Nowhere did I see in
<the FAQ that you had to be an expert in Perl to post to this NG.  Perhaps
<you should refrain from posting replies if you can't take a lighter tone
<with people and be a little more helpful.
<
<
<Martien Verbruggen wrote in message <6bvuj0$ak4$3@comdyn.comdyn.com.au>...
<>In article <34e33aa2.0@myth.vianet.on.ca>,
<> "Lainer" <elaine@lainer.com> writes:
<>> I am calling it as a separate executable using "require" at the end of
<the
<>> loop.
<>
<>Then you are NOT calling it as a seperate process. You would need
<>system, exec, backticks or qx// for that.
<>
<>perldoc -f require
<>
<>Please read.
<>Martien
<
<
<


-- 
Eric D. Friedman
friedman@uci.edu


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

Date: 13 Feb 1998 23:44:56 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: combine lines(swap 2)for novice user
Message-Id: <6c2ltp$k4e$1@marina.cinenet.net>

P.M.Wong (s11976@net1.hkbu.edu.hk) wrote:
: Sorry for asking the trivial question as i'm a newbir in perl
: I have a file with 3 lines, say:
: this is line 1
: this is line 2
: this is line 3
: 
: My objective is to turn them into one single line with first and 
: second swapped, i.e. the result should be like:
: 
: this is line 2 this is line 1 this is line 3

chomp(my @lines = <>);
my $oneLine = join ' ', @lines[1, 0, 2];

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


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

Date: 14 Feb 98 01:19:58 GMT
From: "TomH" <beans@bedford.net>
Subject: Re: Creating Arrays from a file of names
Message-Id: <01bd389a$43d82640$4c9163ce@beans.bedford.net>

Read the file, split each line (on whitespace) and join with a space, use
 .= to concatenate into a big string. After all lines are read you could get
clever with a substitution to put newlines every 10 names, or split it
again and use a counter and % (modulo) inside a foreach loop. 

Maybe if it weren't Friday night I'd write and test the code for you, but
this really isn't hard. I'd guess  it's about a 10 line program...

-Tom

Joseph Roundtree <rondtree@cadence.com> wrote in article
<34E4A307.53EF41CD@cadence.com>...
> Hello,
> 
> I have a file containing machine names. The file can be put into either
> of two forms; one form has
> the names each to a line, all 1100 of them; the other form has the names
> occupying one long line
> with the names separated by spaces.  I need to know how do I produced a
> file with lines containing
> 10 hostnames per row with the names separated by spaces.
 ...


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

Date: Fri, 13 Feb 1998 19:39:32 -0500
From: "Kelby Valenti" <kelby@mplx.com>
Subject: DBM Authorization
Message-Id: <6c2p83$13l@aaron.hamilton.edu>

Does anyone know how to use dbm Authorization from within a perl script.  I
would like to have this script automatically enter users passwords and
usernames when they are provided from the web.  In fact, if there is a
better system then DBM out there, please let me know.  What i am doing is
protecting a directory so that only registered users can get access when
they enter their password.  This could also use cookies if possible.  There
are going to be thousands of different users entering this directory.

    Thank you,

        Kelby




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

Date: Fri, 13 Feb 1998 23:42:40 GMT
From: stephenc@granddesign.com (Stephen P. Clouse)
Subject: Re: Decryptable crypt?
Message-Id: <34e4d7b8.2928931@news2.kc.net>


Hash: SHA1

On Fri, 13 Feb 1998 15:10:35 -0500 in message
<<6c28vv$g2v@bgtnsc02.worldnet.att.net> comp.lang.perl.misc>, "Michael R.
Harper" <mikihasa@worldnet.att.net> wrote:

>The Unix man page says that crypt is a one-way street.  I am looking for
>an encryption command for which there is an inverse operation
>(decrypt?).  The Camel book suggested the possibility of using a PGP
>module.
>
>I was only able to find one post to this group that mentioned PGP.  Can
>someone steer this newbie in the right direction?  I currently only need
>the ability to encrypt and decrypt data, so I guess I do not need
>anything fancy.

If you're looking for something implementable completely in Perl, browse to
http://www.dcs.ex.ac.uk/~aba/rsa/.  At the bottom of this page are several
encryption and hash algorithms written in Perl (and several other languages)
that you can use, including RSA, RC4, RC5, SHA, and MD5.

There are additionally several modules on CPAN (including the PGP module you
mentioned); most of these link into other C libraries to do their work.  This is
likely due to US export regulations on strong crypto implementations, which
would cause a headache for CPAN if they wanted to distribute one that was fully
Perl implemented...since the page above is in England it's not subject to the
inane US ITAR laws.

- -- 
Stephen P. Clouse
stephenc@granddesign.com -- steve@warpcore.org -- UIN 135012
Grand Design, Inc. (http://www.granddesign.com) -- Quality Business Web Design
The Warp Core (http://www.warpcore.org) -- The Web's Premier Descent Site
PGP-Encrypted E-Mail Preferred (Key available at www.granddesign.com/~stephenc)
Fight Spam/UCE -- http://www.cauce.org


Version: PGP for Business Security 5.5

iQA/AwUBNOTaWWOLD55Fj/ZkEQLgYwCfe+i68eCVT4EvZutRk+QIYOkwR6YAoIRQ
ZefBIagHlu8LqIcg5yNRlo2t
=lsIW
-----END PGP SIGNATURE-----



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

Date: 13 Feb 1998 17:07:48 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Decryptable crypt?
Message-Id: <m3sopnxacb.fsf@windlord.Stanford.EDU>

Michael R Harper <mikihasa@worldnet.att.net> writes:

> The Unix man page says that crypt is a one-way street.  I am looking for
> an encryption command for which there is an inverse operation
> (decrypt?).  The Camel book suggested the possibility of using a PGP
> module.

> I was only able to find one post to this group that mentioned PGP.  Can
> someone steer this newbie in the right direction?  I currently only need
> the ability to encrypt and decrypt data, so I guess I do not need
> anything fancy.

Good news:  PGP would probably do what you want.

Bad news:   Trying to use PGP is probably going to be a major problem.

PGP is a separate program with weird licensing restrictions, and I don't
believe there is any general module for doing either public key or
conventional encryption using PGP that doesn't have flaws or severe
deficiencies.  You'll probably have to do a lot of playing around with
pipes and coping with odd PGP behavior, and I wouldn't recommend starting
unless you have the time to become fairly familiar with PGP.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Fri, 13 Feb 1998 17:03:13 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
To: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: foreach and my() [GUTS; LONG]
Message-Id: <34E4ED51.24C0AD73@ixlabs.com>

If you want to make your global variables a little safer you could put
them in an object and only access them by methods like GetStatus and
SetStatus.

You could also do this with plain old subroutines, but you would still
need them to reference a global variable unless you know of a trick to
emulate a static variable in perl (I don't, offhand!).

-Chris



? the platypus {aka David Formosa} wrote:
> 
> In <34E25F62.17A9E971@us.oracle.com> Denis Goddard <dgoddard@us.oracle.com> writes:
> 
> >Chipmunk wrote:
> [...]
> 
> >All the more reson to code in a disciplined, maintainable fashion.
> >"Global variables. Hurt people. Bad scene."
> 
> I would have to aggry with you here that in general Global variables are
> baad things.  However it is good pratice if the code has multipal modes of
> behavor eg if you have a program that works in both cammel and llema modes
> you can have,
> 
> ungulate='Cammel'
> 
> --
> Please excuse my spelling as I suffer from agraphia see the url in my header.
> Never trust a country with more peaple then sheep.
> Support NoCeM http://www.cm.org/
> I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Fri, 13 Feb 1998 17:05:21 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
To: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: garbage collection in perl
Message-Id: <34E4EDD1.34B15477@ixlabs.com>

Wow that has to be a Perl thing, but I never realized that. That kinda
sucks. Is this the way Java works as well?

-Chris

? the platypus {aka David Formosa} wrote:
> 
> In <6bp1re$7k$2@marina.cinenet.net> cberry@cinenet.net (Craig Berry) writes:
> 
> [...]
> 
> >Also, Perl never returns any
> >memory to the OS (it keeps it in a pool for reuse instead),
> 
> Is this a perl thing or an OS thing?
> 
> --
> Please excuse my spelling as I suffer from agraphia see the url in my header.
> Never trust a country with more peaple then sheep.
> Support NoCeM http://www.cm.org/
> I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: 14 Feb 1998 00:03:40 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: getting strings
Message-Id: <6c2n0s$k4e$2@marina.cinenet.net>

Martien Verbruggen (mgjv@comdyn.com.au) wrote:
[gigasnip]
: What about
: 
: while (<SESSIONIX>)
: {
: 	if (/^$querystring\s+/)

Or:         /^\Q$querystring\E\s+/

 ...just in case one of your users has weird punctuation in their ID.  
It's good to be cautious about this sort of thing.

: 		print $_;

You can leave off the $_ if you're programming for terseness, job 
security, or cool-factor ranking. :-)

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


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

Date: Fri, 13 Feb 1998 17:35:49 -0800
From: Tommy <tkho@technologist.com>
To: Martien Verbruggen <mgjv@comdyn.com.au>
Subject: Re: Help: "use strict" & passing variables to subroutine
Message-Id: <34E4F4F5.2988623C@technologist.com>

Thank you for your help. I believe I have to study more to fix it.

Correct me if I am wrong. To do a variable passing between main and
subroutine, the structure for Perl 4 is something like this:

#!/usr/local/bin/perl
use strict;
my (@global_var);     # Global variables such as folder's name
 ...
@result_var= &routine(%passing_var);     # Passing variables such as filename
 ...

sub routine {
  %Q= @_;
  my (@routine_var, @result);    # temporary variable such as $i
  &DoSomething if (@global_var);
  ...
  return @result;
}

So, how is Perl 5 look like?

---------------------------------------
My main question is "How can I run strict and use hash ref together?" i.e

#!/usr/local/bin/perl
use strict;
my $VAL= &RetVal5( ARRAY => "TEST", POS => "FIRST" );
print $VAL;    # exactly equal to print $TEST{FIRST};

sub RetVal5 {
# for Perl 5
  my %Q= @_;
  my $A= "TEST";
  $A->{FIRST}= 1;    # equals to $$A{FIRST}= 1; I guess
  $A->{SECOND}= 2;    # equals to *A= "TEST"; $A{SECOND}= 2; I guess

  $A= "TEST2";
  $A->{WHITE}= "FFFFFF";
  $A->{BLACK}= "000000";

  $A= $Q{ARRAY};
  return $$A{$Q{POS}};
}

sub RetVal4 {
# for Perl 4
  my %Q= @_;
  my $A= "TEST";
  $$A= ( FIRST => 1, SECOND => 2);

  $A= "TEST2";
  $$A= ( WHITE => "FFFFFF", BLACK => "000000");

  $A= $Q{ARRAY};
  return $$A{$Q{POS}};
}

Correct me if I am wrong. I really appreciate for your help.

----------------------------
Martien Verbruggen wrote:

> You are using mixed perl4 and perl5 ways of doing things. You most
> likely do not want to use local, but my. You most likely don't want to
> use symbolic references, but hard ones. In this case, you want
> something like:
>
> ParseTable(\@text)
>
> sub ParseTable
> {
>         my $text_ref = shift;
>         my $id = $text_ref->[0];
>         ...
> }
>
> You should read a few documentation pages:
>
> perldoc perlref
> perldoc perlsub
> perldoc strict
> perldoc -f local
> perldoc -f my
>
> And possibly
>
> perldoc perldata
> perldoc perllol
> perldoc perldsc
>
> *sigh* Please don't do this. Configure your browser to not output
> HTML. HTML is for the web, Usenet is a plain text medium.

Thank you for your advice. I did not intend to put my text in HTML.

--
Tommy =P
tkho@technologist.com




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

Date: Fri, 13 Feb 1998 17:50:00 -0800
From: Tommy <tkho@technologist.com>
Subject: help: Question on hash ref
Message-Id: <34E4F848.8E7BC70F@technologist.com>

I have a question on hash ref. For some reasons, the first script works
but the second one.

#!/usr/local/bin/perl
# This script works
my $VAL= &RetVal( ARRAY => "TEST", POS => "FIRST" );
print $VAL;    # exactly equal to print $TEST{FIRST};

sub RetVal {
  my %Q= @_;
  my $A= "TEST";
  $A->{"FIRST"} = 1;
  $A->{"SECOND"} = 2;
  $A= "TEST2";
  %$A = ( "WHITE" => "FFFFFF", "BLACK" => "000000" );

  $A= $Q{ARRAY};
  return $A->{$Q{POS}};
}


#!/usr/local/bin/perl
# This script does not work
my %TEST= ( "FIRST" => 1, "SECOND" => 2 );
my %TEST2= ( "WHITE" => "FFFFFF", "BLACK" => "000000" );
my $VAL= &RetVal( ARRAY => "TEST", POS => "FIRST" );
print $VAL;    # exactly equal to print $TEST{FIRST};

sub RetVal {
  my %Q= @_;
  $A= $Q{ARRAY};
  return $$A{$Q{POS}};
}

I really appreciate if some can help.
--

Tommy Ho
---------------------------------------------------------------
   Email: tkho@technologist.com




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

Date: Fri, 13 Feb 1998 20:23:18 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Learning Perl
Message-Id: <34e47c98.10190015@news.btinternet.com>

On 13 Feb 1998 08:26:42 GMT, "Eric D. Friedman" <friedman@uci.edu>
wrote:

<snip>

>(note the chance of the filename: you're opening your program source
>and not the datafile)
>
Nasty business,  I had a bad habit a few years ago of using the source
file name as the output file in Informix ACE reports but you dont it
much more than a few times after trashing a couple hundred lines of
complicated SQL.

/J\


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

Date: 13 Feb 1998 23:43:29 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: on reading FAQs and gurus answering questions
Message-Id: <6c2lr1$qji@fridge.shore.net>

Douglas Clifton (doug@weboneinc.com) wrote:

: comp.lang.perl.cgi

Too bad there aren't "symbolic groups" in the sense that we have
symbolic links.  Then, we could just link all traffic from
comp.infosystems.www.authoring.cgi to comp.lang.perl.cgi.  :-)

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 13 Feb 1998 16:43:30 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: on reading FAQs and gurus answering questions
Message-Id: <m33ehnyq19.fsf@windlord.Stanford.EDU>

I R A Aggie <fl_aggie@thepentagon.com> writes:

> My first exposure to moderation was soc.feminism, which probably wasn't
> a good first exposure...and I've had a tainted view of moderation since.

Ugh.  I'm sorry to hear your previous experience has been bad.

With time, we've gotten a *lot* better at robomoderation, even in groups
that aren't just robomoderated.  About 50% of the traffic, and 90% or more
of the legitimate traffic, in rec.arts.comics.creative goes straight
through my front-end robomoderator (which uses my News::Gateway module)
without any human intervention at all, and the group has active
discussions just like an unmoderated group.

Propagation times are fairly fast now; the difference between when a post
appears in a moderated versus an unmoderated group is getting less and
less noticeable.

I honestly do believe it's possible to robomoderate a group in such a
fashion that the culture of the group is not appreciably different than an
unmoderated group except that there's a way of applying some filters in
advance.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 14 Feb 1998 01:37:31 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: on reading FAQs and gurus answering questions
Message-Id: <ebohlmanEoCHuJ.JuK@netcom.com>

I R A Aggie <fl_aggie@thepentagon.com> wrote:

: My first exposure to moderation was soc.feminism, which probably wasn't
: a good first exposure...and I've had a tainted view of moderation since.

While moderation in both technical groups and social groups has basically 
the same goal (to keep certain topics from being rehashed endlessly, with 
everybody repeating the same thing), it "feels worse" in a social group 
because the rehashed issues are usually things that people feel very 
strongly about, and it can be quite off-putting to be told that even if 
*you* haven't brought this issue up before, others have to the point 
where you have nothing new to offer.

I'd really check out a bunch of other moderated groups, preferably not 
"hot button" ones, before sticking to your first impression.



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

Date: Sat, 14 Feb 1998 01:17:13 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Open Remore File
Message-Id: <ebohlmanEoCGwq.IHC@netcom.com>

Bruce Davidson <bruce@allied.demon.co.uk> wrote:
: sub print_header {
: print "Content-type: text/html\n\n";
: open (HEADER,"$ext/$header") || print "Could not
: open $ext/$header $! \n"; while (<HEADER>) { print
: $_;
:  }
: close(HEADER);	

: I want to open a header on another server instead.
: Can anyone give a correction to the above to allow
: opening of remote header.

You'll need to do things quite a bit differently, and the LWP module, 
available from finer CPAN mirrors everywhere, will probably be a big part 
of what you'll be doing.  Grab it today!  It comes with a complete tutorial.



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

Date: 13 Feb 1998 17:29:40 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Passing values into a subroutine from an array...
Message-Id: <m3lnvfx9bv.fsf@windlord.Stanford.EDU>

Premgith Vidyanandan <vidyanan@pilot.msu.edu> writes:

> I call this subroutine in the following manner,
>   @val[0] = &result(@array[0]);

> sub result{
>   $value = grep "who" @array[$i];
>   return $value;
>  }

Why on earth are you doing things this way?  What's wrong with:

        @values = grep { /who/ } @array;

rather than all this work?  (And I don't think grep does what you think it
does, but maybe I'm misunderstanding.)

Right now, you're passing an array slice into result(), which also isn't
what you want to do.  If you call result with:

        result ($array[0])

then you're passing one and only one value into result.  You're not
passing an array into it at all.  If you want to pass a whole array into
result, you need to do:

        result (@array)

and then in result:

        sub result {
            my @array = @_;

When you call a sub, the parameters are put in @_; they're not passed by
name.  If you want to name them, you have to do that yourself by assigning
@_ to something (or the moral equivalent).

> The question I have is how can I pass the values from the call to the
> subroutine for different values of the array, for instance how can I call
> the same subroutine with @array[1];@array[2] .... and so on and make it
> return different values.

        foreach (@array) {
            subroutine ($_);
        }

is one way.  There are lots of ways to do this.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 14 Feb 1998 01:11:26 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: perl -e in Win95?
Message-Id: <ebohlmanEoCGn2.HxB@netcom.com>

Ed Avis <epa@datcon.co.uk> wrote:

: On NT, the quoting rules aren't quite as bad, and you can do

: perl -e "print \"Hello\n\";"

: but I'm not sure this works with command.com.

Works fine for me under 95.



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

Date: Sat, 14 Feb 1998 01:29:29 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <ebohlmanEoCHH5.J6J@netcom.com>

Fritz Knack <fritz.knack@nospam.POPULUS.net> wrote:
: For a report I've written, I'm trying to determine if a given phone
: number is an 800-class number, i.e., it begins with 800 or 888.

You've already received several explanations of how you were using 
character classes incorrectly, and have received suggestions on how to 
write your regex properly.  May I suggest another one?

if ($phone =~ /^8([02-9])\1/)...

This will match 800, 822, 833, 844, 855, 866, 877, 888, and 899.  All 
these area codes are designated for toll-free numbers (though 800 and 888 
are the only ones currently in use).  If you account for them now, you 
won't have to rewrite your script when a new one is added (which is 
expected to happen pretty soon).



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

Date: Fri, 13 Feb 1998 19:28:05 -0500
From: Dan Boorstein <danboo@negia.net>
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <34E4E515.4E6323F4@negia.net>

Francois Trousset wrote:
> 
> In article <34e45fe8.8296270@cnews.newsguy.com>,
>         fritz.knack@nospam.POPULUS.net (Fritz Knack) writes:
> > For a report I've written, I'm trying to determine if a given phone
> > number is an 800-class number, i.e., it begins with 800 or 888.
> >
> > Anyway, below are two snippets of code. The first one is what works
> > the way I want it to. The second pulls too much, e.g., area code 813
> > (Houston? Dallas?) "counts" as an 800-class number.
> >
> > Can anyone tell me what's going on? I would have though the two were
> > classic TMTOWTDI. (If it matters: perl 5.0003_07, Win32 build 311.)
> >
> > # Snippet 1:
> >       if ($phone =~ /^8[0{2}|8{2}]/) {
> > #             do stuff
> >       }
> >
> > #     Snippet 2:
> >       if ($phone =~ /^[800|888]/) {
> > #             do stuff
> >       }
[snip]
>         I think the good solution is /^800|888/
                                       ^^^^^^^^^^

i believe this will match any number that begins with 800 or any number
with 888 anywhere in it. the caret only binds the first regex element
to the beginning of the string so $phone = '543-1888' returns true.
that is why the parens are needed. try /^(800|888)/ or /^(:?800|888)/.

cheers,

--
danboo rstein


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

Date: 13 Feb 1998 23:59:34 GMT
From: dwaring@nwsr.com (David Waring)
Subject: Re: retrieving html files
Message-Id: <dwaring-1302981600310001@blv-lx102-ip35.nwnexus.net>

In article <34E44275.11CD@netjob.dk>, e.christensen@netjob.dk wrote:

> Hi
> 
> I think this is a simple question:
> How do I get a file from a remote webserver, without using the LWP
> module (I am not allowed to install this module on our server).
> 
> reg
> Ernst

---------------------
Ernst

 I have retrieved html files using a nice library script called url_get
(which in turn requires a couple of other other librarys) I have found
this to be quite stable an simple to use. They aren't new, the version I
have was last modified in 94 but I have had no problem with them in Perl
5.

I can't remember where I got them, but the comments say that it was last
modified by Jack Lund <j.lund@cc.utexas.edu> don't know if this address is
current.

I could send them to you if you want.

David

PS. If anyone has experience with url_get and LWP can you give me a reason
to use LWP instead for retrieving html pages.  I really can't tell what
all of the benefits of LWP are until I install it but I really would
prefer not to install it if I do not need it. (space limitations) Of
course it would be best if I could get my ISP to install it but that might
not happen too soon.


In article <34E44275.11CD@netjob.dk>, e.christensen@netjob.dk wrote:

> Hi
> 
> I think this is a simple question:
> How do I get a file from a remote webserver, without using the LWP
> module (I am not allowed to install this module on our server).
> 
> reg
> Ernst

******************************
*  
*  David Waring
*  Freelance Web Developer
*  HTML, Perl/CGI, Graphics etc.
*  dwaring@nwsr.com
*  http://www.nwsr.com
*  
******************************


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

Date: Fri, 13 Feb 1998 16:55:54 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
To: Pieter Ouwehand <pwo@speed.a2000.nl>
Subject: Re: sending files with email
Message-Id: <34E4EB9A.4B739275@ixlabs.com>

Hmmm..not as easy as that I don't think...
You will probably need the MIME::Lite module, which will prepare the
format before you invoke sendmail:

http://perl-com.songline.com/CPAN-local//modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/MIME/MIME-Lite-1.121.tar.gz

-Chris

Pieter Ouwehand wrote:
> 
> I've been testing to send email's trough a perlscript
> and everything works fine, accept how do i tell
> my mailserver that's it not a ordinary email but one
> with a attachment?
> 
> Pieter Ouwehand
> pedro@speed.a2000.nl


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

Date: 13 Feb 1998 17:24:24 -0800
From: Russ Allbery <rra@stanford.edu>
To: Allen Choy <achoy@us.oracle.com>
Subject: Re: Stupid problem that got me stumped
Message-Id: <m3pvkrx9kn.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Allen Choy <achoy@us.oracle.com> writes:

> Okay.  The require function can include modules dynamically by doing a

>                             require MODULE;

> Since I don't know which module I'm requiring ahead of time, I need to
> pass in a variable to the require. But the variable is a string, and I
> get a runtime error on the require line.  Anyone know how I can get
> around this?

You can do the transformation that require performs on barewords yourself:

            If EXPR is a bareword, the require assumes a ".pm" extension and
            replaces "::" with "/" in the filename for you, to make it easy
            to load standard modules. This form of loading of modules does
            not risk altering your namespace.

So do:

        $module =~ s%::%/%g;
        $module .= '.pm' unless ($module =~ /\.pm$/);
        require $module;

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

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

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