[7235] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 860 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 13 15:17:50 1997

Date: Wed, 13 Aug 97 12:00:32 -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, 13 Aug 1997     Volume: 8 Number: 860

Today's topics:
     Re: Can You Title Case A String ?. <rootbeer@teleport.com>
     Re: Capitals <tom@mitra.phys.uit.no>
     Re: Capitals (Bill Napier)
     Re: Capitals (Sami Sandqvist)
     Comma Delimited Proggy Example <ed@ncia.net>
     Re: complex argument passing (Brand and Karina Hilton)
     Re: converting from hex (Jim Traugott)
     Re: Creating a mega-multi-dimensional hash?? <tom@mitra.phys.uit.no>
     Re: Enabling Perl on the MS Personal Web Server. <petri.backstrom@icl.fi>
     Re: Extracting a string between two tags (Andreas Schmidt)
     File read rate (Krishnan Jayakrishnan)
     HELP!  Full-text search in large DB (Anonymous)
     Re: Help! - Reformatting Date <rschwein@philly.infi.net>
     Re: Hex in ascii to ascii: what module ? <eike.grote@theo.phy.uni-bayreuth.de>
     Re: Hex in ascii to ascii: what module ? <aas@bergen.sn.no>
     how can i find out how much  free disk space is availab <kweiner@bloomberg.com>
     Re: How to open a file to a variable instead of an arra <petri.backstrom@icl.fi>
     Re: how to use format to build strings <rootbeer@teleport.com>
     I can't make my sentence appear when I want (C E Havlioglu)
     Re: Insecure dependency in glob <rootbeer@teleport.com>
     Re: Is there a perl IDE? <bsugars@sunpub.com>
     Re: Looking for a routine to trim white space  (like VB (Tad McClellan)
     Need help! <cmartin@interware.net>
     Re: Need help! <tw36027@glaxowellcome.com>
     Re: Need help! <tw36027@glaxowellcome.com>
     Re: Need help! <tw36027@glaxowellcome.com>
     Nevermind <smcclurg@inet.net>
     New web page: Visual Perl++ (Scott McMahan)
     Re: NEWBIE NEEDS HELP!!!!!! <rootbeer@teleport.com>
     Odd perl quirk? <smcclurg@inet.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Aug 1997 07:49:11 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Andy Marr <andy@pindar.com>
Subject: Re: Can You Title Case A String ?.
Message-Id: <Pine.GSO.3.96.970813073956.10950I-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Andy Marr wrote:

> I know the following would work for each word in the string.
> 
> @word = split ( / / ,$string);
> print ("\L\u@word[x]\E\n");

No it wouldn't. That hurts my eyes. :-)  Here's one possible alternative,
although it has a flaw if the text may have an apostrophe. 

    print map "\L\u$_", split /\b/, $string;

If the flaw bothers you, maybe you want something like this. It doesn't
have that flaw. (Its flaws are more subtle. :-)

    ($copy = $string) =~ s/([\w']+)/\L\u$1/g;
    print $copy;

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1997 15:31:07 +0000
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: Capitals
Message-Id: <nqo7mdq6qx0.fsf@mitra.phys.uit.no>

John Grimm <jgrimm@wireedm.com> writes:

> How can I convert a string to all capitals?

First step is to read the manpages.

Second step is to see if someone has asked that question already,
perhaps even frequently?  (hint: FAQ)

Third step is looking to see whether the question has been answered
recently, for instance via dejanews or altavista.

If all of that fails, try asking here, but make sure to have a valid
From: line when you do, or nobody's able to answer you.

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 13 Aug 1997 17:20:00 GMT
From: napier@seas.upenn.edu (Bill Napier)
Subject: Re: Capitals
Message-Id: <slrn5v3r5v.lh8.napier@blue.seas.upenn.edu>

On Wed, 13 Aug 1997 11:49:32 -0400, the count <eglamkowski@mathematica-mpr.com> wrote:
>John Grimm wrote:
>> How can I convert a string to all capitals?
>
>I was contemplating almost the exact opposite problem:  Given a string
>that is in all uppercase, how to make all but the first letter 
>lowercase?  I wanted to use regular expressions and substition, but
>I am not sure how.

Here's how I would do it

$upper = "ALL CAPS";
$lower = ucfirst lc $upper;

or do it in place with

$upper = "ALL CAPS";
substr($upper,1) = lc substr($upper,1);

I think what you were trying to do was overkill for this problem.

Bill Napier - CSE '98 | e-mail: napier@seas.upenn.edu
----------------------| WWW:    http://www.seas.upenn.edu/~napier
 This space for rent  | finger for more information (phone, PGP, etc.)
-----------------------------------------------------------------------
Duct tape is like the force.  It has a light side, and a dark side, and
it holds the universe together.			-Carl Zwanzig


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

Date: 13 Aug 1997 17:28:13 GMT
From: sami@d246a.mtalo.ton.tut.fi (Sami Sandqvist)
Subject: Re: Capitals
Message-Id: <slrn5v3rn9.2pn.sami@d246a.mtalo.ton.tut.fi>

On	Wed, 13 Aug 1997 11:49:32 -0400, the count <eglamkowski@mathematica-mpr.com>
wrote:
>John Grimm wrote:
>> How can I convert a string to all capitals?
>
>I was contemplating almost the exact opposite problem:  Given a string
>that is in all uppercase, how to make all but the first letter 
>lowercase?  I wanted to use regular expressions and substition, but
>I am not sure how.
>
[SNIP]
>I'd like it to be something like:
>s/(^^.)/($1 - ('A' - 'a'))/g
>
>but that doesn't work (which comes as no big surprise ;-)

s/^(.*)$/\L\u$1/; works, but do you like it? :) OTOH, I think there are 
better ways.

Sami
-- 
    "What is the sound of Perl?  Is it not the sound of a wall that
     people have stopped banging their heads against?"
		--Larry Wall in <1992Aug26.184221.29627@netlabs.com>


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

Date: Wed, 13 Aug 1997 12:31:08 -0400
From: Ed Paquette <ed@ncia.net>
Subject: Comma Delimited Proggy Example
Message-Id: <33F1E14C.5110@ncia.net>

I'd like to find a small Perl script that shows examples for dealing
with comma delimited files in the following ways:

- Reading lines
- Changing certain fields
- Adding lines
- Deleting lines

Anyone know where I can find something like this?

Ed Paquette
ed@ncia.net


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

Date: Wed, 13 Aug 1997 13:54:12 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: Re: complex argument passing
Message-Id: <bkhiltonEEuuMC.EEM@netcom.com>

In article <5spo1l$dcn@news-central.tiac.net>,
Mike Stok <mike@stok.co.uk> wrote:
>
>Probably the easiest thing to do for some arbitrary function in C is to
>write an extension using either XS or swig where the extension language
>helps you pass parameters between perl and a C and return values back. 

Ok, I give up.  What's swig?

Thanks.


	Brand


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

Date: 13 Aug 1997 08:47:23 -0700
From: jtraugot@physio-control.com (Jim Traugott)
Subject: Re: converting from hex
Message-Id: <siug1seozjo.fsf@pirates.physio-control.com>

>>>>> "Prince" == Prince Mystery <mystery@itis.com> writes:

    > Hi,
    > I'm trying to take a hex rgb value (ala #ffffff) and convert it to a
    > three member array of decimal equivalents for each of those values, r,
    > g, and b.

    > for example:

    > string '#ffffff' would then produce (255,255,255);

    > Thanks for your help,

    > Myst
    > -- 
    > 
    > Version: 2.6.2

    > owEBiAB3/4kAdQMFADPY9d1hGXgCUdEssQEBvREDAJodjyXMMZnOxrzl6Z5Anldh
    > p/mCNLshfYr/aLB+vmR2CrdySGCqBZFg+GanInyn/Vg6oRNoLgM/sU5+sbYntGt1
    > nI2B8/PZIDxOTA3S6BktLawONN/RGcqjPhDPm8l636wOYgh0ZXh0ZmlsZQAAAAA=
    > =beaq
    > -----END PGP MESSAGE-----


How about:

my $hexval = 0xcedf29; ## test value

my $red = ( $hexval & 0xff0000 ) >> 16 ;
my $green = ( $hexval & 0xff00 ) >> 8 ;
my $blue = ( $hexval & 0xff ) ;

print "($red,$green,$blue)\n";




jim


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

Date: 13 Aug 1997 15:26:11 +0000
From: Tom Grydeland <tom@mitra.phys.uit.no>
To: Janne Blomqvist <Janne.Blomqvist@lmf.ericsson.se>
Subject: Re: Creating a mega-multi-dimensional hash??
Message-Id: <nqobu326r58.fsf@mitra.phys.uit.no>


Janne Blomqvist <Janne.Blomqvist@lmf.ericsson.se> writes:

> Hi!

Hello, there!

> I would like to create some sort of multi-dimensional hash (or array)
> which would be [insert your lucky number here] levels deep. 

Really?

> that scans C++ code and generates a class hierarchy (in HTML).
> So far I've succeeded in spitting out a list (an array actually) which
> contains the first line of the class definitions, i.e looks like this:
> 
> class classname : public base_class
> class anotherclassname : public another_base_class
> class base_class
> etc.

That looks like input I can use.  Actually, to keep the parsing of the
input as simple as possible, I'm going to assume the following input:

Each line looks like:

classname:baseclass
or
baseclassname

(as usually allowing empty lines and comment lines.)

I'll leave it to you to glue the stuff together.

> The final output should be a html list looking a bit like this:

> base_class
> 	class_name
> 		child_class
> another_base_class
> 	anotherclassname
> etc.

Ok, I can do that.

> Note that this is not supposed to be a CGI script (not that it
> matters...). So now I've been banging my head against the wall for
> a while trying to figure out how to generate this hierarchial list...
> Any suggestions? The main problem, as I see it, is that I don't know
> how to generate a hash of hashes which is n (n=1,2,3....) levels deep,
> let alone print it. I've thought of generating one hash containing all
> the base classes, and then other hashes which are named after the base
> classes, i.e. %base_class, %another_base_class etc.
> Is there an elegant way of achieving this? Could I use arrays instead
> of hashes (but the basic problem would remain the same, though)? Or 
> can I get by without making a data structure to represent the hierarchy?
> Thanks in advance!

As long as each class name is unique (it has to be, right?) you'll
only need your hash to be one deep, with each value being a reference
to an anonymous list.

I have made one further assumption:  All base classes are explicitly mentioned
somewhere.  If they are not, you'll have to fix that.

OK, with those limitations: Here goes:

#!/store/bin/perl -w

require 5.004;		# but see below

# I've used strict here to make sure I'm not accidentally creating any
# symbolic references.
use strict;

# Here are my globals
use vars qw / @bases %derived /;

# forward declaration
sub doclass;

# Read input from standard input or files
while (<>) {
    next if /^$/;	# skip blank lines
    next if /^#/;	# skip comment lines
    chomp;

    # parse line into base and derived classes.  If base is empty,
    # we'll assume that this is a base class.
    my ($class, $base) = split/:/;

    # print "Base is <$base>, derived is <$class>\n";

    if ($base) {	# This is derived class
	# print "got class $class derived from $base\n";
	push @{$derived{$base}}, $class;

        # This is the tricky line.  We're adding $class to the anonymous
        # array hiding behind $derived{$base}.
    }
    else {		# mother class
	# print "got base class $class\n";
	push @bases, $class;

        # maintain a separate list of base classes.
        # If you have unmentioned base classes, add them to @bases
        # before it's too late

    }
}

# Here's the output routine

# This assumes 5.004.  You'll have to adjust if your
# perl is any older.
foreach my $base (@bases) {
    # print "$base: @{$derived{$base}}\n";
    doclass $base, 0;
}

sub doclass {
    my ($class, $level) = @_;

    print "    " x $level, $class, "\n";

    # This assumes 5.004.  You'll have to adjust if your
    # perl is any older.
    foreach my $derived (@{$derived{$class}}) {
        doclass $derived, $level+1;
    }
}


As you can see, I'm using the 5.004 syntax

foreach my $var ...

which won't work on older perls.  You'll have to adjust for that if
your perl is old.  That's why I put the 'require 5.004;' in there.

This code has been tested, and produces the expected output within
the limitations stated above.

Hope that helps.

> Janne Blomqvist

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Wed, 13 Aug 1997 14:00:39 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Enabling Perl on the MS Personal Web Server.
Message-Id: <33F193D7.7762@icl.fi>

Box Holder wrote:
> 
> Does anybody know if the MS Personal Web Server can run Perl scripts,
> and if so how does one enable it to do so?

Yes, and it is even documented in many places.

Doing a search via services such as

   http://www.dejanews.com

or

   http://altavista.digital.com

would've find you online references such
as the Perl for Win32 Frequently Asked
Questions (FAQ) list:

  http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html

Search for "Script Map" in the above document (allthough,
searching for "Personal Web Server" would lead you to the
answer just as well).

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: 13 Aug 1997 15:31:41 GMT
From: schmidt@miserv2iai.kfk.de (Andreas Schmidt)
To: stefano bonacina <stefano.bonacina@st.com>
Subject: Re: Extracting a string between two tags
Message-Id: <5ssk0t$5n5$1@nz12.rz.uni-karlsruhe.de>

hi stefano

In article <33F0829F.167EB0E7@st.com>, stefano bonacina <stefano.bonacina@st.com> writes:
|> Hello all
|> can anyone suggest me how to extract the string between the two tags?
|> Here comes the string:
|> 
|> <AUTHORS>Johnstone, W.; Fawcett, G.; Yim, L.W.K.</AUTHORS>
|>   /\                                               /\
|>   ||                                               ||
|>  TAG                                               TAG
|> 
|> Thanks in advance for your help
|> 
|> -- 
|> Stefano Bonacina                E-mail: stefano.bonacina@st.com
|> SGS-Thomson Microelectronics



try something like this:


    $in = "<AUTHORS>Johnstone, W.; Fawcett, G.; Yim, L.W.K.</AUTHORS>";
    $in =~ /<(\w+)>(.*?)<\/\1>/; 
    print "$2\n";


for an explantation see the perlre manpages and perlfaq6

hopethathelps
smiff




========================================================================
andreas schmidt                                email: schmidt@iai.fzk.de 
institut fuer angewandte informatik (iai)        phone: +49 7247 82 5714
forschungszentrum karlsruhe gmbh
    - technik und umwelt -       
postfach 3640                                  76021 karlsruhe (germany)
          http://www.iai.fzk.de/Institut/MI/mitarbeiter/schmidt.html



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

Date: 13 Aug 1997 16:04:15 GMT
From: saljxk@dix.agl.uh.edu (Krishnan Jayakrishnan)
Subject: File read rate
Message-Id: <5ssltv$l5v$1@Masala.CC.UH.EDU>

Hi all,
		I am writing a CGI script to search html files for 
keywords and was wondering if it really matters to search a file line by 
line instead of globbing the entire contents into an array and then 
searching the first element of the array. This seems to be the 
conventional approach taken by PERL gurus.
					Since, when the file is searched 
line by line the loop could be terminated with a 'last' statement instead 
of going forward.

	Example of the code fragment:

		while(<READ>){
		if (/\b$var\b/){
		print "found it\n";
		last;
		}
		}


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

Date: Wed, 13 Aug 1997 18:57:44 +0200 (MET DST)
From: nobody@REPLAY.COM (Anonymous)
Subject: HELP!  Full-text search in large DB
Message-Id: <199708131657.SAA16927@basement.replay.com>



Hi.  I want to write a perl front-end to access (read & write) a
largish database (ca. 20 MB).  I'm just now finding my way around and
learning about DB_File and Berkeley DB, but there's a particular
feature I need that doesn't seem to be supported by this system (as
far as I can tell).  I'm hoping to get some helpful pointers that will
channel my search and programming efforts.

This is a bibliographic database, and it is crucial that users be able
to search the full text of certain fields such as Keywords, Abstract,
and Comments.  Can someone please tell me what is the standard
approach to this problem, and whether there is anything out there that
I can use to speed up a Perl implementation of this?

Thank you *very much* in advance.

K.

(please post; no email, please)



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

Date: 13 Aug 1997 17:25:11 GMT
From: "Rick Schwein" <rschwein@philly.infi.net>
Subject: Re: Help! - Reformatting Date
Message-Id: <01bca80e$8695bd20$1335bca1@pni3188.phillypapers.com>

Albert W. Dorrington <awdorrin@ictest.delcoelect.com> wrote in article
<5sanl7$ies@ws051eng.ictest.delcoelect.com>...
> 
> One way to do this is to use the localtime function.
> 
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
> 
> For a date format like '8/4/1997' you would then do:
> 
> 	$mon =+ 1; 	# Needed because $mon is 0-11
> 	$year =+ 1900; 	# needed because $year has 1900 subtracted from it
> 	$datestamp = "$mon/$mday/$year";
> 
I don't recall seeing anything about Year 2000 issues in the FAQ , but
could easily have overlooked it.  If not, what happens in three years? 
This fragment looks like Year 2000 will give a problem.  

Rick Schwein
Just Another Perl Hacker (wannabe)


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

Date: Tue, 12 Aug 1997 15:25:40 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Hex in ascii to ascii: what module ?
Message-Id: <33F06454.2781@theo.phy.uni-bayreuth.de>

Michael Kagalenko wrote:
> 
> Is there standard module that would convert hex codes (in ascii form,
> not binary) into their ascii equivalent ?

You could, of course, create a module (why not ?), but it is rather
overkill  ;-)

