[8110] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1729 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 26 03:08:24 1998

Date: Mon, 26 Jan 98 00:00:41 -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, 26 Jan 1998     Volume: 8 Number: 1729

Today's topics:
        !Wanted: Perl assistance <admin1@bbs.shadowmac.org>
        _Effective Perl Programming_ <vladimir@cs.ualberta.ca>
    Re: Bad (Swear) Word Checking <rjk@coos.dartmouth.edu>
    Re: BASE64 Decode (brian d foy)
    Re: Browser Identification? <wha@tuique.com>
    Re: Calling CGI script from other CGI script (Tad McClellan)
        declarating subroutine prototypes <rjk@coos.dartmouth.edu>
    Re: Decrypting modules for Perl <rjk@coos.dartmouth.edu>
        Fed up with CGI.pm (Matt Fischer)
        Help with opening and copying to a file <dhoober@interserv.com>
    Re: how to do formfeed/pagebreak (brian d foy)
        Howto match similar line item in different files? <r.hazeltine@nepean.uws.edu.au>
    Re: html user needing perl? (brian d foy)
    Re: IIS/NT 4.0 and PERL5, got it to work! (Martin Vorlaender)
    Re: Odd syntax problem <rjk@coos.dartmouth.edu>
    Re: Perl module documentation format? (Tad McClellan)
    Re: Perl Source Obfuscator (brian d foy)
    Re: POSIX (?) under perl for Win95 rodney@bond.net
    Re: returning values out of a recursed sub <rjk@coos.dartmouth.edu>
    Re: simple perl question, regx, please help. <rjk@coos.dartmouth.edu>
    Re: simple perl question, regx, please help. (brian d foy)
    Re: Where do my "my" variables go in the debugger? <vladimir@cs.ualberta.ca>
    Re: White Hats and Black (Don Groves)
    Re: Why does split return undef? - My own followup <rjk@coos.dartmouth.edu>
    Re: Why does split return undef? <rjk@coos.dartmouth.edu>
    Re: Why enable CreateProcessWithNewConsole? (Martin Vorlaender)
    Re: WIN32 LWP Problem (Martin Vorlaender)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 26 Jan 1998 07:21:56 GMT
From: ShadowMAC Admin <admin1@bbs.shadowmac.org>
Subject: !Wanted: Perl assistance
Message-Id: <6ahdik$iv$1@blackice.winternet.com>

  As the subject states, we are looking for a couple of Mac people who
know Perl to assist here at ShadowMAC with a few filebase and system
Perl scripts and Perl CGIs.

  This is a site composed of Mac volunteers, this is a site which totally
exists only by donations and thus this is a request for a couple of
volunteers who wish to support the platform we all prefer.

  The site operates under the Solaris 2.5.1 unix OS, so unix knowledge is
needed.

  If you would like to assist in growing ShadowMAC's filebase, and helping
other Mac'ers, then please access our Co-Admin application web page at

http://www.ShadowMAC.org/application_coadmin.html


-- 

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
|        Mac file archives, you want Mac archives?        |
|        Then stop by ShadowMAC for a look around!        |
|                                                         |
|        anonymous ftp in via:  ftp.ShadowMAC.org /pub    |
|  or set your web browser to:  http://www.ShadowMAC.org  |
|   ShadowMAC's IP address is:  198.174.169.113           |
|                       Email:  Admin@ShadowMAC.org       |
|                                                         |
|   Supporting the Mac in all its incarnations;           |
| Mac (680x0), Newton, PowerBook (680x0),                 |
| PowerBook (PPC), PowerMac (PPC Mac), and Mac clones!    |
|                                                         |
| Not only does ShadowMAC have it's own archives, but, we |
| also provide mirrors of other Mac and Newton filesites. |
|                                                         |
| Freely supporting the Mac!                              |
|                                                         |
|                    S h a d o w M A C                    |
|               Twin Cities, Minnesota  USA               |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+


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

