[7234] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 859 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 13 13:37:08 1997

Date: Wed, 13 Aug 97 10:00:26 -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: 859

Today's topics:
     arrays (David Siebert)
     Re: arrays (Tad McClellan)
     Re: Bug in sort at 5.003? <rootbeer@teleport.com>
     Capitals <jgrimm@wireedm.com>
     Re: Capitals (Tad McClellan)
     Re: Capitals <eglamkowski@mathematica-mpr.com>
     Comma & Quotes delimited file <dphan@comsource.net>
     Re: converting from hex <merlyn@stonehenge.com>
     Re: create a file in a user directory with a perl scrip <rootbeer@teleport.com>
     Re: Creating a mega-multi-dimensional hash?? <bsugars@sunpub.com>
     DBD::Oracle and Perl <acgator@erols.com>
     Re: emacs?  No thank you (Gabor)
     Re: Extracting a string between two tags <rootbeer@teleport.com>
     Re: Extracting a string between two tags <clark@s3i.com>
     Re: FTP Script <petri.backstrom@icl.fi>
     Re: Hashes of hashes <rmangi@tgix.com>
     Re: Hashes of hashes <rootbeer@teleport.com>
     Re: HELP! system() and the MS IIS <witz@uni-muenster.de>
     Insecure dependency in glob <wborba@bse.com.uy>
     jumping to a URL <slmingol@kodak.com>
     Re: map problem <merlyn@stonehenge.com>
     Re: map problem (Tony Bass)
     NEWBIE NEEDS HELP!!!!!! <mental@netscafe.co.uk>
     Re: NT Perl Sources and problem <rootbeer@teleport.com>
     Re: PerlShop <rootbeer@teleport.com>
     Re: Problems with split (Honza Pazdziora)
     Re: Problems with split <rootbeer@teleport.com>
     Set $! after success system call <clark@s3i.com>
     Split strings in perl dannyl@computize.com
     Re: Split strings in perl <merlyn@stonehenge.com>
     Re: Split strings in perl (Tony Bass)
     Re: Time problem. <b1ff@idnopheq.moc>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 13 Aug 1997 13:23:53 GMT
From: dsiebert@gate.net (David Siebert)
Subject: arrays
Message-Id: <5ssch9$19vs$1@news.gate.net>

is there an esy function to find the length of an array?



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

Date: Wed, 13 Aug 1997 10:14:52 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: arrays
Message-Id: <c1jss5.6m3.ln@localhost>

David Siebert (dsiebert@gate.net) wrote:
: is there an esy function to find the length of an array?

$ra_len = @ra;      # give it a scalar context

print scalar(@ra);  # force a scalar context


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


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

Date: Wed, 13 Aug 1997 07:26:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: train12@cacd.rockwell.com
Subject: Re: Bug in sort at 5.003?
Message-Id: <Pine.GSO.3.96.970813072528.10950E-100000@julie.teleport.com>

On Tue, 12 Aug 1997 train12@cacd.rockwell.com wrote:

>    @x = sort (50,10,2,30,4);
>    print "@x\n"; #results in the incorrect 10 50 2 4 30

This should be fixed in current versions of Perl. If you find otherwise,
please run perlbug. Thanks!

-- 
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 06:28:58 -0700
From: John Grimm <jgrimm@wireedm.com>
Subject: Capitals
Message-Id: <33F1B69A.6051@wireedm.com>

How can I convert a string to all capitals?


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

Date: Wed, 13 Aug 1997 10:17:10 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Capitals
Message-Id: <m5jss5.6m3.ln@localhost>

John Grimm (jgrimm@wireedm.com) wrote:
: How can I convert a string to all capitals?
                                    ^^^^^^^

You look in the Perl FAQ, part 4:

"How do I capitalize all the words on one line?"


I guess you missed that somehow when you searched the FAQ before
posting as all good 'net citizens do...


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


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

Date: Wed, 13 Aug 1997 11:49:32 -0400
From: the count <eglamkowski@mathematica-mpr.com>
Subject: Re: Capitals
Message-Id: <33F1D78C.60D5@mathematica-mpr.com>

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.