Is this what you are looking for ?

    $hexstring = '0x4e';                  # works with '4e', too
    $asciisymbol = chr(hex($hexstring));  # Here we go ...
    print $asciisymbol;                   # gives 'N'


Bye, Eike
-- 
======================================================================
 Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
----------------------------------------------------------------------
 e-mail -> eike.grote@theo.phy.uni-bayreuth.de
 WWW    -> http://www.phy.uni-bayreuth.de/theo/tp4/members/grote.html 
           http://www.phy.uni-bayreuth.de/~btpa25/
======================================================================


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

Date: 13 Aug 1997 16:35:51 +0200
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Hex in ascii to ascii: what module ?
Message-Id: <h4t8utak8.fsf@bergen.sn.no>

mkagalen@lynx.dac.neu.edu (Michael Kagalenko) writes:

> Is there standard module that would convert hex codes (in ascii form,
> not binary)
> into their ascii equivalent ?

pack("H*", $hex_string)

What are binary hex codes?

-- 
Gisle Aas <aas@sn.no>


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

Date: Wed, 13 Aug 1997 13:04:51 -0400
From: weiner <kweiner@bloomberg.com>
Subject: how can i find out how much  free disk space is available in perl
Message-Id: <33F1E933.57AA@bloomberg.com>

thanks!!!!!


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