Date: 25 Jan 1998 23:20:55 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
Subject: _Effective Perl Programming_
Message-Id: <om3eibzrg8.fsf@tees.cs.ualberta.ca>

A quote from the recently completed book of Joseph Hall and Randal
Schwartz (http://www.effectiveperl.com/intro.html) that strikes me as
odd:

    I don't use English. It's just too verbose for this little book.
    Furthermore, English is not common practice among Perl
    programmers, and scripts that use English suffer a speed penalty.
    This is not to say that English is not useful, just that you won't
    see it here.

Words to live by :)

PS: I was quite proud of myself for spelling Randal's last name
correctly without looking. Then I saw that I had written "Randalf"!
I guess that I had mixed up Merlyn and Gandalf. :)


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

Date: Sun, 25 Jan 1998 23:49:33 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Bad (Swear) Word Checking
Message-Id: <34CC15DC.D9E7F56E@coos.dartmouth.edu>

Dave Power wrote:
> 
> On Sun, 25 Jan 1998 15:03:15 -0500, Chipmunk <rjk@coos.dartmouth.edu>
> wrote:
> 
> >Dave Power wrote:
> >>
> >> Does anyone know if a 'Bad Word' (dubious or definite swear words)
> >> file exists which may be available. I think I know most of the English
> >> ones (but then I'm not that sure that I do). I'm really looking for a
> >> definitive list covering at least the western world languages.
> >
> >This one's more of a phrase than a word:
> >
> >"People who post questions to clpm which have nothing to do with Perl."
> >
> >Chipmunk
> >
> >(Hope I didn't offend anyone. ;-)
> 
> The thing is I'm trying to validate a form, the contents of which will
> be transmitted to ithers.
> 
> I need to know if the content may be offensive. This is a Perl app

Whether or not anyone knows of a list of naughty words in foreign languages
has absolutely nothing to do with Perl.

Consider:
If you were writing this application in C, you would be using the same list
of naughty words.
If you were writing this application in Java, you would be using the same
list of naughty words.
If you were writing this application on punch cards, you would be using the
same list of naughty words.

Catching on yet?

Chipmunk


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

Date: Mon, 26 Jan 1998 02:36:37 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: BASE64 Decode
Message-Id: <comdog-2601980236370001@news.panix.com>
Keywords: just another new york perl hacker

In article <6agv81$4eh$1@winter.news.erols.com>, "The Smiths" <smiths@erols.com> posted:

> Before I write one, I was wondering if a BASE64 decode routine might already
> be available in PERL?

there is a module for almost everything, and one can find most of them
at a CPAN mirror.

good luck :)

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Sun, 25 Jan 1998 22:06:42 -0800
From: Peter Crockford <wha@tuique.com>
Subject: Re: Browser Identification?
Message-Id: <34CC27F2.66F8@tuique.com>

darkcyde wrote:
> 
> Hello,
> 
> I am writing a Perl script to do browser identification, does anyone
> know of a web site that has all the latest UserAgent variables for all
> the latest browsers.
> 
> I need them for Netscape Navigator 3.0, Netscape Communicator 4.0,
> Internet Explorer 3.0, and Internet Explorer 4.0.
> 
> Thanks,
> Michael Bazaillion
> --
> So Brain, whatdya wanna do tonight?
> Same thing we do every night, Pinky.  Try to take over the world!

Hi Michael,

I have been compiling a list of USER_AGENT values for various browsers. 
Thanx go out to Eli for the Lynx info.  Anyone else??

Here is my admittedly small list ( my hard drive has been full for a
while now :-] )

browser info 		USER_AGENT value
(from help -"About")	(empirically tested!)

Microshite IE 3.02	'Netscape/2.0 (compatible; MSIE 3.02; Update a;
Windows 95)'
ditto (another box)	'Netscape/2.0 (compatible; MSIE 3.02; AK; Windows
95)'

Netscape 3.0 - 96223	'Mozilla/3.0 (Win95;I)'

