[9181] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2798 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 3 15:07:26 1998

Date: Wed, 3 Jun 98 12:00:25 -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, 3 Jun 1998     Volume: 8 Number: 2798

Today's topics:
    Re: c.l.p.misc is `perl support' (was Re: O'Reilly has  <Russell_Schulz@locutus.ofB.ORG>
    Re: FORMAT to console <rootbeer@teleport.com>
        how can I invoke concurrent perl processes in win-NT <hoang.d.uong@intel.com>
        Incrementing zero-padded numbers (Andy Chandler)
    Re: Incrementing zero-padded numbers <tchrist@mox.perl.com>
    Re: Incrementing zero-padded numbers (Josh Kortbein)
    Re: map in void context regarded as evil - suggestion (Michael J Gebis)
    Re: novice question: improving this code? (Mark-Jason Dominus)
    Re: perl Security Mode. <rootbeer@teleport.com>
        Perl/cgi problem - truncating of output (Rufus Xavier Sarsparilla)
    Re: perlshop error (Jonathan Stowe)
        POD vs. HTML (was Re: map in void context regarded as e <Russell_Schulz@locutus.ofB.ORG>
        regex help. bthak@bascom.com
    Re: regex help. (Mike Stok)
    Re: regex help. <rootbeer@teleport.com>
    Re: scalar string to array (Mike Stok)
    Re: scalar string to array dlynch@morrisonscientific.com
    Re: scalar string to array (Mike Stok)
    Re: scalar string to array <zenin@bawdycaste.org>
    Re: setting precision??? <zenin@bawdycaste.org>
        Untainting a variable (Bernard Cosell)
    Re: Use of HTML, POD, etc in Usenet (was: Re: map in vo chris+usenet@netmonger.net
        value of a environment variable indhiraa@hotmail.com
    Re: value of a environment variable <jdporter@min.net>
    Re: value of a environment variable (Mike Stok)
    Re: value of a environment variable <mbl@startext.de>
    Re: value of a environment variable (Jonathan Stowe)
        When will Perl 5.005 come out? <robpang@cs.stanford.edu>
    Re: When will Perl 5.005 come out? <tchrist@mox.perl.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 3 Jun 1998 10:53:55 +0100
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: c.l.p.misc is `perl support' (was Re: O'Reilly has helped promote the acceptance of Perl)
Message-Id: <19980603.105355.8U3.rnr.w164w@locutus.ofB.ORG>

rjk@coos.dartmouth.edu (Ronald J Kimball) quotes and writes:

>> it seems `mightly clear' to me that the readers of c.l.p.misc do
>> NOT want to be `perl support', except for particularly interesting
>> problems.
>
> That's because we've already answered the uninteresting problems over
> and over again.  Hence the FAQ.

if I wanted to say `non-FAQ', I would have said `non-FAQ'.

but I said `particularly interesting'.

I find your claim that all the uninteresting problems are answered in
the FAQ to be... incorrect.

I think Usenet is `user community'; the Perl conference is a bit of
that and also `support'; the books are `documentation'.

but none of them should be confused with the folks at `perl.com' and
`stonehenge.com' and these other places that actually offer support,
day-to-day, for interesting _and_ uninteresting problems.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Wed, 03 Jun 1998 17:07:23 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: FORMAT to console
Message-Id: <Pine.GSO.3.96.980603095651.13600G-100000@user2.teleport.com>

On Wed, 3 Jun 1998, Phil R Lawrence wrote:

> Is there a good way to send 24 lines at a time, wait for the user to
> strike ENTER, and then display the next screen?  

Sure - tell the person running your script to pipe its output through
more. :-)

Or, if you wish, you can run the user's choice of $PAGER from within your
program. That's a good way to keep the user happy, since you can presume
that they have their $PAGER configured just as they like it. 

Cheers!

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



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

Date: Wed, 03 Jun 1998 10:57:35 -0700
From: hoang uong <hoang.d.uong@intel.com>
Subject: how can I invoke concurrent perl processes in win-NT
Message-Id: <35758E8F.DB661A79@intel.com>