Date: Wed, 13 Aug 1997 13:34:48 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: How to open a file to a variable instead of an array?
Message-Id: <33F18DC8.402@icl.fi>

Morten Simonsen wrote:
> 
> I should of course have added theese things, but this works perfectly all-
> right for me. My philosophy is that nothing wrong happens if my design is
> good. Hardware failure may of course occur, but in my case I won't clutter
> the code with hundreds of statement '|| die "..."' just to make sure I know
> what happend. But still I agree that those statement should be there.

It isn't necessarily just a hardware failure that makes a file 
open fail; someone could have deleted the file (by accident or 
with a purpose), changed the file protections, a software fault
in someone else's code could have corrupted the directory, your
compiler could have generated buggy instructions, etc., etc.

Unless you've written every single line of code (including
the compiler(s), the O/S and drivers), your philosophy (which, 
IMO, seems to be a close relative to the testing and debugging 
philosophy of "but it works on my machine" ;-) doesn't guarantee 
anything. 

And even if you'd written every line of code on the system, I 
have to admit that I'd still hesitate to trust that everything
works no matter how good the design is.

And I'm also sure that in many minds good design includes
writing code to take into account all expected and as many 
unexpected error situations imaginable.

A good exception handling mechanism built into the language
makes this, of course, more straight-forward to code - or
at least easier to separate the error handling from what
one is trying to accomplish (than it would be 
without one).