Netscape 4.03[en] - 97247	'Mozilla/4.03 [en] (Win95;I;Nav)'

I have yet to download and test the new MSIE 4, due to a lack of space,
and general loathing.  I'd appreciate it if anyone would send me the
info.

Cheers


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

Date: Sun, 25 Jan 1998 21:41:55 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Calling CGI script from other CGI script
Message-Id: <3m0ha6.7ea.ln@localhost>

Chip Salzenberg (chip@mail.atlantic.net) wrote:
: According to tadmc@flash.net (Tad McClellan):
: >Default (danielle@broken-heart.com) wrote:
: >: Please reply
: >: to   webmaster@_nospam_whitney-fan.com
: >: but remove the _no spam_ part first.
: >
: >That joke is too old to be funny anymore...

: Spam is no joke.  Neither is Spam fighting.


No, of course not.

Expecting email when your address has been munged is the "joke"
I was referring to. 

Not spam fighting. 

Not even choosing to munge your address. 

That is your choice to make.

It seems unreasonable to expect other people to do more work because
of _your_ ("you" the munger, not "you" Chip) decision though.

If you choose to munge, you should resign yourself to having
to actually go find answers to your posts in the newsgroup
where you asked the question.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 26 Jan 1998 00:18:46 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: declarating subroutine prototypes
Message-Id: <34CC1CB6.F6C66466@coos.dartmouth.edu>

I've noticed that declaring subroutine prototypes has no effect when the
declaration is done
later in the code than the subroutine call.

i.e.:

sub foo ($) {
  print "@_\n";
}

foo(1, 2);

causes a compilation error.

Whereas:

foo(1, 2);

sub foo ($) {
  print "@_\n";
}

does not, and in fact prints out "1 2\n".


Why is that?  I find it frustrating, since I like to define my subroutines below
the main code, and I'd rather not have the prototypes at the top of the file and
the definitions at the bottom - it would be harder to maintain.
Programming Perl says nothing about declaring prototypes before the subroutine calls.

Chipmunk


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

Date: Mon, 26 Jan 1998 01:10:12 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Decrypting modules for Perl
Message-Id: <34CC28C4.2E0A24C3@coos.dartmouth.edu>

Ed Finch wrote:
> 
> In article <6aequf$800$1@volt.electriciti.com>, "David" <davidu@eciti.com> posted:
>
> > I have written a perl script that takes input, incrypts it via 'crypt,' and
> > then stores it in a file.  I need to be able to decrypt this file when it is
> > needed, the 'crypt' function does not allow me to do this.
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> "man crypt" would also have indicated that reversing the encryption is not possible,
> except by brute force.

Now tell him something he didn't know.

That's why he asked for another method of encryption, duh.

Chipmunk


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

Date: Mon, 26 Jan 1998 01:08:50 -0600
From: mfischer@bad.spam.bad.umr.edu (Matt Fischer)
Subject: Fed up with CGI.pm
Message-Id: <MPG.f35f2817426c572989680@usenet.umr.edu>

	I am trying to use CGI.pm (v.2.37010), and attempting to use 
autoEscape to save some data from a form, but it doesn't seem to work.  I 
want to save data like ( ), { }, and spaces, however, CGI.pm saves them 
as % and then their Hex ASCII representation.  

	I figured that using autoEscape would let me not save as Hex ASCII 
if I did me->autoEscape(undef), but it doesn't work!

	Am I using it wrong, or is it wrong?
	
	Here's a bit of code..

#pmtest.cgi
use CGI;
$query = new CGI;
$query->autoEscape(undef);

#blah blah...

