[8502] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2119 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 17 16:07:27 1998

Date: Tue, 17 Mar 98 13:00:36 -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           Tue, 17 Mar 1998     Volume: 8 Number: 2119

Today's topics:
        [Q] MacPerl - How to use libraries? (John Moreno)
        Bitwise? rfonline@nbn.com
    Re: calculating distance between strings (fortune cooki (Kevin Reid)
        Chicago Perl Mongers (Jim Allenspach)
        Creating an array for e-mail addresses for online form <kurt.stype@bani.com>
    Re: Creating an array for e-mail addresses for online f (A. Deckers)
        Dynamically checking for existing functions <egon@tasmanet.com>
        Escape Charachter in PERL5 <whaidri@ford.com>
    Re: exact match <dformosa@st.nepean.uws.edu.au>
    Re: Finding a key thanks to a value in a hash <vallon@pearl.fi.bear.com>
        How to implement "timeouts" in perl? <paganini@paganini.net>
    Re: Illegal octal digit error? <stan@thunder.ocis.temple.edu>
        loop detection in symlink-following tree walkers (was R (Bennett Todd)
    Re: Multiple substitues dfrench@aig.vialink.com
    Re: Multiple substitues <jwy@shasta-view.com>
        Need some help converting a string into an array <stackhou@elk.cray.com>
    Re: Need some help converting a string into an array (Jason Gloudon)
    Re: Need some help converting a string into an array (Kevin B Cohen)
    Re: Need some help converting a string into an array <stackhou@elk.cray.com>
    Re: Need some help converting a string into an array <dboorstein@shopcfn.com>
    Re: Output <barnett@houston.Geco-Prakla.slb.com>
    Re: parsing perl [Pointer to www.perl.com et al] (Jason Gloudon)
        perl consulting paul@netmagic.net
    Re: Perl Tk rulez! - but how Cut/Paste.... <zenin@archive.rhps.org>
    Re: Perl5 compile error <quentin@jihad.amd.com>
    Re: Problem determining if system function worked (Tom Grydeland)
    Re: Problem stripping Mac headers off of GIF's (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
    Re: redirect stderr and stdout to the same file (Phil Hanna)
        Setting locale failed. <brian@rickjames.sapien.net>
        stripping "special" characters from string (Michael Shavel)
        Tainted Data Problems <curt@vphos.net>
        using ptys to run programs for buffering control (Bennett Todd)
    Re: Why this one doesn't work ? (Tom Grydeland)
    Re: Why this one doesn't work ? (Tom Grydeland)
    Re: Why this one doesn't work ? (Dave Brown)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 17 Mar 1998 13:57:52 -0500
From: phenix@interpath.com (John Moreno)
Subject: [Q] MacPerl - How to use libraries?
Message-Id: <1d61fj6.13ys5vh14bde7vN@roxboro0-003.dyn.interpath.net>

I've looked in Shuck, I've looked in the MacPerl FAQ (which needs to be
updated) I've read the standard perl docs, and I still can't figure out
why:

#!/usr/local/bin/perl -w

use Mac::Memory;
use Mac::Resources;

gives me:

# Can't locate Mac/Memory.pm in @INC.
File 'Programming:MacPerl :testres'; Line 3
# BEGIN failed--compilation aborted.
File 'Programming:MacPerl :testres'; Line 3


Obviously it's not finding it or the directory inside lib, but
everything looks like it's in the right place to me.

This is obviously some stupid thing that I'm overlooking and will kick
myself in the ass for missing, but I just can't figure it out and can't
think of anywhere else to look!

Help?

-- 
John Moreno


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

Date: Tue, 17 Mar 1998 20:45:18 GMT
From: rfonline@nbn.com
Subject: Bitwise?
Message-Id: <3512e0db.12537344@nntp2.ba.best.com>

Greetings,

I have a set of "items," which are represented by a series of 0s and
1s.  For example, an item might look like this:

10011

Each 0 or 1 stands for either yes or no on a series of
characteristics.

I am comparing the items to see how "alike" they are, that is, how
many characteristics they have in common.  For example:

10011
00000

The above two items have two characteristics in common (the second and
third).

I'm currently making my comparison with a for loop, which works just
fine.  What I'm thinking, though, is that there must be some way, with
perl's bitwise operators, to make the comparison much more efficiently
-- or at least more elegantly!  I'm not really a programmer (perl is
my first language), and I'm not very familliar with sophisticated
bitwise idioms, so I'm kind of in the dark here.

Any suggestions?

TIT
Richard


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

Date: Tue, 17 Mar 1998 14:15:29 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: calculating distance between strings (fortune cookies)
Message-Id: <1d5zccd.14fdhpf78jfjqN@slip166-72-108-157.ny.us.ibm.net>

> I read a while ago (here?) that someone produced a thing to transform
> a string into some form of phonetic representation. Perhaps this
> transformed input is more robust to this kind of offsets & normal
> spelling errors.

Text::Soundex?

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 17 Mar 1998 13:44:57 -0600
From: jima@MCS.COM (Jim Allenspach)
Subject: Chicago Perl Mongers
Message-Id: <6emjrp$gce@Mercury.mcs.net>
Keywords: chicago perl mongers chi pm


	All right, since even St. Louis has a PM contact by now, I think
it's about time to set up a group in Chicago. I've made tentative
contact with a couple people, but now I'm officially announcing my
intent. All you Windy City Perl M(o|u)ngers interested in participating,
e-mail me and make yourselves known. This is not an exercise.
jma

-- 
Jim Allenspach            Laziness. Impatience. Hubris.
jima at mcs dot com
Chicago IL                It's great to be a Perl programmer.



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

Date: Tue, 17 Mar 1998 15:10:47 -0500
From: Kurt Stype <kurt.stype@bani.com>
Subject: Creating an array for e-mail addresses for online form
Message-Id: <350ED8C7.2F81@bani.com>

Hello all.

I need to have a user fill out a form that they can use to request
infomation about various topics.  Each topic on the form has a checkbox
next to it and each selection if checked might have a specific e-mail
address that gets added to the "send to" list.  I need some neat code
that will check if the topic was selected and add the appropriate e-mail
address to the "send to" array.  Then when the mail is sent, the "send
to" array is used to populate the mail programs "To:" field.

Can anyone help?

Thanks!


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

Date: 17 Mar 1998 20:31:31 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: Creating an array for e-mail addresses for online form
Message-Id: <slrn6gtnd3.5rh.Alain.Deckers@bashful.rediris.es>

In <350ED8C7.2F81@bani.com>,
	Kurt Stype <kurt.stype@bani.com> wrote:
>Hello all.
>
>I need to have a user fill out a form that they can use to request
>infomation about various topics.  Each topic on the form has a checkbox
>next to it and each selection if checked might have a specific e-mail
>address that gets added to the "send to" list.  I need some neat code
>that will check if the topic was selected and add the appropriate e-mail
>address to the "send to" array.  Then when the mail is sent, the "send
>to" array is used to populate the mail programs "To:" field.
>
>Can anyone help?

I'll try.

I suggest you grep the FAQ for the following strings:

use CGI
foreach
open
print
close

>Thanks!

Welcome.

Hint: next time, you try it first. If you have any problems, post some
code and any relevant diagnostic information. Then folks might make the
effort to help you.

Alain
-- 
Perl reference: <URL:http://reference.perl.com/>
 Perl language: <URL:http://language.perl.com/>
  Perl archive: <URL:http://www.perl.com/CPAN/>
      Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>


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

Date: Tue, 17 Mar 1998 15:39:55 -0500
From: Cole Tuininga <egon@tasmanet.com>
Subject: Dynamically checking for existing functions
Message-Id: <350EDF9B.1A0107F5@tasmanet.com>

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

Is there a way in perl to check for the existence of a function?  I know
about autoloading, but as far as I can tell, there's no way for
autoloading to check that without actually making the call to the
function (which I want to avoid).  Any thoughts?   Thanks in advance...
--------------ED3497FA0305B06FFA86848E
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Tuininga, Cole
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Cole Tuininga
n:              Tuininga;Cole
org:            The Tasmanet Company, LLC
adr;dom:        170 West Road;;Suite 11;Portsmouth;New Hampshire;03801;
email;internet: egon@tasmanet.com
title:          Sysadmin/Netadmin/Programmer
tel;work:       (603) 427-1100
tel;fax:        (603) 427-1177
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------ED3497FA0305B06FFA86848E--



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

Date: Tue, 17 Mar 1998 13:45:42 -0500
From: Wali Haidri <whaidri@ford.com>
Subject: Escape Charachter in PERL5
Message-Id: <350EC4D6.1588@ford.com>

PERL4 compiles the Octal code for Escape character but perl4 does not
=====================================================================


MY PROBLEM:

We upgraded from PERL4 to Perl5 and so modified our 'oraperl' scripts
and installed DBI/DBD modules.

OLD system was : HP 9.X / ORACLE 7.1
NEW system is  : HP 10.20 / ORACLE 7.3.3

We used to have 'require' statement for printer-specific perl script
wherein we had the PCL codes embedded (we used \033 as Escape character
which is OCTAL).

Now when we upgraded to perl5, the OCTAL code for Escape character don't
generate the required 'Escape character', it rather prints a 'space' and
rest of the PCL commands are printed.

Do you have any clue as to why it is happening  ? Is it a system
specific issue or Perl-version related ?

SORRY IF I AM UNABLE TO ELABORATE MY QUESTION CORRECTLY because it is a
totally new stuff for me.

Can anybody help.

Wali Haidri
Visteon Finance Systems


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

Date: 17 Mar 1998 19:15:01 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: exact match
Message-Id: <890162099.593808@cabal>

In <6ejn2j$31d6@mirac.unm.edu> hamjavar@unm.edu (Farid Hamjavar) writes:


>Greetings,

>I use the following to know if ARGV[1] is all digit characters. 
[...]
>How can I compare  $item  against something like /^[0-9].*[0-9]$/  and
>know that it's all digits?

Howeeveer this says $item starts and ends with a digit.  You most likly
need something like $item =~ /^[0-9]+$/  and as digets are importent [0-9]
can be replaced with \d so you have $item =~ /^\d+$/


--
Please excuse my spelling as I suffer from agraphia see the url in my header. 
Never trust a country with more peaple then sheep. 
Support NoCeM http://www.cm.org/                   
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: 17 Mar 1998 15:21:57 -0500
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: Finding a key thanks to a value in a hash
Message-Id: <x6een01m5ju.fsf@pearl.fi.bear.com>

If you don't want to create a hash from values to keys, then
you won't have an index.  If you don't have an index, you'll 
have to search.  If you don't want to search, you're out of
luck.

BTW, the inverse hash is no larger than the original (or at
least should be).

cfockeu@atos-group.com (ATOS) writes:

> Hello,
> 
> I'm wondering how I can find a key by its value in a hash ???
> Ex: 
> $hash{'key1'} = 'value1';
> ...
> if I got 'value1', how can I get the key
> 
> I don't want to create a second hash (data are huge)
> I don't want to look each value in the hash :
> Ex : foreach $scalar (values(%hash)) {
> 	if ($scalar  = $the_value_I_have) {
> 	# I've found the key
> 		...
> 	}
>      }
> because it's to long
> 
> May I use Reference ????
> 
> Thanks a lot,
> Cedric
> 
> 
> PS : keys and values in the hash are unique
> 

-- 
-Justin
vallon@bear.com


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

Date: Tue, 17 Mar 1998 14:48:54 -0600
From: Marco Paganini <paganini@paganini.net>
Subject: How to implement "timeouts" in perl?
Message-Id: <6emngf$540$1@nnrp1.dejanews.com>

Hello!

I've run across a small problem in perl: Implementing timeouts.
Basically, I have two cases: a) I need to `backtick` a program
and make sure I won't lose control if it hangs, b) Do a "connect"
call in a non-blocking way.