And as we've seen from recent discussions, Perl could have
a better mechanism for handing exceptions.


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

Date: Tue, 12 Aug 1997 22:09:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ian Duplisse <duplisse@rentwks1.golden.csc.com>
Subject: Re: how to use format to build strings
Message-Id: <Pine.GSO.3.96.970812220836.29850K-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Ian Duplisse wrote:

> In Perl5, how can one use format statements to construct a string? 

This FAQ entry may be useful, though small. Hope this helps! 

    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq5/
          How_can_I_use_write_into_a_str.html

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 13 Aug 1997 17:12:58 GMT
From: havliogc@cs.man.ac.uk (C E Havlioglu)
Subject: I can't make my sentence appear when I want
Message-Id: <5sspuq$3af$1@m1.cs.man.ac.uk>


Hi,
I have written something like:
    print "Reading URL...";
      :
    some stuff about sockets, reading the URL and processing it
      :
    print "done \n";

I wan't it to write
    Reading URL...
do the sockets stuff (which takes seconds) and when finished write
                                                    ^^^^^^^^
    done

However, when I run it, instead of doing this it waits until the 
socket stuff is finished and then writes
    Reading URL...done
all at once.

Any ideas how I can solve this problem?
Cheers,
Cuneyt
--
   _______________________
__/ Cuneyt Emre HAVLIOGLU \________________________
   
   The University of Manchester
   Department of Computer Science, ACS   
  
   e-mail: havliogc@cs.man.ac.uk
