[19030] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1225 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 1 06:05:31 2001

Date: Sun, 1 Jul 2001 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <993981906-v10-i1225@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 1 Jul 2001     Volume: 10 Number: 1225

Today's topics:
        [OT] IMNERHO (Was: Re: PERL and CGI under NT IIS) <webmaster@webdragon.unmunge.net>
    Re: Coordinates for perl print command like ksh  print  <somewhere@in.paradise.net>
    Re: Create unique file in dir? (Martien Verbruggen)
        HTML to Printable files via Perl CGI? <amittai@amittai.com>
        inline average <nogard@gnosrehtaew.ten>
    Re: inline average <webmaster@webdragon.unmunge.net>
    Re: inline average <nogard@gnosrehtaew.ten>
    Re: inline average (Eric Bohlman)
    Re: inline average <webmaster@webdragon.unmunge.net>
    Re: inline average <bigrich318@yahoo.com>
    Re: inline average <bigrich318@yahoo.com>
    Re: Need help again with global vars! (Joe Smith)
        Newbie - Unix Commands in Perl <rig01@yahoo.com>
    Re: Newbie - Unix Commands in Perl <krahnj@acm.org>
    Re: Newbie - Unix Commands in Perl <bowman@montana.com>
    Re: Problem using "*" in System(...) command (Joe Smith)
        read/write ksh env array in Perl? (Sergio Vidales)
        read/write ksh env array in Perl? (Sergio Vidales)
    Re: read/write ksh env array in Perl? (Steven Smolinski)
    Re: readdir(..) function (Greg Andrews)
    Re: Selling Scripts <no@spam.net>
        stripping Underscores <defont@nospam.iinet.net.au>
    Re: test <jurgenex@hotmail.com>
    Re: timing can make the difference: <c-kleinheitz@freenet.de>
    Re: unix `ps` (Villy Kruse)
    Re: What kind of object is an old-fashioned DBM? (Joe Smith)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 1 Jul 2001 04:34:35 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: [OT] IMNERHO (Was: Re: PERL and CGI under NT IIS)
Message-Id: <9hm98r$4ba$0@216.155.32.50>

In article <3B3CC488.39803AA6@yahoo.com>,
 David <ddNOSPAM0001@yahoo.com> wrote:

 | Pardon me, but what do IHMO  and IMNHSO mean?

In my Humble Opinion
In My Not So Humble Opinion

and my favorite, IMNERHO 
(first saw Stanton McCandlish [of EFF fame]  use this one years ago)
In My Never Even Remotely Humble Opinion

:-)

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Sun, 1 Jul 2001 16:01:11 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Coordinates for perl print command like ksh  print "\033[1;37HHello"
Message-Id: <E1z%6.7$gQ3.404517@news.interact.net.au>


"Eugene" <e.broeren@food-express.nl> wrote in message
news:9hi5jo$dah$1@ncc1701.cistron.net...
> Hello all,
>
>
> Is it possible to position the perl print command like in unix ksh print
> "\033[1;37HHello"
> How can i do this in perl


Classic SAQ.  Just add a ; to the end of the print.




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

Date: Sun, 1 Jul 2001 12:35:58 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Create unique file in dir?
Message-Id: <slrn9jt34e.tjn.mgjv@martien.heliotrope.home>

On Sat, 30 Jun 2001 04:08:07 GMT,
	Tony L. Svanstrom <tony@svanstrom.com> wrote:
> Ren Maddox <ren@tivoli.com> wrote:
> 
>> On Fri, 29 Jun 2001, tony@svanstrom.com wrote:
>> 
>> > Craig Berry <cberry@cinenet.net> wrote:
>> > 
>> >> I'd prefer something deterministic (I know, I'm obsessive).  The
>> >> FAQ answer (perldoc -q temp, as suggested in another response)
>> >> involving POSIX tmpnam and sysopen seems to be the right course.  I
>> >> missed finding it because my intended use is not as a temporary
>> >> file.
>> > 
>> > well, for time-pid to fail you need to have (dependin on the set up
>> > on the machine, of course) more than 10'000 processes running at the
>> > same time, and you have to be so unlucky that, if things work at all
>> > then (anyone geekier than me that knows?), that your script has the
>> > same pid as the first one... and then adding four random
>> > numbers/characters... It just won't happen.
>> 
>> Until your code becomes multi-threaded on a high transaction-per-
>> second system.  Arbitrary restrictions should be avoided if possible
>> -- particularly when the avoidance mechanism is straight-forward.
> 
> Yes, it is, you simply check if the file exists before trying to create
> it...