Pseudo code:
s/not first character in string/substitute corresponding lower char/g;

My problem is, ^ represents both the first character AND the negation
operator, so how do you do something like 'not the first char'?
/^^./  ??!?
Is that 'not the first char', or 'the first non-char'?
Or even 'the first char'? (double negation?)
Is there another negation symbol I should be aware of?

I'd like it to be something like:
s/(^^.)/($1 - ('A' - 'a'))/g

but that doesn't work (which comes as no big surprise ;-)


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

Date: Wed, 13 Aug 1997 09:15:21 -0500
From: David Phan <dphan@comsource.net>
Subject: Comma & Quotes delimited file
Message-Id: <33F1C179.5545@comsource.net>

Hi,

I need to translate a comma & quotes delimited file into a comma
separated list.

Requirements:

1. A comma found in a string will be escaped with a slash in 
   front of it (\,).
2. A placeholder will be generated for an empty string (e.g. 
   1,"",2 -> 1,,2)
3. Two double quotes ("") or a backslash and a double quote (\") 
   will be translated to one double quote.

Can anyone help me with a perl script that would translate this line:

"1", 2, "3""", "4\"", "", "a,b", 5

to this line:

1,2,3",4",,a\,b,5

The PERL script I got from someone else met requirements #1 and #2 but
failed on #3.

#!/usr/local/bin/perl
$filename = @ARGV[0];
$currentdir = `pwd`;
if (!$filename) {
        print STDERR "Usage Error: \n";
        print STDERR "\n";
        print STDERR "     $0 filename\n";
        exit;
}
if (! -e $filename) {
        print STDERR "$filename - not found\n";
        exit;
}
open (EXPORT, $filename) || die "Error opening file: $!";
while (!eof(EXPORT)) {
        $line = <EXPORT>;

        ## find anything in quotes replace it with 
        ## what the function returns.
        $line =~ s/"([^"]*)"/&comma_fixer($1)/ge;
        print $line;
}
close (EXPORT);

##
##  Search for comma and use a different character
##
sub comma_fixer {
        $string = @_[0];

        $string =~ s/,/\\,/g;         ##  replace , with \,
        return $string;
}


Your help is greatly appreciated.

-- 
David Phan  <dphan@comsource.net>
Systems/Internet Programmer
ComSource, Inc.    http://www.comsource.net/
____________________________________________


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

Date: 13 Aug 1997 06:51:01 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: converting from hex
Message-Id: <8cwwlqur7e.fsf@gadget.cscaper.com>

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

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

Prince> for example:

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

No problem.

    print join ",", hex_to_rgb("#ffffff");

    sub hex_to_rgb {
      map { hex($_) } shift =~ /#(..)(..)(..)/;
    }

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 384 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Wed, 13 Aug 1997 07:24:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Stephane RICHARD <srichard@san-jose.ate.slb.com>
Subject: Re: create a file in a user directory with a perl script ...
Message-Id: <Pine.GSO.3.96.970813072124.10950D-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Stephane RICHARD wrote:

>         I'm looking for the best way for an user to create by the web a
> file in his own directory on an Unix system.

You may want to make a set-id root CGI script. This has some severe
security worries, so be sure that you understand the WWW security FAQ and
the perlsec(1) manpage before you start writing.

    http://www.genome.wi.mit.edu/WWW/faqs/www-security-faq.html

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 09:16:21 -0400
From: Benjamin Sugars <bsugars@sunpub.com>
Subject: Re: Creating a mega-multi-dimensional hash??
Message-Id: <33F1B3A5.1311@sunpub.com>

Janne Blomqvist wrote:
> 
> Hi!
> 
> I would like to create some sort of multi-dimensional hash (or array)
> which would be [insert your lucky number here] levels deep.
> ...
> 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!
> 
> --
> Janne Blomqvist

Just extend the techniques suggested for a hash of hashes to an
arbitrary number of levels.