___________________________________________________



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

Date: Wed, 13 Aug 1997 10:18:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Wilter Borba <wborba@bse.com.uy>
Subject: Re: Insecure dependency in glob
Message-Id: <Pine.GSO.3.96.970813095418.10950Z-100000@julie.teleport.com>

On Wed, 13 Aug 1997, Wilter Borba wrote:

>    I'm having a little trouble with perl tainting.

>  chop($file_spec=<STDIN>);

chomp is safer than chop, and is usually preferred.

>  # untaint file_spec
>  $file_spec =~ /^(\w*)$/;         # <<< line 94
>  $untainted = $1;

Watch out - if the pattern match failed, $1 is not necessarily undef or
the empty string. It's usually whatever was left there by the last
successful pattern match! That's not usually what you want, especially in
a script which you want to be secure and dependable. 

    ($untainted) = ($file_spec =~ /^(\w*)$/);

This is much safer. $untainted has a predictable value, which will be
undef if the pattern match failed.

> I tried others expressions in line 94, but always get an error:
> "Insecure dependency in glob while running setuid at /dev/fd/3 line 96."

Yes; the current implementation of globbing (except on VMS) in inherently
insecure. This is because Perl uses another program (usually /bin/csh) to
do the work, and that program isn't trustworthy.  :-(