I've tried the simplest form: Using an eval block and a "die bla"
with the alarm() call. Unfortunately, this causes problems due
to non-reentrancy in certain kernel routines.

I've also been using Proc::Simple, but since it always forks,
it's impossible to communicate back (without pipes and all the
messy stuff) to the parent program.

Any help would be appreciated.
Thanks a lot
Paga

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


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

Date: Tue, 17 Mar 1998 14:42:30 -0500
From: Stan Horwitz <stan@thunder.ocis.temple.edu>
Subject: Re: Illegal octal digit error?
Message-Id: <Pine.OSF.3.91.980317143900.22562B-100000@thunder.ocis.temple.edu>

On 16 Mar 1998, Uri Guttman wrote:

> Date: 16 Mar 1998 18:41:51 -0500
> From: Uri Guttman <uri@sysarch.com>
> To: Stan Horwitz <stan@thunder.ocis.temple.edu>
> Newgroups: comp.lang.perl.misc
> Subject: Re: Illegal octal digit error?
> 
> The following message is a courtesy copy of an article
> that has been posted to comp.lang.perl.misc as well.
> 
> 
> here i go again into the bowels of newbiedom!

Thanks for helping this Perl newbie! I am used to REXX for scripting so
Perl throws me for a loop sometime. Now, I am trying to figure out why the
commands

   $x = "03";
   printf OUTFILE ("%2s", $x);