That's not atomic, but neither is the use of POSIX tmpnam. In either
case, the file you check for, or the file name you generate does not
exist while you're doing it. When you open it, that condition may no
longer be true.

There was a discussion on generating unique identifiers on this very
list not that long ago. This problem is fairly much the same.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | What's another word for Thesaurus?
NSW, Australia                  | 


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

Date: Sun, 1 Jul 2001 10:09:48 +0200
From: "Amittai Aviram" <amittai@amittai.com>
Subject: HTML to Printable files via Perl CGI?
Message-Id: <9hmlvu$c60$1@rznews2.rrze.uni-erlangen.de>

Hi!  I have a series of Perl CGI scripts that produce HTML views of data
drawn from databases (DBMs), and I would like to offer the viewer the option
of printing the files.  Naturally, nowadays, you can just print the HTML
file, but I have no control over layout, and, in fact, the right edge of the
HTML page winds up cut off the printed page, even though the HTML page is
designed to fit easily on an 800x600 screen.  I could make a second version
of the same HTML page, within the script, using the <pre> or <tt> tag, or I
could likewise offer a remake of the page as type: text/plain.  Either way,
the text must be absolutely plain ASCII, with no italics or bold or font
sizes or other printing effects.  Again, I also have no control over
pagination -- there is no "required page break" or "required block" option.
I've seen (and downloaded) the RTF::Document module, but after reading the
(for me, extremely short and cryptic) documentation, I am not sure whether
this is the best solution.  Surely, other people out there have faced this
problem before.  What is the best solution?  The printed page need not have
anything very fancy, but a few font options would be nice, and some sort of
"block protect" function (i.e., keeping certain lines together and not
splitting them across a page break) would be really great.

(I know that this posting borders on a comp.infosystems.www.authoring.cgi
question, but [a] it's also a Perl question, and [b] their newsfeed is
having trouble and has not posted any of my messages lately.)

Thanks for any help!

Amittai Aviram


--
Amittai Aviram
Please note new address! --  amittai@amittai.com





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

Date: Sat, 30 Jun 2001 19:27:11 -0700
From: "David Frauzel" <nogard@gnosrehtaew.ten>
Subject: inline average
Message-Id: <9hm1cs$2h15$1@news.aros.net>

This is perhaps esoteric, but I'm curious.

Let's say I have the hash:

%values = (
  "red" => 5.0,
  "orange" => 4.0,
  "yellow" => 5.5,
  ...
)

I'd like to have a final element in the hash, "average", which always points
to the average of all of the other elements - something like an inline
function. I'm thinking it would look like this:

$values{"average"} = {
  my $total = 0;
  foreach $color (@spectrum) {
    $total += $values{$color};
  }
  $total = $total / ($#spectrum + 1);
  return $total;
}

(The above is obviously not real perl, it's just for the sake of
illustration.)

Given that, I could then say:

$values{"red"} = 6.0;

and immediately ask for:

print $values{"average"};

to get an updated average of red, orange, and yellow.

Is this possible?

David Frauzel





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

Date: 1 Jul 2001 05:05:01 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: inline average
Message-Id: <9hmb1t$d5f$0@216.155.32.50>

In article <9hm1cs$2h15$1@news.aros.net>,
 "David Frauzel" <nogard@gnosrehtaew.ten> wrote:

 | (The above is obviously not real perl, it's just for the sake of
 | illustration.)
 | 
 | Given that, I could then say:
 | 
 | $values{"red"} = 6.0;
 | 
 | and immediately ask for:
 | 
 | print $values{"average"};
 | 
 | to get an updated average of red, orange, and yellow.
 | 
 | Is this possible?

You might want to check into Object Oriented programming, and Damian 
Conway's _Object Oriented Perl_ book. There's a section in there [ 
chapter 9, "Ties"] that describes the procedures for creating a bit of 
code that 'eats' the inside of a variable and inserts a little alien[1] 
into it :-) It's a neat trick. 

For example:

package Track;
$VERSION  =  1.00;
use strict;

sub TIESCALAR
{
    my ($class, $val) = @_;
    bless {val => $val, src => [caller(1)] }, $class
}

sub FETCH
{
    my ($impl) = @_;
    return $impl->{val};
}