For example, to assign to a hash that is - effectively - three levels
deep:

$class{'level 1'}{'level 2'}{'level 3'} = 'value';

To get you value back, just try something like:

print $class{'level 1'}{'level 2'}{'level 3'}, "\n";

Note that even if the "deep" levels of %class don't yet exist,
references will be created on the fly to accommodate them.

-Ben

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


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

Date: Wed, 13 Aug 1997 11:27:17 -0400
From: ErnieCee <acgator@erols.com>
Subject: DBD::Oracle and Perl
Message-Id: <33F1D255.1231@erols.com>

I am using version 0.44 of DBD::Oracle with version 0.79 of the DBI with
Perl 5.003.  I have been running Perl scripts successfully on a DEC
Alpha machine under UNIX 3.2C until a system upgrade was completed this
past weekend.  Apparently the path in whic to get to Oracle was changed
and the directory structure was altered.  I am now unable to connect to
Oracle and am unsure why, I rebuilt everything and reinstalled
everything to no avail.  I have set the environment variable for the
oracle home path to the correct path in my .profile file.  I cannot seem
to find the missing link as to why the DBD driver is looking for the old
path.  Can anyone give me any insight as to what could be causing this
problem?

Please respond to me at my email address aron_ceely@pw.notes.com

thank you


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

Date: 13 Aug 1997 13:37:46 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: emacs?  No thank you
Message-Id: <5ssdba$a60$1@flint.sentex.net>

Kenneth Vogt (KenVogt@rkymtnhi.com) wrote:

: Thanks to everyone that suggested emacs for Windows.  However, it is one
: of the UGLIEST things I have ever seen!  (I'm not trying to start an

There are things in life that should be pretty.  An editor is not one
of them.  I expect an editor to be functional, don't you?

--
And don't tell me there isn't one bit of difference between null and space,
because that's exactly how much difference there is.  :-)
        --Larry Wall in <10209@jpl-devvax.JPL.NASA.GOV>



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

Date: Wed, 13 Aug 1997 08:20:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Extracting a string between two tags
Message-Id: <Pine.GSO.3.96.970813081517.10950M-100000@julie.teleport.com>

On Wed, 13 Aug 1997, Petri Backstrom wrote:

>     if ( $data =~ /<AUTHORS>(.*?.*)<\/AUTHORS>/s ) {
>         $authors = $1;
>     }

I don't think you want that. Try it on this $data.

    $data = '</AUTHORS>' . '<AUTHORS>' x 1000;

(Hint: Hope you're patient! :-)

I think you meant something like this for the pattern match.

    $data =~ m!<AUTHORS>(.*?)</AUTHORS>!is

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 08:39:35 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Re: Extracting a string between two tags
Message-Id: <dhgcu1cl4.fsf@s3i.com>


stefano bonacina <stefano.bonacina@st.com> writes:
> 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

Assuming that you are guaranteed to have tags on the same line in the proper
order: 

#!/home/dorman/bin/perl -w

$line = 'blah <AUTHORS>Johnstone, W.; Fawcett, G.; Yim, L.W.K.</AUTHORS> foo';

($junk,  $stuff) = split /<AUTHORS>/, $line;
($stuff2, $junk) = split /<\/AUTHORS>/, $stuff;
print " ($stuff2) \n";
__END__


-- 
Clark Dorman				"Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html                -Francis Crick


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

Date: Wed, 13 Aug 1997 13:54:03 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: FTP Script
Message-Id: <33F1924B.7601@icl.fi>

MCNSAT SERVICE wrote:
> 
> Greetings all !
> 
> I am looking for a Perl script to be ran on Windows NT that would
> automate the transfer of a data file from a server to various
> distant IP-station. The IP addresses are sent to the server in a
> attribute file along with the data file to be broadcast.
> 
> I would be most grateful if one of you could help me ! It is urgent...
> 
> Patrick

I doubt that a script that does exactly what you want exists,
but it should be relatively easy to write using the Net::FTP
module (available from http://www.perl.com/CPAN/).

Consider hiring someone to write it for you, if you don't have
the skills or resources. Note that "it is urgent" will be more
expensive than, say, "it is to be ready by next summer" (assuming 
Northern hemisphere here ;-).

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


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

Date: Wed, 13 Aug 1997 11:10:57 -0400
From: Rick Mangi <rmangi@tgix.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Hashes of hashes
Message-Id: <33F1CE81.460388BB@tgix.com>

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

ftp://ftp.digital.com/pub/plan/perl/CPAN/doc/manual/html/pod/perldsc.html

The perl data structures cookbook. That's really what you want. It's the
most comprehensive document on HoH and LoL and HoL and LoH etc...lots of 
examples.

good luck

Rick

Tom Phoenix wrote:
> 
> On Tue, 12 Aug 1997, Daniel GUEGUEN wrote:
> 
> > Does someone know how to build a hash of hashes by reading two files
> > linked by a key, and how to access these hashes to rewrite the two files
> > after modifications ?
> 
> No, but if you check out the perlref(1), perllol(1), and perldsc(1)
> manpages, those may make it clear to you what needs to be done! :-)
> 
> If you have more questions after you've seen those docs, please ask again.
> 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/

-- 
_______________________________________________________________

Rick Mangi                                  Tel: (212) 972-2030
Thaumaturgix, Inc.                          Fax: (212) 972-2003
310 Madison Avenue, Suite 704               rmangi@tgix.com
New York, NY 10017                          http://www.tgix.com
          thau'ma-tur-gy, n. the working of miracles
  "Perl is a state of mind as much as it is a language grammar" 
_______________________________________________________________
--------------B12A9510A18318AE9B2A5B9A
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Rick Mangi
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Rick Mangi
n:              Mangi;Rick
org:            Thaumaturgix,Inc.
adr:            310 Madison Ave.;;;New York;NY;10017;USA
email;internet: rmangi@tgix.com
title:          Web Application Engineer
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
end:            vcard


--------------B12A9510A18318AE9B2A5B9A--



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

Date: Wed, 13 Aug 1997 07:20:03 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Daniel GUEGUEN <daniel.gueguen@elantiel.fr>
Subject: Re: Hashes of hashes
Message-Id: <Pine.GSO.3.96.970813071803.10950C-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Daniel GUEGUEN wrote:

> Does someone know how to build a hash of hashes by reading two files
> linked by a key, and how to access these hashes to rewrite the two files
> after modifications ? 

No, but if you check out the perlref(1), perllol(1), and perldsc(1)
manpages, those may make it clear to you what needs to be done! :-)

If you have more questions after you've seen those docs, please ask again.
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 15:52:06 +0200
From: "Andreas Wytzisk" <witz@uni-muenster.de>
To: "Jeremy D. Zawodny" <zawodny@hou.moc.com>
Subject: Re: HELP! system() and the MS IIS
Message-Id: <33F1BC06.96549D36@proplant.de>

> <witz@uni-muenster.de> wrote:
>
> >>Hi,
> >>I try to start a commandline executable within a CGI script using
> the
> >>system() / Win32::Process::Create commands (both fails). Running the
>
> >>script from the commandline everthing works fine. But when it's
> started
> >>by a web request (MS Internet Information Server 2.0; NT4.0) nothing
> >>happens. The IIS registry entry CreateProcessWithNewConsole is done.
>
>

Jeremy D. Zawodny wrote

> >Have you isolated the problem to Perl?
>
> >Try running a simple .CMD or .BAT file through the web server first,
> >to make sure that it knows how to start command-line tools in the CGI
>
> >environment.
>
> >Also, consider upgrading to IIS3.0.
>
> >Jeremy

Hi,
you're right. It's an IIS problem. IIS doesn't handle command line
executables. I tried it with the Netscape Server and everything works
fine...

Regards,
Andreas.

--

Andreas Wytzisk
Institut fuer Agrarinformatik
pro_Plant GmbH
Nevinghoff 40
D-48147 Muenster

Tel.  : +49 251 / 2376-592
Fax.  : +49 251 / 2376-551
Email : A.Wytzisk@proPlant.de
        witz@farmer.uni-muenster.de
http://www.proplant.de




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

Date: Wed, 13 Aug 1997 09:51:58 -0600
From: Wilter Borba <wborba@bse.com.uy>
To: wborba@bse.com.uy
Subject: Insecure dependency in glob
Message-Id: <871483122.7356@dejanews.com>

Hi,
   I'm having a little trouble with perl tainting.

There is part of my script, it run with setuid:

 chop($file_spec=<STDIN>);
 ...
 ...
 # untaint file_spec
 $file_spec =~ /^(\w*)$/;         # <<< line 94
 $untainted = $1;
 @all_files = glob($untainted);   # <<< line 96
 ...
 ...

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

I'm using Solaris 2.4 with perl 5.004_01.

I have read perlsec and perldiag many times, but can't get the solution.

My questions:
   1. How to escape perl-tainting mechanism ?
   2. What are the security implications/risks in this case ?

Thanks for your help, and excuse my little english :).