outputs "0003" instead of "03" into the file, but when I print the same value
to the screen, it prints correctly. 

Any suggestions? My Perl programming manual, the Perl Web site docs, and
that "Learn Perl in 21 Days" book shed no light on this mystery.


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

Date: Tue, 17 Mar 1998 19:17:00 GMT
From: bet@network.rahul.net (Bennett Todd)
Subject: loop detection in symlink-following tree walkers (was Re: find.pl ??)
Message-Id: <slrn6gtje2.es.bet@ritz.mordor.net>

1998-03-17-15:45:01 Randal Schwartz:
>If you wanna follow symlinks, you *must* maintain a dev/ino tracking
>hash that tells when you've already visited the directory previously.

For some reason I'm feeling argumentative today:-).

Such a hash is easy to implement in perl, and will often be the most
reasonable way to write the program, but I think "*must*" is perhaps a little
strong.

For instance, I could fantasize that symlinks were used in a fashion that
never created a loop. I've even set up things like that --- e.g. /usr/local in
my populated-by-pkgadd Solaris systems; basically everything in /usr/local is
symlinks into /opt; there are very, very few symlinks there, and those only
within packages. Turns out none of those latter make any loops. So in such a
setting I could write and use a symlink-following tree-walker with no loop
detection.

For another instance, suppose you've got oh say fifty or a hundred of those
cool-o 23GB drives, all mounted up; perhaps you don't like to type "rm" or
something:-). In such a system it's very believable that it might be
impractical to keep any kind of scoreboard of directories visited. If you have
reason to hope that there may be few or no loops, another loop-detection
algorithm may make more sense. For instance, a favourite algorithm does loop
detection in fixed space, by using a trailing graph-walker; advance the
trailing walker at half the speed of the lead walker, and every advance of the
lead compare and see if the lead and the trailer are pointing at the same
node. If they are you've fallen into a loop. Requires small constant space
regardless of the size graph you're traversing, detects loops in time
proportional to the length of the loop squared (I think). Does have the
problem that should it catch a loop it doesn't document where you should leap
to escape it.