sub STORE
{
    my ($impl, $newval) = @_;
    $impl->{val} = $newval;
    $impl->{src} = [caller];
}

sub scalar
{
    tie $_[1], $_[0], $_[1];
}

sub debug
{
    my $impl = tied($_[1]);
    my ($cur_pkg, $cur_file, $cur_line) = caller;
    my ($src_pkg, $src_file, $src_line) = @{$impl->{src}};

    print STDERR 
            "At $cur_file line $cur_line in package $cur_pkg the\n",
            "tracked variable has the value $impl->{val}, which was\n",
            "assigned at $src_file line $src_line in package $src_pkg\n";
}

1;

then, later on say you have a problem with a variable obtaining an 
incorrect value somewhere, but you're not sure where. So, you 

    Track->scalar($critical_var);

from which point on, the variable $critical_var will behave NORMALLY 
until you call 

    Track->debug($critical_var);

where it will print out to STDERR the point where the file, line, and 
package of the current value of $critical_var was last assigned. The 
idea being to start tracking the variable at a point where you know it 
to be correct, and debug it at the point where it has an incorrect 
value. 

He goes on to state that it's as easy to tie a hash variable to a 
package as it is to tie a scalar, the only difference being that you 
need to have more methods, since a hash is more complex than a scalar. 

[ TIEHASH, FETCH, STORE, EXISTS, DELETE, CLEAR, FIRSTKEY, NEXTKEY, 
DESTROY ]

I'm not as up on this as I should be, and haven't had the opportunity to 
use such a beast in any of my own code as of yet, but the idea is a very 
very neat one, and a trick I'd love to use if need and opportunity 
presents itself. 

The book is great, and presents the whole shebang in slow easy to 
understand steps, with hundreds of examples. Highly recommended. 

Perhaps someone here who has a greater understanding of the concepts 
involved would be able to point the way a little better for you, but 
this is at least a lead :) 

so you could do something like 
    print %values->average; 
or
    print Value->average(%values);
perhaps.

I don't have enough time on my hands at the moment or I'd take a whack 
at hacking together something code-wise, but I hope this was at least 
informative and potentially useful information for you. 

-=-
[1] From the book: 

    Here's another way to think about tie-ing: According to Hollywood, 
the main occupation of extraterrestrial alien species appears to be:

    A. Finding their way inside unsuspecting humans.
    B. Hollowing out a little nest (usually by devouring inconvenient 
and unnecessary internal organs like the brain).
    C. Using the resulting human shell as a disguise to blend into Earth 
society for nefarious purposes.

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Sat, 30 Jun 2001 22:31:37 -0700
From: "David Frauzel" <nogard@gnosrehtaew.ten>
Subject: Re: inline average
Message-Id: <9hmc6m$2oen$1@news.aros.net>

> You might want to check into Object Oriented programming, and Damian
> Conway's _Object Oriented Perl_ book. There's a section in there [
> chapter 9, "Ties"] that describes the procedures for creating a bit of
> code that 'eats' the inside of a variable and inserts a little alien[1]
> into it :-) It's a neat trick.

Object Oriented *Perl*, I never even thought of that. Funny, because while I
was trying to riddle this out, I seemed to remember doing it somewhere
before, then realized I was thinking of a recent Java exercise.

I'll see if I can track it down. Thanks.

David Frauzel





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

Date: 1 Jul 2001 06:38:44 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: inline average
Message-Id: <9hmghk$scm$1@bob.news.rcn.net>

David Frauzel <nogard@gnosrehtaew.ten> wrote:
> This is perhaps esoteric, but I'm curious.

> Let's say I have the hash:

> %values = (
>   "red" => 5.0,
>   "orange" => 4.0,
>   "yellow" => 5.5,
>   ...
> )

> I'd like to have a final element in the hash, "average", which always points
> to the average of all of the other elements - something like an inline
> function. I'm thinking it would look like this:

[snip]

> Given that, I could then say:

> $values{"red"} = 6.0;

> and immediately ask for:

> print $values{"average"};

> to get an updated average of red, orange, and yellow.

> Is this possible?

Yes, by using a tied hash.  perldoc perltie.  The simplest way would be to
base your class on Tie::StdHash and override FETCH to loop through the
keys, adding up and counting the values, when given an argument of
"average."  If you were going to be frequently referring to the average,
that might be a little slow, in which case you'd probably want to store
the average as an ordinary key in your "internal" hash and have your STORE
routine update it whenever a value is added or changes.



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