Hi,
I use cygnus bash shell in Win-NT 3.51.
I intend to invoke perl script 'script_name' multiple times in the
background (I use '&' as in Unix). The following code
does not work
for( $i = 0; $t < 3; $i+= ){
    system("perl script_name param1 param2 &");
}

The '&' is passed as an argument to the 'script_name'. Any one
can help me ?

Thanks very much,
Hoang





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

Date: 3 Jun 1998 17:06:41 GMT
From: andyc@netins.net (Andy Chandler)
Subject: Incrementing zero-padded numbers
Message-Id: <slrn6nb0l1.nnl.andyc@worf.netins.net>

Hi all, looking for some help...

I want to create a series of files based on incrementing zero-padded
numbers.  For example, if I have the number 0001, I want to automatically
increment to 0002.  I've got the incrementing numbers down (1,2,3,etc),
but I need to know how to do it ith the zero-padded numbers.

Any help is appreciated.  Thanks!

-- 
Andy Chandler
netINS, Inc.
andyc@netins.net


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

Date: 3 Jun 1998 17:14:24 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Incrementing zero-padded numbers
Message-Id: <6l409g$8hq$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, andyc@netins.net writes:
:I want to create a series of files based on incrementing zero-padded
:numbers.  For example, if I have the number 0001, I want to automatically
:increment to 0002.  I've got the incrementing numbers down (1,2,3,etc),
:but I need to know how to do it ith the zero-padded numbers.

What's wrong with ++?

--tom
-- 
"Twisted cleverness is my only skill as a programmer." --Elizabeth Zwicky


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

Date: 3 Jun 1998 17:48:27 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Incrementing zero-padded numbers
Message-Id: <6l429b$b0$1@news.iastate.edu>

Andy Chandler (andyc@netins.net) wrote:
: Hi all, looking for some help...

: I want to create a series of files based on incrementing zero-padded
: numbers.  For example, if I have the number 0001, I want to automatically
: increment to 0002.  I've got the incrementing numbers down (1,2,3,etc),
: but I need to know how to do it ith the zero-padded numbers.

: Any help is appreciated.  Thanks!

Why not just use a number, incrementing normally, and then zero-pad it
right before you use the number in a filename?


Josh
NP: Stereolab, _Emperor Tomato Ketchup_

____________________________________________________________________
"In Zen they say: If something is boring after 2 minutes, try it for
4. If still boring, try it for 8, 16, 32, and so on. Eventually one
discovers that it's not boring at all but very interesting."
                      - John Cage



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

Date: 3 Jun 1998 17:47:49 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: map in void context regarded as evil - suggestion
Message-Id: <6l4285$q5f@mozo.cc.purdue.edu>

Russ Allbery <rra@stanford.edu> writes:
}Zenin <zenin@bawdycaste.org> writes:
}> Russ Allbery <rra@stanford.edu> wrote:

}>> It's less intrusive.  Count the number of characters of markup per amount
}>> of text.  If HTML were as light-weight as POD, I doubt anyone would
}>> complain about it.

}> 	When <insert a shell newsreader here> can handle POD, sure.

}No, that's my point.  POD is *so* lightweight that it doesn't interfere at
}all with the readability of the text.  I'm not saying that B<everyone>
}should I<immediately> start using POD to mark up their articles; I'm just
}saying that a little POD scattered into a message really isn't at all
}comperable to HTML.

}Of course, if people were using =over, =item, =back lists all the time, I
}may consider that a bit much, because that *is* intrusive.

Way back when I was an undergrad and the web was new, I seem to
remember the utter simplicity of turning a document into HTML.  All
one had to do was throw a bracketed P at the end of every paragraph,
and you were done.<P>

Of course, things being the way they were, people wanted <I>change</I>
and <B>progress</B>. <A HREF="about:marca">Marc</A> added <IMG
SRC="http://people.netscape.com/marca/marca.gif"> images, which of
course violated a standard few people knew existed.  After all, HTML
is really just a DTD for SGML.  Out came the pedants, who decided that
HTML needed rules, which of course meant that everyone lobbied for
their favorite feature and the HTML standard, instead of evolving in the
market, was designed by committee.<P>