What I would agree is that if (a) you have a requirement that you never visit
any file more than once, and (b) you want to follow symlinks, then (c) you
need to think about it.

Hey, in this case I think I've got another possible approach. How about,
whenever you find a symlink, normalize it --- prepend the current dir if it's
relative, and stomp foo/../ sequences. Then check and if the result has as a
prefix any of the starting points of the tree walk, just skip it. That would
again allow you to avoid accumulating a scoreboard with info on all the
directories in the tree.

-Bennett


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

Date: Tue, 17 Mar 1998 13:59:51 -0600
From: dfrench@aig.vialink.com
Subject: Re: Multiple substitues
Message-Id: <6emkkg$15e$1@nnrp1.dejanews.com>

I should have been more clear in my original posting.  The point is NOT to
replace upper case letters with lower case letters.

As I stated in the original posting, the content of the substitutes were just
an example.  What I am trying to do is perform multiple substitutes IN A
SINGLE PASS through a target file/array.

To restate the question, does anybody know how to perform multiple substitutes
in a single command (one pass through a file/array).

An example of this using "sed" would be:

sed -e "s/this/that/g;s/and/the/g;s/other/thing/g" filename

The above example would perform multiple substitues in a single pass through a
file.  Does anybody know how to do this from within a perl script (NOT from a
command line)?

Thanks

Dana French
dfrench@aig.vialink.com

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


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

Date: Tue, 17 Mar 1998 12:47:32 -0800
From: "John Y." <jwy@shasta-view.com>
To: dfrench@aig.vialink.com
Subject: Re: Multiple substitues
Message-Id: <350EE164.71FC@shasta-view.com>

OK I think this is what you are looking for:

first build an associative array like 
$sub{'this'} = 'that';
$sub{'and'} = 'the';
$sub{'other'} = 'thing';

now step thru your keys (looking for them) in a :
foreach $key (keys %sub) {
#  (use the code from page 180 of Programming perl here)
   $pos = -1;
   while (($pos = index($string, $key, $pos)) > -1 {

       # do whatever (substitute)
       $pos++;
   }
}

This is the most efficient code I have used to do this if there is
something more efficient I would like to know.

The above example is not complete nor does it address the UPPER/lower
problem.

But then there wouldn't be anything for you to do :)

-John


dfrench@aig.vialink.com wrote:
> 
> I should have been more clear in my original posting.  The point is NOT to
> replace upper case letters with lower case letters.
> 
> As I stated in the original posting, the content of the substitutes were just
> an example.  What I am trying to do is perform multiple substitutes IN A
> SINGLE PASS through a target file/array.
> 
> To restate the question, does anybody know how to perform multiple substitutes
> in a single command (one pass through a file/array).
> 
> An example of this using "sed" would be:
> 
> sed -e "s/this/that/g;s/and/the/g;s/other/thing/g" filename
> 
> The above example would perform multiple substitues in a single pass through a
> file.  Does anybody know how to do this from within a perl script (NOT from a
> command line)?
> 
> Thanks
> 
> Dana French
> dfrench@aig.vialink.com
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 17 Mar 1998 13:32:36 -0600
From: Mark P Stackhouse <stackhou@elk.cray.com>
Subject: Need some help converting a string into an array
Message-Id: <350ECFD4.6201@elk.cray.com>

I've spent the last several hours reading on both Scalars and Arrays in
Learning Perl.  I've also look in perldata, perllol, and perlfaq4.  I
found some neat stuff but not exactly what I was looking for.

I have successfully openned a file and written it into an array.  I have
also "squeezed" each array element to remove extra spaces and tabs.  Now
I need to convert each element into its own array so that I can query on
the first and last elements.  If I can convert strings to arrays, I can
do the rest.  If it's not too much trouble, please explain the process,
I don't want to just paste code without knowing what I'm doing :-)

