[22255] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4476 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 28 11:06:55 2003

Date: Tue, 28 Jan 2003 08:05:06 -0800 (PST)
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, 28 Jan 2003     Volume: 10 Number: 4476

Today's topics:
        array slicing <thens@nospam.com>
    Re: array slicing <jurgenex@hotmail.com>
    Re: array slicing <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: array slicing <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: array slicing (Ben Morrow)
    Re: array slicing (Anno Siegel)
    Re: loop-array question <jurgenex@hotmail.com>
    Re: loop-array question <jurgenex@hotmail.com>
    Re: More random then other random ctcgag@hotmail.com
        Problem checking for newline in $_ input line <JCornwall@cox.net>
    Re: script <jurgenex@hotmail.com>
        Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
    Re: Tainting individual variables <tassilo.parseval@localhost.localhost>
    Re: Tainting individual variables (Ben Morrow)
    Re: unlink() <perl-dvd@darklaser.com>
    Re: unlink() <jurgenex@hotmail.com>
    Re: Using storable. <tassilo.parseval@localhost.localhost>
    Re: Using storable. (Ben Morrow)
    Re: Using storable. <spikey-wan@bigfoot.com>
    Re: win32 tieregistry html (Ben Morrow)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 28 Jan 2003 19:31:45 +0530
From: Thens <thens@nospam.com>
Subject: array slicing
Message-Id: <20030128193145.38a3ac7c.thens@nospam.com>

Hi,  
    I want a simplistic solution to a problem that i have in slicing
array.

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

use strict;