Wilter.
wborba@bse.com.uy (uy stands for Uruguay :O)

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


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

Date: Wed, 13 Aug 1997 10:11:39 -0400
From: Sam Mingolelli <slmingol@kodak.com>
Subject: jumping to a URL
Message-Id: <33F1C09B.2942CC61@kodak.com>

I am writing a CGI script in perl and would like to do the following...

When the program gets into a specific subroutine I would like to
instruct the browser to jump to a designated URL.  Anyone have any ideas
as to how to do this?


Sam


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

Date: 13 Aug 1997 06:42:52 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: thomaso@shell3.ba.best.com (Thomas Andrews)
Subject: Re: map problem
Message-Id: <8czpqmurkz.fsf@gadget.cscaper.com>

>>>>> "Thomas" == Thomas Andrews <thomaso@shell3.ba.best.com> writes:

Thomas> Why use "foreach" :-)

Thomas> 	grep ( s/bb$// , @b=@a );

Because grep in a void context does unnecessary work to create a list
which then just gets discarded.  Thus, it's not only bad style, it's
also wasteful.

Foreach doesn't have that trouble.

Here's another way to do it though... that's not so destructive to @a
or @b:

	@b = map { /(.*)bb$/s ? $1 : $_ } @a;

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 384 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 13 Aug 1997 15:16:34 +0100
From: aeb@brains.cartoon.bt.co.uk (Tony Bass)
Subject: Re: map problem
Message-Id: <5ssfk2$8pl$1@brains.cartoon.bt.co.uk>

>From article <8czpqmurkz.fsf@gadget.cscaper.com>, by Randal Schwartz <merlyn@stonehenge.com>:
>>>>>> "Thomas" == Thomas Andrews <thomaso@shell3.ba.best.com> writes:

> Thomas> Why use "foreach" :-)