-- 
 Mark Stackhouse
 x64704

 *********************************************************
 *							 
 * Senior Electrical-Mechanical Technician		 
 * Homepage - http://wwwmfg.cray.com/~stackhou	 
 * E-mail - stackhou@elk.cray.com				 
 *							 
 * Off site homepage - http://www.execpc.com/~stackhou
 *
 * Home E-mail - stackhou@execpc.com				 
 *				 			 
 * "The best things in life aren't things"		 
 *							 
 *********************************************************


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

Date: Tue, 17 Mar 1998 19:50:17 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: Need some help converting a string into an array
Message-Id: <slrn6gtkt9.8q9.jgloudon@manitoba.bbn.com>

In article <350ECFD4.6201@elk.cray.com>, Mark P Stackhouse wrote:
>I have successfully openned a file and written it into an array.  I have
>also "squeezed" each array element to remove extra spaces and tabs.  Now
>I need to convert each element into its own array so that I can query on
>the first and last elements.  If I can convert strings to arrays, I can

You really didn't ask a specific question ?
Best I can say is man split.

Jason Gloudon


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

Date: 17 Mar 1998 15:05:30 -0500
From: kcohen@julius.ling.ohio-state.edu (Kevin B Cohen)
Subject: Re: Need some help converting a string into an array
Message-Id: <6eml2a$mdf@julius.ling.ohio-state.edu>

In article <350ECFD4.6201@elk.cray.com>,
Mark P Stackhouse  <stackhou@elk.cray.com> wrote:
>I have successfully openned a file and written it into an array.  I have
>also "squeezed" each array element to remove extra spaces and tabs.  Now
>I need to convert each element into its own array so that I can query on
>the first and last elements.  If I can convert strings to arrays, I can

it sounds like what you want to do is look at the beginning and end of
each word.  is that right?  if so, how about this?

# don't read the whole file into an array.  instead, read it in line
# by line:

open(IN, "your_file_name_here") || die "your_message_here";

while ($line = <IN>) {

# now split that line up into an array.  i'll assume that the line 
# is separated by spaces...

	@words = split(' ', $line);

# each element of the array @words is a word.  now you can go thru
# the words, using perl's frolicsome foreach operator:

	foreach $word (@words) {
		look_at_beginning;
		look_at_end;
	}

}

on the other hand, if i misunderstood your question and you really do
need an array of arrays, i refer you to "Perl 5 for dummies", by paul
e. hoffman, pp. 258-261.  this will help you build the data structure
and then iterate thru it.

kevin

"If we suppose for the moment that a pizza is a syntactical
structure...."  --Nigel Chapman, Perl: The Programmer's Companion





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

Date: Tue, 17 Mar 1998 14:44:27 -0600
From: Mark P Stackhouse <stackhou@elk.cray.com>
To: Kevin B Cohen <kcohen@julius.ling.ohio-state.edu>
Subject: Re: Need some help converting a string into an array
Message-Id: <350EE0AB.63DE@elk.cray.com>

Thanks Kevin,

Actually, I need to look at the first and last word in each string but
writing each line into an array as it comes in might be easier than the
way I was going at it.  Will the extra spaces and tabs end up being
array elements also?

Kevin B Cohen wrote:
> 
> In article <350ECFD4.6201@elk.cray.com>,
> Mark P Stackhouse  <stackhou@elk.cray.com> wrote:
> >I have successfully openned a file and written it into an array.  I have
> >also "squeezed" each array element to remove extra spaces and tabs.  Now
> >I need to convert each element into its own array so that I can query on
> >the first and last elements.  If I can convert strings to arrays, I can
> 
> it sounds like what you want to do is look at the beginning and end of
> each word.  is that right?  if so, how about this?
> 
> # don't read the whole file into an array.  instead, read it in line
> # by line:
> 
> open(IN, "your_file_name_here") || die "your_message_here";
> 
> while ($line = <IN>) {
> 
> # now split that line up into an array.  i'll assume that the line
> # is separated by spaces...
> 
>         @words = split(' ', $line);
> 
> # each element of the array @words is a word.  now you can go thru
> # the words, using perl's frolicsome foreach operator:
> 
>         foreach $word (@words) {
>                 look_at_beginning;
>                 look_at_end;
>         }
> 
> }
> 
> on the other hand, if i misunderstood your question and you really do
> need an array of arrays, i refer you to "Perl 5 for dummies", by paul
> e. hoffman, pp. 258-261.  this will help you build the data structure
> and then iterate thru it.
> 
> kevin
> 
> "If we suppose for the moment that a pizza is a syntactical
> structure...."  --Nigel Chapman, Perl: The Programmer's Companion

-- 
 Mark Stackhouse
 x64704

 *********************************************************
 *							 
 * Senior Electrical-Mechanical Technician		 
 * Homepage - http://wwwmfg.cray.com/~stackhou	 
 * E-mail - stackhou@elk.cray.com				 
 *							 
 * Off site homepage - http://www.execpc.com/~stackhou
 *
 * Home E-mail - stackhou@execpc.com				 
 *				 			 
 * "The best things in life aren't things"		 
 *							 
 *********************************************************


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

