[16378] in Perl-Users-Digest
Perl-Users Digest, Issue: 3790 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 24 21:05:51 2000
Date: Mon, 24 Jul 2000 18:05:17 -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: <964487117-v9-i3790@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 24 Jul 2000 Volume: 9 Number: 3790
Today's topics:
Advice on CGI.pm <josh@projectperl.com>
Re: Any Perl experts in Austin, TX? (David H. Adler)
Re: Duplicate Posts <danny@lennon.postino.com>
Evaluating code from a database? <mauddib@hotmail.com>
Re: Evaluating code from a database? (Logan Shaw)
Re: File & Directory Reading (Logan Shaw)
forking subroutines? dorpus@my-deja.com
Re: forking subroutines? (Logan Shaw)
hash and fork() <eosyn@workmail.com>
Re: hash and fork() (Logan Shaw)
Re: help w/ regular expression <nospam@nospam.com>
Re: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED?? (Keith Calvert Ivey)
Help: Perl DBI & Oracle: from UNIX to NT yudelin@my-deja.com
hoo boy, it's another head-scratcher... <nospam@nospam.com>
How do you delete a file <shawnball@uswest.net>
Re: How do you delete a file (Logan Shaw)
Re: How do you delete a file <tina@streetmail.com>
Re: How do you delete a file <bcaligari@shipreg.com>
how to print every 91st line <ccoffey@nims.wr.usgs.gov>
Re: how to print every 91st line (Logan Shaw)
Re: how to print every 91st line (Abigail)
INfo on the environment variables <mgopalan@students.uiuc.edu>
Re: INfo on the environment variables (Logan Shaw)
Re: INfo on the environment variables (jason)
Re: INfo on the environment variables (Tad McClellan)
Loading of an array <mrhodes@rez.com>
Re: Loading of an array (Logan Shaw)
Re: Loading of an array <lr@hpl.hp.com>
Need a job <webbk@usa.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 24 Jul 2000 18:42:40 -0500
From: "Josh" <josh@projectperl.com>
Subject: Advice on CGI.pm
Message-Id: <snpl4fut3j188@corp.supernews.com>
Hello. I have written administrative CGI scripts with CGI.pm and have
always found it difficult to implement pages that have several command
buttons that take the user to different functions of the administrative
script(i.e. a menu). I usually run into problems such as it re-executing
previous code and generally not following the correct path. I am looking for
someone to give advice on how it would be possible to work these type of
flaws out and if possible some examples of how. Thank you.
-Josh
------------------------------
Date: 24 Jul 2000 22:05:17 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Any Perl experts in Austin, TX?
Message-Id: <slrn8npfct.2b5.dha@panix6.panix.com>
On Tue, 18 Jul 2000 18:56:50 GMT, Whitaker IT
<candy.taylor@whitakercos.com> wrote:
>Our direct client in Austin, TX is looking for a Perl/Linux developer
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
There is a Perl Jobs Announce list that may be more helpful to you. See
<http://www.pm.org/mailing_lists.shtml> for details.
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"It was failure proof technology"
"What happened?"
"It failed" - Doctor Who, Frontios
------------------------------
Date: 24 Jul 2000 23:16:37 GMT
From: <danny@lennon.postino.com>
Subject: Re: Duplicate Posts
Message-Id: <8liiol$11f$1@lennon.postino.com>
User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.14-5.0 (i586))
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Ok, I say it this way. This plastering of selected
> newsgroups with " comp. " in their title, this flood
> of over fourteen-thousand articles here and in a few
> other newsgroups, although accidental, was not accidental.
> It was the back fired results of a person trying to
> conceal himself within this group via unskilled hacking.
But how does the JFK Conspiracy come into play here?
--
Danny Aldham Providing Certified Internetworking Solutions to Business
www.postino.com E-Mail, Web Servers, Web Databases, SQL PHP & Perl
------------------------------
Date: Mon, 24 Jul 2000 16:31:06 -0700
From: Charles Petersen <mauddib@hotmail.com>
Subject: Evaluating code from a database?
Message-Id: <397CD1BA.3EEB26B6@hotmail.com>
I'm using a basic template, written in perl, for my web site design.
I'm then reading in some more perl from a MySQL database that is
supposed to layout and customize the individual content pages. The
problem is, how do I take the text I'll be receiving from the database
and have perl evaluate it?
What you end up with is a scalar that has all your code for the content
stored in it, but how would I make perl interpret this as code?
If it wasn't code I could just say:
print (dollarsign)scalar;
but it won't eval something like
foreach(@country) {
print (dollarsign)_;
}
Charles Petersen
------------------------------
Date: 24 Jul 2000 18:49:46 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Evaluating code from a database?
Message-Id: <8likmq$fel$1@provolone.cs.utexas.edu>
In article <397CD1BA.3EEB26B6@hotmail.com>,
Charles Petersen <mauddib@hotmail.com> wrote:
>I'm using a basic template, written in perl, for my web site design.
>I'm then reading in some more perl from a MySQL database that is
>supposed to layout and customize the individual content pages. The
>problem is, how do I take the text I'll be receiving from the database
>and have perl evaluate it?
>
>What you end up with is a scalar that has all your code for the content
>stored in it, but how would I make perl interpret this as code?
You evaluate with eval.
- Logan
------------------------------
Date: 24 Jul 2000 17:33:29 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: File & Directory Reading
Message-Id: <8lig7p$eu0$1@provolone.cs.utexas.edu>
In article <8lhtn1$e38$1@provolone.cs.utexas.edu>,
Logan Shaw <logan@cs.utexas.edu> wrote:
> while (readdir DIR)
Ooops, I just realize this should be
while ($_ = readdir DIR)
- Logan
------------------------------
Date: Mon, 24 Jul 2000 23:29:21 GMT
From: dorpus@my-deja.com
Subject: forking subroutines?
Message-Id: <8lijgd$g65$1@nnrp1.deja.com>
Hi, I have read through various documentation on the fork command, and
it just seems to call the same program all over again. I would like
for a parent process to make 6 calls to a particular subroutine, and
span a new call whenever one of the child processes finish. How can I
go about doing this?
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 Jul 2000 18:48:01 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: forking subroutines?
Message-Id: <8likjh$fe0$1@provolone.cs.utexas.edu>
In article <8lijgd$g65$1@nnrp1.deja.com>, <dorpus@my-deja.com> wrote:
>Hi, I have read through various documentation on the fork command, and
>it just seems to call the same program all over again. I would like
>for a parent process to make 6 calls to a particular subroutine, and
>span a new call whenever one of the child processes finish. How can I
>go about doing this?
The two key concepts you need to understand are:
1. fork() returns a value which is different for parent and child;
you can use this to make the parent and child do different things.
and
2. after the parent finishes spawning off 6 children, it can wait
for a child to finish by calling wait(), which will return the
process id of some child which has exited.
That should be enough for you to finish that task. Another thing
that's nice to know is that waitpid() is a variation on wait(), and
that you can (if you want a minor headache) arrange to have a signal
delivered when a child exits.
Hope that helps.
- Logan
------------------------------
Date: Mon, 24 Jul 2000 18:58:55 -0500
From: "eosyn" <eosyn@workmail.com>
Subject: hash and fork()
Message-Id: <8likrm$jct$1@nntp9.atl.mindspring.net>
Hash: SHA1
I'm trying to write a program that pre forks and tracks its forks but
it doesn't seem to like it.
$forknum = 3;
for($i = 1; $i <= $forknum; ++$i) {
$forks{$i} = fork();
}
foreach $fork (keys(%forks)) {
print "Forked: $fork\n";
}
This seems to make a whole lot more keys in %forks and some of them
are 0 and others are valid PID's. Anyone know why this is?
SYS: Linux 2.2.13
Perlver: 5.6.0
eos..
insane@null.net
Version: PGP 6.5.3
iQA/AwUBOXzYPU05gNfRWbAXEQIU2QCgvMx4GAbxdN+zJoEVTplfCw3ZVyQAmwUT
dhITb81kOuEVn/9NU40gYYYE
=Z0Vw
-----END PGP SIGNATURE-----
------------------------------
Date: 24 Jul 2000 18:56:17 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: hash and fork()
Message-Id: <8lil31$fh7$1@provolone.cs.utexas.edu>
In article <8likrm$jct$1@nntp9.atl.mindspring.net>,
eosyn <eosyn@workmail.com> wrote:
>
>Hash: SHA1
>
>I'm trying to write a program that pre forks and tracks its forks but
>it doesn't seem to like it.
>
>
>$forknum = 3;
>
>for($i = 1; $i <= $forknum; ++$i) {
> $forks{$i} = fork();
>}
>
>
>foreach $fork (keys(%forks)) {
> print "Forked: $fork\n";
>}
>
>
>This seems to make a whole lot more keys in %forks and some of them
>are 0 and others are valid PID's. Anyone know why this is?
Look at the documentation. Look at what the return values are for
fork(). Also, consider this: At what point does the code resume
execution in the parent? At what point does it resume in the child?
Hint: you need a conditional somewhere.
- Logan
------------------------------
Date: 24 Jul 2000 23:52:51 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: help w/ regular expression
Message-Id: <8liksj$clf$1@216.155.32.41>
In article <MPG.13e6597b89d5e4d498abe2@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> wrote:
| > No. 5.6 still doesn't know that tr/...// only serves to count
| > characters.
|
| I thought so too, until I tested it. On both 5.005_03 and 5.6.0, the
| following program works fine (prints "1\n"):
|
| #!/usr/bin/perl -w
| use strict;
| 'x' =~ /(.)/;
| print $1 =~ tr/x//, "\n";
|
| But if we change tr/x// to tr/x/x/, it doesn't compile.
|
| As Eric Bohlman posted the following line of code, and you reposted it
| with a minor change:
|
| if ($arg =~ /([-\d\s()]+)$/ and ($1 =~ tr/0-9//)>=7) {
|
| why do you now say that it doesn't compile?
basically because I still get
# Modification of a read-only value attempted.
File 'Untitled #4'; Line 5
even with your tiny 4-line piece of code there :)
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Mon, 24 Jul 2000 23:50:41 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: HELP: longSyntax ok, but: rHsh->{myKey} UNDEFINED??
Message-Id: <397dd3b5.5295771@news.newsguy.com>
dkcombs@netcom.com (David Combs) wrote:
>Hmmm. I suppose that is yet another undocumented DWIMS -- because
>it seems to "work".
Yes, %hash->{key} has been discussed here occasionally.
I wouldn't rely on it, though.
>Fixing it, it still works (hey, with perl, you don't know
> until you actually TRY it!):
>
> # NEXT LINE WORKS OK!!
> print(STDERR $indentStr, "[$i]: WORKS OK!!!: NOW, TRY FOR x=>{curLine}: ",
># dQuoteIt(%{$recordHashRef}->{"curLine"}), "\n");
> dQuoteIt(${$recordHashRef}->{"curLine"}), "\n");
Now you've got an extra $ there, unless $recordHashRef is
actually a reference to a reference to a hash. It should be
just $recordHashRef->{curLine}.
>>'curline' ne 'curLine'
>
>Yes, thanks. Now, why didn't -w CATCH it?:
But -w *did* catch it. That's why you got the warning about the
undefined value. What did you expect it to do? It's a hash
key, not a variable name.
By the way, the "silly capitalization style" I referred to
wasn't simple midstring capitalization. It was capitalization
in the middle of a string that starts with a lowercase letter.
I wouldn't have remarked on "CurLine", but "curLine" seems
almost as bizarre as, say, "cURlINE". I know it's popular in
other languages, but to me it's just wrong. You're welcome to
do whatever you wish, of course.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Tue, 25 Jul 2000 00:47:02 GMT
From: yudelin@my-deja.com
Subject: Help: Perl DBI & Oracle: from UNIX to NT
Message-Id: <8lio25$jg9$1@nnrp1.deja.com>
Hi,
I wonder if anybody has experience on configuration to run Perl DBI on
UNIX to connect to Oracle on NT machine. We are unable to figure out how
this connection is made and what the steps are. It will be highly
appreciated if somebody can give some information on how set up
DBD::ORACLE and DBI and/or other related configuration.
Thank you very much!
Yude Lin
Email: ylin@tradeloop.com / yudelin@go.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 Jul 2000 23:46:08 GMT
From: The WebDragon <nospam@nospam.com>
Subject: hoo boy, it's another head-scratcher...
Message-Id: <8likg0$clf$0@216.155.32.41>
does anyone vaguely remember the perlish project I had put together
about a month or so ago, wherein I was parsing a bunch of html files
from a website to extract the data, create a flat-file database out of
the text I wanted, and then using a CGI.pm script to re-output that data
in the format I wanted?
This might refresh some memories
http://x69.deja.com/[ST_rn=ps]/getdoc.xp?AN=621855998&CONTEXT=964479679.7
12769594&hitnum=177
Basically they changed the format of the files recently so that all the
data is fetched from a SQL database via .asp instead of simply being in
a java-scripted html file ( thus the html files they have now are HUGE
in comparison .. the DeathMatch maps list .htm went from around 80K
total to around 368K total ! =:o )
I figured out on my own how to grab the new files, and hacked together a
method using HTML::Parser 3.07 to extract the important text from the
pages.. sort of :)
what I wind up with now (or want to anyway), is 6 text files (each from
a different $section of map gametypes .. (utdm, utassault,
utcapturetheflag, utdomination, utother) of the format :
<<EOF
head1
head2
head3
col_title1
col_title2
col_title3
(none of which I really need.. then comes tons of data ->)
map_download_link \t mapname\n
map_filesize\n
(N/A) or (map_review_link\tmap_rating)\n
etc.\n
etc.\n
etc.{ad infinitum}\n
EOF
basically I need to devise a new method of parsing this data into the
same sort of flat-file I had before .. so, I want to loop through these
files, and throw out the headx/col_titlex data, and then parse through
the rest, and sort into one single sorted output file of the format:
$section=$file=$title=$size=$review=$rating\n
again, like before.
I've gotten almost this far, this time, but something puzzling is
happening: the first file processed is handled correctly
(ut_assault_maps.htm), but the remainder of the output files wind up 0K
in size ..
here's the script so far.. any comments welcome, and any assistance or
suggestions you have for helping me figure out how to parse the separate
datafiles further into the flat-file would be MUCH appreciated.
-=-
#!perl -w
use strict;
#use diagnostics -verbose;
use LWP::UserAgent;
use File::Spec;
use HTML::Parser 3.07 ();
my $input_dir = File::Spec->catfile( File::Spec->curdir(),
'input_files', '');
my $baseURL = "http://www.planetunreal.com/nalicity/listmaps.asp";
# for reference purposes:
# entire deathmatch url is
http://www.planetunreal.com/nalicity/listmaps.asp?type=6&listall=2
# map fileslist to section titles
my %files_list = (
'ut_dm_maps.htm' => [ 'utdm', '6' ],
'ut_assault_maps.htm' => [ 'utassault', '7' ],
'ut_domination_maps.htm' => [ 'utdomination', '8' ],
'ut_capturetheflag_maps.htm' => [ 'utctf', '9' ],
'ut_other_maps.htm' => [ 'utother', '10' ]
);
for (keys %files_list) {
my $ua = new LWP::UserAgent;
my $request = new HTTP::Request 'GET' => $baseURL .
"?type=$files_list{$_}->[1]\&listall=2";
my $response = $ua->request($request);
die "$baseURL $_ failed: ",$response->error_as_HTML
unless $response->is_success;
print "Successful request of $_\n";
open(OUT, ">$input_dir$_") or die ('Aieeeeee');
print OUT $response->content;
close OUT;
};
# ok let's start by paring down all the unnecessary filesize
# and JUST leave ourselves with the important data
for (sort(keys %files_list)) {
my (%inside, @filedata);
my $infile = $input_dir . $_;
my $outfile = $infile . "l";
HTML::Parser->new(
'api_version' => '3',
'handlers' => [ 'start' => [ \&tag, "tagname, '+1', attr" ],
'end' => [ \&tag, "tagname, '-1'" ],
'text' => [ \&text, "text" ], ],
'marked_sections' => '1',
)->parse_file($infile) || die "Can't open input file: $!\n";;
open(OUT, ">$outfile") or die ("Cannot open output file $!");
print OUT @filedata;
close(OUT);
sub tag {
my($tag, $num, $info) = @_;
$inside{$tag} += $num;
if (($tag eq 'a') and ($num eq '+1')) {
push @filedata, "$info->{'href'}\t"; # not for all tags
}
}
sub text {
return if $inside{script} || $inside{style};
chomp(my $txt = $_[0]);
$txt =~ s/^\s+$//;
return if $txt eq "";
push @filedata, "$txt\n";
}
};
-=-
Another odd thing is that the HTML::Parser routine runs fine as a
MacPerl Droplet (wherein I drag-and-drop the files one at a time, onto
the droplet and they all get parsed (via $infile = shift; ) correctly),
but not in the main script body.
I'm considering the possibility of trapping the <tr></tr> tagpairs (like
I'm doing with the a href="")to grab the three lines between them and
using THOSE to signal for the \n's and using all \t's inbetween the
relevant data (in order to make parsing the datasets MUCH easier), but I
haven't wrapped my brain around that part yet. :)
-=-
From sharp minds comes .. pointy heads!
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Mon, 24 Jul 2000 18:17:15 -0700
From: "Ferk Da Jerk" <shawnball@uswest.net>
Subject: How do you delete a file
Message-Id: <OR3f5.2493$lI6.232094@news.uswest.net>
Excuse me but I'm kinda not that good in perl and know only the basics.
Well I was wondering how you delete a file. Do you need to use "use" and
grab something with it or is there a certain command. Well thanks.
------------------------------
Date: 24 Jul 2000 18:09:20 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How do you delete a file
Message-Id: <8liib0$f4m$1@provolone.cs.utexas.edu>
In article <OR3f5.2493$lI6.232094@news.uswest.net>,
Ferk Da Jerk <shawnball@uswest.net> wrote:
>Excuse me but I'm kinda not that good in perl and know only the basics.
>Well I was wondering how you delete a file. Do you need to use "use" and
>grab something with it or is there a certain command. Well thanks.
unlink($filename) is one way. system ("rm", $filename) is another.
(At least on Unix systems it is...)
- Logan
------------------------------
Date: 24 Jul 2000 23:10:51 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: How do you delete a file
Message-Id: <8liidr$4ijap$2@ID-24002.news.cis.dfn.de>
hi,
Ferk Da Jerk <shawnball@uswest.net> wrote:
> Excuse me but I'm kinda not that good in perl and know only the basics.
> Well I was wondering how you delete a file. Do you need to use "use" and
> grab something with it or is there a certain command. Well thanks.
please read
perldoc perlfunc
bevor asking. saves you and us all a lot of time.
there's a section
| Functions for filehandles, files, or directories
| -X, chdir, chmod, chown, chroot, fcntl, glob, ioctl,
| link, lstat, mkdir, open, opendir, readlink, rename,
| rmdir, stat, symlink, umask, unlink, utime
ok, it is unlink.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Tue, 25 Jul 2000 01:50:57 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: How do you delete a file
Message-Id: <8lik52$43o$1@news.news-service.com>
"Tina Mueller" <tina@streetmail.com> wrote in message
news:8liidr$4ijap$2@ID-24002.news.cis.dfn.de...
> hi,
> Ferk Da Jerk <shawnball@uswest.net> wrote:
> > Excuse me but I'm kinda not that good in perl and know only the basics.
> > Well I was wondering how you delete a file. Do you need to use "use"
and
> > grab something with it or is there a certain command. Well thanks.
>
> please read
> perldoc perlfunc
> bevor asking. saves you and us all a lot of time.
> there's a section
is that a perlfaq in your pocket or are you just happy to be here?
>
> | Functions for filehandles, files, or directories
> | -X, chdir, chmod, chown, chroot, fcntl, glob, ioctl,
> | link, lstat, mkdir, open, opendir, readlink, rename,
> | rmdir, stat, symlink, umask, unlink, utime
>
> ok, it is unlink.
hmm..ok....still got a heart and soul
>
> tina
>
B
------------------------------
Date: Mon, 24 Jul 2000 22:51:47 GMT
From: Chris Coffey <ccoffey@nims.wr.usgs.gov>
Subject: how to print every 91st line
Message-Id: <Pine.LNX.4.10.10007241545420.16468-100000@nims.wr.usgs.gov>
I hope this isn't a stupid question, but how would I print every 91st
line in one file? To clarify, I want to first print the 8th line and then
every 91st line after that. I don't think it's possible to increment the
$. operator is it? Thanks in advance for your he
Chris
------------------------------
Date: 24 Jul 2000 18:11:39 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: how to print every 91st line
Message-Id: <8liifb$f7b$1@provolone.cs.utexas.edu>
In article <Pine.LNX.4.10.10007241545420.16468-100000@nims.wr.usgs.gov>,
Chris Coffey <ccoffey@nims.wr.usgs.gov> wrote:
>I hope this isn't a stupid question, but how would I print every 91st
>line in one file? To clarify, I want to first print the 8th line and then
>every 91st line after that. I don't think it's possible to increment the
>$. operator is it? Thanks in advance for your he
$. isn't an operator; it's a special variable. Just write a little
logic to check whether it has the right value and print if so.
Hint: you can compare $. to 8, and you can also the expression
'$x % 91' takes on a special value when $x is a multiple of 91.
- Logan
------------------------------
Date: 24 Jul 2000 19:24:52 EDT
From: abigail@foad.org (Abigail)
Subject: Re: how to print every 91st line
Message-Id: <slrn8npk1v.vcg.abigail@alexandra.foad.org>
Chris Coffey (ccoffey@nims.wr.usgs.gov) wrote on MMDXIX September
MCMXCIII in <URL:news:Pine.LNX.4.10.10007241545420.16468-100000@nims.wr.usgs.gov>:
,, I hope this isn't a stupid question, but how would I print every 91st
,, line in one file? To clarify, I want to first print the 8th line and then
,, every 91st line after that. I don't think it's possible to increment the
,, $. operator is it? Thanks in advance for your he
perl -nwe 'print if 8 == $. % 91' file
Abigail
--
:;$:=~s:
-:;another Perl Hacker
:;chop
$:;$:=~y
:;::d;print+Just.
$:;
------------------------------
Date: Mon, 24 Jul 2000 18:20:35 -0500
From: Murari Gopalan <mgopalan@students.uiuc.edu>
Subject: INfo on the environment variables
Message-Id: <Pine.GSO.4.10.10007241817220.7191-100000@ux13.cso.uiuc.edu>
I need more info on %ENV. more specifically i need info on the varius env
variables accessible through this hash... is there any online
documentation for this. ive been browsing www.perl.com but have not found
anything that helps...
Thanks for your help..
--m.
------------------------------
Date: 24 Jul 2000 18:23:00 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: INfo on the environment variables
Message-Id: <8lij4k$f9p$1@provolone.cs.utexas.edu>
In article <Pine.GSO.4.10.10007241817220.7191-100000@ux13.cso.uiuc.edu>,
Murari Gopalan <mgopalan@students.uiuc.edu> wrote:
>
>I need more info on %ENV. more specifically i need info on the varius env
>variables accessible through this hash... is there any online
>documentation for this. ive been browsing www.perl.com but have not found
>anything that helps...
First please mention what operating system you're using. It depends on
the operating system. For instance, Unix is a multi-user operating
system and each user has their own home directory. On Unix systems,
HOME is an environment variable that gives the pathname to that
directory. Single-user systems don't have the notion of a home
directory, though, so they don't have a HOME environment variable.
- Logan
------------------------------
Date: Mon, 24 Jul 2000 23:41:26 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: INfo on the environment variables
Message-Id: <MPG.13e7717f5e010f1b989686@news>
Murari Gopalan writes ..
>I need more info on %ENV. more specifically i need info on the varius env
>variables accessible through this hash... is there any online
>documentation for this. ive been browsing www.perl.com but have not found
>anything that helps...
the environment is system dependant .. just print yours out to see what
you have available
print "$_\t=> $ENV{$_}\n" for sort keys %ENV;
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Mon, 24 Jul 2000 19:10:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: INfo on the environment variables
Message-Id: <slrn8npj71.9vp.tadmc@magna.metronet.com>
On Mon, 24 Jul 2000 18:20:35 -0500, Murari Gopalan <mgopalan@students.uiuc.edu> wrote:
>I need more info on %ENV. more specifically i need info on the varius env
>variables accessible through this hash...
Then you do not need info on Perl's %ENV hash, you need info
on the environment of whatever Operating System you happen
to be using.
Perl just passes through whatever your OS uses.
>is there any online
>documentation for this. ive been browsing www.perl.com but have not found
>anything that helps...
Because it is not a Perl question, it is an OS question.
So try searching in places related to your OS.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 24 Jul 2000 16:07:42 -0700
From: "mrhodes" <mrhodes@rez.com>
Subject: Loading of an array
Message-Id: <8lii7v$208j$1@baraddur.anasazi.com>
I am running a program within my program that returns a list of tables
that need reextenting in my a database. The list consist of a
(dbname,tablename,extent#, sizeofextent). How can I store this in perl do I
use a hash or just a two diminsional array or is a hash a 2d array in perl?
Also once I figure out the correct structure what would be a good way to
load array.
Thanks for your help;
Michael Rhodes
Database Engineer
Sample List:
test_db|msg_body|5.0|77352.0|
test_db|msg_que|4.0|6304.0|
test_db|sysindexes|4.0|32.0|
test_db|srp_ginv|3.0|7232.0|
test_db|prop_astat|3.0|4864.0|
test_db|sysobjstate|3.0|24.0|
test_db|systables|3.0|24.0|
test_db|client|2.0|1040.0|
test_db|inv_iextra|2.0|832.0|
Current code:
use POSIX qw(locale_h tmpnam);
use strict;
use Cmd;
use UI;
use Page;
use msg::sql;
use CGI qw(:standard);
use CGI::Carp qw(carpout fatalsToBrowser);
my @tabextent = ();
my $dbaccess = &sysmaster("select dbsname Database, tabname Table,
count(*) Extents,sum( pe_size ) Total_Size from systabnames,
sysptnext w
here partnum = pe_partnum and dbsname = 'test_db' group by 1,2 order by 3
desc
, 4 desc");
# print &start_output();
while (<$dbaccess>) {
my ($dbname) = split('\|'); # cvt called
print $_;
if (defined $dbname) {
push(@tabextent, $dbname);
}
# print &end_output();
}
------------------------------
Date: 24 Jul 2000 18:19:53 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Loading of an array
Message-Id: <8liiup$f8u$1@provolone.cs.utexas.edu>
In article <8lii7v$208j$1@baraddur.anasazi.com>,
mrhodes <mrhodes@rez.com> wrote:
> I am running a program within my program that returns a list of tables
>that need reextenting in my a database. The list consist of a
>(dbname,tablename,extent#, sizeofextent). How can I store this in perl do I
>use a hash or just a two diminsional array or is a hash a 2d array in perl?
>Also once I figure out the correct structure what would be a good way to
>load array.
>Sample List:
>
>test_db|msg_body|5.0|77352.0|
>test_db|msg_que|4.0|6304.0|
>test_db|sysindexes|4.0|32.0|
>test_db|srp_ginv|3.0|7232.0|
>test_db|prop_astat|3.0|4864.0|
>test_db|sysobjstate|3.0|24.0|
>test_db|systables|3.0|24.0|
>test_db|client|2.0|1040.0|
>test_db|inv_iextra|2.0|832.0|
Perl doesn't really have two-dimensional arrays. Instead, it has one
dimensional arrays whose values can be references to arrays. This is a
pretty good substitute for two dimensional arrays, but it's not exactly
the same thing.
One way to store your data would be as an array full of elements which
are references to (anonymous) arrays. The anonymous arrays would then
contain the data for each row in the list you gave above.
You could read the stuff in by using "split" to build an array
from your string based on delimiters. Something like this:
while (<>)
{
@row = split (/|/);
push @allrows, [@row];
}
>Current code:
Also, based on this code (which I've deleted), it looks like you're
trying to parse data that is actually coming back from a database in
the first place. In that case, you probably want to consider using DBI
(and a DBD driver module) to access your database, because with DBI,
you can do database queries and get the results back in a format that
won't have to be parsed.
Hope that helps.
- Logan
------------------------------
Date: Mon, 24 Jul 2000 17:12:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Loading of an array
Message-Id: <MPG.13e67b27d677a76c98abe3@nntp.hpl.hp.com>
In article <8liiup$f8u$1@provolone.cs.utexas.edu> on 24 Jul 2000
18:19:53 -0500, Logan Shaw <logan@cs.utexas.edu> says...
...
> You could read the stuff in by using "split" to build an array
> from your string based on delimiters. Something like this:
>
> while (<>)
> {
> @row = split (/|/);
> push @allrows, [@row];
> }
Something like that, but not that. `perldoc perlre` to see what that
split is really using.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 24 Jul 2000 22:18:32 GMT
From: "Zaqwer" <webbk@usa.net>
Subject: Need a job
Message-Id: <Yg3f5.5649$5N1.183038@newsread1.prod.itd.earthlink.net>
Hi friends ! First, apologies if this does not belong here.
Next: I have been doing Perl/CGI scripting for about a year and half now in
an academic institution. I want an entry level commercial job in the Silicon
Valley. Can anybody give me some pointers on how to get one. TIA.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3790
**************************************