sub save_parameters {
   $filename = '.XXXXXX/XXXXXXX';		#sorry, its public writable.
   if (open(FILE,">>$filename"))
    {
        $query->save(FILE);
        close FILE;
    }
   else
    {
        print "<STRONG>Error:</STRONG> couldn't write to file $filename: 
$!\n";
    }
}

	(can you please CC me the answer? our news server sometimes 
doesn't (okay, always) doesn't get all the articles it necessarily 
should.

			-mlf


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

Date: Fri, 23 Jan 1998 13:42:18 -0800
From: "DianaH" <dhoober@interserv.com>
Subject: Help with opening and copying to a file
Message-Id: <6ab2rl$4pe$1@lal.interserv.com>

I am new to perl scripting but have been creating internal pages using html,
perl and cgi scripts for about 5 months now so I do understand a little.  I
have a project which requires placing information from an internal web page
into another web page.  Normally, to place information in the destination
page it is necessary to login in using passwords and identification, then a
form is filled out and the information is placed on the external web page.
Both pages are on the same server.  Is this an instance where the open
command would be used to pass info and if so, is it necessary to write any
sort of subroutine to take care of the password entry to the destination
page?




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

Date: Mon, 26 Jan 1998 02:43:24 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: how to do formfeed/pagebreak
Message-Id: <comdog-2601980243240001@news.panix.com>
Keywords: just another new york perl hacker

In article <6agnmj$ae3$1@cyprus.atlantic.net>, chip@pobox.com posted:

> According to comdog@computerdog.com (brian d foy):
> >doesn't Perl do the translation of \f to whatever the local
> >representation of a form feed is?
> 
> Perl at present works only with ASCII, and ASCII only has exactly one
> character that can be the form feed (decimal 12).  Any environment that
> uses ASCII that doesn't think that 12 is the form feed is broken.

and?  i have all sorts of clients using broken enviromeNTs. :)

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Sun, 25 Jan 1998 20:42:43 +1100
From: Robert Hazeltine <r.hazeltine@nepean.uws.edu.au>
Subject: Howto match similar line item in different files?
Message-Id: <Pine.GSO.3.96.980125194156.775A-100000@lyvvie.virago.org.au>

Hi

I'm not too sure how to tackle this problem and would appreciate any
assistance:  is it best to use map to achieve the result I want or is it
necessary to reiterate through each file? 

I have two files, each with a corresponding entry identified with a non 
unique key, ie the files are a list of line items.  The field separator is
the "|".

I want to join the contents of the second file to the reciprocal line in
the first file as in the following example

file1.txt

85213|N03|1|Thu|01:00pm|02:00pm|1-6,8-15|K|KXA104 
85213|N03|1|Thu|02:00pm|03:00pm|1-6,8-15|K|KXA104 
85213|N03|1|Thu|03:00pm|04:00pm|1-6,8-15|K|KXA104 

file2.txt

85213|PEN|LEC*1|1998.1
85213|PEN|LEC*2|1998.1
85213|PEN|TUT*1|1998.1

result.txt

85213|N03|1|Thu|01:00pm|02:00pm|1-6,8-15|K|KXA104|PEN|LEC*1
85213|N03|1|Thu|02:00pm|03:00pm|1-6,8-15|K|KXA104|PEN|LEC*2
85213|N03|1|Thu|03:00pm|04:00pm|1-6,8-15|K|KXA104|TUT|TUT*1

The correct form is to have a corresponding entry in each file so each
item has the same number of entries for each key in both files. They are,
generally, on the same line in their respective file but cannot be
guaranteed to be so.

That there is the same number of entries for each key in both files needs
to be checked.  Additionally, there is noise identified by a non
conforming pattern in the keys, which needs to be filtered out and I seem
to be able to manage this part ok.

Can anyone help me with this problem as the various solutions I have
tried over the last couple of days do not seem to work? I can provide more
information if necessary.  I seem to be missing the simple solution.

Rob...
Robert Hazeltine
r.hazeltine@nepean.uws.edu.au (University of Western Sydney, Nepean)
grove@zeta.org.au (Private account at Zeta Microcomputer Software)



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

Date: Mon, 26 Jan 1998 02:41:16 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: html user needing perl?
Message-Id: <comdog-2601980241160001@news.panix.com>
Keywords: just another new york perl hacker

In article <34CBEA09.F9791AD9@viser.net>, bbank@viser.net posted:

> I've been administration under html code and I'd like to know if I need
> a domain?  

depends on what you are trying to do.  

>I'm reading a book called programing in perl and I'm starting
>to comprehend a small %.  

yes, hashes are nice.

> Where would I nest my files? #user/perl/my
> files.  On my domain, on my service provider?  

how would we know?  ask you local system administrator.

>Please help me to
> understand perl better.

what do you want to know?




>I need perl for database management.

Perl is not necessary for database management, but it's usually a
good choice ;)

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Mon, 26 Jan 1998 06:44:06 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: IIS/NT 4.0 and PERL5, got it to work!
Message-Id: <34cc22a6.524144494f47414741@radiogaga.harz.de>

Bryan Ingram (zeropage@computek.net) wrote:
: Despite the fact that not a single person responded with any words of
: wisdom to my earlier query as to possible reasons why my perl
: implementation was not working, I did manage to get the situation
: resolved!

: Basically, though I found this no where in the documentation for Perl
: Win32, when you are setting up the Registry
: HKEY_LOCAL_MACHINE......scriptmap ... you must include a "%s %s" to the
: end of your command line.  For instance.

: .pl: c:\perl\bin\perl.exe %s %s

: If this is indeed in the documentation, it was not readily apparent.

Since this is not really a perl problem, but a problem with IIS3's setup,
I would suspect it is mentioned in IIS' documentation, not in perl's.
As with all of MicroCrap's documentation, it sure isn't readily apparent:
It's in the chapter about registry variables in your "IIS Installation
and Maintainance Manual" (you did install it, didn't you?!). There's
also an article in the Knowledge Base about it.

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: Mon, 26 Jan 1998 00:58:37 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: VladimirAlexiev <vladimir@cs.ualberta.ca>
Subject: Re: Odd syntax problem
Message-Id: <34CC260D.A07F712@coos.dartmouth.edu>

[posted and mailed]

Vladimir Alexiev wrote:
> 
> In article <34C8335E.41658334@coos.dartmouth.edu> Chipmunk <rjk@coos.dartmouth.edu> writes:
> 
> > > s {/[^/]*?$} {} if /=/;    # remove / and the shortest string of non-/
> > Not quite right.
> > That should not be a non-greedy quantifier.
> > First, it makes the regex slower.
> What if you do `s|/.*?$||'? Is that faster or slower compared to
> `s|/[^/]*$||'?

Not only would that be slower, it is not the same thing and will not do what
you expect.
m{.} will match *any* character (except newline).
m{[^/]} will match any character *except* slash (and will match newline).

"foo/bar/baz/" =~ m{(/.*?$)} will set $1 to "/bar/baz", *not* "/baz",
because .*? can match the second backslash.  non-greedy matching *does not* force
the shortest match: it forces the first leftmost match in which the quantified
expression matches as little as possible.  (As opposed to greedy matching,
where the quantified expression matches as much as possible.)


But why would you want to specify non-greedy matching if you're anchoring the match
to the end of the string anyway?

/.*$/ will match exactly the same way as /.*?$/
(except for strings ending in newline.  but if you're concerned with that,
use /.*\Z(?!\n)/ instead.)

Check out Mastering Regular Expressions, by Jeffrey Friedl, for better explanations
of the above.

Chipmunk


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

Date: Sun, 25 Jan 1998 21:33:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl module documentation format?
Message-Id: <e60ha6.vca.ln@localhost>

Andrew Brown (atbrown@halcyon.com) wrote:
: Most Perl modules include documentation at the beginning of the file,
: such as:

:    =head1 DESCRIPTION
:    Blah blah blah, lots of other =head1's deleted.
:    =cut

: Could someone point me toward a description of the syntax for this 
: documentation format?  I notice tags like C<>, E<>, and F<>... I'd like
: a full description of this format, if possible.


