[8778] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2396 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 22 22:07:26 1998

Date: Wed, 22 Apr 98 19:01:41 -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           Wed, 22 Apr 1998     Volume: 8 Number: 2396

Today's topics:
        print $fh redefinition <china.no-spam@pprd.abbott.com>
        Probblems with perl on win95 m144103303@abonados.cplus.es
        Problem creating users on an NT server via Perl script <Scott_LeWarne@BigFoot.com>
    Re: Regular Expression to match a valid IP address <jdporter@min.net>
    Re: Removing spaces from a variable, how? (Abigail)
    Re: Removing spaces from a variable, how? (Matthew Cravit)
    Re: Removing spaces from a variable, how? <danboo@negia.net>
    Re: RMS should be invited to O'Reilly's "Free Software  (Eugene O'Neil)
    Re: Sending a text file via perl scott@softbase.com
    Re: Setting environment variables <rootbeer@teleport.com>
    Re: Setting environment variables (Abigail)
        Spaces in directory names (Jim Ray)
    Re: spoiled noobie (Sitaram Chamarty)
    Re: Testing <rootbeer@teleport.com>
    Re: UNIX mail script <bsw@hematronix.com>
    Re: WebMail Server ? nick@webthing.com
        win32::eventlog does not work. (User)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 21 Apr 1998 17:58:31 GMT
From: Albert Chin-A-Young <china.no-spam@pprd.abbott.com>
Subject: print $fh redefinition
Message-Id: <6himo7$mda12@fizban.pprd.abbott.com>

I'd like to have:
	print $fh "foo";
call my own print routine. What I have in mind is something like:

	use MyIO::File;

	my ($fh) = new MyIO::File;
	print $fh "this ", "that ";
	print $fh "theother\n";
	$fh->close;

Is this possible? What I want to do is buffer error output into an
array that is printed at the end if we don't have a controlling
terminal (say something running from cron). For non-error output,
it'll go to /dev/null.

-- 
albert chin (china.no-spam@pprd.abbott.com)


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

Date: Wed, 22 Apr 1998 08:54:33 -0600
From: m144103303@abonados.cplus.es
Subject: Probblems with perl on win95
Message-Id: <6hksqp$8ik$1@nnrp1.dejanews.com>

Hi
I'm getting started with perl and I would like to know if the folder
/flk is a normal folder in perl development, because I'm dealing with a forum
program and I'm having trouble with this folder, the server keeps on giving me
an error trying to locate the folder, it must be in a particular folder?
what this folder its used to?
I'm also going nuts with mail problems
I would like to know if there is a FAQ about perl with w95, I know perl that
perl works specially well with unix but we have crap windoze95 at work..so...
Chuck

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


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

Date: Wed, 22 Apr 1998 10:01:16 -0700
From: "Scott LeWarne" <Scott_LeWarne@BigFoot.com>
Subject: Problem creating users on an NT server via Perl script
Message-Id: <6hl8n6$a8q@news.or.intel.com>

I have a PERL script that takes new user info and creates a user account on
an NT server.  The script works fine when run locally on the server, but not
when run from a web browser.

I think it has something to do with the fact that when I run it locally, I
am running under the Administrator account and when it goes through the web
it uses the internet guest account.

I've gone back and given the guest account all the same access as the
Administrator account.  I've even setup IIS to use the Administrator account
for anonymous access instead of the internet guest account.  It still
doesn't work.

Does anyone know if there is something else going on here besides a
permission problem?  The same code works locally when run from a command
prompt, but not when run through IIS.

Here is the code that I'm using:

#system("createuser $accountname $password $firstname $lastname $company");
open("NET","createuser $accountname $password $firstname $lastname $company
| ");

Both the system and open approaches work locally.

Thanks for any info.

Scott LeWarne




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

Date: Wed, 22 Apr 1998 15:57:50 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Regular Expression to match a valid IP address
Message-Id: <353E14F6.6FB2@min.net>

Quentin Fennessy wrote:
> 
> An IP address is a 32 bit quantity.  Some 32 bit values
> are unlikely to be valid IP addresses. 

Unlikely? So what? The IP address space is defined to be 32 bits.
Are you going to flag a number as invalid just because some heuristic
categorizes it as "unlikely"?


> By using the common
> dotted-quad representation we can visually (or via regex) check for
> basic errors.

The regex to test that a number is in (0..255) is far too hairy.
Regexes can ensure that the components are decimal numbers; but 
range-checking is better done after the regex.  And this is true
regardless of whether we're looking at 8.8.8.8, 8.8.16, or 8.24.


> The valid IP address of 192.100.12.1 might be represented in several
> ways: base 16, base 27, Roman numerals, or whatever.

Sure, but so what? I'm talking about the representations that the
usual programs accept -- ping, telnet, ftp, Netscape...
based as they are (presumably) on the standard networking library.


> You suggest that some uncommon representations be matched by `any test
> one writes' (and I know you did not suggest Roman numnerals!).  I
> don't think that is useful for most folks.  Most folks want what most
> folks recognize, dotted quad addresses.

Perhaps. But that doesn't mean that your application should reject
valid IP addresses as invalid.
http://137.3406855 is valid; it points to my employer's web page.
666.234345868349843 is not valid.  And discriminating between valid and 
invalid is certainly easy enough to do.

Restricting input to the "dotted quad" notation strikes me as being
a very Microsoftian thing to do.
The internet standards are there for all to see and follow.
That's why they're called "standards".

John Porter


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

Date: 22 Apr 1998 16:30:15 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Removing spaces from a variable, how?
Message-Id: <6hl5un$d6r$1@client3.news.psi.net>

bjf (ben@wallroyds.demon.co.uk) wrote on MDCXCV September MCMXCIII in
<URL: news:893222683.6503.0.nnrp-06.c2de5b4a@news.demon.co.uk>:
++ 
++ How do you remove all spaces ... ie ... " " .... from a variable using
++ pattern-matching?


You read the manual.



Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: 22 Apr 1998 09:33:12 -0700
From: mcravit+usenet@mcravit.vip.best.com (Matthew Cravit)
Subject: Re: Removing spaces from a variable, how?
Message-Id: <6hl648$seo$1@shell3.ba.best.com>

In article <6hkb02$h1n@eng-ser1.erg.cuhk.edu.hk>,
Sleep  <mhchau@cse.cuhk.edu.hk> wrote:
>
>> This is actually a much better job for tr:
>
>>   $var =~ tr/ //d;
>
>what's the difference if we use :
>
>   $var =~ s/ //g;

The difference is that using tr is significantly faster. Using the benchmark
module and running the two above commands on the string created by

     my $string = " this   is a test " x 100;

produces the following results on my system (Sparc 20, Solaris 2.6, perl
5.004_04):

     Benchmark: timing 5000 iterations of s///, tr///...
           s///: 20 secs (17.35 usr  0.01 sys = 17.36 cpu)
          tr///:  3 secs ( 2.71 usr  0.00 sys =  2.71 cpu)

/MC

-- 
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@net.com (work)      | time you make it.


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

Date: Wed, 22 Apr 1998 12:00:18 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Removing spaces from a variable, how?
Message-Id: <353E1412.A1F9AC64@negia.net>

Sleep wrote:
> 
> Craig Berry <cberry@cinenet.net> wrote:
> > bjf (ben@wallroyds.demon.co.uk) wrote:
> > : How do you remove all spaces ... ie ... " " .... from a variable using
> > : pattern-matching?
> 
> > This is actually a much better job for tr:
> 
> >   $var =~ tr/ //d;
> 
> what's the difference if we use :
> 
>    $var =~ s/ //g;
> 
> ?


speed. if this is going on inside a tight loop then you can benefit
greatly from 'tr':

use Benchmark;

timethese( 50000, {
  'tr///' =>  sub {
                    my $var = 'potato spam monkey' x 100;
                    $var =~ tr/ //d;
                  },
  's///' =>  sub {
                    my $var = 'potato spam monkey' x 100;
                    $var =~ s/ //g;
                  },
});

Benchmark: timing 50000 iterations of s///, tr///...
      s///: 18 secs (19.56 usr  0.00 sys = 19.56 cpu)
     tr///:  6 secs ( 5.31 usr  0.00 sys =  5.31 cpu)

hope this clarifies,

-- 

dan boorstein


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

Date: Wed, 22 Apr 98 15:45:18 GMT
From: eugene@cs.umb.edu (Eugene O'Neil)
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <6hl3a6$euf@dfw-ixnews8.ix.netcom.com>

In article <m3k98qmyvh.fsf@stoli.spirits.org.au>, nathanh@chirp.com.au wrote:
>tzs@halcyon.com (Tim Smith) writes:
>
>> With there now being at least five reasonable ways one could release free
>> software (public domain, GPL, MPL, BSD/X (I'll count these as one even
>> though many people find the differences significant), and Artistic), people
>> should really consider very carefully the license they use.  They should
>> not automatically use GPL just because, say, they develop on Linux and most
>> of the stuff on Linux is GPL'ed, nor should they choose BSD just because
>> they happen to be using FreeBSD.
>
>You should choose GPL because none of the other license guarantees
>that the software you write today will continue to be developed as
>free software tomorrow.

The GPL does not guarantee your software will continue to be developed at all!
It certianly doesn't magically turn commercial developers into free software 
developers, it just tells the commercial developers to fuck off. Thus, the 
only guarentee you get is that large numbers of highly skilled, professional 
developers won't even look at your code.

>Your other licenses allow free code to be hoarded. The GPL takes a
>firm *positive* stance against hoarding by requiring that GPL code
>must never be distributed non-freely.

Or you could say it takes a *negative* stance against people making money. The 
only difference is how you phrase it.

>None of the other licenses guarantee this, therefore all the other
>licenses are inferior.

None of the other licenses guarentee that your work won't be touched by 
most commercial developers with a ten-foot pole, therefore, all other licenses 
are... um... could you run that by me again?

>It's a difference between being generous, and being responsible. A
>free software developer who doesn't release code under the GPL has
>not guaranteed the software's continuing freedom.

Yes they have. The version that was RELEASED as free code will ALWAYS be free! 
Any improvements people CHOOSE to contribute as free software will also be 
free! Only non-free dirivative works will not be free: they wouldn't be free 
under the GPL either, they simply wouldn't exist. Does less software make the 
world a better place?

-Eugene


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

Date: 22 Apr 1998 16:06:40 GMT
From: scott@softbase.com
Subject: Re: Sending a text file via perl
Message-Id: <6hl4ig$gcr$4@mainsrv.main.nc.us>

Glenn Schworak (Glenn.J.Schworak@state.or.us) wrote:
> I have this chunk of perl code that works great under Netscape but
> InterNet Explorer 4.0 loses its mind when it starts to download.

> This code will take the file name from the web page and then tack on the
> content-type header to get the web browser to start downloading (rather
> than displaying it).

The content type in question is probably undefined. I've learned the
hard way to ZIP everything I put on the Internet because if you put an
EXE or some other file format most people will not get the file. At
best, the browser reads the binary data and tries to rasterize it in
the browser window! You have to stick to the lowest common denominator
that most browsers can swallow. It may look like fun to use
exotic content types in your CGI programs, but the state of the art
is HTML, TXT, and ZIP.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Wed, 22 Apr 1998 15:59:40 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Jeff Spray <jespray@one.net>
Subject: Re: Setting environment variables
Message-Id: <Pine.GSO.3.96.980422085548.6132K-100000@user2.teleport.com>

On Wed, 22 Apr 1998, Jeff Spray wrote:

> I need to manipulate a current environment variable and then set a new,
> previously unset variable and make it permanent for all subseqent shells
> that start. 

If you mean "_all_" subsequent shells which are to run on that machine,
this is a task to be handled at the system administration level. If you
mean merely to affect all shells started from your current process,
though, that should be pretty straightforward. How far have you gotten? 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 22 Apr 1998 16:36:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Setting environment variables
Message-Id: <6hl6a8$d6r$2@client3.news.psi.net>

Jeff Spray (jespray@one.net) wrote on MDCXCV September MCMXCIII in
<URL: news:353D6BE0.9C29ADD6@one.net>:
++ Hello list,
++     I have a problem that I need to manipulate a current environment
++ variable and then set a new, previously unset variable and make it
++ permanent for all subseqent shells that start.  I can get them set, but
++ they are not permanent.  This must be accomplished on NT platforms
++ (corporate bought them, not me).  Any help would be appreciated.  TIA


Read the faq.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Wed, 22 Apr 1998 16:05:35 GMT
From: james.a.ray2@boeing.com (Jim Ray)
Subject: Spaces in directory names
Message-Id: <MPG.fa7b5264e9bb1c5989680@news.boeing.com>

I have a perl script that will be a list of files and directorys.  It 
works really good till you come to a direcory that has a space in it.  I 
am using HP/UX and perl 5.  

The results are the same when using Netscape as IE.  

This is the code I use to fill the spaces with the right code.      
"$dirname=~ s/ /%20/g; "

Any help would be helpful.

Thanks again


Jim


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

Date: 22 Apr 1998 14:49:49 -0700
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: spoiled noobie
Message-Id: <slrn6jsfpe.ti.sitaram@localhost.localdomain>

On Mon, 20 Apr 1998 21:07:33 -0400, Sahagian <sahagian@ziplink.net> wrote:
>I grew up? with the trim() function which returns a string with the
>leading and the trailing space-chars removed.
>
>Any elegant way to do this in PERL5 ?  Thanks. -dvs-

$var =~ s/(^ +)|( +$)//g;

Change the spaces inside the parens to \s if you mean whitespace,
not just space.


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

Date: Wed, 22 Apr 1998 16:48:55 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Fain <mindmore@mindless.com>
Subject: Re: Testing
Message-Id: <Pine.GSO.3.96.980422094630.6132P-100000@user2.teleport.com>

On Wed, 22 Apr 1998, Fain wrote:

> Charlene Yanke wrote:
> 
> > This is only a test.
> 
> Your test worked.

No, it didn't. If it had been a successful test, it would not have
appeared in c.l.p.misc. It would have been in a newsgroup whose name ends
in ".test", like all proper Usenet test messages.

But I know what you meant. :-) 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 22 Apr 1998 11:01:13 -0500
From: Brian Waugh <bsw@hematronix.com>
To: anpap@usa.net
Subject: Re: UNIX mail script
Message-Id: <353E1449.483648D1@hematronix.com>

This is a multi-part message in MIME format.
--------------55E21FFD4723EDC87105122F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I found a demo script that uses perl to connect directly to a SMTP host
to send the email. It is included in the CPAN perl archive in the libnet
module. 

It is located here.

ftp://ftp.metronet.com/pub/perl/authors/id/GBARR/libnet-1.0605.tar.gz

Once unpacked look in the ./demos directory for smtp.self

anpap@usa.net wrote:
> 
> I need a Unix (or perl) cgi script that will enable me to
> send mail without a mail client.
> I have tried telneting on port 25 from within a shell cgi
> script, but it didn't work.
> Anyone has a script that works??
> 
> Andreas Papagapiou.
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading
--------------55E21FFD4723EDC87105122F
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Brian Waugh
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Brian Waugh
n:              Waugh;Brian
org:            Hematronix, Inc.
adr;dom:        1505 Capital Ave;;;Plano;TX;75074;
email;internet: bsw@hematronix.com
title:          System Architect
tel;work:       (972) 596-6165 x 254
tel;fax:        (972) 423-4395
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------55E21FFD4723EDC87105122F--



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

Date: Wed, 22 Apr 1998 10:35:34 -0600
From: nick@webthing.com
Subject: Re: WebMail Server ?
Message-Id: <6hl2o6$gjk$1@nnrp1.dejanews.com>

In article <353DDFCB.EE2B4B69@mindless.com>#1/1,
  Fain <mindmore@mindless.com> wrote:

( I like the email address ;-)

> news.seed.net.tw wrote:
 .tw - the author is probably not as comfortable as you or I writing in
English.  We should IMO be liberal with interpreting the wording.

> > If i created a like Yahoo WebMail Server , How can i do ?
> >
> > write a cgi-script ? Please list it ....

Do you mean "where can I get one"?

> You mean something like hotmail?

There are two different types of mail-by-web systems:
(1) Complete self-contained systems.
(2) Readers that work with a POP server.
To be anything more than a toy, the latter needs to be a double-server
(e.g. fastcgi) architecture, as the overhead of connecting to POP is
far too big for standard CGI.

There's a complete mail-by-web system available for download from
<URL:http://www.webthing.com/software/>.  It's free for non-commercial
use; OTOH if you want to compete with the likes of hotmail, you have to
pay for it.  There are also some free pop-client CGIs floating around.

> There is nothing wrong with your question but I think your trying to
> shoot the moon on this one. I'm sure the script is rather large and
> complicated. A better question for you to ask would be (or a starting
> question to ask would be):
>
> In theory... what would it take to write a program like what we see in
> Yahoo WebMail Server? CGI?

I don't know: an answer to that is either superficial or long and detailed.
For a start, processing incoming mail messages is entirely separate from CGI.

> In USENET it should be a general rule that you ask one question at a
> time and ask ones that are specific (or as specific as you can get)
> instead broad band one liners. If you can't be specific then ask
> questions that will give you more insight so that you can be more
> specific

erm, yes, but, ...

>  Basically, get one detail at a time. That's how it works.

I'm going to disagree: few things annoy me more than a single poster
asking to be continually spoon-fed on the way to making something work.
Most questions can be answered by browsing FAQs, webpages, Dejanews, etc,

I'm not sure that's actually what you meant, but it reads like that to me.

> When I saw your question the first thing I thought is (weather true
> about you or not) Here is a guy that has found something he thinks is
> cool... wants to know what it is written in but doesn't want to learn
> how to write it, just wants to have it (for private or commercial).
> That's my first impression and probably allot of other as well.

But that's the difficulty when writing in a language that's not your
mother-tongue.  The subtelties of how a particular wording will come
across are very difficult for a foreigner to acquire - and even Brits vs
Americans vs Aussies (/etc) can misunderstand each other.

Hmmm .. this is getting increasingly off-topic.  Followups set.

Nick Kew.

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


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

Date: Wed, 22 Apr 1998 12:53:37 GMT
From: you@somehost.somedomain (User)
Subject: win32::eventlog does not work.
Message-Id: <353de816.1118478026@news.btinternet.com>

Help !

Has anyone got any example code using this to either post a test event
to the eventlog or reporting on a specific event.

I cant seem to get the examples working in the win32 documentation.

So any better docs on this particular module or some pointers to
example code would be great

Perl is 316 active state.


Thanks

Ian


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

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

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