<P ALIGN="Left">Of course, now <BLINK>EVERYTHING</BLINK> is <FONT
SIZE=+1>out of control</FONT>.  Paragraphs are containers, <TABLE
BGCOLOR=FFFFFF cellpadding=0 cellspacing=0 border=0 width=99%><TR> <TD
valign=top align=left >&nbsp;<BLINK><FONT SIZE=+4><I><U><B>AND I FOR
ONE AND SICK AND TIRED OF IT</B></U></I></FONT></BLINK></TD></TR></TABLE><P>
         
-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 3 Jun 1998 14:53:53 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: novice question: improving this code?
Message-Id: <6l4641$86d$1@monet.op.net>
Keywords: antithetic fisherman Lopez nirvana


In article <brinton-0306980914230001@p026.intchg3.net.ubc.ca>,
Ralph Brands <brinton@unixg.ubc.ca> wrote:
>     I am not  a programmer, but have been able to develop a perl script
>that does the following:

Congratulations!  You're now a programmer.  You might as well admit it.


If you're likely to be searching the same file repeatedly, a good
strategy is to build an index database.  The best way to do that is to
do some research and to use someone else's search programs.  Check
around.  (I'd recommend one, but I don't know the answer myself.)

If you're bent on doing it yourself, the basic strategy is to read the
file *once* and record the position of every word in it, say in a DBM
file.  So, for example, suppose you want to find all the occurrences
of word $w2 that is followed by an occurrence of word $w2 not more
than 2 lines later.

Suppsose you had A DBM file that said, for each word, the numbers of
the lines in which it occurred:

	   a: 1
	   DBM: 1
	   the: 1,2
	   occurred: 2
	   (etc.)

Let's say that this database is bound to the Perl variable %DB.
Then the code to find the words you want in the file is simple:

	@w1_lines = split /,/ , $DB{$w1};
	@w2_lines = split /,/ , $DB{$w2};

	# Construct temporary hash for easy lookup
	foreach $line (@w2_lines) {
	  $has_w2{$line} = 1;
	}

	foreach $line (@w1_lines) {
	  for ($i= 0; $i < 3; $i++) {
	    if ($has_w2{$line + $i}) {
	      print "$w1 on line $line is followed by ";
	      print "$w2 on line ", ($line + $i), "\n";
	      # Or do whatever else is appropriate.
	    }
	  }
	}

Better algorithms are possible, but the code is more complicated and I
wanted you to get the idea of what is really going on.

To handle constraints like `must not be separated by more than 3
words', you have a couple of choices.  The simplest one is to forget
about searching by lines entirely.  It's dumb to find the places where
w1 is followed by w2 two lines later if your next step is to find w1
followed by w2 three words later.  You might as well just do the
second part since then you get the first part for free.  So instead of
building the DBM file to list the lines on which eachword occurs,
imagnig that the words in the file are numbered consecutively,
starting from 1 and going up.  Then if you know that w1 occurs at
position 157 in the file and w2 occurs at position 159, you know
there's only one word in between them.  The code will look very much
the same as the code I put above.

To build these databases is typically pretty simple.  For example, to
build the word index:

	use DB_File;
	tie %db => DB_File, $FILENAME, O_CREAT | O_RDWR, 0666
	  or die "Couldn't bind database $FILENAME: $!; aborting";

	# Analyze the input
	$wordno = 0;
	while (<>) {
	  @words = split;
	  foreach $word (@words) {
	    push @{$positions{$word}}, $wordno;
	    $wordno++;
	  }
	}

	# Store the results
	while (($word, $position_list) = each %positions) {
	  $db{$word} = join ',' , @$position_list;
	}

	untie %db;

You run this program *once* on your text file to build the index, and
from then on you can do fast searches with the index, at least until
the original text changes.  

The other important trick to use is to build another database which
says, for each word number, where in the file it occurs.  You do this
with an index file of byte offsets.  For example, if the 37th word in
your original text file happens to begin at byte 197, then the 37th
integer in the index file will contain the number 197.

Now suppose you're interested in word #58 and you want to look at it
in situ:  Call get_word_N(58), where `get_word_N' is as follows:

	sub get_word_N {
	  my $N = shift;
	  my $offset;
	  seek(INDEX, 4*$N, 0);
	  read(INDEX, $offset, 4);
	  seek(TEXT, $offset, 0);
	  return scalar(<TEXT>);
	}