Date: 1 Jul 2001 06:40:13 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: inline average
Message-Id: <9hmgkd$d5f$4@216.155.32.50>

In article <9hmc6m$2oen$1@news.aros.net>,
 "David Frauzel" <nogard@gnosrehtaew.ten> wrote:

 | > You might want to check into Object Oriented programming, and Damian
 | > Conway's _Object Oriented Perl_ book. There's a section in there [
 | > chapter 9, "Ties"] that describes the procedures for creating a bit of
 | > code that 'eats' the inside of a variable and inserts a little alien[1]
 | > into it :-) It's a neat trick.
 | 
 | Object Oriented *Perl*, I never even thought of that. Funny, because while I
 | was trying to riddle this out, I seemed to remember doing it somewhere
 | before, then realized I was thinking of a recent Java exercise.
 | 
 | I'll see if I can track it down. Thanks.

You're welcome; Hope you are able to solve the problem :)

I'd love to see the end result, if you'd be so kind as to post here, 
while working things out, so we can follow along. :)

(I'm still attempting to grok this stuff myself, y'see... :D

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: Sun, 1 Jul 2001 02:02:49 -0500
From: "Rich" <bigrich318@yahoo.com>
Subject: Re: inline average
Message-Id: <tjtiq6kf3tmh89@corp.supernews.com>


"David Frauzel" <nogard@gnosrehtaew.ten> wrote in message
news:9hm1cs$2h15$1@news.aros.net...
> This is perhaps esoteric, but I'm curious.
>
> Let's say I have the hash:
>
> %values = (
>   "red" => 5.0,
>   "orange" => 4.0,
>   "yellow" => 5.5,
>   ...
> )
>
> I'd like to have a final element in the hash, "average", which always
points
> to the average of all of the other elements - something like an inline
> function. I'm thinking it would look like this:
>
> $values{"average"} = {
>   my $total = 0;
>   foreach $color (@spectrum) {
>     $total += $values{$color};
>   }
>   $total = $total / ($#spectrum + 1);
>   return $total;
> }
>
> (The above is obviously not real perl, it's just for the sake of
> illustration.)

You were on the right track. You want to use an anonymous subroutine.

#!/usr/bin/perl -w

use strict;

my %values = (
  red => 5.0,
  orange => 4.0,
  yellow => 5.5,
  average => "",
);

  $values{average} = &{sub {
  my $total = 0;
  my $colors = 0; #number of valid color values to average
  foreach my $color (keys %values) {
    if ($color ne "average"
        &&
        # Don't use value of  $values{$color} unless it's a number
        $values{$color} =~ /^-?(?:(?:\d+\.?\d*)|(?:\d*\.\d+))$/) {
            $total += $values{$color};
            $colors++;
    }
  }
  return sprintf("%.2f", $total /= $colors);
}};

print "The average is $values{average}";

__END__

sub { ..code..} produces a  reference. Wrapping it in &{ } de-references the
value before assigning it to $values{average}

I didn't spend a lot of time on the example, you can adjust it to suit your
needs. If you are certain that all colors will have a valid numeric value,
you could eliminate the check.


Keep checking back, I'm certain their will be many posts to follow that will
provide micro-efficiency corrections as well as many different ways to get
the same results.



Rich




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

Date: Sun, 1 Jul 2001 02:31:35 -0500
From: "Rich" <bigrich318@yahoo.com>
Subject: Re: inline average
Message-Id: <tjtkee43lh8gca@corp.supernews.com>

> "David Frauzel" <nogard@gnosrehtaew.ten> wrote in message
> news:9hm1cs$2h15$1@news.aros.net...
>Given that, I could then say:

>$values{"red"} = 6.0;

>and immediately ask for:

>print $values{"average"};

>to get an updated average of red, orange, and yellow.

>Is this possible?


Yes, but not using my solution. I didn't read your post thoroughly (been a
long day).

My apologies,

Rich






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

Date: Sun, 1 Jul 2001 09:01:40 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: Need help again with global vars!
Message-Id: <9hmotk$29cv$1@nntp1.ba.best.com>

In article <af3e7ca1.0106282322.7cc6478c@posting.google.com>,
wac <wac@edge-china.com> wrote:
>you can create global vars use this method:
>
>$var:: = $value;

You mean
  $::var = $value;
or
  $main::var = $value;

But that won't work in an environment where processes come and go.

When using mod_perl or other Apache features, sometimes you need a
variable that is more than global.  I heard the term "solar" used
to describe something that was more than global; shared amongst all
instantiations of perl interpereters, not just your child process.
	-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Sat, 30 Jun 2001 23:35:10 -0700
From: Peter <rig01@yahoo.com>
Subject: Newbie - Unix Commands in Perl
Message-Id: <gpgtjtk6ckbq5mqdgmvlcemf20vu10pjj2@4ax.com>

Help Please :
I want to execute the CAT command in Perl,
I am using Active Perl in Win2000 .
This is my scrip ; and  I got the error message :
 " cat  is not reconized as internal or external command .."
WHAT IS WRONG???

SCIPT :
=====
use Shell;
cat("<c:/temp/file1.txt", "<c:/temp/file2.txt", ">>c:/temp/file3.lst"



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

Date: Sun, 01 Jul 2001 04:14:21 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Newbie - Unix Commands in Perl
Message-Id: <3B3EA3A5.50A9A432@acm.org>

Peter wrote:
> 
> Help Please :
> I want to execute the CAT command in Perl,
> I am using Active Perl in Win2000 .
> This is my scrip ; and  I got the error message :
>  " cat  is not reconized as internal or external command .."
> WHAT IS WRONG???
> 
> SCIPT :
> =====
> use Shell;
> cat("<c:/temp/file1.txt", "<c:/temp/file2.txt", ">>c:/temp/file3.lst"

You don't really _need_ the cat command

@ARGV = ( "c:/temp/file1.txt", "c:/temp/file2.txt" );
open CAT, ">>c:/temp/file3.lst" or die "Cannot append to
c:/temp/file3.lst: $!";
print CAT while <>;



John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 30 Jun 2001 22:25:47 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: Newbie - Unix Commands in Perl
Message-Id: <6Bx%6.22396$D92.6478@newsfeed.slurp.net>


"Peter" <rig01@yahoo.com> wrote in message
news:gpgtjtk6ckbq5mqdgmvlcemf20vu10pjj2@4ax.com...
>
> use Shell;
> cat("<c:/temp/file1.txt", "<c:/temp/file2.txt", ">>c:/temp/file3.lst"

The docs for Shell don't make it particularly clear, but I assume that 'cat'
must exist on your system, which isn't the case for box stock Win2000. Can
you do 'cat' from a cmd.exe prompt?

if not, you could either install one of the unix toolkits for windows, try
copy(c:\temp\file1.txt+c:\temp\file.txt c:\temp\file.3.lst);, or do the
whole thing in a more portable Perl fashion.




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

Date: Sun, 1 Jul 2001 08:12:05 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: Problem using "*" in System(...) command
Message-Id: <9hmm0l$299p$1@nntp1.ba.best.com>

In article <3B3CC26F.2A6692B9@oracle.com>,
Prasad Peddamatham  <Prasad.Peddamatham@oracle.com> wrote:
>
>The problem is, I want to make the sourceFile to be set by command line
>argument :
>
>mycopy.pl :
>#!/usr/local/bin/perl
>
>#$sourceFile  = $ARGV[0];
>$sourceFile  = "MyFile*";
>
>print "EXECUTING: cp $sourceFile bak\n";
>system("cp $sourceFile bak/");
>
>exit;
>
>When I call the script as : [providing command line argument]
>mycopy.pl MyFile*
>
>to copy all the files starting with MyFile, it just copies plain file MyFile
>(without extension).

You typed "mycopy.pl MyFile*", but what the program saw was something like
"mycopy.pl MyFile.1 MyFile.2".  That's because the shell expanded the
wildcards; your perl program never saw the asterisk.

>How do I make sure that it behaves exactly the way it works when I set :
>[which obviously works]
>$sourceFile  = "MyFile*";
>
>inside the file ?

You have to explictly call for wildcard expansion if there are any
metacharacters (such as "?", "*", "[]" or "{}".

  $files = "MyFile*";
  print "Before glob(): cp $files destination_dir\n";
  @files = glob $files;		# Expand wildcards
  print "After glob(): cp @files destination_dir\n";
  system("cp @files destination_dir");
  warn "'cp' failed: $?\n" if $?;

	-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Sun, 01 Jul 2001 06:25:45 GMT
From: svidales@please.no.spam.usa.net (Sergio Vidales)
Subject: read/write ksh env array in Perl?
Message-Id: <3b3ec01d.8607357@news-server.socal.rr.com>

A ksh script that I need to use is doing something like this:

$ MYARRAY[0]=TEST1
$ MYARRAY[1]=TEST2
$ echo ${MYARRAY[0]}
TEST1
$ echo ${MYARRAY[1]}
TEST2

I need to write a Perl script that can read and write to this array.
It must be kept as an env variable since other scripts will read it as
well. I have tried using $ENV and assigning it to a Perl array with
little success. 

Any help is appreciated. Thanks!

Sergio Vidales



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

Date: Sun, 01 Jul 2001 06:28:57 GMT
From: svidales@please.no.spam.usa.net (Sergio Vidales)
Subject: read/write ksh env array in Perl?
Message-Id: <3b3ec2f5.9335447@news-server.socal.rr.com>

A ksh script that I need to use is doing something like this:

$ MYARRAY[0]=TEST1
$ MYARRAY[1]=TEST2
$ echo ${MYARRAY[0]}
TEST1
$ echo ${MYARRAY[1]}
TEST2

I need to write a Perl script that can read and write to this array.
It must be kept as an env variable since other scripts will read it as
well. I have tried using $ENV and assigning it to a Perl array with
little success. 

Any help is appreciated. Thanks!

Sergio Vidales



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

Date: Sun, 1 Jul 2001 06:41:00 +0000 (UTC)
From: steven.smolinski@sympatico.ca (Steven Smolinski)
Subject: Re: read/write ksh env array in Perl?
Message-Id: <9hmglr$d8f$1@taliesin.netcom.net.uk>

[ Posting once is generally enough. ]

Sergio Vidales <svidales@please.no.spam.usa.net> wrote:
> A ksh script that I need to use is doing something like this:
> 
> $ MYARRAY[0]=TEST1
> $ MYARRAY[1]=TEST2
> $ echo ${MYARRAY[0]}
> TEST1
> $ echo ${MYARRAY[1]}
> TEST2
> 
> I need to write a Perl script that can read and write to this array.
> It must be kept as an env variable since other scripts will read it as
> well. I have tried using $ENV and assigning it to a Perl array with
> little success. 

A child cannot change the environment of its parent.

Look in perlfaq8:

       I {changed directory, modified my environment} in a perl
       script.  How come the change disappeared when I exited the
       script?  How do I get my changes to be visible?

Steve
-- 
Steven Smolinski => http://arbiter.ca/


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

Date: 1 Jul 2001 07:40:47 GMT
From: gerg@panix.com (Greg Andrews)
Subject: Re: readdir(..) function
Message-Id: <9hmk5u$27d$1@news.panix.com>

gerg@panix.com (Greg Andrews) writes:
>
>
>     $size = (stat _)[7] ;      # gets size from stat buffer
      ^^^^^^^^^^^^^^^^^^^^^

or:

      $size = -s _ ;             # get file size from stat buffer


  -Greg
-- 
+++++ Greg Andrews +++ gerg@panix.com +++++
I have a map of the United States that's actual size
		 -- Steven Wright


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

Date: Sun, 01 Jul 2001 01:40:01 GMT
From: "Misanthrope" <no@spam.net>
Subject: Re: Selling Scripts
Message-Id: <Rbv%6.8953$eL5.958301@newsread1.prod.itd.earthlink.net>


<tsee@gmx.net> wrote in message news:9hdka5$if2$07$1@news.t-online.com...
> "ffg" <john@trumpetweb.co.uk> schrieb im Newsbeitrag
> news:8or_6.4277$4i5.341643@news1.cableinet.net...
> In order to make it run, you need perms to be 555 or more.


Untrue.






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

Date: Sun, 1 Jul 2001 12:26:02 +0800
From: "Banshee" <defont@nospam.iinet.net.au>
Subject: stripping Underscores
Message-Id: <3b3ea612$0$18438@echo-01.iinet.net.au>

Hi all,

I have embedded some code into HTML to display a list of products from a
flat file database. Most of the product categories have sub-categories which
are as such, THING_blue, THING_red, etc...
What I am trying to do is generate the product listing without listing all
the product sub-categories, eg just THING.

The code to generate the listing is below.

If anyone can help in any way I would appreciate it.

TIA,
Malissa

local(%db_ele,$sku,$category,%category_list);
if (!($sc_db_lib_was_loaded =~ /yes/i))
 { &require_supporting_libraries (__FILE__, __LINE__, "$sc_db_lib_path"); }
&capture_STDOUT;
&get_prod_db_element($db{"product"},*db_ele);
foreach $sku (keys %db_ele) {
  $category = $db_ele{$sku};
  $category_list{$category}++;
}
foreach $category (sort(keys %category_list)) {
  print "<a href=\"prog.cgi?cart_id=&product=",
    "$category\"><font class = \"Grey\">&nbsp;&nbsp;
$category</font></a><br>\n";
}
&uncapture_STDOUT; }




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

Date: Sat, 30 Jun 2001 23:48:24 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: test
Message-Id: <3b3ec7bc@news.microsoft.com>

"Joey Moses" <joeymoses1@home.com> wrote in message
news:tsu%6.71372$bH4.674837@e420r-chi2.usenetserver.com...
> Having trouble getting post to the board.

You forgot the word 'right' in
    "Having trouble getting post to the right board"
(where of course it is still unclear what board you are talking about as
this here is a Usenet Newsgroup).

jue




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

Date: Sat, 30 Jun 2001 15:06:38 +0200
From: Christopher Kleinheitz <c-kleinheitz@freenet.de>
Subject: Re: timing can make the difference:
Message-Id: <3B3DCEDE.A5148BB4@freenet.de>

Hi,

Yo schrieb:

> I want the script to start sleeping at the end of execution, here's code:
>
> x is the main problem here.... how to get that value in ms?
> I know for 20 minutes x would be 20*60*1000
> But the script's execution would shift the start-time a few seconds every 20
> minutes.

Try out how long your script takes and subtract this from your 20*60*1000. For
example if the script takes 5 seconds $x=(20*60*1000)-5000

HTH

Chris

--
Christopher Kleinheitz Offenburg Germany http://jahresarbeit.virtualave.net
"Der Dienst wird mit der dem Wesen des Eisenbahnbetriebs entsprechenden
Raschheit, aber ohne Überstürzung ausgeführt" Dienstvorschrift 408 der Bahn




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

Date: 01 Jul 2001 08:00:15 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: unix `ps`
Message-Id: <slrn9jtm4f.qa5.vek@pharmnl.ohout.pharmapartners.nl>

On Sat, 30 Jun 2001 09:12:26 -0600,
    bowman <bowman@montana.com> wrote:

>
>at least on linux, most of the information is in /proc. if your ls was
>working you'd see a bunch of numbered directories, which are the pids. in
>each is a 'cmdline' that contains the name and pid, except for some of the
>daemons. assuming 'find', 'grep' and 'cat' aren't trashed, you could cd to
>/proc and do something like 'find . -name "cmdline" | cat' or a little more
>sophisticated stuff. a little C proggie would do the job as well, if you
>can't find the right perl mod.
>



On most other unix system ps peeks into kernel memory in a very system
dependent way.




Villy


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

Date: Sun, 1 Jul 2001 09:11:48 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: What kind of object is an old-fashioned DBM?
Message-Id: <9hmpgk$29dd$1@nntp1.ba.best.com>

In article <9hhke6$o9i$1@rznews2.rrze.uni-erlangen.de>,
Amittai Aviram <amittai@amittai.com> wrote:
>
>"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
>news:9hfcpg$8aa$2@mamenchi.zrz.TU-Berlin.DE...
>> According to Amittai Aviram <amittai@amittai.com>:
>> > I was trying to change my scripts that had used dbmopen() and dbmclose()
>to
>> > use tie() instead.  Tie requires the name of an object.  I
>
>To which Anno Siegel replied:
>
>> What's the problem?  You use whatever flavor of DB was used creating
>> them.  If you don't know, under Unix the file command may help.
>
>?? file dbmopen --> No such command.
>file db --> No such command.
>
>dbmopen is not a Unix command, AFAIK, it is a Perl function.

That's irrelevant.  Anno was talking about using the 'file' command
on the database files to determine what type of database file they are.
For instance:

  solaris% file /etc/mail/alias*
  /etc/mail/aliases:      ascii text
  /etc/mail/aliases.dir:  empty file
  /etc/mail/aliases.pag:  data

Darn.  I was hoping it would say that aliases.pag was an ndbm file
(as opposed to a gdbm or sdbm or Berkeley DB file).

A list of common object names can be found in "perldoc AnyDBM_File".
The right name to use can be determined through trial and error.
	-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

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


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