A future version of Perl should make globbing safe by not calling an
external program to do the work. The current solution is to use readdir
(and related functions) to get the list of files you want, or possibly to
use a module which does that. 

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/




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

Date: Wed, 13 Aug 1997 12:13:27 -0400
From: Benjamin Sugars <bsugars@sunpub.com>
Subject: Re: Is there a perl IDE?
Message-Id: <33F1DD27.4876@sunpub.com>

Jeremy D. Zawodny wrote:
> 
> On 11 Aug 1997 21:03:27 -0700, danny@lennon.postino.com (Danny Aldham)
> wrote:
> 
> >John Dallman (jgd@cix.compulink.co.uk) wrote:
> >
> >: Read the license agreement. You can't sell perl for money.
> >
> >I hope this is wrong. Certainly not my take on the license agreement.
> 
> ...
> 
> MKS has a verion of Perl that they sell in the MKS Toolkit. Larry has
> never sued them (that I know of).

Netscape, with their Publishing System, and NetGravity, with their
AdManager system, both sell Perl interpreters.  They don't *tell* you
its part of the system, but a little looking around will reveal it.

At least Netscape includes copies of the Artistic License and the GPL
with their Perl interpreter, and the name of executable remains perl.

NetGravity, on the other hand, don't include any of the licenses and
they rename the executable to ngp (I suppose it stands for NetGravity
Perl).  It looks to me like they've gone out of their way to hide the
Perl backbone to their system.  I believe this to be a violation of at
least the Artistic License.  Perhaps I should complain to NetGravity.
Or perhaps someone should tell Larry...

-Ben

--
Ben Sugars <bsugars@canoe.ca>
Senior Webmaster,
CANOE Canadian Online Explorer,
http://www.canoe.ca/


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

