[18370] in Perl-Users-Digest
Perl-Users Digest, Issue: 538 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 20 21:05:55 2001
Date: Tue, 20 Mar 2001 18:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985140312-v10-i538@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 20 Mar 2001 Volume: 10 Number: 538
Today's topics:
[Q] Avoid stripping of command line quotes (Brian R. Jones)
Re: [Q] Avoid stripping of command line quotes <tony_curtis32@yahoo.com>
Re: [Q] Avoid stripping of command line quotes <juex@deja.com>
Re: [Q] Avoid stripping of command line quotes <krahnj@acm.org>
Re: CGI.pm question/problem & other question. <philipg@atl.mediaone.net>
eval problem (Brcin)
Re: files in a directory <tony_curtis32@yahoo.com>
Re: files in a directory <VincentMurphy@mediaone.net>
Hash Problem Redux <jason.baker@stdbev.com>
Re: IPC: where to start? (David Efflandt)
Re: Moving and mkdir in Unix <mjcarman@home.com>
Re: Need help with perl4 && syntax. (Randal L. Schwartz)
Re: Need help with perl4 && syntax. <bart.lateur@skynet.be>
Re: New Perl Bulletin Board available <brondsema@my-deja.com>
Re: newlines in string in Win 32?? <kevin@vaildc.net>
Perl 5.6 - Spinning cursor routine? <dennis.moreno@pop.safetran.com>
Re: Perl 5.6 - Spinning cursor routine? <wuerz@yahoo.com>
Re: Perl 5.6 - Spinning cursor routine? <philipg@atl.mediaone.net>
Re: perl hacker wanted (Jim Kroger)
Re: pretty print cron? (John McNamara)
Re: Print "tar" Success or Failure <peter.sundstrom-eds@eds.com>
Re: Print "tar" Success or Failure (BUCK NAKED1)
Re: Print To Same Line - No Carriage Return (Miguel Cruz)
Re: Print To Same Line - No Carriage Return <wuerz@yahoo.com>
Re: split array and assign fields in sub? <dp@dsoft.com>
Still can't die with Tar (BUCK NAKED1)
Re: substitution for /^[\w\.]\w*/ (Randal L. Schwartz)
Re: substitution for /^[\w\.]\w*/ <tltabor@earthlink.net>
Re: substitution/pattern matching -- setting the positi <bart.lateur@skynet.be>
Re: substitution/pattern matching -- setting the positi (J.B. Moreno)
Re: substitution/pattern matching -- setting the positi (J.B. Moreno)
Re: Win32::TieRegistry <carvdawg@patriot.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Mar 2001 00:40:15 +0000 (UTC)
From: jonesbr@roger.ecn.purdue.edu (Brian R. Jones)
Subject: [Q] Avoid stripping of command line quotes
Message-Id: <998t9f$92$1@mozo.cc.purdue.edu>
Hello!
I'm probably missing something absolutely trivial, but how does
one tell perl _not_ to strip double quotes out of command line
arguments? For example, say I have the following script called
tst.pl:
#!/usr/bin/perl -w
foreach (@ARGV) { print "$_\n" }
exit;
Execute script: tst.pl "hello"
Actual output: hello
Desired output: "hello"
I can't use \Q\E because @ARGV has already stripped the quotes
before I can ever access it... what simple trick am I missing?
Many thanks for the help!
-Brian
------------------------------
Date: 20 Mar 2001 19:00:00 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: [Q] Avoid stripping of command line quotes
Message-Id: <87ofuwrl67.fsf@limey.hpcc.uh.edu>
>> On Wed, 21 Mar 2001 00:40:15 +0000 (UTC),
>> jonesbr@roger.ecn.purdue.edu (Brian R. Jones) said:
> Hello! I'm probably missing something absolutely
> trivial, but how does one tell perl _not_ to strip
> double quotes out of command line arguments?
You're out of luck. It's the shell that eats the quotes,
not perl. To tell the shell not to mess with them, you
could:
$ perl script.pl '"hello world"'
There are other ways of protecting the quotes, but if you
want to follow up to that, try e.g. comp.unix.shells or
check the documentation for your particular shell.
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: Tue, 20 Mar 2001 17:21:02 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: [Q] Avoid stripping of command line quotes
Message-Id: <3ab801fe$1@news.microsoft.com>
"Brian R. Jones" <jonesbr@roger.ecn.purdue.edu> wrote in message
news:998t9f$92$1@mozo.cc.purdue.edu...
> Hello!
>
> I'm probably missing something absolutely trivial, but how does
> one tell perl _not_ to strip double quotes out of command line
> arguments? For example, say I have the following script called
> tst.pl:
You can't because the shell strips them out before Perl ever has a chance to
see them.
Only option: tell the shell that they are part of the string by either
escaping the quotes or enclosing the string in 'the other set of quotes'.
For details please check the manual of your favorite shell.
jue
------------------------------
Date: Wed, 21 Mar 2001 01:11:37 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: [Q] Avoid stripping of command line quotes
Message-Id: <3AB8014C.8802C2AD@acm.org>
"Brian R. Jones" wrote:
>
> Hello!
>
> I'm probably missing something absolutely trivial, but how does
> one tell perl _not_ to strip double quotes out of command line
> arguments? For example, say I have the following script called
> tst.pl:
>
> #!/usr/bin/perl -w
> foreach (@ARGV) { print "$_\n" }
> exit;
>
> Execute script: tst.pl "hello"
Execute script: tst.pl \"hello\"
> Actual output: hello
> Desired output: "hello"
>
> I can't use \Q\E because @ARGV has already stripped the quotes
> before I can ever access it... what simple trick am I missing?
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 21 Mar 2001 01:07:58 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: CGI.pm question/problem & other question.
Message-Id: <O9Tt6.137792$__6.25344734@typhoon.southeast.rr.com>
Tina Mueller <tinamue@zedat.fu-berlin.de> wrote in message
news:9983nr$49l0$1@fu-berlin.de...
> hi,
> In comp.lang.perl.misc Philip Garrett <philipg@atl.mediaone.net> wrote:
>
> > Jon DeCamp <jondecamp@home.com> wrote in message
> > news:3AB6C3CE.A9D9C72B@home.com...
> >> Greetings,
> >>
> >> Question #1: A CGI script that I am writing in perl could probably go
for
> > the
> > [snip]
>
> > my $q = CGI->new;
> > my %params = map { $_ => $q->param($_) } $q->param;
>
> my %params = map { $_ => [$q->param($_)] } @list;
Granted. However, if you don't want to have to access each value as an
array ref, you might want to do:
my %params = map {
my @v = $q->param($_);
$_ => ( @v == 1 ) ? @v : \@v
} $q->param;
p
------------------------------
Date: Wed, 21 Mar 2001 01:23:13 GMT
From: info@ultraviolet.li (Brcin)
Subject: eval problem
Message-Id: <5oTt6.62$98.3110@news.siol.net>
...
eval
{
$result = &sendmail ($email, "subject", "body");
};
if ($@)
{
print "Problems..";
}
else
{
print "Mail sent.";
}
...
This is a part of my cgi script. The problem is this: if the mail address
exists, the script will send the mail and the browser will display "Mail
sent." However, if the address is inexistent, the browser displays
"Internal server error" instead of "Problems.." What am I missing here?
------------------------------
Date: 20 Mar 2001 19:07:06 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: files in a directory
Message-Id: <87k85krkud.fsf@limey.hpcc.uh.edu>
>> On Tue, 20 Mar 2001 21:39:15 GMT,
>> "Waarddebon" <Waarddebon@chello.nl> said:
> How to place all files in a given directory in a string
Do you mean the names of the files, or the contents of the
files?
I'll assume the former: see
perldoc -f glob
or
perldoc -f opendir/readdir/grep/closedir
if you want more direct access and/or name filtering.
Pulling the names into an array seems more logical if you
need to iterate over them in any way subsequently, but
maybe you don't need that.
For the latter case, you need to iterate over the files,
open them and slurp in the contents, appending to a buffer
variable.
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: Wed, 21 Mar 2001 02:02:39 GMT
From: Vinny Murphy <VincentMurphy@mediaone.net>
Subject: Re: files in a directory
Message-Id: <m3wv9jop5f.fsf@vmurphy-hnt1.athome.net>
>>>>> "Waarddebon" == Waarddebon <Waarddebon@chello.nl> writes:
Waarddebon> How to place all files in a given directory in a string ?
perl -e 'opendir(D,".");$str = join(" ", grep -f, readdir(D)); print $str'
perldoc -f closedir
perldoc -f join
perldoc -f opendir
perldoc -f readdir
--Vinny
------------------------------
Date: Tue, 20 Mar 2001 19:35:49 -0600
From: "Jason" <jason.baker@stdbev.com>
Subject: Hash Problem Redux
Message-Id: <tbg1fqgonkec22@news.supernews.com>
Well, we got the file into a hash using the code snippit that Ciaran
McCreesh posted (thanks), but now we have a new problem. As soon as we exit
that while loop, the variable is lost. Is this problem addressed
somewhere? I would think it to be a scoping issue, but when we do research
on scoping, it only ever mentions subroutines and foreach loops.
Jason
www.cyborgworkshop.com
...and the geek shall inherit the earth...
------------------------------
Date: Wed, 21 Mar 2001 01:55:45 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: IPC: where to start?
Message-Id: <slrn9bg2h4.bru.efflandt@efflandt.xnet.com>
On Mon, 19 Mar 2001 17:21:55 +0100, Marc Beck <marc.beck@bigfoot.com> wrote:
>Hello,
>
>I would like to write a daemon that can receive messages from other perl
>programs. These messages are simple arrays. Are the IPC::? modules the
>right place to look at ... and which of them is the one I need?
A good place to start is typing: perldoc perlipc
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Tue, 20 Mar 2001 17:10:29 -0600
From: Michael Carman <mjcarman@home.com>
To: ted <tlav1@mediaone.net>
Subject: Re: Moving and mkdir in Unix
Message-Id: <3AB7E365.AE9BA2F9@home.com>
[Post reordered to follow the arrow of time.]
ted wrote:
> Michael Carman wrote:
>
> > Here's what you think you said:
> >
> > "I don't think I have the documentation, so please take pity on
> > a poor soul and help me out."
> >
> > Here's what that sounds like on Usenet:
> >
> > "I don't think I have the documentation, and I'm too lazy to
> > look for it. I'd rather have you read it to me. Better yet,
> > fix my problem for me."
> >
> > Not quite the same, huh? [...]
>
> Granted these types of questions can be irksome and take up
> valuable space that might otherwise be used for better purposes,
> but aren't we better off just ignoring them instead of taking up
> even more space by replying with lengthy, truculent diatribes that
> help no one?
My hope is that they those diatribes *will* help. If someone out there
reads my post and thinks, "Man, I never realized what I bum I sound like
when I post before checking the docs. From now on I'll look there
first." then I'll have accomplished something.
-mjc
------------------------------
Date: 20 Mar 2001 15:22:43 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Need help with perl4 && syntax.
Message-Id: <m1ae6gm3ek.fsf@halfdome.holdit.com>
>>>>> "Vjay" == Vjay Lescoe <vjayl@emc.com> writes:
Vjay> if (! ( -f $CPUTMPFILE/CPUALARM_$DM ) && ( $CPUIDLE < $CPUALARM ) )
Why are you dividing $CPUTMPFILE by CPUALARM_ ... and then what's this
$DM hanging in there? That seems pretty... messed up.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 21 Mar 2001 00:31:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Need help with perl4 && syntax.
Message-Id: <ektfbt03im5n0dlcak312nj9uqr9mcf2pf@4ax.com>
Vjay Lescoe wrote:
>if (! ( -f $CPUTMPFILE/CPUALARM_$DM ) && ( $CPUIDLE < $CPUALARM ) )
Are you missing some quotes?
--
Bart.
------------------------------
Date: Tue, 20 Mar 2001 23:52:08 GMT
From: "Dave Brondsema" <brondsema@my-deja.com>
Subject: Re: New Perl Bulletin Board available
Message-Id: <I2St6.79728$W05.16043535@news1.rdc1.mi.home.com>
> Date: Sat, 18 Aug 2001 00:56:19 -0400
How about fixing your date?
"necro" <necrorising@hotmail.com> wrote in message
news:tatrntorqhh6euddn6cg280m23pu72s3cb@4ax.com...
> New Perl Bulletin Board available
>
> The MotherBoard is now available! Get the freedom and versatility of a
> high end bulletin board, at cut rate prices.
>
> http://www.worldwidecreations.com
------------------------------
Date: Tue, 20 Mar 2001 20:28:06 -0500
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: newlines in string in Win 32??
Message-Id: <kevin-A3A6EC.20280620032001@vienna7.his.com>
In article <3ab7687f.514245085@news3.mylinuxisp.com>,
cryofan@mylinuxisp.com (cRYOFAN) wrote:
> I am testing this program on win 32 before moving it to UNix.
>
> What I am trying to do is search a web page that I have loaded into a
> string for certain phrases. But I can't do it because somehow the
> string has all these embedded newlines in it. I don't know how they
> got there. And I can't get rid of them. I have tried all sorts of
> substitution regexes to no effect. I cannot seem to get rid of all
> these newlines. They come after each word, so that when I print the
> string, it is a whole bunch of lines, instead of being on one line.
>
> As it is, I cannot search for 2 word phrases.
>
> Here is the code:
>
> local( *URL_temp) = @_;
> open file1, ">>file1.txt";
> foreach $newpageURL (@URL_temp)
> {
> print file1 "\n **3 $newpageURL ";
> sleep(2);
> $page= $newpageURL;
> $urlcontent = get($page);
> I have tried to replace all instances of "\n" with a large string, to
> no effect. I have to tried to sub a single space for a newline, to no
> effect. I have tried using the s and m option, to no effect.
>
>
>
> The output is shown at the bottom:
>
>
> $urlcontent =~ s/\\n/fggggggggggggggggggggggggggggggggggggg/g;
^^
You only need one backslash here. Putting two of them is searching for
a backslash followed by an "n".
> print "\n **3 $urlcontent ";
> print file1 "\n **3 $urlcontent ";
>
> sleep 3;
>
[rest snipped]
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: Wed, 21 Mar 2001 00:37:14 GMT
From: dennis <dennis.moreno@pop.safetran.com>
Subject: Perl 5.6 - Spinning cursor routine?
Message-Id: <3AB7F7B9.E7CE4C71@pop.safetran.com>
Does anyone know wher to get a routine that would display
a stationary spinning cursor while a program is processing?
Thanks
Dennis
------------------------------
Date: Wed, 21 Mar 2001 01:49:55 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: Perl 5.6 - Spinning cursor routine?
Message-Id: <210320010149558681%wuerz@yahoo.com>
In article <3AB7F7B9.E7CE4C71@pop.safetran.com>, dennis
<dennis.moreno@pop.safetran.com> wrote:
> Does anyone know wher to get a routine that would display
> a stationary spinning cursor while a program is processing?
What kind of cursor? Graphic cursor/mouse pointer, text cursor, spinnig
line like -\|/-\|/-...? On a dumb terminal or on a Palm?
Maybe perlfaq8
"How do I do fancy stuff with the keyboard/screen/mouse?"
can help you - maybe you'll find help in the current thread
"Print To Same Line - No Carriage Return"
- or you need to state more clearly what you want.
-mona
------------------------------
Date: Wed, 21 Mar 2001 01:24:19 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Perl 5.6 - Spinning cursor routine?
Message-Id: <7pTt6.137796$__6.25367394@typhoon.southeast.rr.com>
dennis <dennis.moreno@pop.safetran.com> wrote in message
news:3AB7F7B9.E7CE4C71@pop.safetran.com...
> Does anyone know wher to get a routine that would display
> a stationary spinning cursor while a program is processing?
>
Here's a quick example of how you could do the stationary cursor. Of
course, in the real world, you would use the twinkle function as a callback,
and call it every time something's happened.
#!/usr/bin/perl -w
use strict;
use Time::HiRes qw(sleep);
{
my @cursors = qw( - \ | / );
my $current = 0;
sub twinkle {
local($|) = 1;
print "\b$cursors[$current]";
$current = ++$current % @cursors;
}
}
# go for 10 seconds
alarm(10);
$SIG{'ALRM'} = sub { exit };
while (1) {
twinkle;
sleep .02;
}
hth,
p
------------------------------
Date: Tue, 20 Mar 2001 18:31:49 -0500
From: minorseventhSPAMBLOCK@earthlink.net (Jim Kroger)
Subject: Re: perl hacker wanted
Message-Id: <minorseventhSPAMBLOCK-2003011831490001@tritone.csbmb.princeton.edu>
In article <m3n1aktdlr.fsf@mumonkan.sunstarsys.com>, Joe Schaefer
<joe+usenet@sunstarsys.com> wrote:
> items for sale, _or a job opening_, _in an appropriate newsgroup_
Hm, it appears the collective documentation has not left this open to
interpretation as I had thought. I am corrected, and will go sit in my
corner until such time as I feel rehabilitated.
Thanks
Jim
------------------------------
Date: Tue, 20 Mar 2001 23:27:58 GMT
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: pretty print cron?
Message-Id: <3ab7e592.5805671@news1.eircom.net>
Ar 16 Mar 2001 20:18 GMT, do scriobh jtschetter@nospam.vermeermfg.com:
>Does anyone have or know of a script that will take a crontab as input and
>output some format that "user" could understand? It wouldn't really
>matter if it was text or html or whatever.
http://cpan.valueclick.com/authors/id/S/SB/SBURKE/crontab2english_0.61.pl
From the docs:
Example output:
% crontab2english | less
Setting env var MAILTO to hulahoops@polygon.int
Command: (line 2)
Run: /bin/csh -c 'perl ~/thang.pl | mail -s hujambo root'
At: 8:10am on the 15th of every month
Command: (line 5)
Run: df -k
At: 5:40am every day
Command: (line 7)
Run: ls -l /tmp
At: 6:50am every Monday
Yet another useful piece of code from Sean Burke.
John.
--
"The Mosaic code has replaced the law of the jungle."
James Joyce - Ulysses
------------------------------
Date: Wed, 21 Mar 2001 10:41:02 +1200
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: Print "tar" Success or Failure
Message-Id: <998ma9$47b$1@hermes.nz.eds.com>
"What A Man !" <whataman@home.com> wrote in message
news:3AB6E66B.250B4059@home.com...
> Garry Williams wrote:
> >
>
> > >> Run the command from the command line and examine the exit code.
> > >>
>
> > Every command returns an exit value. (There is no way for a command
> > to return "nothing".) You can print it by using the following command
> > from most shells:
> >
> > echo $?
>
> I got nothing for success and 1 for failure. One time I got a 255. I
> don't know what that was.
*All* Unix commands return a status code. They do *not* return nothing for
success, they generally return 0.
------------------------------
Date: Tue, 20 Mar 2001 19:09:45 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Print "tar" Success or Failure
Message-Id: <16480-3AB7FF59-199@storefull-241.iap.bryant.webtv.net>
> peter.sundstrom-eds@eds.com
> *All* Unix commands return a status
> code. They do *not* return nothing for
> success, they generally return 0.
Thank You!!! That's one of the first things that I needed to know. Now
why didn't someone just say that as plainly as you did? :) That I can
understand. So... tar returns 0 if successful. Then, it seems only
logical that tar would return a nonzero value when unsuccessful. Now, at
least, I'm on first base. :-)
However, I am getting a value of "0" out of $?, whether my "tar"
operation is successful or not. On failure, it also prints a child
status of either "1" or "3"... now that's the confusing part... and what
I need to understand in order to stay on first base, without sliding
off.
Anyway, somehow this thread got out of order, and it was too long anyway
so I started a new thread entitled "still can't die with Tar". If you
choose to respond further, you may want to respond to that newer thread
instead.
Thanks for your response,
--Dennis
------------------------------
Date: Wed, 21 Mar 2001 00:32:20 GMT
From: mnc@admin.u.nu (Miguel Cruz)
Subject: Re: Print To Same Line - No Carriage Return
Message-Id: <oESt6.1388$Vl6.838443@typhoon1.ba-dsg.net>
Steve Reiss <NoSPAM@netmind.com> wrote:
> I need to print out the progress of an operation as it iterates
> through its loop. I want to print this out on the same line so there
> is no advancement of the row & column.
>
> In other words, how do I print to the same row & column without a
> carriage return?
Actually, you want a carriage return ("\r"). What you don't want is a newline
("\n").
On old printers, a carriage return was when the print head returned to its
position at the left edge of the page. Then a newline was when the paper was
advanced one line.
In unix, lines are normally terminated by just a newline (in DOS/Windows
they use one of each, which is strictly speaking more historically correct,
but a pain to work with). But you can always send a \r and any text
following will overprint the current line.
miguel
------------------------------
Date: Wed, 21 Mar 2001 01:41:24 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: Print To Same Line - No Carriage Return
Message-Id: <210320010141247910%wuerz@yahoo.com>
In article <oESt6.1388$Vl6.838443@typhoon1.ba-dsg.net>, mnc@admin.u.nu
(Miguel Cruz) wrote:
> But you can always send a \r and any text
> following will overprint the current line.
That's not correct for just any OS/perl implementation. One other way
that I have found to be working is to overprint the output thus far
character-by-character with ASCII 8 - but I don't know how portable
that is, either.
Then, there's always Term::Cap.
-mona
------------------------------
Date: Tue, 20 Mar 2001 23:30:10 GMT
From: Daniel <dp@dsoft.com>
Subject: Re: split array and assign fields in sub?
Message-Id: <B6DD2801.A42%dp@dsoft.com>
Paul,
Thanks for the idea, but that is what I an doing now and trying to avoid.
Currently doing this and it works.
local($sku, $name, $partnum, $descrip, $cpu, $stock, $list, $price, $weight,
$image, $longdesc, $feat, $group, $subgroup) =
split(/\|/,$database_rows[$i]);
Would rather do this, but have not been able to get it to work.
@database_rows = &split_db($database_rows[$i]);
I want to be able to change the fields in one place. eg. I have one
subroutine that reads in the file into @LINES and returns the array. Then
the another subroutine that matches the
items and passes them to @database_rows array. Then a subroutine that
displays the @database_rows arrays as fields.
Last post I left a few things out to make it easier, but I have included
them this time. Any help would be greatly appreciated.
#!/usr/bin/perl -w
use strict;
sub list_items {
print "HTML Stuff";
local(@database_rows);
@database_rows = &load_productdb;
my($max) = $pos + $numtolist;
if ($max > $SIZE2) {
$max = $SIZE2;
}
for ($i=$pos;$i<$max;$i++) {
@database_rows = &split_db($database_rows[$i]);
&disp_item;
}
print "more HTML Stuff";
}
sub split_db {
($sku, $name, $partnum, $descrip, $cpu, $stock, $list, $price) =
split(/\|/,$_);
return ($_);
}
sub disp_item {
print "<tr><td><a href=\"$adminurl\?command=edit\">$sku</a></td>";
print "<td>$name</td>";
print "<td>$partnum</td>";
print "<td>$descrip</td>";
print "<td>$cpu</td>";
print "<td>$stock</td>";
print "<td>$list</td>";
print "<td>$price</td></tr>";
}
sub load_productdb {
local(@LINES)=&open_productdb;
$SIZE=@LINES;
for ($i=0;$i<$SIZE;$i++) {
my($sku, $name, $partnum, $descrip, $cpu, $stock, $list, $price) =
split(/\|/,$LINES[$i]);
if ($type eq 'all') {
push(@database_rows, join("\|", $LINES[$i]));
}
if ($type eq 'search') {
if (index(lc $_,lc $FORM{'search'}) >= 0) {
push(@database_rows, join("\|", $LINES[$i]));
}
}
}
$SIZE2=@database_rows;
return @database_rows;
}
sub open_productdb {
open (FILE,"$basepath$delim$productdb") || die "Content-type:
text/html\n\nCan't open $productdb (w) $!\n";
my(@LINES)=<FILE>;
close(FILE);
return @LINES;
}
------------------------------
Date: Tue, 20 Mar 2001 18:44:53 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Still can't die with Tar
Message-Id: <11237-3AB7F985-124@storefull-246.iap.bryant.webtv.net>
Thanks to all of you who have spent time trying to help me on this...
However, I've been working on this for 12 hours since yesterday and
still can't figure it out after re-studying all the suggested docs. I've
tested, and tested, and tested, and tested.
I understand that I need to use system to get the return value of tar,
and the child return value is in $?, but I never could get qw to work
with tar after testing it for awhile. Maybe I don't need to use qw
anyway.
Anyhow, it looks like the value of tar is 0 when it is successful, and 1
when tar fails. If this is incorrect, please tell me what the value of
tar is on success and on failure because I could not get those shell
commands that were suggested to give a proper value in some instances.
Finding the value of tar and printing success or failure messages
accordingly, appears to be a child problem. Can someone please just give
me a good example, and explain why the example works? That's how I learn
best, and I can't find even one good example on the net anywhere,
including the perl docs.
FWIW... Here's where I'm still at... if you're still willing to help.
!(system("tar -zxf file.tar.gz")) and print "SUCCESS: $?\n" || print
"FAILURE: $?\n"; unlink $tmpfile; exit 1;
Note: the suggestions used above... "!" used to negate tar; "system"
used instead of backticks to get the value; "$?" to see what the value
of the child process returns; and an "exit 1" (my idea) so that it will
exit the program if tar fails.
Of course, it still doesn't work.<sigh>
Thanks anyway,
--Dennis
------------------------------
Date: 20 Mar 2001 15:27:18 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: substitution for /^[\w\.]\w*/
Message-Id: <m13dc8m36x.fsf@halfdome.holdit.com>
>>>>> "Michael" == Michael Carman <mjcarman@home.com> writes:
Michael> As for Randal, he's pretty focused on helping the Perl
Michael> community, and obviously found it offensive that he was being
Michael> "tricked" into helping someone with JavaScript instead.
No, it's just that my hard work is wasted, at least for the OP, since
I was coding in a language he wasn't running. Yet I didn't know that.
I was conned.
Michael> I can understand why he'd feel that way. On top of that, he
Michael> seems a bit grouchy today. ;)
Can you say "stressed-out getting llama3 out to technical review so
that we have it in time for TPC5"? Sure you can. :-)
print "Just another Perl book hacker,";
P.S. no, we don't need any more reviewers.
P.P.S. This is not considered an official announcement by O'Reilly and
Associates, its heirs or assigns. This is merely one lone man
wailing in the distance about the stress he's feeling and
why. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 21 Mar 2001 00:30:12 GMT
From: "Tim Tabor" <tltabor@earthlink.net>
Subject: Re: substitution for /^[\w\.]\w*/
Message-Id: <oCSt6.14639$Im6.1511215@newsread1.prod.itd.earthlink.net>
"Michael Carman" <mjcarman@home.com> wrote >
> As for Randal, he's pretty focused on helping the Perl community, and
> obviously found it offensive that he was being "tricked" into helping
> someone with JavaScript instead. I can understand why he'd feel that
> way.
If he felt tricked (or 'conned'), I can understand it too. On the other
hand, there must
be some history here which would color the understanding. People never
fully disclose the context of their questions - not because its a secret,
but because they're not relevant to the answer. And that's what I did.
Nor didid I disclose that I'm wearing blue pants and a white shirt today.
It didn't even occur to me that someone might not help if they knew that
Perl wasn't the last stop on the linguistic train.
> if you send me a message via email, I'll respond via email.
> But if you've also posted to a newsgroup I should respond there instead.
> If you don't tell me that you've done both, I have no way of knowing
> that.
>
Makes good sense.
> Most seasoned Usenauts take that sort of stuff as flamebait (even from
> one as respected as Randal) and ignore it. That doesn't justify it, but
> does explain the silence. Let it slide -- it's not worth the stress.
>
Where I come from, people's mistakes don't justify bad manners, much
less outright abuse. And I suspect that many more seasoned Usenauts
share the same values.
Thank you very kindly for the explanation.
// tim
------------------------------
Date: Tue, 20 Mar 2001 23:38:23 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: substitution/pattern matching -- setting the position...
Message-Id: <9dpfbtkku9rge2i8llm9tq3lbct18rl315@4ax.com>
J.B. Moreno wrote:
>Is there any way to tell a global substition to start the next search at
>the same place it started the last one when it has made a SUCCESSFUL
>match?
>while ($chat =~ s/\n([hv][^ ]+ )(.+)\n\n\1/\n\1\2 /ig) {
>};
Apparently, you want lookahead. Hoever, that doesn't exist on the latest
MacPerl because it's too old.
$chat =~ s/^([hv]\S+ )(.*)\n\n(?=\1)/\1\2\n/mig;
So, what else can you do? Use perl code on the RHS, I guess. Store the
previous match in a variable, and use this variable instead of your
first subpattern to do the comparison. Does MacPerl already have /\G/?
You could use this to anchor at the end of the previous match, in one of
the alternatives for $1. Likely.
Bt I wouldn't do that. Personally, I'd break this data into an array of
lines, and skip empty lines if it's the same person talking. Untested:
@lines = split /\n/, $_, $chat;
my $person = '';
foreach(@lines) {
if(/^(\S+)/) {
print "\n" if $1 ne $person;
$person = $1;
print "$_\n";
}
}
--
Bart.
------------------------------
Date: Tue, 20 Mar 2001 20:49:50 -0500
From: planb@newsreaders.com (J.B. Moreno)
Subject: Re: substitution/pattern matching -- setting the position...
Message-Id: <1eql18u.7exb6fhexisbN%planb@newsreaders.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> J.B. Moreno wrote:
>
> >Is there any way to tell a global substition to start the next search at
> >the same place it started the last one when it has made a SUCCESSFUL
> >match?
>
> >while ($chat =~ s/\n([hv][^ ]+ )(.+)\n\n\1/\n\1\2 /ig) {
> >};
>
> Apparently, you want lookahead. Hoever, that doesn't exist on the latest
> MacPerl because it's too old.
Actually it does.
> $chat =~ s/^([hv]\S+ )(.*)\n\n(?=\1)/\1\2\n/mig;
You misunderstood what I wanted (probably because my example didn't
work, "[hv]" should have been "[js]"), what I want to do is to join
those lines (leaving out the name where appropriate).
> So, what else can you do? Use perl code on the RHS, I guess. Store the
> previous match in a variable, and use this variable instead of your
> first subpattern to do the comparison. Does MacPerl already have /\G/?
> You could use this to anchor at the end of the previous match, in one of
> the alternatives for $1. Likely.
Yeah, it has /\G/, but that's only _almost_ what I want, \G starts (or
so the documentation says) immediately *after* the start of the last
match, I want to start *at* the last match.
--
JBM
"Your depression will be added to my own" -- Marvin of Borg
------------------------------
Date: Tue, 20 Mar 2001 20:49:47 -0500
From: planb@newsreaders.com (J.B. Moreno)
Subject: Re: substitution/pattern matching -- setting the position...
Message-Id: <1eql11e.wkwzp117jez8kN%planb@newsreaders.com>
John W. Krahn <krahnj@acm.org> wrote:
> "J.B. Moreno" wrote:
> >
> > Is there any way to tell a global substition to start the next search at
> > the same place it started the last one when it has made a SUCCESSFUL
> > match?
> >
> > In this particular case I am trying to join several lines together, and
> > the only way I've found to do that is with a while statement.
-snip example-
> > works, but, using 5.004, if at all possible I'd like to do it without
> > the loop (it slows things down).
>
> Define "works". I tried your example and the variable $chat was not
> changed at all.
Sorry, changed the data set just before posting, and didn't change the
regex...
$chat = qß
john random blahness
john more random blah
john yet more blah
john hasn't any more blah for now
sally has random blah
sally has even more random blah
sally yet more blahß;
while ($chat =~ s/\n([js][^ ]+ )(.+)\n\n\1/\n\1\2 /ig) {
};
print $chat;
Compiles, works and shows what I'm looking for...
--
JBM
"Your depression will be added to my own" -- Marvin of Borg
------------------------------
Date: Tue, 20 Mar 2001 18:20:16 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: Win32::TieRegistry
Message-Id: <3AB7E5B0.D9836F07@patriot.net>
The ActiveState Perl docs on Win32::TieRegistry have such examples.
Carsten Landeck wrote:
> Does anybody has an small example for creating a remote registy key of a
> remote mashine using Win32:.TieRegistry ?
>
> Thanks
> Carsten
------------------------------
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 V10 Issue 538
**************************************