[18056] in Perl-Users-Digest
Perl-Users Digest, Issue: 216 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 5 14:15:56 2001
Date: Mon, 5 Feb 2001 11:15:29 -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: <981400529-v10-i216@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 5 Feb 2001 Volume: 10 Number: 216
Today's topics:
Redirecting stdout/stderr from a call to system() dave_vb@my-deja.com
Re: Redirecting stdout/stderr from a call to system() <amonotod@netscape.net>
Re: Redirecting stdout/stderr from a call to system() <bcaligari@my-deja.com>
Re: Redirecting stdout/stderr from a call to system() dave_vb@my-deja.com
Re: Redirecting stdout/stderr from a call to system() dave_vb@my-deja.com
Re: Redirecting stdout/stderr from a call to system() <amonotod@netscape.net>
Re: search and extract <shino_korah@yahoo.com>
Socket held open indefinitely by server <Info@Porphyrion.com>
Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
Super simple loop Q (really newbie)... <emelin@my-deja.com>
Re: Super simple loop Q (really newbie)... <tore@extend.no>
Re: Super simple loop Q (really newbie)... <ccx138@coventry.ac.uk>
Re: Super simple loop Q (really newbie)... <shino_korah@yahoo.com>
Re: This is driving me nuts and I need a guru <jwmsng@greatNOSPAMwebsolutions.com>
Re: This is driving me nuts and I need a guru <jwmsng@greatNOSPAMwebsolutions.com>
Re: Trouble with split gnari@my-deja.com
Re: Trouble with split (LK)
Re: Trouble with split <ren.maddox@tivoli.com>
Re: update page (Honza Pazdziora)
Re: using hash references to store values from multiple mirvine555@my-deja.com
Re: using hash references to store values from multiple (Anno Siegel)
Re: using hash references to store values from multiple mirvine555@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 05 Feb 2001 16:53:35 GMT
From: dave_vb@my-deja.com
Subject: Redirecting stdout/stderr from a call to system()
Message-Id: <95mlq8$2cb$1@nnrp1.deja.com>
I have a perl script which runs several shell commands (including a
couple C programs I've written) using system(). This perl script runs
from crontab, under Solaris, like so:
30 10 * * 1-6 /bindir/foo.pl >>/logdir/foo.log 2>&1
The output printed directly from foo.pl goes into foo.log, but the
output of the shell commands run with system() from within foo.pl
doesn't apear in the log file... how can I make sure this output also
goes to the log?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 05 Feb 2001 17:04:53 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Redirecting stdout/stderr from a call to system()
Message-Id: <95mmfc$319$1@nnrp1.deja.com>
In article <95mlq8$2cb$1@nnrp1.deja.com>,
dave_vb@my-deja.com wrote:
> I have a perl script which runs several shell commands (including a
> couple C programs I've written) using system(). This perl script runs
> from crontab, under Solaris, like so:
>
> 30 10 * * 1-6 /bindir/foo.pl >>/logdir/foo.log 2>&1
>
> The output printed directly from foo.pl goes into foo.log, but the
> output of the shell commands run with system() from within foo.pl
> doesn't apear in the log file... how can I make sure this output also
> goes to the log?
perldoc is your friend...
perldoc -q stderr
amonototd
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 05 Feb 2001 17:01:44 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Redirecting stdout/stderr from a call to system()
Message-Id: <95mm9f$2u6$1@nnrp1.deja.com>
In article <95mlq8$2cb$1@nnrp1.deja.com>,
dave_vb@my-deja.com wrote:
> I have a perl script which runs several shell commands (including a
> couple C programs I've written) using system(). This perl script runs
> from crontab, under Solaris, like so:
>
> 30 10 * * 1-6 /bindir/foo.pl >>/logdir/foo.log 2>&1
>
> The output printed directly from foo.pl goes into foo.log, but the
> output of the shell commands run with system() from within foo.pl
> doesn't apear in the log file... how can I make sure this output also
> goes to the log?
are you sure your utils are being executed? Try giving the fully
qualified path to the utils and avoid using ~ to mean your home
directory.
B
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 05 Feb 2001 17:26:31 GMT
From: dave_vb@my-deja.com
Subject: Re: Redirecting stdout/stderr from a call to system()
Message-Id: <95mnnp$4aj$1@nnrp1.deja.com>
In article <95mm9f$2u6$1@nnrp1.deja.com>,
Brendon Caligari <bcaligari@my-deja.com> wrote:
> In article <95mlq8$2cb$1@nnrp1.deja.com>,
> dave_vb@my-deja.com wrote:
>how can I make sure this output also
> > goes to the log?
>
> are you sure your utils are being executed? Try giving the fully
> qualified path to the utils and avoid using ~ to mean your home
> directory.
Yes, the output file from my C program's there with the right mdate...
it's log output's just not in the log file. I've also been using full
paths all along since the C program isn't in $PATH or even in the home
directory tree.
In case this helps, my system calls look like the following:
if(system "shell_cmd $FOOFILE $FOOFILE.old") {
die "Bummer\n";
}
... it's not dying, BTW :)
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 05 Feb 2001 17:29:44 GMT
From: dave_vb@my-deja.com
Subject: Re: Redirecting stdout/stderr from a call to system()
Message-Id: <95mntn$4dr$1@nnrp1.deja.com>
with system() from within foo.pl
> >how can I make sure this output also
> > goes to the log?
>
> perldoc is your friend...
>
> perldoc -q stderr
It says that the output from system should go the the same place as the
output from my perl script... that appears not to be happening in this
case. Uneless there's something I'm missing.
It also lists using backticks, but then I'd have to capture the output
in a variable and explicitly print it which seems like a stupid way to
do it to me so I'd like to avoid that.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 05 Feb 2001 17:49:34 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Redirecting stdout/stderr from a call to system()
Message-Id: <95mp3a$5jo$1@nnrp1.deja.com>
In article <95mntn$4dr$1@nnrp1.deja.com>,
dave_vb@my-deja.com wrote:
> with system() from within foo.pl
> > >how can I make sure this output also
> > > goes to the log?
> >
> > perldoc is your friend...
> >
> > perldoc -q stderr
>
> It says that the output from system should go the the same place as
the
> output from my perl script... that appears not to be happening in this
> case. Uneless there's something I'm missing.
> It also lists using backticks, but then I'd have to capture the output
> in a variable and explicitly print it which seems like a stupid way to
> do it to me so I'd like to avoid that.
>
> Sent via Deja.com
> http://www.deja.com/
>
perldoc -q stderr
(...)
To read both a command's STDOUT and its STDERR
separately, it's easiest and safest to redirect them
separately to files, and then read from those files when
the program is done:
system("program args 1>/tmp/program.stdout 2>/tmp/program.stderr");
(...)
You can also make your own:
close (STDERR);
close (STDOUT);
open (STDERR, "> /path/to/my_stderr.txt");
open (STDOUT, "> /path/to/my_stdout.txt");
(...)
close (STDERR);
close (STDOUT);
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 5 Feb 2001 09:50:45 -0800
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Re: search and extract
Message-Id: <95mp5n$jvf@news.or.intel.com>
just to write toa file
open (FD,">>filename");
ur for loop
{
print FD "$line\n";
}
close(FD);
hope it helps for ur first part of the problem
<ray_maharaj@my-deja.com> wrote in message
news:95kpe4$jvf$1@nnrp1.deja.com...
> I have a large file (500K) which I need to search...and extract matched
> lines out of....
> I have matched the lines to an array that holds the elements that I
> wish to search for....
> I can print the matched lines to STDOUT ....what I would like to do is
> print the matched lines to an out file and remove these matched lines
> from the original file....
> I have included a portion of my code that does some of this...I would
> gladly welcome your help....
>
> 37 @poppats = map{qr/\b$_\b/i}@popstates;
> 38 @whole=<$input>;
> 39 while (defined($line = @whole)) {
> 40 # foreach $patobj (@poppats) {
> 41 foreach $line (@whole) {
> 42 foreach $patobj (@poppats) {
> 43 if ($line =~ (/$patobj/)) {
> 44 print $line;
> 45 #print @whole;
>
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Mon, 5 Feb 2001 11:26:10 -0600
From: "Porphyrion" <Info@Porphyrion.com>
Subject: Socket held open indefinitely by server
Message-Id: <003C767B63BC3ADB.E71EC12C7FF88C27.12F2711A049ED1E5@lp.airnews.net>
Keywords: socket, Perl
I'm writing a web client. On a couple of web servers, at some random
occurances, the HTTP server holds open the socket indefinitely.
Here's the code (see below). The servers will hold the session for hours
sometimes on the line that begins: while (<$socket>).
Any suggestions on how to break out of a socket that is held indefinitely?
use IO::Socket;
if ($socket = IO::Socket::INET->new(PeerAddr => $domain,
PeerPort => $remote_port,
Proto => "tcp",
Type => SOCK_STREAM)) {
print $socket "$request";
while (<$socket>) {$reply = $reply . $_;}
close($socket);
} else {
print "Unable to connect to $remote_host:$remote_port : $@\n";
}
------------------------------
Date: Mon, 05 Feb 2001 16:08:25 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <t7tjvpfm8d147d@corp.supernews.com>
Following is a summary of articles spanning a 7 day period,
beginning at 29 Jan 2001 16:07:25 GMT and ending at
05 Feb 2001 14:29:15 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2001 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Excluded Posters
================
perlfaq-suggestions\@(?:.*\.)?perl\.com
Totals
======
Posters: 450
Articles: 1223 (471 with cutlined signatures)
Threads: 407
Volume generated: 2227.4 kb
- headers: 957.6 kb (19,251 lines)
- bodies: 1212.8 kb (39,986 lines)
- original: 828.6 kb (29,108 lines)
- signatures: 55.8 kb (1,382 lines)
Original Content Rating: 0.683
Averages
========
Posts per poster: 2.7
median: 1.0 post
mode: 1 post - 259 posters
s: 4.1 posts
Posts per thread: 3.0
median: 2 posts
mode: 1 post - 139 threads
s: 2.7 posts
Message size: 1864.9 bytes
- header: 801.7 bytes (15.7 lines)
- body: 1015.5 bytes (32.7 lines)
- original: 693.7 bytes (23.8 lines)
- signature: 46.7 bytes (1.1 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
41 71.5 ( 30.0/ 38.5/ 24.5) nobull@mail.com
33 63.1 ( 23.6/ 38.9/ 23.6) Garry Williams <garry@zvolve.com>
27 118.1 ( 20.6/ 96.4/ 96.4) PerlFAQ Server <faq@denver.pm.org>
23 52.0 ( 19.3/ 32.0/ 17.9) Joe Schaefer <joe+usenet@sunstarsys.com>
21 47.5 ( 18.1/ 29.4/ 21.3) "Godzilla!" <godzilla@stomp.stomp.tokyo>
20 39.4 ( 19.6/ 16.1/ 14.8) abigail@foad.org
19 33.1 ( 16.3/ 16.6/ 8.8) Bart Lateur <bart.lateur@skynet.be>
19 28.0 ( 16.5/ 10.1/ 7.2) Jonathan Feinberg <jdf@pobox.com>
18 28.5 ( 13.7/ 14.8/ 10.3) dtbaker_dejanews@my-deja.com
17 26.7 ( 13.2/ 10.9/ 6.0) Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
These posters accounted for 19.5% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
118.1 ( 20.6/ 96.4/ 96.4) 27 PerlFAQ Server <faq@denver.pm.org>
71.5 ( 30.0/ 38.5/ 24.5) 41 nobull@mail.com
63.1 ( 23.6/ 38.9/ 23.6) 33 Garry Williams <garry@zvolve.com>
52.0 ( 19.3/ 32.0/ 17.9) 23 Joe Schaefer <joe+usenet@sunstarsys.com>
47.5 ( 18.1/ 29.4/ 21.3) 21 "Godzilla!" <godzilla@stomp.stomp.tokyo>
39.4 ( 19.6/ 16.1/ 14.8) 20 abigail@foad.org
36.3 ( 8.9/ 25.2/ 18.2) 16 Chris Stith <mischief@velma.motion.net>
33.1 ( 16.3/ 16.6/ 8.8) 19 Bart Lateur <bart.lateur@skynet.be>
31.4 ( 8.9/ 22.5/ 15.9) 9 amonotod <amonotod@netscape.net>
28.8 ( 13.4/ 13.7/ 3.4) 15 grauezellen@gibts.net
These posters accounted for 23.4% of the total volume.
Top 10 Posters by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
1.000 ( 96.4 / 96.4) 27 PerlFAQ Server <faq@denver.pm.org>
0.949 ( 11.4 / 12.0) 9 The WebDragon <nospam@nospam.com>
0.921 ( 14.8 / 16.1) 20 abigail@foad.org
0.833 ( 8.8 / 10.6) 7 Clinton A. Pierce <clintp@geeksalad.org>
0.829 ( 1.0 / 1.2) 5 "Ron Savage" <ron@savage.net.au>
0.774 ( 4.7 / 6.0) 8 "John Lin" <johnlin@chttl.com.tw>
0.731 ( 4.2 / 5.8) 6 "Jody Fedor" <Jodyman@usa.net>
0.724 ( 21.3 / 29.4) 21 "Godzilla!" <godzilla@stomp.stomp.tokyo>
0.724 ( 18.2 / 25.2) 16 Chris Stith <mischief@velma.motion.net>
0.723 ( 4.9 / 6.8) 7 David H. Adler <dha@panix2.panix.com>
Bottom 10 Posters by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.416 ( 5.2 / 12.6) 5 Bob Walton <bwalton@rochester.rr.com>
0.415 ( 2.6 / 6.4) 7 bits101010@my-deja.com
0.412 ( 3.2 / 7.8) 11 Rafael Garcia-Suarez <rgarciasuarez@free.fr>
0.359 ( 0.7 / 1.9) 5 "Jason Wong" <wo_ah_ho@yahoo.com>
0.338 ( 2.7 / 8.1) 8 H C <carvdawg@patriot.net>
0.308 ( 1.6 / 5.1) 5 "georg_a_k" <georg_a_k@gnuage.com>
0.287 ( 1.3 / 4.5) 5 Dan Sugalski <dan@tuatha.sidhe.org>
0.280 ( 4.3 / 15.2) 5 "John W. Krahn" <krahnj@acm.org>
0.275 ( 1.5 / 5.6) 8 John Tutchings <ccx138@coventry.ac.uk>
0.247 ( 3.4 / 13.7) 15 grauezellen@gibts.net
61 posters (13%) had at least five posts.
Top 10 Threads by Number of Posts
=================================
Posts Subject
----- -------
20 Apologies to Joyce Kilmer, a hack for your enjoyment
15 Question on appending to file
14 Modules/Constants.
14 qr and backreferences
12 Sorting in NT like in Unix
12 question about sort
11 JAPH
11 Should this code work?
11 Calling all DB_File Gurus.
11 matching integer's and end of a string problem
These threads accounted for 10.7% of all articles.
Top 10 Threads by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Subject
-------------------------- ----- -------
35.6 ( 19.4/ 14.0/ 7.2) 20 Apologies to Joyce Kilmer, a hack for your enjoyment
32.2 ( 10.0/ 22.1/ 14.3) 9 Finding a char in string
30.5 ( 7.2/ 22.3/ 14.1) 9 Seeking timezone conversion advice
28.6 ( 8.2/ 19.7/ 12.8) 12 question about sort
28.4 ( 11.6/ 16.2/ 8.9) 14 Modules/Constants.
27.6 ( 12.4/ 13.5/ 8.5) 14 qr and backreferences
26.8 ( 5.1/ 21.4/ 8.9) 6 first real PERL script . . .
26.5 ( 13.7/ 12.7/ 6.0) 15 Question on appending to file
25.6 ( 8.7/ 16.6/ 9.4) 11 Should this code work?
23.9 ( 6.5/ 17.1/ 9.9) 8 Localtime Question
These threads accounted for 12.8% of the total volume.
Top 10 Threads by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.884 ( 3.5/ 3.9) 5 Security based on REMOTE_ADDR
0.855 ( 3.0/ 3.5) 5 Is it possible for perl to open Dos programs?
0.805 ( 3.8/ 4.7) 10 Help: Script only runs if ' -w' is on line 1
0.802 ( 4.7/ 5.8) 6 Array Question
0.798 ( 8.2/ 10.2) 5 code review request
0.760 ( 3.9/ 5.1) 6 sort: how do I ignore a specific word?
0.758 ( 2.2/ 2.9) 5 Text::Template Problem
0.749 ( 4.4/ 5.9) 6 to shift, or not to shift
0.722 ( 5.1/ 7.1) 8 <>, tie *STDIN or *ARGV
0.717 ( 3.5/ 5.0) 5 race condition or lock problem
Bottom 10 Threads by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.435 ( 2.8 / 6.5) 7 pushing hash onto an array
0.426 ( 1.8 / 4.2) 5 regexp
0.420 ( 4.1 / 9.8) 5 how do I temporarily close part of my site?
0.415 ( 8.9 / 21.4) 6 first real PERL script . . .
0.406 ( 2.0 / 4.9) 9 Can't read entire file into string.
0.370 ( 2.3 / 6.2) 5 'print' problem-again!
0.335 ( 1.9 / 5.7) 6 forcing compile errors on undeclared vars?
0.309 ( 2.2 / 7.2) 5 Win32ChangeNotify problems w/WinNT while Win98 is OK
0.285 ( 1.1 / 3.9) 7 buffering of STDIN
0.261 ( 1.1 / 4.4) 5 too many errors for dos screen
73 threads (17%) had at least five posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
30 alt.perl
12 comp.lang.perl
5 comp.lang.perl.moderated
3 comp.os.linux.misc
3 comp.lang.misc
3 comp.unix.questions
2 comp.answers
2 news.answers
1 nl.comp.os.ms-windows
1 de.comp.lang.perl.misc
Top 10 Crossposters
===================
Articles Address
-------- -------
5 jean@ematic.com
5 Johan Vromans <JVromans@Squirrel.nl>
4 Joe Smith <inwap@best.com>
3 kurt elmiger <ke@idm.ch>
3 Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
2 efflandt@xnet.com
2 jari.aalto@poboxes.com
2 Tony Curtis <tony_curtis32@yahoo.com>
2 abigail@foad.org
2 "flash" <bop@mypad.com>
------------------------------
Date: Mon, 05 Feb 2001 14:59:30 GMT
From: emelin <emelin@my-deja.com>
Subject: Super simple loop Q (really newbie)...
Message-Id: <95mf4c$rie$1@nnrp1.deja.com>
foreach $thing(@array){
if $thing eq "something"){
print "something";
}
How do I print out an error message if there is no $thing that
eq "something", without printing it out for EVERY $thing that doesn't
eq "something"??? (this is obviously what happens if I put "else" in
the "if"...)
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 5 Feb 2001 16:26:05 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: Super simple loop Q (really newbie)...
Message-Id: <MPG.14e8e47df820d51798988e@news.online.no>
In article <95mf4c$rie$1@nnrp1.deja.com>, emelin@my-deja.com says...
> foreach $thing(@array){
> if $thing eq "something"){
> print "something";
> }
>
> How do I print out an error message if there is no $thing that
> eq "something"
You could try:
print "Not found" unless (grep(/$string/i, @array));
Note; The 'i' states that your search will be ignoring case.
--
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: Mon, 05 Feb 2001 15:27:05 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: Super simple loop Q (really newbie)...
Message-Id: <3A7EC648.61DA1C2@coventry.ac.uk>
If you are looking for the occurrence in the array I suggest you look at
using an associative array. You then do not have to loop through each
element in the array (that will cut down the run time), this will only
work if there is only one "something" in the array.
e.g. if (exists($ass_array{"something"})){
print "Something";
}else{
print "Nothing";
}
It all depends on what you are trying to do.
or
try the heavy handed way of using grep to search the array, if it returns
nothing the "something" was not in the array, if it returns something
then there was "something" in the array.
emelin wrote:
> foreach $thing(@array){
> if $thing eq "something"){
> print "something";
> }
>
> How do I print out an error message if there is no $thing that
> eq "something", without printing it out for EVERY $thing that doesn't
> eq "something"??? (this is obviously what happens if I put "else" in
> the "if"...)
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Mon, 5 Feb 2001 09:18:41 -0800
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Re: Super simple loop Q (really newbie)...
Message-Id: <95mn9i$iln@news.or.intel.com>
foreach $thing(@array){
> if $thing eq "something"){
> print "something";
> }
else
{
print "error\n";
last;
}
}
does this answer ur qn?
if not please explain it bit more...
"emelin" <emelin@my-deja.com> wrote in message
news:95mf4c$rie$1@nnrp1.deja.com...
> foreach $thing(@array){
> if $thing eq "something"){
> print "something";
> }
>
> How do I print out an error message if there is no $thing that
> eq "something", without printing it out for EVERY $thing that doesn't
> eq "something"??? (this is obviously what happens if I put "else" in
> the "if"...)
>
>
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Mon, 5 Feb 2001 11:08:09 -0500
From: "John W" <jwmsng@greatNOSPAMwebsolutions.com>
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <3a7ecddd_3@goliath2.newsfeeds.com>
Just curious, what's Jeopardy style?
Tim, the only additional bits of advice I've been able to turn up so far are
pretty much along the lines of what Agibail has suggested.
Best wishes,
John Woodman
> Yes. Don't post Jeopardy style.
>
> *plonk*
>
>
> Abigail
> --
> perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Mon, 5 Feb 2001 11:28:12 -0500
From: "John W" <jwmsng@greatNOSPAMwebsolutions.com>
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <3a7ed27a_3@goliath2.newsfeeds.com>
> "" my $dbh = $self->{'dbh'}; #this is inherited
> "" my $query = (
> "" "select fieldone, fieldtwo ",
> "" "from db1..table1 ",
> "" "where crit = value ",
> "" );
>
> A print $query would help. -w would have told you so.
Mmm. Problem here. Is this indeed close to the actual code?
JW
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Mon, 05 Feb 2001 14:38:18 GMT
From: gnari@my-deja.com
Subject: Re: Trouble with split
Message-Id: <95mdsp$q5v$1@nnrp1.deja.com>
In article <3a7ea93d.1364071@wingate>,
lkenny@fisheries.org (LK) wrote:
> On Fri, 02 Feb 2001 20:50:08 GMT, tigra@sky.deep.ru wrote:
>
> >First of all, why do you use s/\n/"|"/eg instead of just s/\n/|/g ?
>
> Becasue when I take the quotes off I get the following error message:
>
> syntax error at c:\windows\TEMP\DzTemp.pl line 13, near "{ |"syntax
> error at c:\windows\TEMP\DzTemp.pl line 20, near "}"
> c:\windows\TEMP\DzTemp.pl had compilation errors.
>
this probably means you tried
s/\n/|/eg;
but not
s/\n/|/g;
lookup perldoc perlre for the meaning og the 'e'
gnari
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 05 Feb 2001 15:02:15 GMT
From: lkenny@fisheries.org (LK)
Subject: Re: Trouble with split
Message-Id: <3a7ec019.4971880@wingate>
On Mon, 05 Feb 2001 14:38:18 GMT, gnari@my-deja.com wrote:
>In article <3a7ea93d.1364071@wingate>,
> lkenny@fisheries.org (LK) wrote:
>> On Fri, 02 Feb 2001 20:50:08 GMT, tigra@sky.deep.ru wrote:
>>
>> >First of all, why do you use s/\n/"|"/eg instead of just s/\n/|/g ?
>>
>> Becasue when I take the quotes off I get the following error message:
>>
>> syntax error at c:\windows\TEMP\DzTemp.pl line 13, near "{ |"syntax
>> error at c:\windows\TEMP\DzTemp.pl line 20, near "}"
>> c:\windows\TEMP\DzTemp.pl had compilation errors.
>>
>this probably means you tried
>s/\n/|/eg;
>but not
>s/\n/|/g;
>
>lookup perldoc perlre for the meaning og the 'e'
>
>
>gnari
>
>
>Sent via Deja.com
>http://www.deja.com/
I thought the meaning of the "e" was execute. But ewither way I
figured out my problem with split. I wasn't setting up the foreach I
needed to set up.
I solved it and got the format I needed with the following code:
#!/usr/local/bin/perl
opendir(DIR, "C:\\") || die("Cannot cd to \jobs: $!");
$file="C:\\C-01DATA.txt";
$dats = time;
if (-r $file && -w $file){
open(FILE,"$file") || die("Cannot open file $file: $!");
$data = do { local $/; <FILE>; };
close (FILE);
$data =~ s/\n/"|"/eg;
$data =~ s//"~"/eg;
}else{
print "Unable to open $file: $!\n";
}
@records = split(/~/, $data);
open (FIEL, ">>$dats");
foreach $i(@records){
print FIEL "$i\n";
}
close (FIEL);
closedir(DIR);
print "$dats\n";
Thanks for all your help everyone.
LK
------------------------------
Date: 05 Feb 2001 09:09:23 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Trouble with split
Message-Id: <m37l352ml8.fsf@dhcp11-177.support.tivoli.com>
lkenny@fisheries.org (LK) writes:
> On Fri, 02 Feb 2001 20:50:08 GMT, tigra@sky.deep.ru wrote:
>
> >First of all, why do you use s/\n/"|"/eg instead of just s/\n/|/g ?
>
> Becasue when I take the quotes off I get the following error message:
>
> syntax error at c:\windows\TEMP\DzTemp.pl line 13, near "{ |"syntax
> error at c:\windows\TEMP\DzTemp.pl line 20, near "}"
> c:\windows\TEMP\DzTemp.pl had compilation errors.
This error is complaining about "{ |", but the code you gave did not
have this structure (even with quotes around the pipe symbol). That
makes it seem like there is more to this code than you are showing, or
that you have made additional changes.
Perhaps this would be a good time to take a step back and re-state the
problem, including a clear description of the data and the goal, along
with the a self-contained piece of code demonstrating the problem.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Mon, 5 Feb 2001 10:58:13 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: update page
Message-Id: <G8A6H1.KyL@news.muni.cz>
On Mon, 5 Feb 2001 11:47:52 +0100, Hans <hkamp1@hotmail.com> wrote:
>
> Person A visits my page generated with database stuff.
>
> Person B drops some stuff in the database.
>
> When B drops stuff the page by A must be updated.
>
> The solution of refreshing the page every x seconds I know.
>
> From A and B I know how to get their session_id and their ip_address, but I
> do not know how, by example the script activated by person B can update the
> page by person A.
By the solution you know: refresh the page of A every x seconds.
Not a Perl issue though.
Yours,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, DBD::XBase.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------
------------------------------
Date: Mon, 05 Feb 2001 15:59:33 GMT
From: mirvine555@my-deja.com
Subject: Re: using hash references to store values from multiple tables
Message-Id: <95mikv$uqp$1@nnrp1.deja.com>
Anno,
thanks for your reply.
In article <95maf5$ctt$1@mamenchi.zrz.TU-Berlin.DE>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> >That way I can simply use
> >$var=$M1E507{InProd};
> >and get '11:45'
> How will you know if you even *have* a variable named %M1E507 in a
> particular run?
>
Thats a fair point, I will know all the column names, they change very
infrequently, so I'll look at that aspect.
> With a hash as described (named %table, for want of a descriptive
> name) you can check if "M1E507" was even mentioned via "exists
> $table{ M1E507}". You can still do
>
> $var = $table{ M1E507}->{ InProd};
>
> to get the corresponding time (if it is indeed a time).
I really just want the string that states the time, even if it's just a
dot. Don't actually need to use it as a time.
> I am appending a sketch of how to build %table from your data.
>
> Anno
>
> #!/usr/bin/perl
> use strict; use warnings; $| = 1;
>
> my %table;
>
> my @header = split / +/, <DATA>; # first line is special
> shift @header; # get rid of "reason"
> chomp @header; # ...and line feed
>
> while ( <DATA> ) {
> chomp;
> my( $reason, @times) = split / +/;
> for ( my $i = 0; $i < @header; $i++ ) {
> my $time = $times[ $i];
> if ( defined $time and $time ne '.' ) {
> $table{ $header[ $i]}->{ $reason} = $time;
> }
> }
> }
>
> my $var = $table{ M1E510}->{ No_WIP} if exists $table{ M1E510};
> print "var: $var\n"; # $var can still be undefined
>
> __DATA__
> Reason M1E507 M1E508 M1E509 M1E510
> InProd 11:45 11:45 9:04 .
> WtMtce 0:15 0:15 . .
> InMtce . . 2:56 .
> No_WIP . . . 12:00
>
>
Copied it, pasted it, ran in, and got:
$ perl table.pl
var:
$
Nothing in $var ?!
Hmmm.... did I miss something? ok, you did say a sketch. I'll work on it
some more, and get back if I still need help.
Thanks,
Mark Irvine
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 5 Feb 2001 16:27:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: using hash references to store values from multiple tables
Message-Id: <95mk90$k42$3@mamenchi.zrz.TU-Berlin.DE>
<mirvine555@my-deja.com> wrote in comp.lang.perl.misc:
[snip, including code example]
>Copied it, pasted it, ran in, and got:
>$ perl table.pl
>var:
>$
>Nothing in $var ?!
>Hmmm.... did I miss something? ok, you did say a sketch. I'll work on it
>some more, and get back if I still need help.
It runs as is, and $var is "12:00". My best guess is the data part got
messed up in the transfer. A few unexpected blanks mess up a split
on / +/ pretty bad.
In the "sketchy"-remark I was more referring to possible variability
in your data (which is never clear from a single example) and different
ways of dealing with them.
Anno
------------------------------
Date: Mon, 05 Feb 2001 17:28:54 GMT
From: mirvine555@my-deja.com
Subject: Re: using hash references to store values from multiple tables
Message-Id: <95mns6$4cp$1@nnrp1.deja.com>
In article <95mk90$k42$3@mamenchi.zrz.TU-Berlin.DE>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> >Nothing in $var ?!
> >Hmmm.... did I miss something? ok, you did say a sketch. I'll work on
it
> >some more, and get back if I still need help.
>
> It runs as is, and $var is "12:00". My best guess is the data part
got
> messed up in the transfer. A few unexpected blanks mess up a split
> on / +/ pretty bad.
>
>
> Anno
>
Anno,
yes, there were some extra blanks when i pasted (right at the start of
the lines in the data list. Cleared them up, and now it does give 12:00.
I was trying to find the problem, and added in some extras (I use print
statments alot to debug, can't use the debugger yet).
In particular, I was wondering why the folling:
while (($key,$val) = each(%table)){
print "KEY: $key, VAL:".$val."\n";
}
Gives:
KEY: M1E508, VAL:HASH(0x1a6527c)
KEY: M1E510, VAL:HASH(0x1a61c20)
KEY: M1E509, VAL:HASH(0x1a61c2c)
KEY: M1E507, VAL:HASH(0x1a6f210)
Is it possible to do something like this with 'each' ?
(I don't think I'll need it, just curious).
> In the "sketchy"-remark I was more referring to possible variability
> in your data (which is never clear from a single example) and
different
> ways of dealing with them.
Fair enough, I didn't mean to suggest your code was bad, just didn't
want to be too pushy looking for more help.
Thanks again for your help,
Mark Irvine
Sent via Deja.com
http://www.deja.com/
------------------------------
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 216
**************************************