Date: Tue, 12 Aug 1997 22:40:57 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Looking for a routine to trim white space  (like VB trim$)
Message-Id: <9cars5.7mr.ln@localhost>

Peter J. Schoenster (pschon@baste.magibox.net) wrote:
: cberry@cinenet.net (Craig Berry) wrote:

: >Steve O'Hara Smith (sohara@mardil.elsevier.nl) wrote:
: >Why not just use
: >
: >  ($stripped) = $unstripped =~ /^\s*(.*?)\s*$/;

: >cberry@cinenet.net (Craig Berry) wrote:
: >Though even this is woefully inefficient, involving lots of backtracking 
: >internally on many strings.  Better still might be doing it in two 
: >passes, one for each end of the string:
: >
: >  $stripped = $unstripped;
: >  $stripped =~ s/^\s+//;

The regex engine "scans" left to right.

If the very first char is not a space, it know right then that there
is no match. It had to examine one char.

That's a beginning of an understanding ;-)


: >  $stripped =~ s/\s+$//;
: >
: >Hope this helps!

: How would I begin to understand why the first method was inefficient.


You get "Mastering Regular Expressions" by Jeffrey Friedl (www.ora.com).


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Wed, 13 Aug 1997 11:52:17 -0400
From: Craig Martin <cmartin@interware.net>
Subject: Need help!
Message-Id: <33F1D830.53D1@interware.net>

Hi There,

My name is Craig Martin and I currently work for an ISP in Toronto,
Ontario, Canada. I am trying to write a simple little PERL script that
will let the user know how many e-mail messages he has. The way the
script is to work is that you call up the script and it asks for what
e-mail account they want the information. Then it reads in the info, and
spits out the number of messages. This is not to be a script run over
the Internet, just locally on the Unix server. MY PROBLEM IS THAT I HAVE
NO IDEA HOW TO READ INPUT IN FROM THE KEYBOARD. Please, if anyone can
give me the syntax for this it would be much appreciated.

Thanks in advance.

-- 
	Craig Martin
	cmartin@interware.net
	http://www.interware.net
	mailto:cmartin@interware.net


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

Date: Wed, 13 Aug 1997 13:00:53 -0400
From: Thad Welch <tw36027@glaxowellcome.com>
To: cmartin@interware.net
Subject: Re: Need help!
Message-Id: <33F1E845.81A1E825@glaxowellcome.com>

Here's my solution:

chop( $line = <STDIN> );
print "\nline='$line'";

Craig Martin wrote:

> Hi There,
>
> My name is Craig Martin and I currently work for an ISP in Toronto,
> Ontario, Canada. I am trying to write a simple little PERL script that
>
> will let the user know how many e-mail messages he has. The way the
> script is to work is that you call up the script and it asks for what
> e-mail account they want the information. Then it reads in the info,
> and
> spits out the number of messages. This is not to be a script run over
> the Internet, just locally on the Unix server. MY PROBLEM IS THAT I
> HAVE
> NO IDEA HOW TO READ INPUT IN FROM THE KEYBOARD. Please, if anyone can
> give me the syntax for this it would be much appreciated.
>
> Thanks in advance.
>
> --
>         Craig Martin
>         cmartin@interware.net
>         http://www.interware.net
>         mailto:cmartin@interware.net





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

Date: Wed, 13 Aug 1997 13:11:20 -0400
From: Thad Welch <tw36027@glaxowellcome.com>
To: cmartin@interware.net
Subject: Re: Need help!
Message-Id: <33F1EAB8.13150984@glaxowellcome.com>

Here's my solution:

chop( $line = <STDIN> );
print "\nline='$line'";

Craig Martin wrote:

> Hi There,
>
> My name is Craig Martin and I currently work for an ISP in Toronto,
> Ontario, Canada. I am trying to write a simple little PERL script that
>
> will let the user know how many e-mail messages he has. The way the
> script is to work is that you call up the script and it asks for what
> e-mail account they want the information. Then it reads in the info,
> and
> spits out the number of messages. This is not to be a script run over
> the Internet, just locally on the Unix server. MY PROBLEM IS THAT I
> HAVE
> NO IDEA HOW TO READ INPUT IN FROM THE KEYBOARD. Please, if anyone can
> give me the syntax for this it would be much appreciated.
>
> Thanks in advance.
>
> --
>         Craig Martin
>         cmartin@interware.net
>         http://www.interware.net
>         mailto:cmartin@interware.net





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