Here INDEX is the index file of integers, and TEXT is the original
file with the real text in it.  This returns the rest of the line that
contains word #58, starting with that word.

To write out such an index file is easy.  You can do it while you're
constructing the other index above:


	# Analyze the input
	while (<>) {
	  @words = split;
	  foreach $word (@words) {
	    print INDEX pack("N", tell ARGV);
	  }
	}
	

Anyway, this is all rather drastically different from the approach you
have been taking.  The basic strategy is to cmopute some structure for
the file beforehand, and save the information about that for later and
use it to speed up the searches.  If the original data rarely changes,
it doesn't matter how long it takes to compute and index it, because
you only do that once.

It's not a complete solution, but more a bag of ideas that you can use
to grow your own ideas.


Hope it helps.



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

Date: Wed, 03 Jun 1998 16:51:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: perl Security Mode.
Message-Id: <Pine.GSO.3.96.980603094210.13600F-100000@user2.teleport.com>

On 3 Jun 1998, Kenny Nguyen wrote:

> 	I'm wondering if anyone could help me with perl script. 
> Recently my ISP has just switched perl to run it under secure mode. 

What's secure mode? Do you mean that it's running with taint checks turned
on? Or is there something else happening?

> What I have found out is that i need to untaint the variable I have set. 
> But I really don't know how to do it. I read perlsec but it didn't give
> much help. 

You can't "untaint" a variable, but you can extract untainted data
from a tainted source. What code did you use to try to do that?

> $number = "4";
> $file_path = "../read/poetry/";
> open (file, ">$file_path$number.html");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

In this case, neither $number nor $file_path is tainted. But it's
generally not a good idea to use a relative path in a CGI script, since
you can't be sure what working directory it will have. (That's not part of
the CGI interface specification.)

Hope this helps!

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




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

Date: 3 Jun 1998 11:52:40 -0700
From: kirbyk@best.com (Rufus Xavier Sarsparilla)
Subject: Perl/cgi problem - truncating of output
Message-Id: <6l461o$pnc$1@shell2.ba.best.com>

We're having some problems with a cgi script, which can be simplified and
replicated with this simple test case:

#!/usr/local/bin/perl

$| = 1;

print "Content-type: text/plain\n\n";

$result = `/usr/ucb/rsh (routername) traceroute www.ibm.com.`;
print $result;


(Where routername is replaced by the actual name of our router, which I'm
not going to publish to Usenet.)

Running this from the command line returns the expected results without a 
problem.  Running it from a web browser, though, only returns the first
few lines of the traceroute output, and then stops.

Has anyone run into a similar problem?  (Or, know someone/somewhere more
appropriate to ask?)  Any suggestions for a workaround?  This one has me
stumped, but I'm still somewhat novice on these things. (Though jumping in
with both feet, so to speak.)

Thanks!

-- 
Kirby Krueger      O-     kirbyk@best.com 
<*> "Most .sigs this small can't open their own jump gate."


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

Date: Wed, 03 Jun 1998 17:07:36 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: perlshop error
Message-Id: <35757df6.2778545@news.btinternet.com>

On Wed, 03 Jun 1998 11:48:05 -0400, Albert Cunningham wrote :

>can anybody help me
>we are setting up perlshop and have encountered the following problem
>we have an enter button on our top page--when you click on it, we get
>the following message::
>Invalid Transmission #3 received from: 136.142.74.83
>If your connection was interrupted, you must Enter the shop from the
>beginning again.
>