Date: Tue, 17 Mar 1998 15:52:58 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
To: Mark P Stackhouse <stackhou@elk.cray.com>
Subject: Re: Need some help converting a string into an array
Message-Id: <350EE2AA.1DD15C05@shopcfn.com>

Mark P Stackhouse wrote:
> the first and last elements.  If I can convert strings to arrays, I can
> do the rest.  If it's not too much trouble, please explain the process,
> I don't want to just paste code without knowing what I'm doing :-)

without knowing what your text looks like i can only suggest that you
should look at the 'split' function:

perldoc -f split

cheers,

-- 
# dan boorstein <dboorstein@shopcfn.com>
seek DATA,0,0;print scalar<DATA>,__END__
Just another Perl hacker,


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

Date: Tue, 17 Mar 1998 13:20:36 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Output
Message-Id: <350ECD04.A3FB1CC8@houston.Geco-Prakla.slb.com>

James R. Edgar wrote:
> 
> I have written a script that will take in information and lay it out
> into an html document. My only problem is I am trying to figure out how
> to ouput the file to a filename I choose.

Well, James, my first advice would be to look at open() in the blue
camel, or the perldoc -f open pages.

What exactly are you having trouble with?  A code snippet would greatly
improve my (and the other readers) ability to help.

open(FILE,">TheFileNameIChose.html") or die "Cannot open
TheFileNameIChose.html: $!\n";

Feel free to substitute for "TheFileNameIChose.html", such things as:
open(FILE,">$filename") or die "Cannot open: $!\n";
open(FILE,">$filename.html") or die "Cannot open: $!\n";
open(FILE,">$someotherFilename") or die "Cannot open: $!\n";

Always check return codes.  Always.

Some more good advice:  Include $! in the die portion so that you know
what error the OS gave when you tried to do whatever you tried to do. 
e.g.  If you do not have write permissions in the directory you try to
create this file in, $! will come back with "Permission Denied".

>         If any one has any ideas it will be gladly appreciated.
>         I have only been doing Perl for six months.
> 
You have read the llama book at least once, already, right?

>         James R. Edgar

Hope that helps.

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Tue, 17 Mar 1998 20:04:32 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: parsing perl [Pointer to www.perl.com et al]
Message-Id: <slrn6gtlo1.8q9.jgloudon@manitoba.bbn.com>

In article <350EACFE.204A3CD9@NOSPAMintr.net>, Rob Collins wrote:
>Thanks to it, I'm pouring through perly.y now... hoping to derive some
>knowledge at the end of all this.
>So, to rephrase my question more intelligibly, is there any detailed
>information on the rules of parsing Perl syntax?  Like an equivilant to "How a
>bill becomes a law", perhaps some documentation: "How a text file becomes an
>op-code"?  Or like Gisle Aas' "PerlGuts Illustrated"?

No. Best you can do is read the parser et al.

Jason Gloudon


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

Date: Tue, 17 Mar 1998 14:33:05 -0600
From: paul@netmagic.net
Subject: perl consulting
Message-Id: <6emmic$3sa$1@nnrp1.dejanews.com>

I need a perl consultant interested in a short contract. Where would I find
such an individual?

Thank you,
paul

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


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

Date: 17 Mar 1998 19:21:12 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Perl Tk rulez! - but how Cut/Paste....
Message-Id: <890162861.94353@thrush.omix.com>

Oliver Harvey <o.harvey@andtech.co.uk> wrote:
: I've been playing with Perl32/Tk on Windoze95 (yuk.....), and
: am generally rocking happily......but can't sort/find docs about
: using Cut/Copy/Paste facilities..........

	my $text = $MW->SelectionGet (-selection => 'PRIMARY');

	Alternate '-selection' types include 'CLIPBOARD', 'CUT_BUFFER',
	'SECONDARY', and 'FRAMROD'.

	I always wrap this call in an eval() myself, because it loves to
	try and blowup if the selection asked for doesn't currently exist.
	I've yet to find a way to test for it first, but there has to be
	a way...

	Followups redirected to comp.lang.perl.tk.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 17 Mar 1998 14:56:06 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: Perl5 compile error
Message-Id: <ximpvjlavfd.fsf@jihad.amd.com>

>>>>> "B" == ByrneJB  <ByrneJB@Harte-Lyne.ca> writes:

I suggest you clean up your build directory.  I've seen this
problem when some .o or .a files persisted from earlier builds.

make clean should do this -- but it may have missed a file or two.

-- 
Quentin Fennessy			AMD, Austin Texas


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

Date: 17 Mar 1998 19:03:54 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Problem determining if system function worked
Message-Id: <slrn6gti8q.tgq.Tom.Grydeland@mitra.phys.uit.no>

On Mon, 16 Mar 1998 13:12:11 -0500,
Russ Conway <russ_conway@cytec.gm.com> wrote:

Heads up, Russ!  Your reply-to address bounced.  Fix your headers!

> $result = system('rename ' . $importFileName . ' ' . $archiveFileName);

perldoc -f rename


> TIA

HTH

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


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

Date: Tue, 17 Mar 1998 20:46:50 +0200
From: lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
Subject: Re: Problem stripping Mac headers off of GIF's
Message-Id: <lassehp-1703982046500001@ygdrasil.imv.aau.dk>

In article <6ein44$f0p@bgtnsc03.worldnet.att.net>, "Creede Lambard"
<fearless@io.com> wrote:

>Unless the file is being copied onto a Mac, or onto an NT system with NTFS
>and File Services for Macintosh, the resource fork will be stripped out
>anyway, so that's not a problem. Unless, of course, the resource fork has
>some of the information you need . . .
>

The files in question were being received as e-mail attachments, and
presumably encoded in some way: BinHex (.hqx), BASE64 applesingle or
BASE64 appledouble. The original poster talked about binary header
information, and was able to seek into the file, which seems to indicate
that it was not BinHex, or that BinHex had already been decoded (to
MacBinary?).

So the Mac-specific stuff was obviously retained, and a resource fork
_would_ get in the way if the original file had one.

-Lasse


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

Date: Tue, 17 Mar 1998 18:34:54 GMT
From:  (Phil Hanna)
Subject: Re: redirect stderr and stdout to the same file
Message-Id: <350ec1c4.10070250@newshost.unx.sas.com>

The command line syntax you need is the same as the Unix idiom:

perl scriptname.pl 1>outputfilename 2>&1

Use ">>" instead of ">" if you want to append rather than replace.

Here is an example:

perl caller.pl 1>test.out 2>&1

where "caller.pl" is a file containing the following line

system("perl redirTest.pl");

and "redirTest.pl" is a file containing the lines:

print STDOUT "This is a message to STDOUT\n";
print STDERR "This is a message to STDERR\n";

You should see both messages written to test.out

NOTE:  You have to specify "perl <scriptname>.pl", not just
"<scriptname>" if you want to use I/O redirection from the command
line.  This is a limitation of the way the NT command processor works.

NOTE2: This does not work at all on Windows 95.  So far as I know, you
can't redirect stderr from the command line (someone please correct me
if I'm wrong).

----------
Phil Hanna
saspeh at unx dot sas dot com


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

Date: Tue, 17 Mar 1998 16:06:00 -0500
From: "Brian J.S. Miller" <brian@rickjames.sapien.net>
Subject: Setting locale failed.
Message-Id: <350EE5B8.7E168A4@rickjames.sapien.net>

can anyone tell me why I get the following errors whenever I run any
perl scripts? I used to use perl v5.003, and got the same errors
(although the wording was slightly different)...
today I upgraded to 5.004, and I'm still getting the following errors:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LC_ALL = (unset),
        LANG = "us"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

-- 
Brian J.S. Miller
mailto:brian@rickjames.sapien.net
http://rickjames.sapien.net/
--


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

Date: Tue, 17 Mar 1998 15:24:18 -0500
From: mshavel@erols.com (Michael Shavel)
Subject: stripping "special" characters from string
Message-Id: <mshavel-1703981524180001@130.9.16.207>

Hi

I am trying to rename a file called   PADM.ATEX.LGLGMP(+1) to
PADM.ATEX.LGLDMP.dayofmonth

the code I am using is as follows:


use File::Copy;
$fname = "PADM.ATEX.LGLDMP(+1)";

(undef,undef,undef,$mday) = localtime(time);
print "Day of the month is $mday\n";

#copy file to archive dir with day of week appended to filename
$archive_name = "$fname.$mday";
print "Archive name is $archive_name\n";


#THIS IS THE PROBLEM LINE
#HOW DO I MATCH THE STRING  (+1)  ??
$archive_name =~ s/[(+1)]//g;

print "After stripping the archive name is $archive_name\n";
copy("$fname", "test/$archive_name")


I am trying using quotes and backslashes in the regexp but my efforts have
failed. If the day of the month has a 1 in it the  1 is also stripped out.


I need to strip out ONLY the string  (+1)  from the filename. 

This is probably a simple thing (but then again what isn't when you know
the answer). 

Help would be very much apprecaited as always

thank you very much 

Sincerely

Mike Shavel
mshavel@erols.com



Ps.. I am going to pick up the book  "Mastering Regular Expressions" but
have not had the chance yet.


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

Date: Tue, 17 Mar 1998 12:02:31 -0800
From: Curt Cranfield <curt@vphos.net>
Subject: Tainted Data Problems
Message-Id: <350ED6D7.8499D93D@vphos.net>

Hi Everyone,

I am having some problems figuring out how to over come a problem which
is caused by tainted data.  I am writting a small client/server program
and using the -Tw switches to make sure I keep security problems to a
min.