Date: Wed, 13 Aug 1997 13:12:52 -0400
From: Thad Welch <tw36027@glaxowellcome.com>
To: cmartin@interware.net
Subject: Re: Need help!
Message-Id: <33F1EB14.F95AC055@glaxowellcome.com>

Here's my solution:

chop( $line = <STDIN> );
print "\nline='$line'";

Craig Martin wrote:

> Hi There,
>
> My name is Craig Martin and I currently work for an ISP in Toronto,
> Ontario, Canada. I am trying to write a simple little PERL script that
>
> will let the user know how many e-mail messages he has. The way the
> script is to work is that you call up the script and it asks for what
> e-mail account they want the information. Then it reads in the info,
> and
> spits out the number of messages. This is not to be a script run over
> the Internet, just locally on the Unix server. MY PROBLEM IS THAT I
> HAVE
> NO IDEA HOW TO READ INPUT IN FROM THE KEYBOARD. Please, if anyone can
> give me the syntax for this it would be much appreciated.
>
> Thanks in advance.
>
> --
>         Craig Martin
>         cmartin@interware.net
>         http://www.interware.net
>         mailto:cmartin@interware.net





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

Date: Wed, 13 Aug 1997 13:38:40 -0400
From: scott mcclurg <smcclurg@inet.net>
Subject: Nevermind
Message-Id: <33F1F120.6979@inet.net>

Found the problem.
Thanks anyway


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

Date: 13 Aug 1997 16:35:19 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: New web page: Visual Perl++
Message-Id: <5ssno7$bnm$3@scully.new-era.net>

I have created a web page for "Visual Perl++", my ongoing attempt to
turn Microsoft's Developer Studio into an adequate Perl development
tool.

You can read all about it at:

	http://www.skwc.com/essent/visualperl.html

As I discover more ways to use DevStudio for Perl development, I'll add
them to this page. Right now, I'm looking into the VBScript scripting
component of DS, and am trying to automate configuring the project
manager to automatically support the custom build and run steps
described in manual step by step format on my web page. I'll either do
that or start working on "Wizards" next, code snippets to insert
various common Perl code snippets.

If anyone else is considering using DS for Perl development and would
want to contribute, please contact me! I'd love to get a list of names,
particularly corporations, who want to use DS for Perl development too,
so it will be obvious to Microsoft that there's a big, untapped market
for them to tackle.

Scott




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

Date: Wed, 13 Aug 1997 08:46:39 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: mental <mental@netscafe.co.uk>
Subject: Re: NEWBIE NEEDS HELP!!!!!!
Message-Id: <Pine.GSO.3.96.970813084409.10950Q-100000@julie.teleport.com>

On 13 Aug 1997, mental wrote:

> Subject: NEWBIE NEEDS HELP!!!!!!

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I need a script that will add entries to my hatelist

That doesn't sound very nice. But it's your karma, not mine. :-)

> I just want to enter a line of text in a form, and put it at the bottom
> of the list in the HTML file, and line break it at the end... 

I think you could write a CGI script in Perl to do this. It may be
helpful to use a module like CGI.pm. If you don't have that module, you
can get Perl 5.004 (recommended) or just CGI.pm from CPAN.

    http://www.perl.com/CPAN/

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 13 Aug 1997 13:32:58 -0400
From: scott mcclurg <smcclurg@inet.net>
Subject: Odd perl quirk?
Message-Id: <33F1EFCA.4B35@inet.net>

Anyone have any thoughts on this?

The following bit of code works for all letters except the letter j:

#!/usr/bin/perl -w

for($dir = 'a';$dir ne 'aa';$dir++) {
   print ("Directory $dir follows...\n");
   print   `find /export/home/www/$dir*/public_html -name index.html`;
}                                                                             

This is part of a program we are using to list the pages of our users,
separated by the first letter of their usernames.  If you replace $dir
with the letter j, it still does not work, but it works fin from a UNIX
prompt.
This is driving me nuts :)

If your answer is simple or obvious, chances are that I tried it, but
maybe not, so please post any ideas


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

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

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