The description for that format is in the 'perlpod' man page
that comes with the perl distribution.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 26 Jan 1998 02:35:10 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl Source Obfuscator
Message-Id: <comdog-2601980235100001@news.panix.com>
Keywords: just another new york perl hacker

In article <6ah0an$1vi$1@ndnws01.ne.highway1.com>, "B. K. Oxley (binkley)" <binkley@bigfoot.com> posted:

> Take a look at the Filter modules
> 
> --binkley
> 
> brian d foy wrote in message ...
> >>There are utilities available which make C source code unreadable, yet
> >>compilable. The purpose is to distribute source code for recompilation,
> but
> >>without revealing trade secrets etc.

sorry - i didn't write that.  let's be more careful with the attributions.

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Mon, 26 Jan 1998 01:11:05 -0600
From: rodney@bond.net
To: gsar@umich.edu
Subject: Re: POSIX (?) under perl for Win95
Message-Id: <885798107.1673199617@dejanews.com>

In article <6aen4c$joh@srvr1.engin.umich.edu>,
  gsar@engin.umich.edu (Gurusamy Sarathy) wrote:
[snip]
> >The MS Posix subsystem is Posix.1. But it is hard to use. If you replace
> >the MS Posix subsystem with the OpenNT subsystem (read Unix) the above
> >problems largely go away.
>
> Yeah.  If you replace WindowsNT with Linux, the above problems completely
> go away, too.  ;-)

I was working within the context of the posting. People are using and
will continue to use Windows NT and Linux. The two do not form a union
and may/do avoid an intersection.

> >                          The Unix version of Perl runs on OpenNT with
> >no functionality loss (you can fork, exec, access sockets).
>
> Is it possible to access the Win32 subsystem from the OpenNT subsystem?

A lot of what the Win32 subsystem provides an interface for are "thin"
API's to other subsystems or to NT calls. There's no point in adding
another layer there. For things where co-ordination is good, like
sockets, OpenNT is mapping Unix socket API's onto WinSock API's. There's
no carte blanche to Win32 API's. Unix and Win32 API's are designed
differently. A Unix file descriptor can be used in ways that a Win32 fd
cannot for example. Likewise, the other way. But at the same time the
side effects and interactions when doing such a mixture could has serious
side-effects that are really unknown.

- Rodney

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Sun, 25 Jan 1998 23:21:29 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: returning values out of a recursed sub
Message-Id: <34CC0F49.F9D9E3F7@coos.dartmouth.edu>

Jason Holland wrote:
> 
>     $string =~ s/ +/ /g; # This looks for one or more space characters
> and changes them for a single space.

This would be faster:

$string =~ tr/ //s;

With tabs:

$string =~ tr/ \t/ /s;

Chipmunk


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

Date: Sun, 25 Jan 1998 23:42:00 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: simple perl question, regx, please help.
Message-Id: <34CC1417.14FCC6B4@coos.dartmouth.edu>

brian d foy wrote:
> 
> In article <6adshm$6rv@drn.zippo.com>, chad posted:
> 
> >$string should contain only a-z A-Z 0-9 if it contains anything else fail.
> 
> use subs qw(fail);
> fail unless
> $string =~ m/ ^             #anchor at start of string
>               [A-Za-z0-9]+  # any of those characters, any amount
>               $             # anchor at end of string
>             /x;             #eXtended format

That will not work for strings such as "abc\n".

Try this instead:

$string =~ m/ ^             #anchor at start of string
              [A-Za-z0-9]+  # any of those characters, any amount
              $ (?!\n)      # anchor at end of string, and not before \n
            /x;             #eXtended format

Someone also suggested this simpler solution:

$string !~ /[^A-Za-z0-9]/;

Chipmunk


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

Date: Mon, 26 Jan 1998 02:31:14 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: simple perl question, regx, please help.
Message-Id: <comdog-2601980231140001@news.panix.com>
Keywords: just another new york perl hacker

In article <34CC1417.14FCC6B4@coos.dartmouth.edu>, rjk@coos.dartmouth.edu posted:


> $string =~ m/ ^             #anchor at start of string
>               [A-Za-z0-9]+  # any of those characters, any amount
>               $ (?!\n)      # anchor at end of string, and not before \n
>             /x;             #eXtended format

that's what happens when you're used to using chomp()  :) 


> Someone also suggested this simpler solution:
> 
> $string !~ /[^A-Za-z0-9]/;

hmmm...

   /[^A-Za-z0-9]/ is true if you match an out of character class
   !~ negates that result

   so the expression is false if you match bad characters.  this
   could get complicated :)

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: 25 Jan 1998 20:43:07 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
To: Ian Boys <boys@aspentech.com>
Subject: Re: Where do my "my" variables go in the debugger?
Message-Id: <om67n7zyr8.fsf@tees.cs.ualberta.ca>

In article <34C7CD40.5656@aspentech.com> Ian Boys <boys@aspentech.com> writes:

> PS: Is there any way to get straight into the debugger without it trying
> to debug a script?  Having to debug "1" and then exit seems clumsy...
>   DB<1> exit
> DB::fake::(/usr/local/lib/perl5/perl5db.pl:2043):
> 2043:     "Debugged program terminated.  Use `q' to quit or `R' to
> restart.";
You don't need to exit, just start typing commands.
(In fact in 5.003 you can't exit because the debugger is not restartable.)

> I like the way that V pretty-prints structures,
So does `x'. V (and X) take a var name and print all vars of that name
(scalars/arrays/hashes). x on the other hand takes an expression,
evaluates it in array context, and examines the result. `X foo' doesn't
work for "my $foo", but `x $foo' does.

> Or should I not bother with "my" in the debugger and let variables
> be auto-declared?
You shouldn't bother.

> Are there any traps
Don't use junk names that the program you're debugging might use.

> (I was trying complex structures with hashes and stuff)?
No problem with this.
> 
> somehow.
> 
> Ian


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

Date: Sun, 25 Jan 1998 20:03:10 -0800
From: see@my.sig (Don Groves)
Subject: Re: White Hats and Black
Message-Id: <MPG.f35aad82143fb1e989696@news.europa.com>

In article <6agu93$phs$2@csnews.cs.colorado.edu>, tchrist@mox.perl.com 
says...
> In comp.lang.perl.misc, Eli the Bearded <*@qz.to> writes:
> :this is a very interesting and dramatic move, I find your presentation
> :of it all to be grandiloquent and presumptious.
> 
> I can't believe you're knocking the freeing of software.  Or was it that
> you just didn't like my writing style?  Please write something better then.
> 
> --tom
> -- 
> 	Tom Christiansen	tchrist@jhereg.perl.com
> "L'extension des privileges des femmes est le principe general de tous
>  progres sociaux."
>     --Charles Fourier, 1808
> 

I don't think Eli is knocking either Netscape's action or your writing
style.  He is merely pointing out, and I agree, that we should wait
and see exactly how Netscape follows through.  If they do indeed license
Navigator/Communicator as GPL, or equivalent, then it's hallelujah time.
But if they hold back, try to keep it even partially theirs, then it's
not likely to draw the kind of free programming support you describe.
Your piece described very well how I felt after reflecting on Netscape's
action, let's hope it turns out that way.

Don

#------------------------------------------------------------
my %sig = (name => "Don Groves", email => "groves\@acm.org");
#------------------------------------------------------------


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

Date: Mon, 26 Jan 1998 01:40:47 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Felix Morley Finch <felix@crowfix.com>
Subject: Re: Why does split return undef? - My own followup
Message-Id: <34CC2FEE.CEF36637@coos.dartmouth.edu>

[posted and mailed]

Felix Morley Finch wrote:
> 
> Alright, in trying to make a workaround, I discovered it's not split
> itself, it's return () that is undef, ie
> 
> sub xyz { return (); }
> 
> returns undef, not an empty array.  Is this because I am hopelessly
> wedded to thinking of them as arrays, when they are really lists, and
> it's the same as
> 
> sub xyz { return; }

Yes, they're the same.

> ??? Sure doesn't seem *right*.  But maybe I just need to get out of my
> fossilized old fashioned obsolete thinking, is that it?   =8-O

According to Programming Perl, "A return with no argument returns the
undefined value in scalar context, and a null list in a list context."

What context is your function being called in?
(You can find out from within the function by using wantarray.)

Chipmunk


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

Date: Mon, 26 Jan 1998 01:52:03 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: FelixMorleyFinch <felix@crowfix.com>
Subject: Re: Why does split return undef?
Message-Id: <34CC3292.AC8C015D@coos.dartmouth.edu>

[posted and mailed]

Felix Morley Finch wrote:
> 
> If I split an empty string to an array, it returns an empty array if
> inline, but undef if returned from a subroutine.
> 
> @ary = &spitme("");
> if (defined (@ary)) {
>     print "Defined, " . scalar(@ary) . " elements\n";
> } else {
>     print "Not defined\n";
> }
> 
> sub spitme {
>     my($text) = @_;
>     return split(/_/, $text);
> }

Hmm...  According to Programming Perl (pg 155),

  defined EXPR
  This function returns a boolean value saying whether EXPR has
  a real value or not...
  You may also check to see whether arrays, hashes, or subroutines
  have been allocated any memory yet.  Arrays and hashes are allocated
  when you first put something into them...

So, your problem is not that the function is returning undef, but
that defined() returns false because you haven't put anything into
the array: it's a null list.

Note the following behavior:

  DB<1> p defined(@a)

  DB<2> @ a= ()

  DB<3> p defined(@a)

  DB<4> @a = (1)

  DB<5> p defined(@a)
1
  DB<6> @a = ()

  DB<7> p defined(@a)
1

Even though I've assigned a null list to @a again, defined() still returns
true because memory has been allocated for @a.

Perhaps you should be checking whether @ary has any elements, not whether
memory has been allocated to it:

if (scalar(@ary)) {
  # do something
} else {
  # do something else
}

Hope that helps!

Chipmunk


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

Date: Mon, 26 Jan 1998 07:07:09 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Why enable CreateProcessWithNewConsole?
Message-Id: <34cc280d.524144494f47414741@radiogaga.harz.de>

Bryan Ingram (zeropage@computek.net) wrote:
: Recently while attempting to install ActiveStates latest version of
: Perl, I noticed it enabled the registry entry
: "CreateProcessWithNewConsole" ..

: Under IIS Documention it clearly states that this should only be done
: with caution, and that it could have severe repurcussions in terms of
: speed ..

: So .. is there any good reason why this is being turned on?  I went back
: and manually disabled this setting on my system, and everything is still
: working fine.

The reason not to turn it off is that else it has severe repurcussions in
terms of I/O redirection, which won't work without it. So, without it, no

open("foo|")

or

$bar = `baz`

will work.

Another reason to dump IIS in favor of a real web server software...

As this really is more of a problem with MS-Windows and IIS than with
Perl, consider to take it to any of the comp.os.ms-windows.* and
comp.infosystems.www.* hierarchies.

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: Mon, 26 Jan 1998 07:19:17 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: WIN32 LWP Problem
Message-Id: <34cc2ae5.524144494f47414741@radiogaga.harz.de>

John Kotwicki (Webmaster@csa.clpgh.org) wrote:
: I have the LWP Module installed on a Win95 machine and whenever I try to 
: use it I receive the following compilation error:

: 	Can't locate /auto/LWP/UserAgent/env_proxy.al in @INC ....

: Where do I find this file?  How do I fix this problem?

On my OS/2 system, it's installed in perl's site library directory.
If it isn't on your system, a workaround would be not to use the
env_proxy() method of LWP::UserAgent (as it isn't common outside the
Eunichs world, anyway), but to replace it by the proxy() method to set
up proxies. See LWP::UserAgent's POD.

Hope it helps,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

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

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