The problem lies in the fact that I need to create a new file on the
server side if certain data is transmitted by the client.  Of course I
get an error like:
Insecure dependency in open while running with -T switch at
/xx/xx/programname line 517, <STDIN> chunk 4.

This occurs if I use the data that was directly inputed or if I use the
data inputed to search a local file that gives me back the absolute path
of the new file to create.

for example:
$datainputed = "boo.txt";

while (<DOG>)    {
    chop;
    @info = split(/\./,$_);

    if ($info[0] eq $datainputed)    {
        $openfile = $info[1]; #where $info[1] = /usr/local/boo.txt
        last;
   }
}

open (TMP,"+>>$openfile") or &error; #this is where we get the tainted
data

I have checked the man pages and such but none of the suggestions given
seem to help.

If you have any ideas?

Thanks,

Curt



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

Date: Tue, 17 Mar 1998 19:36:25 GMT
From: bet@network.rahul.net (Bennett Todd)
Subject: using ptys to run programs for buffering control
Message-Id: <slrn6gtkig.es.bet@ritz.mordor.net>

I wanted to run a simple program, and suck the bits out of its stdout without
buffering; what I was doing was massaging the output format of a program that
does a running display. I.e. instead of the canonical

	while true;do
		echo -n '^[[H'
		command|sed 's/$/^[[K'
		echo -n '^[[J'
		sleep 10
	done

I wanted to run command with an option so it'd internally loop, generating a
fresh report every 10 seconds, and postprocess that output into a pretty
screen-painter. Of course when I ran it from a pipe the program said to itself
"stdout isn't a tty, so I'm going to block buffering". Chat2.pl is dead and
gone, and I couldn't get Comm.pl to work, so just for yolks I tried doing the
job myself and son of a gun, it didn't ouch too badly at all. This works fine
on a SunOS 4.x machine; I've yet to need to try this trick elsewhere.

	# open FD, "command yadda yadda|" or die;

	my($tty) = 'OOPS';
	for (</dev/ptyp*>) {
		if (open FD, "<$_") {
			($tty = $_) =~ s#/pty#/tty#;
			last;
		}

	}
	die "no pty" if $tty eq 'OOPS';
	if (fork == 0) {
		open STDIN, "<$tty" or die;
		open STDOUT, ">$tty" or die;
		open STDERR, ">&STDOUT" or die;
		exec qw(command yadda yadda);
		die;
	}

-Bennett


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

Date: 17 Mar 1998 19:10:37 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Why this one doesn't work ?
Message-Id: <slrn6gtild.tgq.Tom.Grydeland@mitra.phys.uit.no>

On 17 Mar 1998 13:40:15 GMT,
Hunter Johnson <jhunterj@lexis-nexis.com> wrote:

> Try starting with
> #!perl
> if it's important to avoid hard-coding the path.

That won't work.

> J. Hunter Johnson        | "A little consistent wholesome modeling and

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


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

Date: 17 Mar 1998 19:09:47 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Why this one doesn't work ?
Message-Id: <slrn6gtijr.tgq.Tom.Grydeland@mitra.phys.uit.no>

On Mon, 16 Mar 1998 17:39:28 -0600,
indhiraa@hotmail.com <indhiraa@hotmail.com> wrote:
> I have a PERL program whose first 3 lines are like this:
> 
> #!/bin/sh
> # this line will be comment for PERL \
> exec perl "$0" $@"

Blech.  You've been fiddling with Tcl again.  Wash your hands.

Now repeat after me:

    In Perl, a comment extends from '#' to end-of line.  \ does *not*
    continue the comment onto the next line.

man perlrun for the right way to do it.

> My intention is to avoid hard-coding the path to the Perl interpreter.
> but this script continuously execs and never goes beyond that.

This has been explained by others.

> Am I missing anything here.

Yup.  A question mark.  :-)

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


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

Date: Tue, 17 Mar 1998 18:47:21 GMT
From: dagbrown@undergrad.math.uwaterloo.ca (Dave Brown)
Subject: Re: Why this one doesn't work ?
Message-Id: <Epz86x.650@undergrad.math.uwaterloo.ca>

In article <6ekd3v$7u2$1@nnrp1.dejanews.com>,  <indhiraa@hotmail.com> wrote:
: I have a PERL program whose first 3 lines are like this:
: 
: #!/bin/sh
: # this line will be comment for PERL \
: exec perl "$0" $@"
: 
: print "hello..\n";
: 
: My intention is to avoid hard-coding the path to the Perl interpreter.
: but this script continuously execs and never goes beyond that.

Try

    #!/bin/sh
    exec perl "$0" "$@"
        unless $running_under_some_shell;

    print "Hello...\n";

--Dave
-- 
"Fluffy bunnies are cute. Not that I have any but they should be eaten more."
                                        --Debbie Wu
http://www.csclub.uwaterloo.ca/u/dagbrown/


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

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

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