> Thomas> 	grep ( s/bb$// , @b=@a );

> Because grep in a void context does unnecessary work to create a list
> which then just gets discarded.  Thus, it's not only bad style, it's
> also wasteful.
[...]

Void context is scalar context (documentation), and this and
space-time measurements (5.001) indicate that grep here would count
items rather than creating a list.  Wastefulness is greater than
foreach, less than (technically undefined) map.

    Tony Bass

-- 
# A E Bass                                      Tel: (01473) 645305
# MLB 3/19, BT Laboratories                     e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE   DO NOT e-mail to From: line
#                                               Opinions are my own


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

Date: 13 Aug 1997 14:45:34 GMT
From: "mental" <mental@netscafe.co.uk>
Subject: NEWBIE NEEDS HELP!!!!!!
Message-Id: <01bca7ea$0a911f40$cbbba4c1@NETSCAFE.CO.UK>

I'm a bit of a newbie to scripting, so I need help....

I need a script that will add entries to my hatelist

www.netscafe.co.uk/mental/hate.htm

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

Can anyone help???

mental@netscafe.co.uk


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

Date: Wed, 13 Aug 1997 07:39:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kitty Smith <smith@twsuvm.uc.twsu.edu>
Subject: Re: NT Perl Sources and problem
Message-Id: <Pine.GSO.3.96.970813073437.10950H-100000@julie.teleport.com>

On Tue, 12 Aug 1997, Kitty Smith wrote:

> I am looking for NT Perl sources on the Web.  

Do you mean the source for Perl which could compile on an NT machine, or
do you mean Perl scripts which could run on Perl on an NT machine?

> In particular, I am looking for some way to determine the username of
> the person accessing the page, as opposed to their IP address.  Is this
> possible? 

Whether it's possible or not doesn't depend upon Perl; it depends upon
whether that information can be coaxed out of their server. You could ask
this question in a newsgroup about HTTP or CGI, or look it up in their
FAQs, but I'll save you some trouble: The way to get somebody's name on
the web, as in real life, is to simply ask for it. (Even if their browser
tells you something, it may not be accurate. More than one person can use
a browser, after all.) 

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 07:29:34 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: admin@web-design.net
Subject: Re: PerlShop
Message-Id: <Pine.GSO.3.96.970813072813.10950F-100000@julie.teleport.com>

On Wed, 13 Aug 1997, Beck Web Virtual Servers & Design wrote:

> It runs from the shell...no errors.
> From the web....as soon as I try to enter the store....I get a Server
> Error, misconfiguration or internal error...argghhhh.  I've looked at it
> upside down, and sideways....

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to
solving such problems. It's available on the perl.com web pages. 

   http://www.perl.com/perl/
   http://www.perl.com/perl/faq/
   http://www.perl.com/perl/faq/idiots-guide.html

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 08:57:06 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Problems with split
Message-Id: <adelton.871462626@aisa.fi.muni.cz>

crr026@email.mot.com writes:

[...]

> I want to store the pattern part of split into a variable. However, the
> following try
> 
> #!perl
> $Line = "one|two|three";
> print "$Line\n";
> $sep = "\|";
> @Atoms = split (/$sep/, $Line);
> foreach (@Atoms) {
> 	print "$_\n";
> }
> 
> gives me this output
> 
> one|two|three
> o
> n

[...]

Let's make a test:

$sep = "\|";
print "$sep\n";

will give just | because under double quotes the backslash is
considered escape sequence, here \| yielding |. So you will want to
escape the backslash, like this:

$sep = "\\|";

Or use single quotes or some other quotation.

> Can someone explain what's wrong with my program?

For Perl, split /|/ is the same as split //, matching between
characters.

Hope this helps!

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
    European RC5 56 bit cracking effort -> http://www.cyberian.org/


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

Date: Wed, 13 Aug 1997 07:32:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: crr026@email.mot.com
Subject: Re: Problems with split
Message-Id: <Pine.GSO.3.96.970813073023.10950G-100000@julie.teleport.com>

On Wed, 13 Aug 1997 crr026@email.mot.com wrote:

> $sep = "\|";

That's misleading. It's a one-character string, just a vertical bar (which
you might have discovered by using Perl's built-in debugger). You probably
meant this.

    $sep = "\\|";

As a general rule: whenever you want a real backslash in the text of your
Perl script, type two. 

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 08:57:00 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Set $! after success system call
Message-Id: <dg1se1bs3.fsf@s3i.com>



	I normally check my opens and make sure that my system calls work,
and such stuff like that.  I have been working with eval'ed things and in the
perlfunc page it says stuff like:

	# Code 1
	$a = 10; $b = 0
	eval { $answer = $a / $b; };
	warn $@ if $@;
	print "We're still here \n";

(Which puts out:
	Illegal division by zero at auth.pl line 7.
	We're still here 
which is spiffy)

I like this way of programming and structuring the error calls, and it
reminds me of shell programming where we can check the value of
$status.  So, I modified the following:

	# Code 2
	$anls = `ls` or die "Die: ($!)";

into the following, which I thought would be similar in operation:

	# Code 3
	$anls = `ls`;
	die "Die: ($!)" if $!;

As it turns out, they are quite different.  Code 2 produces nothing (since I
didn't print $anls).  Code 3 produced:

	Die: (Illegal seek) at auth.pl line 4.

Eeek!

Checking perlvar:

$!
     If used in a numeric context, yields the current value of errno,
     with all the usual caveats.  (This means that you shouldn't depend
     on the value of "$!" to be anything in particular unless you've
     gotten a specific error return indicating a system error.) If
     used in a string context, yields the corresponding system error
     string.  etc.

I am concerned about this.  Is this the normal response of $! ?  Is
this part of the "usual caveats"?  And what does "Illegal seek" mean
anyway?  

--
Clark


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

Date: Wed, 13 Aug 1997 09:02:14 -0600
From: dannyl@computize.com
Subject: Split strings in perl
Message-Id: <871480679.4806@dejanews.com>

How do I split a string like this:

"here1here2here3here4here5here6here7"

every 5th character?

And all are char (s).

I want to be able to take this string
and split it every five chars and the string
can be anywhere from 0 to 100 chars long.
Also want to be able to compare each to a string.

Can anyone help me?
I Need something efficient.

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


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

Date: 13 Aug 1997 08:03:48 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: dannyl@computize.com
Subject: Re: Split strings in perl
Message-Id: <8cvi1aunu3.fsf@gadget.cscaper.com>

>>>>> "dannyl" == dannyl  <dannyl@computize.com> writes:

dannyl> How do I split a string like this:
dannyl> "here1here2here3here4here5here6here7"

dannyl> every 5th character?

    @result = $your_string =~ /(.{1,5})/gs;

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 384 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 13 Aug 1997 15:46:28 +0100
From: aeb@brains.cartoon.bt.co.uk (Tony Bass)
Subject: Re: Split strings in perl
Message-Id: <5sshc4$ced$1@brains.cartoon.bt.co.uk>

>From article <871480679.4806@dejanews.com>, by dannyl@computize.com:
> How do I split a string like this:

> "here1here2here3here4here5here6here7"

> every 5th character?

> And all are char (s).

> I want to be able to take this string
> and split it every five chars and the string
> can be anywhere from 0 to 100 chars long.
> Also want to be able to compare each to a string.

   ('here1here2here3here4here5here6here7' =~ /.{5}/g)

in list context is a list ('here1', 'here2', ...) of the five-character
strings, which you can then foreach or grep or map through a comparison
with a test string depending on your needs.  You might want to take
additional measures if newlines can occur or if your initial string
might be other than a multiple of 5 characters long.  Alternatively, a
scalar comparison without explicit decomposition, on the lines of

   ('here1here2here3here4here5here6here7' =~ /^(.{5})*?here3/)

might be suitable.

    Tony Bass

-- 
# A E Bass                                      Tel: (01473) 645305
# MLB 3/19, BT Laboratories                     e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE   DO NOT e-mail to From: line
#                                               Opinions are my own


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

Date: Wed, 13 Aug 1997 08:48:54 -0400
From: Paul Jorgensen <b1ff@idnopheq.moc>
Subject: Re: Time problem.
Message-Id: <33F1AD35.8026CA7D@idnopheq.moc>

Hi.

Yeah.  Same thing here.  I reasoned that Perl (or my OS) counts months
beginning at 0 insted of 1.  What is the ruling on this?

Charles Boone wrote:

> I am using perl to gather some info from wtmp.  I just happened to
> notice that when I convert the login time it gives me the wrong month
> ex. 7 for Aug instead of 8.  I was wandering if there is a bug in
> 5.003 or what.  Please email me ccboone@amber.indstate.edu
>
> Charles Boone
> Unix System Administrator  -- Indiana State University



--
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Paul Jorgensen
LNUSCSTS.PJORGE01@eds.com

"If there are two or more ways to do something,
and one of those ways can result in
catastrophe, Micro$oft will implement it and
market it as a feature."
  - Murphy's Law (SP3 applied)




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

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

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