Oh dear,  you appear to have stumbled on something you shouldnt have.

That error message was deliberately omitted as I'm sure you noticed
from the perldiag documentation in order to prevent widespread panic
in the general population. I'm sure you'll appreciate our reticence to
discuss iit if I tell you it could affect the future of the entire
world.  I think you had better take it up with the appropriate
authority.

/J\
;-}
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Wed, 3 Jun 1998 11:10:33 +0100
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: POD vs. HTML (was Re: map in void context regarded as evil - suggestion)
Message-Id: <19980603.111033.6n6.rnr.w164w_-_@locutus.ofB.ORG>

  (why can't people change the Subject: header?)

Gellyfish@btinternet.com (Jonathan Stowe) qutoes quotes and writes:

>>> Just a thought but shouldnt POD markup be deprecated in usenet
>>> postings just as HTML is ?
>>
>> You've *got* to be kidding.  Whyever would you think that we should
>> deprecate *simple* text markups?
>
> Does C<scalar keys %hash> carry any more or any less typographical
> information  than <CODE>scalar keys %hash</CODE> ?

for those who have a text/html handler set up (or for whom it came
pre-installed), it can carry less (unless they also set up a
text/x-pod handler, source available everywhere, carry it with you
wherever you go and re-install...).

but if it makes things easier to copy+paste into messages that are
actually answering people's questions, I can't say I mind that much.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Wed, 03 Jun 1998 17:24:26 GMT
From: bthak@bascom.com
Subject: regex help.
Message-Id: <6l40sc$q9p$1@nnrp1.dejanews.com>

Need some help.

$temp = shift;

if ($temp =~ /[a-zA-Z_0-9]{8,}/){
        if ($temp =~ /\d{2,3}/) {
                print "good has 8 chars and 2-3 number";
        }
        else {
                print "8 chars but needs to have numbers";
        }
}
else {
        print "not eight chars";
}

"($temp =~ /\d{2,3})"  <-- checks for consecutive digit how can i have it so
something like 1blahblah1 will be a match.

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


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

Date: 3 Jun 1998 19:41:46 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: regex help.
Message-Id: <6l48tq$k5g@news-central.tiac.net>

In article <6l40sc$q9p$1@nnrp1.dejanews.com>,  <bthak@bascom.com> wrote:

>"($temp =~ /\d{2,3})"  <-- checks for consecutive digit how can i have it so
>something like 1blahblah1 will be a match.

you could use tr to count the decimal digits in $temp

  $digits = $temp =~ tr/0-9/0-9/;

similar examples can be found in the perlop man page in recent
distributions.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Wed, 03 Jun 1998 18:52:30 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: regex help.
Message-Id: <Pine.GSO.3.96.980603114325.13600J-100000@user2.teleport.com>

On Wed, 3 Jun 1998 bthak@bascom.com wrote:

> Subject: regex 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

> "($temp =~ /\d{2,3})"  <-- checks for consecutive digit how can i have it so
> something like 1blahblah1 will be a match.

It looks as if you want to count how many digits are in a string. tr///
can do this.

It also looks as if you're trying to warn users who have picked bad
passwords. There's a program on CPAN for doing something like that; 
you'll find it in the admin scripts section. Hope this helps! 

    http://cpan.perl.org/scripts/admin/

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



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

Date: 3 Jun 1998 18:02:59 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: scalar string to array
Message-Id: <6l434j$g9m@news-central.tiac.net>

In article <35756DAC.279@nortel.ca>, Don Skinner  <studft@nortel.ca> wrote:
>Thanks for the response,
>        I will explain in a little bit more detail what I am trying do. 
>I need to take a string roughly 35k characters in length, and rearrange
>the characters according to another (arbitrary) order.  I felt the best
>way to do this was to get the information into an array and then
>reorder, but getting the info into an array is taking a significant
>amount of time.  I take it from your response that there is no easy way
>to get at a string's array, but any other ideas about how to do this
>more quickly would be appreciated.
>Thanks 
>Don

Give this a go and see if it gives you any ideas...

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

use Benchmark;

$len = 35_000;
@alphabet =  ('a' .. 'z');

print "setting up string...\n";
$input = ' ' x $len;
for ($index = 0; $index < $len; $index++) {
  substr ($input, $index, 1) = @alphabet[rand @alphabet];
  push @list, $index;
}
print "setting up order...\n";

push @order, splice (@list, rand @list, 1) while @list;

timethese (10, {
  'pack' => '$output1 = pack "C$len", (unpack "C$len", $input)[@order];',
  'split' => '$output2 = join "", (split / */, $input)[@order];',
});

warn "something's wrong\n" unless $output1 eq $output2;

__END__

on my linux box it says

[mike@stok tmp]$ ./try.pl
Name "main::output1" used only once: possible typo at ./try.pl line 23.
Name "main::output2" used only once: possible typo at ./try.pl line 23.
Name "main::order" used only once: possible typo at ./try.pl line 16.
setting up string...
setting up order...
Benchmark: timing 10 iterations of pack, split...
      pack:  2 wallclock secs ( 1.84 usr +  0.02 sys =  1.86 CPU)
     split:  6 wallclock secs ( 5.14 usr +  0.00 sys =  5.14 CPU)

and at work it says

thrak.nis.newscorp.com> ./try.pl
Name "main::output1" used only once: possible typo at ./try.pl line 23.
Name "main::output2" used only once: possible typo at ./try.pl line 23.
Name "main::order" used only once: possible typo at ./try.pl line 16.
setting up string...
setting up order...
Benchmark: timing 10 iterations of pack, split...
      pack:  3 secs ( 2.75 usr  0.07 sys =  2.82 cpu)
     split:  8 secs ( 7.28 usr  0.08 sys =  7.37 cpu)

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Wed, 03 Jun 1998 17:01:44 GMT
From: dlynch@morrisonscientific.com
Subject: Re: scalar string to array
Message-Id: <3575811c.425773129@news.canuck.com>

On Wed, 03 Jun 1998 10:37:52 -0400, Don Skinner <studft@nortel.ca>
wrote:

>I am looking for a way to quickly convert a string of characters to an
>array.  I am currently splitting on null (i.e. split //, $someString),
>but this takes a while.  I would really like to know a way to access the
>underlying array that represents the string, but any other suggestions
>would be helpful.
>Don Skinner


What about using the chop() function?  Index the array backwards and
chop() chops the string starting from the end.


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

Date: 3 Jun 1998 19:11:35 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: scalar string to array
Message-Id: <6l4757$k5g@news-central.tiac.net>

In article <6l434j$g9m@news-central.tiac.net>,
Mike Stok <mike@stok.co.uk> wrote:

>  substr ($input, $index, 1) = @alphabet[rand @alphabet];
                                ^

That should really have been $alphabet[rand @alphabet];

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 3 Jun 1998 18:21:44 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: scalar string to array
Message-Id: <896898609.336151@thrush.omix.com>

Don Skinner <studft@nortel.ca> wrote:
: I need to take a string roughly 35k characters in length, and rearrange
: the characters according to another (arbitrary) order.  I felt the best
: way to do this was to get the information into an array and then
: reorder, but getting the info into an array is taking a significant
: amount of time.  I take it from your response that there is no easy way
: to get at a string's array, but any other ideas about how to do this
: more quickly would be appreciated.

	Using a perl array, you will have a huge overhead as well.

	How to best handle this really, really depends on what type of
	rules you are rearranging the string by.  You can modify
	Perl's strings inplace in a large number of ways very quickly,
	and which way you use depends on the why.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 3 Jun 1998 18:24:11 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: setting precision???
Message-Id: <896898756.736262@thrush.omix.com>

Larry Rosler <lr@hpl.hp.com> wrote:
: It works just like in C.

	Yep, but the really sad thing is that many universities are now
	teaching C++ without teaching C.  Thus, they are turning out
	programmers that have *never* seen *printf and friends...
-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Wed, 03 Jun 1998 18:54:41 GMT
From: bernie@rev.net (Bernard Cosell)
Subject: Untainting a variable
Message-Id: <35769bba.427796231@newnews.rev.net>

I'd appreciate a small clue, because I'm being a bit confused by
something in the untainting machinery.  This with Perl 5.003.

I run into tainted data that is actually 'safe' all the time, so I
have a little routine in my program:

sub untaint
{
    $_[0] =~ /^(.*)$/s ;
    return $1 ;
}

Now in using it I'm a bit confused... I have some code that looked
like:

   return &untaint($loginid) if &password_check($loginid, $password) ;

I needed the untainted version of the loginid for other things in the
subroutine, and so edited the program to be:

  my $id = &untaint($loginid) ;
  return $id if &password_check($loginid, $password) ;

What's confusing me is that while the first form [with the untaint
call -in- the 'return' statement] works perfectly, the second form
[with the intermediate variable] gets me taint-errors when the
calling-routine tries to make use of the returned value.   What am I
not understanding about how taintedness moves through variables and
expressions??  [I'm just not seeing how/why '$id' ended up tainted in
the above]

Thanks!!
  /Bernie\
-- 
Bernie Cosell                        mailto:bernie@rev.net
Roanoke Electronic Village


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

Date: 3 Jun 1998 18:12:50 GMT
From: chris+usenet@netmonger.net
Subject: Re: Use of HTML, POD, etc in Usenet (was: Re: map in void context regarded as evil - suggestion)
Message-Id: <6l43n2$7js$1@schenectady.netmonger.net>

In article <896891858.711190@thrush.omix.com>,
Zenin  <zenin@bawdycaste.org> wrote:
> Chris Nandor <pudge@pobox.com> wrote:
> : Yep.  I would bounce excessive POD from clp.mod (depending on the
> : circumstances), and I would allow HTML like yours to pass.
> 
> 	The problem I have with even the minor use of HTML, POD, etc
> 	is simply that it isn't needed, ever.  This isn't opinion, it's
> 	simple logic. Any use of anything but plain text isn't going to
> 	read the same on every reader, ever.

What bothers me about it is that it makes no sense to, for example,
put <p> markers in your text.  If you don't assume usenet documents
contain HTML, then <p> is meaningless.  But if you DO make that
assumption, then you should be collapsing whitespace unless otherwise
specified, which is even worse.

Chris^H^H^H^H^H Chris^H^H^H^H^H Chris^H^H^H^H^H^HChris^H^H^H^H^H^HChris
-- 
	    Christopher Masto <chris+usenet@netmonger.net>
	Director of Operations, NetMonger Communications, Inc.

		     "Behold the Power of Cheese"


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

Date: Wed, 03 Jun 1998 17:04:08 GMT
From: indhiraa@hotmail.com
Subject: value of a environment variable
Message-Id: <6l3vm8$ob5$1@nnrp1.dejanews.com>

Hi,

I need to get the value of environment variable whose name
is stored in another variable.

Something like,

$envVar = "$LD_LIBRARY_PATH";

As of now I do like,

$ldpath = `echo $envVar`; chop ($ldpath);

to get its value. Is there any elegant way of
doing it.

When I tried something:

eval "$ldpath = $$envVar";

it complained about the scope since I am using 'use strict' pragma.

Any suggestions..

Thanks,
Indira.

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


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

Date: Wed, 03 Jun 1998 17:19:57 GMT
From: John Porter <jdporter@min.net>
Subject: Re: value of a environment variable
Message-Id: <35758767.4C1C@min.net>

indhiraa@hotmail.com wrote:
> 
> I need to get the value of environment variable whose name
> is stored in another variable....

Is it possible you've never read any perl documentation?
Try: perldoc perlvar, and search for the string "environment".
This info is also contained in both the Llama and Camel books,
and probably every other perl book ever printed.

> Any suggestions..

Sure: rtfm.

John Porter


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

Date: 3 Jun 1998 19:15:39 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: value of a environment variable
Message-Id: <6l47cr$k5g@news-central.tiac.net>

In article <6l3vm8$ob5$1@nnrp1.dejanews.com>,  <indhiraa@hotmail.com> wrote:
>Hi,
>
>I need to get the value of environment variable whose name
>is stored in another variable.
>
>Something like,
>
>$envVar = "$LD_LIBRARY_PATH";

You probably want single quotes there otherwise $envVar ends up containing
whatever $LD_LIBARAY_PATH is in the perl interperter at that point...

>As of now I do like,
>
>$ldpath = `echo $envVar`; chop ($ldpath);

You migth want to review the perl documentation, in particular the perlvar
page.

Does this work for you?

  $envVar = 'LD_LIBRARY_PATH';
  $ldpath = $ENV{$envVar};

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Wed, 03 Jun 1998 20:33:42 +0200
From: Marcus Blaha <mbl@startext.de>
To: indhiraa@hotmail.com
Subject: Re: value of a environment variable
Message-Id: <35759706.5625@startext.de>

indhiraa@hotmail.com wrote:
> 
> Hi,
> 
> I need to get the value of environment variable whose name
> is stored in another variable.
> 
> Something like,
> 
> $envVar = "$LD_LIBRARY_PATH";
> 
> As of now I do like,
> 
> $ldpath = `echo $envVar`; chop ($ldpath);
> 
> to get its value. Is there any elegant way of
> doing it.
> 
> When I tried something:
> 
> eval "$ldpath = $$envVar";
> 
> it complained about the scope since I am using 'use strict' pragma.
> 
> Any suggestions..
> 
> Thanks,
> Indira.
Hi Indira,

do you need something like :

   $var = 'PATH';
   print $ENV{$var};

?
Marcus

-- 
#################################################################
# Marcus Blaha  startext Unternehmensberatung GmbH
#               Kennedyallee 2 / 53175 Bonn
# Tel.:         +49.228.95996-16        Fax.: +49.228.95996-66
# Compuserve    101317,3140             eMail  mbl@startext.de
# WWW           http://www.startext.de
#################################################################


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

Date: Wed, 03 Jun 1998 18:45:49 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: value of a environment variable
Message-Id: <357593f3.5989736@news.btinternet.com>

On Wed, 03 Jun 1998 17:04:08 GMT, indhiraa@hotmail.com wrote :

>Hi,
>
>I need to get the value of environment variable whose name
>is stored in another variable.
>
<snip>

Just for fun you understand why dont we examine the output of this
deceptively simple (and actually rather flawed) little program:

#!/develop/bin/perl

foreach $hash (sort keys %::)
{
   foreach $key (sort keys %{$hash})
   {
      print '$' . $hash . '{' . $key . '} = ' . ${$hash}{$key} , "\n";
   }

}


Hmm,  something familiar about some of the lines of output ?  I hope
so.  Of course a quick look at the perlvar documentation would have
told you the same thing but this is more fun isnt it (?).

/J\

Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Wed, 3 Jun 1998 09:52:56 -0700
From: "Robert Pang" <robpang@cs.stanford.edu>
Subject: When will Perl 5.005 come out?
Message-Id: <6l3uv4$3sv@masters0.InterNex.Net>

Hi folks,

Do you have any idea when 5.005 will come out?  Is it possible to have early
access to it?

Thanks.

Robert




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

Date: 3 Jun 1998 17:13:37 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: When will Perl 5.005 come out?
Message-Id: <6l4081$8hq$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Robert Pang" <robpang@cs.stanford.edu> writes:
:Do you have any idea when 5.005 will come out?  

Good question.

:Is it possible to have early
:access to it?

http:/www.perl.com/CPAN/authors/Malcolm_Beattie/perl5.004_66.tar.gz

--tom
-- 
    Just don't compare it with a real language, or you'll be unhappy...  :-)
            --Larry Wall in <1992May12.190238.5667@netlabs.com>


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

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

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