# NUMBERS in order
my @numbers = ( 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE' ) 

# I want to print numbers greater than or equal to three
# I expect a magical operation to return me the elements in the list after THREE.

print join(' ', <your code operating on @numbers>);



I did a perldoc -f splice, but could not find any information relating
to that. It says i need the OFFSET, but i only have the element from
which i should slice the array.



Thanks in advance

Thanks and regards
Thens.


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

Date: Tue, 28 Jan 2003 14:20:34 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: array slicing
Message-Id: <SkwZ9.8121$P64.3771@nwrddc02.gnilink.net>

Thens wrote:
> Hi,
>     I want a simplistic solution to a problem that i have in slicing
> array.
>
> #! /usr/local/bin/perl -w
>
> use strict;
>
> # NUMBERS in order
> my @numbers = ( 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE' )
>
> # I want to print numbers greater than or equal to three
> # I expect a magical operation to return me the elements in the list
> after THREE.
>
> print join(' ', <your code operating on @numbers>);
>
>
>
> I did a perldoc -f splice, but could not find any information relating
> to that. It says i need the OFFSET, but i only have the element from
> which i should slice the array.

You want to remove the elements starting at the first element, and you want
to remove the first two elements, right?
Then your offset is 0 and the length is 2.

jue




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

Date: Tue, 28 Jan 2003 15:20:09 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: array slicing
Message-Id: <784d3vosh9rpgo4qjh20minvgnj8mp2gas@4ax.com>

On Tue, 28 Jan 2003 19:31:45 +0530, Thens <thens@nospam.com> wrote:

>Hi,  
>    I want a simplistic solution to a problem that i have in slicing
>array.
>
>#! /usr/local/bin/perl -w
>
>use strict;
>
># NUMBERS in order
>my @numbers = ( 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE' ) 


Easier to write that like so:


my @numbers = qw(ONE TWO THREE FOUR FIVE);


># I want to print numbers greater than or equal to three
># I expect a magical operation to return me the elements in the list after THREE.
>
>print join(' ', <your code operating on @numbers>);


print join ' ', @numbers[3 .. $#numbers];


>I did a perldoc -f splice, but could not find any information relating
>to that. It says i need the OFFSET, but i only have the element from
>which i should slice the array.


Checkout

  
  perldoc perldata



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Tue, 28 Jan 2003 15:21:45 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: array slicing
Message-Id: <te4d3vsb4ik46409jrpte2upser5ljhm46@4ax.com>

On Tue, 28 Jan 2003 15:20:09 +0100, Bernard El-Hagin
<bernard.el-hagin@DODGE_THISlido-tech.net> wrote:

>On Tue, 28 Jan 2003 19:31:45 +0530, Thens <thens@nospam.com> wrote:
>
>>Hi,  
>>    I want a simplistic solution to a problem that i have in slicing
>>array.
>>
>>#! /usr/local/bin/perl -w
>>
>>use strict;
>>
>># NUMBERS in order
>>my @numbers = ( 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE' ) 
>
>
>Easier to write that like so:
>
>
>my @numbers = qw(ONE TWO THREE FOUR FIVE);
>
>
>># I want to print numbers greater than or equal to three
>># I expect a magical operation to return me the elements in the list after THREE.
>>
>>print join(' ', <your code operating on @numbers>);
>
>
>print join ' ', @numbers[3 .. $#numbers];


Sorry, start at 2, not 3.


print join ' ', @numbers[2 .. $#numbers];



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Tue, 28 Jan 2003 14:23:28 +0000 (UTC)
From: mauzo@ux-ma160-16.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: array slicing
Message-Id: <b163p0$eom$1@wisteria.csv.warwick.ac.uk>

Thens <thens@nospam.com> wrote:
>Hi,  
>    I want a simplistic solution to a problem that i have in slicing
>array.
>
>#! /usr/local/bin/perl -w
>
>use strict;
>
># NUMBERS in order
>my @numbers = ( 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE' ) 
>
># I want to print numbers greater than or equal to three
># I expect a magical operation to return me the elements in the list after THREE.
>
>print join(' ', <your code operating on @numbers>);
>
>
>
>I did a perldoc -f splice, but could not find any information relating
>to that. It says i need the OFFSET, but i only have the element from
>which i should slice the array.

You need to run through the array to find the index of the last element you
want to keep. Then use splice.

Ben


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

Date: 28 Jan 2003 14:31:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: array slicing
Message-Id: <b1647p$ils$1@mamenchi.zrz.TU-Berlin.DE>

Thens  <thens@nospam.com> wrote in comp.lang.perl.misc:
> Hi,  
>     I want a simplistic solution to a problem that i have in slicing
> array.
> 
> #! /usr/local/bin/perl -w
> 
> use strict;
> 
> # NUMBERS in order
> my @numbers = ( 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE' ) 
> 
> # I want to print numbers greater than or equal to three
> # I expect a magical operation to return me the elements in the list
> after THREE.
> 
> print join(' ', <your code operating on @numbers>);
> 
> 
> 
> I did a perldoc -f splice, but could not find any information relating
> to that. It says i need the OFFSET, but i only have the element from
> which i should slice the array.

Conclusion:  splice() is not the right tool for the job.

    while ( @numbers ) {
        last if shift @numbers eq 'THREE';
    }

Anno


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

Date: Tue, 28 Jan 2003 14:06:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: loop-array question
Message-Id: <Z7wZ9.8100$P64.2@nwrddc02.gnilink.net>

patric wrote:
> What is the best way for me to proceed through a loop, find an item in
> an array that matches a condition, delete it and then proceed to the
> next match without having to go back to the beginning of the array and
> re-loop?

The simplist approach is to negate your condition and to use "grep"
    @result = grep (!cond, @data);

If you insist on doing it the hard way then start your loop at the high end
of the array and loop downwards. Then you don't have to worry about moved
items. You can use splice to remove the unwanted items. But don't do that.

jue




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

Date: Tue, 28 Jan 2003 14:13:36 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: loop-array question
Message-Id: <kewZ9.1933$8p1.407@nwrddc04.gnilink.net>

perlsage wrote:
> "patric" <patrick_cusack@hotmail.com> wrote in message
> news:1ec975dc.0301280130.6b44e0f@posting.google.com...
>> What is the best way for me to proceed through a loop, find an item
>> in an array that matches a condition, delete it and then proceed to
>> the next match without having to go back to the beginning of the
>> array and re-loop?
>
> I think the easiest way to do this is:
>
> foreach (@arr){
>     if ($_=~/\bpattern\b/){
> ## do your stuff
>     }
> }

Which will give wrong results if handling $arr[i] affects the element
$arr[i+1] which is what happens here because after deleting $arr[i] the old
$arr[i+1] can suddenly be found at $arr[i] and will be skipped in the next
loop.

This is a typical beginner mistake and can easily be avoided if you walk
through the array from the high end (when deleting items).

BTW: Please note that the OP didn't mention if his condition had anything to
do with finding a word in the array items. We don't even know if array
contains text at all.

jue




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

Date: 28 Jan 2003 15:44:46 GMT
From: ctcgag@hotmail.com
Subject: Re: More random then other random
Message-Id: <20030128104445.928$bY@newsreader.com>

Bob Walton <bwalton@rochester.rr.com> wrote:
> ctcgag@hotmail.com wrote:
>
> > "ColdCathoids" <mememe@meme.com> wrote:
> ...
> > $rating = ceiling ((-1+sqrt(1+8*(rand(55)+1)))/2)
> ...
>
> > Xho
>
> Hmmmm...where does ceiling come from?  It's not a Perl function, unless
> it is a function from some module.  Thanks!

It's in the POSIX module.  And it's spelled ceil.  Oops.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Tue, 28 Jan 2003 15:17:35 GMT
From: "J. F. Cornwall" <JCornwall@cox.net>
Subject: Problem checking for newline in $_ input line
Message-Id: <jaxZ9.32353$Vh.7331@news2.central.cox.net>

Hi, I am working out the last problem in my script to parse Fortran
comments (header blocks) and put the information into HTML pages.  I am
having problems checking for the newline in some of the llines of text
being parsed though.

Fortran comment line:

"C *(\n)"

C in column 1, variable number of spaces, variable number of "*" chars.

If I get a line like this in the header block, I want to skip over it,
so I try this:

#  check for blank line after "c *", else strip "c *" and print comment
if (s/^C\s+\*+\n//i)
    {  $ignore_fg = 1;  $purpose_fg = 0;  print "</I> <BR>\n";  }
else
    {  s/^C\s+\*+\s+/ /i;  print $_;   }
}

The "^C\s+\*+" part is working as far as I can tell, but it isn't
recognizing the newline "\n" part of the pattern matching.  Any
suggestions?

Jim Cornwall
jcornwall@cox.net



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

Date: Tue, 28 Jan 2003 14:16:44 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: script
Message-Id: <ghwZ9.17685$uR.6744@nwrddc01.gnilink.net>

Pons wrote:
> Problem resolved.
>
> d:
> cd d:\orant\net80\admin
> DIR
> ECHO.open 10.5.1.100>script.ftp
> ECHO.ftp>>script.ftp
[...]

Generates tons of syntax errors for me when I try to run it.

jue




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

Date: Tue, 28 Jan 2003 14:35:06 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <v3d58qdj9mtcee@corp.supernews.com>

Following is a summary of articles spanning a 8 day period,
beginning at 20 Jan 2003 14:35:26 GMT and ending at
28 Jan 2003 14:21:56 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 2003 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Excluded Posters
================

perlfaq-suggestions\@(?:.*\.)?perl\.com
faq\@(?:.*\.)?denver\.pm\.org
comdog\@panix\.com

Totals
======

Posters:  279
Articles: 1028 (366 with cutlined signatures)
Threads:  225
Volume generated: 2034.0 kb
    - headers:    916.7 kb (17,183 lines)
    - bodies:     1068.9 kb (35,382 lines)
    - original:   639.3 kb (23,116 lines)
    - signatures: 47.4 kb (1,204 lines)

Original Content Rating: 0.598

Averages
========

Posts per poster: 3.7
    median: 2 posts
    mode:   1 post - 118 posters
    s:      7.4 posts
Posts per thread: 4.6
    median: 3 posts
    mode:   1 post - 49 threads
    s:      4.9 posts
Message size: 2026.1 bytes
    - header:     913.2 bytes (16.7 lines)
    - body:       1064.7 bytes (34.4 lines)
    - original:   636.8 bytes (22.5 lines)
    - signature:  47.2 bytes (1.2 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   76   214.1 ( 89.4/114.5/ 85.5)  tadmc@augustmail.com
   54    99.9 ( 41.0/ 58.9/ 25.2)  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
   29    45.7 ( 25.7/ 20.0/ 10.8)  "Jürgen Exner" <jurgenex@hotmail.com>
   27    54.3 ( 23.9/ 28.4/ 14.6)  Brian McCauley <nobull@mail.com>
   24    48.5 ( 20.4/ 28.1/ 11.1)  Ben Morrow <mauzo@mimosa.csv.warwick.ac.uk>
   22    32.6 ( 14.6/ 18.0/ 10.0)  Jay Tilton <tiltonj@erols.com>
   22    35.1 ( 19.8/ 15.2/  9.8)  Bart Lateur <bart.lateur@pandora.be>
   22    41.6 ( 22.7/ 14.2/  8.7)  "Harald H.-J. Bongartz" <bongie@gmx.net>
   22    49.1 ( 20.0/ 24.3/  9.8)  tassilo.parseval@post.rwth-aachen.de
   20    42.4 ( 16.9/ 21.6/ 11.8)  Benjamin Goldberg <goldbb2@earthlink.net>

These posters accounted for 30.9% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

 214.1 ( 89.4/114.5/ 85.5)     76  tadmc@augustmail.com
  99.9 ( 41.0/ 58.9/ 25.2)     54  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
  56.6 ( 19.9/ 30.6/ 13.7)     20  Uri Guttman <uri@stemsystems.com>
  54.3 ( 23.9/ 28.4/ 14.6)     27  Brian McCauley <nobull@mail.com>
  49.1 ( 20.0/ 24.3/  9.8)     22  tassilo.parseval@post.rwth-aachen.de
  48.5 ( 20.4/ 28.1/ 11.1)     24  Ben Morrow <mauzo@mimosa.csv.warwick.ac.uk>
  45.7 ( 25.7/ 20.0/ 10.8)     29  "Jürgen Exner" <jurgenex@hotmail.com>
  42.4 ( 16.9/ 21.6/ 11.8)     20  Benjamin Goldberg <goldbb2@earthlink.net>
  41.6 ( 22.7/ 14.2/  8.7)     22  "Harald H.-J. Bongartz" <bongie@gmx.net>
  35.1 ( 19.8/ 15.2/  9.8)     22  Bart Lateur <bart.lateur@pandora.be>

These posters accounted for 33.8% of the total volume.

Top 10 Posters by Volume of Original Content (min. five posts)
==============================================================

        (kb)
Posts   orig  Address
-----  -----  -------

   76   85.5  tadmc@augustmail.com
   54   25.2  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
    8   15.9  "Eric Anderson" <eric.anderson@cordata.net>
   27   14.6  Brian McCauley <nobull@mail.com>
   20   13.7  Uri Guttman <uri@stemsystems.com>
   10   12.9  "Charles R. Thompson" <charlest@indysoft.com>
   12   12.0  "Alan J. Flavell" <flavell@mail.cern.ch>
   20   11.8  Benjamin Goldberg <goldbb2@earthlink.net>
   24   11.1  Ben Morrow <mauzo@mimosa.csv.warwick.ac.uk>
   29   10.8  "Jürgen Exner" <jurgenex@hotmail.com>

These posters accounted for 33.4% of the original volume.

Top 10 Posters by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.985  (  7.3 /  7.4)      8  abigail@abigail.nl
0.980  (  1.5 /  1.6)      7  Markus Elfring <Markus.Elfring@web.de>
0.919  (  4.7 /  5.2)      5  Dave Fraleigh <dave@fraleigh.net>
0.903  (  9.4 / 10.5)      7  "Bullet" <no_spam@fromyou.thanks-anyways.com>
0.809  (  4.8 /  6.0)      5  "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
0.807  (  8.7 / 10.8)      6  John Smith <clearguy02@yahoo.com>
0.779  ( 12.9 / 16.5)     10  "Charles R. Thompson" <charlest@indysoft.com>
0.747  ( 15.9 / 21.3)      8  "Eric Anderson" <eric.anderson@cordata.net>
0.747  ( 85.5 /114.5)     76  tadmc@augustmail.com
0.720  ( 12.0 / 16.7)     12  "Alan J. Flavell" <flavell@mail.cern.ch>

Bottom 10 Posters by OCR (minimum of five posts)
================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.433  (  2.6 /  6.0)      6  "Michael Peuser \(h\)" <post@mpeuser.de>
0.428  ( 25.2 / 58.9)     54  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
0.427  (  7.4 / 17.2)     15  Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
0.416  (  5.9 / 14.2)     20  Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
0.409  (  6.5 / 15.8)     15  "John W. Krahn" <krahnj@acm.org>
0.403  (  9.8 / 24.3)     22  tassilo.parseval@post.rwth-aachen.de
0.395  ( 11.1 / 28.1)     24  Ben Morrow <mauzo@mimosa.csv.warwick.ac.uk>
0.394  (  2.1 /  5.3)      7  "Tintin" <me@privacy.net>
0.392  (  2.2 /  5.6)     11  Malte Ubl <ubl@schaffhausen.de>
0.380  (  7.6 / 20.0)     10  "codeWarrior" <GPatnude@HotMail.com>

46 posters (16%) had at least five posts.

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

   29  unlink()
   25  Paragraph Mode
   21  Reverse Inheritance?
   19  Converting a string to a valid date..
   18  Changing the context of a code block
   16  OO perl : object containing ref to other object
   16  Regex: optional word boundary
   14  FAQ: How do I handle binary data correctly?
   14  How can a SMTP mail be deleted from a Unix mailbox by a script?
   13  Is there a better way to format numbers to use commas?

These threads accounted for 18.0% of all articles.

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

  59.2 ( 27.6/ 29.7/ 14.2)     29  unlink()
  56.5 ( 18.0/ 37.0/ 21.9)     18  Changing the context of a code block
  51.8 ( 24.6/ 26.0/ 14.5)     25  Paragraph Mode
  50.9 (  2.9/ 48.0/ 48.0)      3  Posting Guidelines for comp.lang.perl.misc ($Revision: 1.3 $)
  49.8 ( 22.7/ 26.5/ 18.4)     19  Converting a string to a valid date..
  42.9 ( 18.7/ 23.2/ 12.4)     21  Reverse Inheritance?
  33.0 ( 14.4/ 18.0/  9.5)     16  Regex: optional word boundary
  32.3 ( 15.4/ 16.6/  8.7)     16  OO perl : object containing ref to other object
  30.2 ( 10.4/ 19.2/ 11.0)     11  To extract a specific portion of a text file
  29.9 ( 14.1/ 14.9/  6.9)     14  FAQ: How do I handle binary data correctly?

These threads accounted for 21.5% of the total volume.

Top 10 Threads by OCR (minimum of five posts)
=============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.889  (  6.4/   7.1)      5  Can I store an array into a DataBase?
0.767  ( 12.4/  16.2)     10  Reading French-Accented Data
0.761  ( 11.9/  15.6)      8  Help With Nested Hash/Array Requested
0.752  (  2.7/   3.6)      5  win32 tieregistry html
0.752  (  6.6/   8.7)      7  Dynamically Declaring Variables
0.695  ( 18.4/  26.5)     19  Converting a string to a valid date..
0.693  (  2.2/   3.2)      5  perl code to "fix" VBR mp3s with bogus time information?
0.687  (  1.6/   2.3)      8  commenting out code
0.683  (  2.8/   4.1)      6  Newbie: How to remove some characters from a string
0.674  (  6.4/   9.5)     10  slow grep

Bottom 10 Threads by OCR (minimum of five posts)
================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.412  (  3.9 /  9.4)      9  function overriding
0.407  (  3.3 /  8.1)      5  ActivePerl 5.8 / MySQL / Apache Problem
0.404  (  3.1 /  7.6)      6  how to make my perl cgi program run in IE
0.399  (  4.3 / 10.7)      8  Splitting a configuration file into a hash
0.395  (  0.8 /  2.0)      5  Whois script?
0.394  (  2.5 /  6.3)      8  Passing a glob reference doesn't work with 'strict'
0.381  (  4.4 / 11.6)     12  execute b.pl script from within a.pl script and b.pl vars remain
0.381  (  2.0 /  5.2)      8  identifying web host platform?
0.366  (  2.5 /  6.7)      7  script
0.313  (  1.9 /  6.0)      9  How to make standalone perlscript

81 threads (36%) had at least five posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      15  comp.programming
      15  comp.lang.perl.modules
      15  comp.lang.tcl
      14  comp.mail.misc
       5  de.comp.lang.perl.misc
       5  comp.lang.perl
       4  mailing.database.mysql-win32
       4  comp.infosystems.www.authoring.cgi
       4  microsoft.public.windowsxp.network_web
       4  microsoft.public.win98.gen_discussion

Top 10 Crossposters
===================

Articles  Address
--------  -------

      22  Markus Elfring <Markus.Elfring@web.de>
       6  "Alex Banks" <alex@alexbanks.com>
       6  "Donal K. Fellows" <donal.k.fellows@man.ac.uk>
       6  Bart Lateur <bart.lateur@pandora.be>
       5  Johan Vromans <jvromans@squirrel.nl>
       4  Philip Lees <pjlees@ics.forthcomingevents.gr>
       4  "I'm Dan" <dg1261@cs-REMOVE_THIS-.com>
       4  "Thomas Brooks" <tombrooks.nospam@hotmail.com>
       3  "William Hymen" <t18_pilot@hotmail.spam.com>
       3  Andreas Kupries <akupries@shaw.ca>


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

Date: 28 Jan 2003 14:15:14 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@localhost.localhost>
Subject: Re: Tainting individual variables
Message-Id: <slrnb3d43a.5bg.tassilo.parseval@localhost.localhost>

Also sprach John Ramsden:

> I have an app in which the user can specify a 'boiler plate' text string
> to appear in an alert email, and this string can contain any of a dozen
> or so variables, such as $msg_severity, $device_name, etc, which means
> I must eval() the text with variables of the valid names all in scope
> in order to plug in the values of any referred to in the text.
> 
> Although the users will all be internal, so it can be assumed they are
> cooperative from the standpoint of the app, and certainly not malicious,
> I'd like to avoid even the theoretical possibility of some joker setting
> up a string such as `rm -rf /` or something. So is there a way of tainting
> a single variable before evaling it?
> 
> (I'd rather eval than simply substitute values via su///, as this allows
> the string to include logical constructs such as '? :'.)

You might have a look at the String::Interpolate module. I haven't ever
used it myself but I remember that Brian wrote it for that very purpose:
a safe interpolation without involving any possibly harmful eval().

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Tue, 28 Jan 2003 14:15:42 +0000 (UTC)
From: mauzo@ux-ma160-16.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Tainting individual variables
Message-Id: <b163ae$ein$1@wisteria.csv.warwick.ac.uk>

john_ramsden@sagitta-ps.com (John Ramsden) wrote:
>I have an app in which the user can specify a 'boiler plate' text string
>to appear in an alert email, and this string can contain any of a dozen
>or so variables, such as $msg_severity, $device_name, etc, which means
>I must eval() the text with variables of the valid names all in scope
>in order to plug in the values of any referred to in the text.
>
<snip>
>
>(I'd rather eval than simply substitute values via su///, as this allows
>the string to include logical constructs such as '? :'.)

You might want to look at the Safe module.

OTOH it is always safer to parse something yourself: a parser that understands
+, -, ., ?:, &&, || wouldn't be that hard to write.

Ben



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

Date: Tue, 28 Jan 2003 14:40:17 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: unlink()
Message-Id: <lDwZ9.6$Xb7.3873@news-west.eli.net>

"Joel Konkle-Parker" <joeljkp@tabdemo.larc.nasa.gov> wrote in message
news:3E2FFC7E.1060906@tabdemo.larc.nasa.gov...
> I have the following lines at the end of my script:
>
> unlink ("./temp_trail.txt") || die $!;
> unlink ("./prt0001__out.log.1") || die $!;
>
> But when my script ends each time, the files are still there. The
'die'
> doesn't produce any output. This is Perl 5.004. What's wrong here?

The "./" preceding each file name.   Omit that, and I bet it will work
for you (assuming you have the file names entered correctly).

Regards,
David




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

Date: Tue, 28 Jan 2003 14:55:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: unlink()
Message-Id: <KRwZ9.17977$uR.7026@nwrddc01.gnilink.net>

David wrote:
> "Joel Konkle-Parker" <joeljkp@tabdemo.larc.nasa.gov> wrote in message
> news:3E2FFC7E.1060906@tabdemo.larc.nasa.gov...
>> I have the following lines at the end of my script:
>>
>> unlink ("./temp_trail.txt") || die $!;
>> unlink ("./prt0001__out.log.1") || die $!;
>>
>> But when my script ends each time, the files are still there. The
>> 'die' doesn't produce any output. This is Perl 5.004. What's wrong
>> here?
>
> The "./" preceding each file name.   Omit that, and I bet it will work
> for you (assuming you have the file names entered correctly).

If this really helps then I would very much like to learn why.
Is this for some odd file system where "." does not denote the CWD or "/" is
not used as path separator? Or a file system which does not have a
hierarchal tree structure?
For all file system I know "foo" and "./foo" denote the same file.

jue




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

Date: 28 Jan 2003 14:21:56 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@localhost.localhost>
Subject: Re: Using storable.
Message-Id: <slrnb3d4fv.5bg.tassilo.parseval@localhost.localhost>

Also sprach Richard S Beckett:

> I have successfully used storable to store and retrieve a hash of hashes
> to/from a file.
> 
> If I had 2 hashes of hashes, and a scalar variable that I wanted to store
> and retrieve to/from a single file, how would I go about this?

I'd simply put all that into an array and store that:

    push my @array, \%hash1, \%hash2, $scalar;
    store \@array, "file";

On retrieving the stuff later, do the reverse:

    my $aryref = retrieve "file";
    my %hash1  = %{ $aryref->[0] };
    my %hash2  = %{ $aryref->[1] };
    my $scalar = $aryref->[2];
    
Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Tue, 28 Jan 2003 14:19:23 +0000 (UTC)
From: mauzo@ux-ma160-16.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Using storable.
Message-Id: <b163hb$ekv$1@wisteria.csv.warwick.ac.uk>

"Richard S Beckett" <spikey-wan@bigfoot.com> wrote:
>Hello World! :-)
>
>I have successfully used storable to store and retrieve a hash of hashes
>to/from a file.
>
>If I had 2 hashes of hashes, and a scalar variable that I wanted to store
>and retrieve to/from a single file, how would I go about this?

Stuff them into a hash.

my $to_store = { scalar => $scalar,
                 onehoh => \%hoh1,
		 twohoh => \%hoh2
	       };
store $to_store, 'file';

Then unpack them after retrieve.

Ben


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

Date: Tue, 28 Jan 2003 14:37:52 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: Using storable.
Message-Id: <b164lk$i0k$1@newshost.mot.com>


"Tassilo v. Parseval" <tassilo.parseval@localhost.localhost> wrote

> > If I had 2 hashes of hashes, and a scalar variable that I wanted to
store
> > and retrieve to/from a single file, how would I go about this?
>
> I'd simply put all that into an array and store that:
>
>     push my @array, \%hash1, \%hash2, $scalar;
>     store \@array, "file";
>
> On retrieving the stuff later, do the reverse:
>
>     my $aryref = retrieve "file";
>     my %hash1  = %{ $aryref->[0] };
>     my %hash2  = %{ $aryref->[1] };
>     my $scalar = $aryref->[2];

Thanks Tassilo!

I had a feeling that it would be something like that, but I had no idea how
to implement it.

R.




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

Date: Tue, 28 Jan 2003 14:12:43 +0000 (UTC)
From: mauzo@ux-ma160-16.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: win32 tieregistry html
Message-Id: <b1634r$eeh$1@wisteria.csv.warwick.ac.uk>

nac@advancecare.com (Nuno Cancelo) wrote:
>hi
>the reason that i don't use the getlogin function is when i run on a
>web server, using ie as a cliente, insted of giving me the username of
>the person logged in the machine shows me "SYSTEM".

That is because SYSTEM is who the webserver is running as. The webserver has
nothing to do with the person logged on: it will run fine with noone logged
on, and accesses it's own user registry even when a different user is logged
on.

If you want a script running with webserver privileges to find out who is
currently logged on, I'd recommend you stick something in the logon script
(or in the registry wherever it goes) that writes your username to a file
somewhere, and something in a logoff script that deletes it. If you can't do
logoff scripts in windows then have a background process go to sleep until
it's killed, whereupon it wakes up and deletes the file. Then read the file
from the CGI script. You can do all this in Perl if you want: USE
LOCKING. This is very important.

Ben



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 4476
***************************************


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