[9320] in Perl-Users-Digest
Perl-Users Digest, Issue: 2915 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 19 17:07:37 1998
Date: Fri, 19 Jun 98 14:00:41 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 19 Jun 1998 Volume: 8 Number: 2915
Today's topics:
Re: [Q] On WAKING a sleeping process... (Stuart McDow)
Re: add a record into file DBF with perl <mike@newfangled.com>
Re: Appending one file to another <aqumsieh@matrox.com>
Re: Appending one file to another <aqumsieh@matrox.com>
Re: Checking for timeouts when using IO:Socket::INET andrew@ugh.net.au
Re: Copying an Anonymous Hash <cberry@cinenet.net>
Re: Efficiency: required reading (jeremy howard todd)
Re: first language <lfw@airmail.net>
Help Customizing yForm.cgi <bradely@mail.utexas.edu>
How do I periodically run a program in a certain time i <bth@acsu.buffalo.edu>
Re: How do I periodically run a program in a certain ti <rootbeer@teleport.com>
Re: How do I periodically run a program in a certain ti (Joel Coltoff)
Re: How do I periodically run a program in a certain ti (Larry Rosler)
How to make Web work with "rsh" in Perl <peng@cae.cig.mot.com>
Re: How to make Web work with "rsh" in Perl <rootbeer@teleport.com>
Re: Is setlogsock really in Perl 5.004_04? andrew@ugh.net.au
Re: Little help on grabbing text (Larry Rosler)
My child dies...but why? andrew@ugh.net.au
Re: My child dies...but why? <mike@newfangled.com>
Re: My child dies...but why? <rootbeer@teleport.com>
Re: Need to split a line with spaces (Eric)
Re: Need to split a line with spaces <bth@acsu.buffalo.edu>
Re: parsing <mike@newfangled.com>
perl in html email <kimplera@med.unc.edu>
printf in assignments <eglamkowski@angelfire.com>
Re: Regular Expression Question (Eric)
Re: REVIEW: Perl CGI Programming - No Experience Requir (Rahul Dhesi)
Starting a Perl Mongers group in Dallas (Brand and Karina Hilton)
Re: String manipulation question? <rootbeer@teleport.com>
substr() behavior - -Solution? <pierre_porter@y2k1000.ps.compuware.com>
TELNET changing values of Timeout etc after they have b (John Kelly)
Re: Writing to a file on the same line <peng@cae.cig.mot.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Jun 1998 19:56:41 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: [Q] On WAKING a sleeping process...
Message-Id: <6mefpp$79t$1@ns1.arlut.utexas.edu>
Tom Phoenix <rootbeer@teleport.com> writes:
>
> Causes the script to sleep for EXPR seconds, or forever if no EXPR.
> May be interrupted by sending the process a SIGALRM.
I would add that it may be interrupted by any caught signal (at least
according to the man page for sleep(3): "The actual suspension time
may be less than that requested because any caught signal will
terminate the sleep(3) following execution of that signal's catching
routine.")
And that sleep() returns the actual number of seconds slept.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: Fri, 19 Jun 1998 16:15:18 -0400
From: "Michael S. Brito, Jr." <mike@newfangled.com>
To: peacemakers@my-dejanews.com
Subject: Re: add a record into file DBF with perl
Message-Id: <358AC6BE.6A3D2195@newfangled.com>
I agree with the last poster (steve) that you should have provided more
information, but I think that HE hasn't done his homework in Human
Relations. I think we could have done without the sarcastic scolding
technique.....
Now, here is a liitle code for creating an HTML form that will grab the
form data from the form fields and append (add) it to a file:
------------------- START -------------------
#!/usr/bin/perl
read(STDIN,$buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name,$value) = split(/=/,$pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;
}
open(OUTF,">>database.txt");
print OUTF
"$FORM{'fieldname1'},$FORM{'fieldname2'},$FORM{'fieldname3'}\n";
close(OUTF);
-------------------- EOF ---------------------
Thats it. If this helps at all, or even if it doesn't, e-mail me or post a
response & we'll figure something out. Just include all the neccessary
info this time! ;-)
peacemakers@my-dejanews.com wrote:
> How to add a record into file DBF with Perl.
> To read I'm acctualy using module Xbase.pm
> and I dont know how to write...
>
> Joshua
> joshua@ph.edu
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
-----------------------------------------------------------
Michael S. Brito, Jr., Web Developer
Newfangled Graphics Co. Inc.
mike@newfangled.com
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=(#####censored######)
-----------------------------------------------------------
------------------------------
Date: Fri, 19 Jun 1998 15:02:59 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Appending one file to another
Message-Id: <358AB5E3.88B444B5@matrox.com>
Bryan Camp wrote:
>
> Hello,
>
> I've been struggling on a very simple matter.
> What I'm trying to do is append one file on to
> the end of another file.
> For example, 'output_file' is a file that
> I would like to append onto an already existing
> file, which was earlier named by the user.
>
> open(HANDLE, ">> $user_named") || die;
> print HANDLE output_file;
>
> On the second line, I have tried placing
> single, double, and no quotes around output_file,
> but all this does is write the word "output_file"
> to the user-named file insted of the output_file
> itself. Could someone help me fix this problem?
How do you want Perl to know that output_file is the name of an actual
file ? As far as Perl is concerned, output_file is just a bare word
equal to the string "output_file" (unless you use the strict pragma.)!
So ..
open OUTFILE, "output_file" or die "Can't open: $!\n";
@lines = <OUTFILE>;
foreach (@outlines) {
print HANDLE "@_";
}
> Thanks.
>
> Bryan
Alternatively, you can use cat.
--
Ala Qumsieh | No .. not just another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: Fri, 19 Jun 1998 15:04:30 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Appending one file to another
Message-Id: <358AB63E.DEBAF072@matrox.com>
Ala Qumsieh wrote:
>
>> open OUTFILE, "output_file" or die "Can't open: $!\n";
> @lines = <OUTFILE>;
> foreach (@outlines) {
That should've been
foreach (@lines) { #ofcourse
> print HANDLE "@_";
> }
--
Ala Qumsieh | No .. not just another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: Sat, 20 Jun 1998 06:22:32 +1000
From: andrew@ugh.net.au
To: Phoenixl <phoenixl@aol.com>
Subject: Re: Checking for timeouts when using IO:Socket::INET
Message-Id: <Pine.BSF.3.96.980620061658.19534B-100000@house.key.net.au>
On 18 Jun 1998, Phoenixl wrote:
> see if there was a timeout while reading. Can someone give me a suggestion?
I make no guarentees but...
> use IO::Socket;
>
> $socket = IO::Socket::INET->new(PeerAddr => 'www.aol.com',
> PeerPort => 'http(80)',
> Proto => 'tcp',
> Timeout => 120);
>
> if( ! defined $socket)
> {
> print "Bad address\n";
> exit;
> }
> # set for no buffering
>
> $old_fn = select($socket);
> $| = 1;
> select($old_fn);
Try:
$socket->autoflush(1);
> # turn off character mapping
>
> binmode($socket);
I dont think this is needed is it? What effect would it have? I'm not to
sure.
> print $socket "GET / HTTP/1.0\n\n";
> while(<$socket>)
> {
> print $_;
> }
Try:
eval {
$SIG{'ALRM'} = sub { die 'Timeout' };
alarm(600);
while(<$socket>)
{
print $_;
}
alarm(0);
};
if ($@ and $@ !~ /Timeout/) {
die 'I timed out :-(';
}
See also man perlipc which is were I learnt the above technique.
Andrew
------------------------------
Date: Fri, 19 Jun 1998 13:11:15 -0700
From: Craig Berry <cberry@cinenet.net>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Copying an Anonymous Hash
Message-Id: <Pine.GSO.3.95.980619130731.13669F-100000@hollywood.cinenet.net>
On Fri, 19 Jun 1998, Tom Phoenix wrote:
> > Sean McAfee (mcafee@qbert.rs.itd.umich.edu) wrote:
> > : $h2 = { %$h1 };
> >
> > No need for that anon-hash-ctor wrapper, which actually just wastes a
> > whole lot of processing time to achieve exactly the same effect as
> >
> > $h2 = %$h1;
>
> I believe that you're mistaken. And if you merely omitted a backslash,
> then you're still mistaken. Hope this helps!
Gads, but my proofreading sucks at times. :( I thought Sean was solving
the original poster's problem -- copying from hash ref $h1 into hash %h2.
I didn't notice that Sean had modified the problem to be one of creating a
reference to a copy of the hash refered to by $h1. His version is correct
for that purpose; my version should read
%h2 = %$h1;
-- as it did in my other post on this thread. I can't believe I actually
typed $h2 while thinking %h2 -- sometimes the brain is a very dangerous
tool. :-)
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 19 Jun 1998 20:26:46 GMT
From: jhtodd@students.uiuc.edu (jeremy howard todd)
Subject: Re: Efficiency: required reading
Message-Id: <6mehi6$n8r$1@vixen.cso.uiuc.edu>
petdance@maxx.mc.net (Andy Lester) writes:
>"Writing Efficient Programs" by Jon Bentley. Don't be scared that it's 16
>years old. It's a programming book for the ages.
The fact that it's 16 years old, and therefore written at a time
when fast and compact code was -important-, should be considered a big
plus. Plus a lot of optimization theory dates back to -Newton- and before,
back when you have to think hard why in the world they would care.
That's one reason I like to code on obsolete machines: it's in
my own best interest to make my code as tight as possible. I swear to
God, I saw a database programming book whose only piece of advise
concerning speeding up applications was "buy more memory."
-jht
--
Jeremy Todd Computer Programmer _,/
jhtodd@uiuc.edu ITCS On-line Development <__ \_.---.
http://www.cen.uiuc.edu/~jhtodd/ College of ACES, UIUC \_ / \
Zupfe Boy and Night Owl (And Kangaroo Aficianado) \)\ /\.\
=========================================================== // \\
"M-O-O-N, that spells moon" - Tom Cullen ,/' `\_,
------------------------------
Date: Fri, 19 Jun 1998 15:49:53 -0500
From: Larry Weiss <lfw@airmail.net>
Subject: Re: first language
Message-Id: <CEB5F1CD331A59DA.804D7B87D2DABEFF.44F0CB0AB5AFF52D@library-proxy.airnews.net>
Mark-Jason Dominus wrote:
> Pointers are an essential part of the solution to the data hiding
> problem, which is an essential issue. Therefore, they cannot be
> avoided, and in fact should be addressed as soon as possible. The
> idea of a pointer should be separated from issues of pointer
> arithmetic, which is not necessary until later.
>
And also by delaying the teaching of the concept and basic practice
of pointers it gives the subject an undeserved sense of mystery and
complexity.
- Larry Weiss
------------------------------
Date: Fri, 19 Jun 1998 15:38:39 -0500
From: Bradely <bradely@mail.utexas.edu>
Subject: Help Customizing yForm.cgi
Message-Id: <358ACC4E.5EBA14DD@mail.utexas.edu>
I am using yForm on my site to email and record form data. However, I
have one problem. It does not allow me to exclude form fields from the
email and HTML report. I am very new to programmig perl, and cannot
determine a way to have the program do this. Can anyone help me out?
One possible way I thought of was to exclude any fields that begin with
an underscore. However, I am running into a problem coding this.
Any help or ideas would be greatly appreciated. Thanks!
------------------------------
Date: Fri, 19 Jun 1998 15:58:23 -0400
From: Bryan T Hoch <bth@acsu.buffalo.edu>
Subject: How do I periodically run a program in a certain time interval?
Message-Id: <Pine.GSO.3.96.980619155506.2469B-100000@joxer.acsu.buffalo.edu>
Hi,
I'm trying to write a program in Perl that will inform me when someone i
know logs on to the system. What I need to is have it run in the
background and periodically check to see who is on line.
Does anyone know how to set up a perl program so it is run periodically
(according to a user defined interval)?
Thank you.
Bryan H
------------------------------
Date: Fri, 19 Jun 1998 20:25:49 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: How do I periodically run a program in a certain time interval?
Message-Id: <Pine.GSO.3.96.980619131959.15366S-100000@user2.teleport.com>
On Fri, 19 Jun 1998, Bryan T Hoch wrote:
> Subject: How do I periodically run a program in a certain time interval?
Sounds like a task for cron, or your system's equivalent. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 19 Jun 1998 20:24:49 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: Re: How do I periodically run a program in a certain time interval?
Message-Id: <6mehdn$m45@netaxs.com>
In article <Pine.GSO.3.96.980619155506.2469B-100000@joxer.acsu.buffalo.edu>,
Bryan T Hoch <bth@acsu.buffalo.edu> wrote:
>
>Hi,
>Does anyone know how to set up a perl program so it is run periodically
>(according to a user defined interval)?
This depends on your OS. On Un*x I'd look at cron. If you can't do that then
you could search dejanews for the other solutions to this task.
I'd do a search on the word cron. If you can't do that then ...
--
Joel Coltoff
I'd explain it, but there's a lot of math. -- Calvin
------------------------------
Date: Fri, 19 Jun 1998 13:27:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I periodically run a program in a certain time interval?
Message-Id: <MPG.ff469a72837ad729896a8@nntp.hpl.hp.com>
In article <Pine.GSO.3.96.980619155506.2469B-
100000@joxer.acsu.buffalo.edu>, Bryan T Hoch <bth@acsu.buffalo.edu>
says...
>
> Hi,
> I'm trying to write a program in Perl that will inform me when someone i
> know logs on to the system. What I need to is have it run in the
> background and periodically check to see who is on line.
> Does anyone know how to set up a perl program so it is run periodically
> (according to a user defined interval)?
> Thank you.
> Bryan H
The solution has to do with the operating system, not Perl.
On my HPUX system, `man 1 crontab` and `man 1M cron`. You may need
permission from the system administrator to use this facility.
On Windows NT, there is some facility, but I haven't used it. Consult
the docs there, if any.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 19 Jun 1998 14:32:26 -0500
From: Ying Peng <peng@cae.cig.mot.com>
Subject: How to make Web work with "rsh" in Perl
Message-Id: <358ABCCA.632762FF@cae.cig.mot.com>
I am working on an Archive/Restore project
that let UNIX users fill out archive or restore forms via web forms,
then CGI(Perl) checks the data filled by users, such as login,
workstation, directories or files. The data-checking or archive or
restore require to use rsh(remote shell) in the CGI or Perl. The
problems I am having are that the file cannot be generated via Web(call
request.cgi) and
"rsh" doesn't work (do nothing) when you click the submit button
in the Web form. Following is the info for your reference:
In request.html, there is a line stating the CGI:
<FORM ACTION="/cgi-bin/request.cgi" METHOD=POST>
The request.cgi resides in a small web server with the file attributes:
-rwxr-xr-x 1 root other 939 Jun 19 12:29 request.cgi in
/home/wn/docs/cgi-bin
Problems in the script are:
1) Cannot generate the "webinf"
#Write the web input to a web input file
open(OUTFILE, "$DBPATH/webinf")
|| die "ERROR: cannot open Web input file";
print OUTFILE "$in{datatype}\n";
$rdate=`date '+%y%m%d'`;
print OUTFILE "$rdate\n";
print OUTFILE "$in{reqname}\n";
print OUTFILE "$in{reqemail}\n";
print OUTFILE "$in{reqphone}\n";
:
:
Close OUTFILE;
where $DBPATH="/net/sys99/archive/db"
2) "rsh" does not work
sub Validate_Input
{
if ( $in{data1} !~ /^\s*$/)
{
push(@err, "Directory/File 1")
if (`rsh in{workstation} ls $in{data1} 2>&1` =~ /not
found/ );
}
if ( $in{data2} !~ /^\s*$/)
{
push(@err, "Directory/File 2")
if (`rsh in{workstation} ls $in{data2} 2>&1` =~ /not
found/ );
}
:
:
}
For better understand, I include the request.cgi as an attachment
for further query.
The problems might relate to how to make "web" run the CGI or Perl
scripts as root. The "print getpwuid($<);" shows me
"nobodyx6000160001NobodyNobody/".
Your quick reponse will be highly appreciated in advance.
mailto:peng@cae.cig.mot.com
------------------------------
Date: Fri, 19 Jun 1998 20:30:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: How to make Web work with "rsh" in Perl
Message-Id: <Pine.GSO.3.96.980619132653.15366T-100000@user2.teleport.com>
On Fri, 19 Jun 1998, Ying Peng wrote:
> The problems I am having are that the file cannot be generated via
> Web(call request.cgi) and "rsh" doesn't work (do nothing) when you click
> the submit button in the Web form.
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
> The problems might relate to how to make "web" run the CGI or Perl
> scripts as root.
Concerning security issues, that is generally considered a Bad Thing.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 20 Jun 1998 06:26:59 +1000
From: andrew@ugh.net.au
To: Gunnar Henneberg <henneberg@netco.de>
Subject: Re: Is setlogsock really in Perl 5.004_04?
Message-Id: <Pine.BSF.3.96.980620062543.19534D-100000@house.key.net.au>
On Thu, 18 Jun 1998, Gunnar Henneberg wrote:
> Undefined subroutine &main::setlogsock called at ....
setlogsock dosnt appear to be exported by default. You could use
Sys::Syslog::setlogsock('unix');
or just export it when you use Sys::Sylog (I would guess)
Andrew
------------------------------
Date: Fri, 19 Jun 1998 13:31:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Little help on grabbing text
Message-Id: <MPG.ff46a71cabf05b49896a9@nntp.hpl.hp.com>
In article <358ABF98.A4AD6F9C@newfangled.com>, Michael S. Brito, Jr.
<mike@newfangled.com> says...
> Thanx, seriously. You and Tom are providing some good tips. I've only been at
> this for like 3 weeks so I need all the help I can get! Here is how I fixed
> my problem (before reading your posting):
>
> $filename = "body.txt";
> $T = $/;
> $/ = "";
> open(INF,$filename);
> $indata = <INF>;
> close(INF);
> $/ = $T;
>
> assuming I add your suggested code is there anything else I should
> try/add?????
This is much neater, because it does what you want automatically:
{ local $/ = ''; $indata = <INF> }
One line for four (you can figure out which four :-).
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Jun 1998 06:16:22 +1000
From: andrew@ugh.net.au
Subject: My child dies...but why?
Message-Id: <Pine.BSF.3.96.980620060513.19534A-100000@house.key.net.au>
Hi,
I have a perl script that opens a TCP stream (using IO::Socket) and then
forks. One process reads from the stream, the other writes.
Unfortunatly under certain circumstances my child dies (parent receives
SIGCHLD and if I inset a sleep int he CHLD handler long enough for me to
do a ps before I reap the child is definitly dead (in a zombie state).
I need to know why my child dies. If I run it through the debugger I get:
Forked, but do not know how to change a TTY.
Define $DB::fork_TTY or get_fork_TTY().
If I just ignore the error and keep going my program dies when it hits a
read protected from timeout with eval. It dies with the message 'Alarm
Clock'. that string dosnt appear in my code.
Anyone have any suggestions?
Thanks,
Andrew
------------------------------
Date: Fri, 19 Jun 1998 16:40:22 -0400
From: "Michael S. Brito, Jr." <mike@newfangled.com>
Subject: Re: My child dies...but why?
Message-Id: <358ACC9C.A284DB69@newfangled.com>
Well lets see. Judging by the evidence provided it looks like the parent
wasn't paying attention and the SIGCHLD fell in the TCP stream and
drowned..... ;-(
CASE CLOSED! RACK ONE UP FOR DETECTIVE MIKE!
j/k ;-)
andrew@ugh.net.au wrote:
> Hi,
>
> I have a perl script that opens a TCP stream (using IO::Socket) and then
> forks. One process reads from the stream, the other writes.
>
> Unfortunatly under certain circumstances my child dies (parent receives
> SIGCHLD and if I inset a sleep int he CHLD handler long enough for me to
> do a ps before I reap the child is definitly dead (in a zombie state).
>
> I need to know why my child dies. If I run it through the debugger I get:
>
> Forked, but do not know how to change a TTY.
> Define $DB::fork_TTY or get_fork_TTY().
>
> If I just ignore the error and keep going my program dies when it hits a
> read protected from timeout with eval. It dies with the message 'Alarm
> Clock'. that string dosnt appear in my code.
>
> Anyone have any suggestions?
>
> Thanks,
>
> Andrew
--
-----------------------------------------------------------
Michael S. Brito, Jr., Web Developer
Newfangled Graphics Co. Inc.
mike@newfangled.com
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=(#####censored######)
-----------------------------------------------------------
------------------------------
Date: Fri, 19 Jun 1998 20:44:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: My child dies...but why?
Message-Id: <Pine.GSO.3.96.980619134324.15366U-100000@user2.teleport.com>
On Sat, 20 Jun 1998 andrew@ugh.net.au wrote:
> Subject: My child dies...but why?
> It dies with the message 'Alarm Clock'.
Sounds as if you've gotten the signal from alarm(), or the equivalent.
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 19 Jun 1998 20:04:04 GMT
From: tallguy999@hotmail.com (Eric)
Subject: Re: Need to split a line with spaces
Message-Id: <6megau$o6q$1@news-1.news>
On Fri, 19 Jun 1998 13:02:07 -0400, "John Madden"
<john.madden@ssa.gov> wrote:
>I have a directory listing which looks like this:
>
>6/17/98 09:04p 9,324 file1
>6/17/98 09:02 5,342 file2
>
>
>and so on. I want to get the filename(i.e. file1 or file2) out of this
>directory list.
>
>I have tried
>
>foreach $entry(@entries)
>{
>$f1=(split/s*/)[4];
>print ($f1 . "\n");
>}
>
>With no luck..any help would be appreciated...
Problems:
1) split (as you have it) operates on $_, not $entry. Removing the
$entry from the foreach fixes this. Alternatively, add $entry to the
split command.
2) Splitting on s* looks for 0 or more of 's'. You want to split on
\s+, which splits on 1 or more whitespace.
3) The file name would indeed be the 4th item, but would be index
number 3, as counting starts from 0
This works:
@entries =("6/17/98 09:04p 9,324 file1",
"6/17/98 09:02 5,342 file2");
foreach (@entries)
{
$f1=(split/\s+/)[3];
print ($f1 . "\n");
}
------------------------------
Date: Fri, 19 Jun 1998 16:31:58 -0400
From: Bryan T Hoch <bth@acsu.buffalo.edu>
Subject: Re: Need to split a line with spaces
Message-Id: <Pine.GSO.3.96.980619161831.2469C-100000@joxer.acsu.buffalo.edu>
I'm somewhat new at this, but I'll give it a shot.
First, if this is the order in which the items appear you could first use
a split (I'm assuming that you're reading this all in as a string,
correct?) according to white space.
@items = split(/\s+/, $input_strng);
then what you could do is check each item to see if it ends with a \n
character (since each of the file names appear at the end of the line).
If it does, put it into a stack (I don't know if you need one specific
file or all of them...).
foreach $individual_item (@items){
if ($individual_item =~ /\n$/){
push(@file_names, $individual_item);
} #end if
} #end foreach
This will give you an array of just file names (though, you'll probably
want to remove the new line characters from each of the file names).
I hope this helped. If it didn't, well, like i said, I'm still new at
this.
Bryan H
On Fri, 19 Jun 1998, John Madden wrote:
> I have a directory listing which looks like this:
>
> 6/17/98 09:04p 9,324 file1
> 6/17/98 09:02 5,342 file2
>
>
> and so on. I want to get the filename(i.e. file1 or file2) out of this
> directory list.
>
> I have tried
>
> foreach $entry(@entries)
> {
> $f1=(split/s*/)[4];
> print ($f1 . "\n");
> }
>
> With no luck..any help would be appreciated...
>
>
>
>
>
>
>
------------------------------
Date: Fri, 19 Jun 1998 16:00:27 -0400
From: "Michael S. Brito, Jr." <mike@newfangled.com>
To: Amanda Silver <aks@cs.brown.edu>
Subject: Re: parsing
Message-Id: <358AC343.CC22E28B@newfangled.com>
I'm sure, as you can see, sarcasm, inability to detect the obvious, and very
in-humorus ridicule is a part of every newbie posters replies...... See you at
next seasons hockey games, GO BROWN!
Amanda Silver wrote:
> i've been trying to write a script that takes a directory and then takes every
> file in that directory and parses it looking for the word 'foo' and changes the
> word to 'bar' but i can't figure out how parsing is done...do i use the grep
> command somehow...? can someone please help? (beginner at perl...)
>
> --
> ~ a m a n d a s i l v e r ~
> ~ b r o w n u n i v e r s i t y ~
> ~ a k s @ c s . b r o w n . e d u ~
-----------------------------------------------------------
Michael S. Brito, Jr., Web Developer
Newfangled Graphics Co. Inc.
mike@newfangled.com
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=(#####censored######)
-----------------------------------------------------------
------------------------------
Date: Fri, 19 Jun 1998 16:13:50 -0400
From: Randy Kimple <kimplera@med.unc.edu>
Subject: perl in html email
Message-Id: <358AC67E.F7EAAF8C@med.unc.edu>
I've tried posting this question to various microsoft and netscape
newgroups to no avail. Hopefully this group has someone who can help
me.
OS-WinNT/95
Program--Netscape messenger or microsoft outlook express
issue--use and processing of "forms"
I am trying to design a form for use in either of the above programs
that has many 'radio' buttons and several text fields. When the user
clicks send (preferrably on the bottom of my form, but acceptably in the
program) I want to do error checking of the form elements. Mainly just
an ID and several other elements. Can anyone suggest a way to do this
in perl? I have been using the html <form name=XYZ
action=mailto:xxx@xxxx.xxx method=post> but can not do the error
checking.
Thanks.
Randy
------------------------------
Date: Fri, 19 Jun 1998 16:37:38 -0400
From: the count <eglamkowski@angelfire.com>
Subject: printf in assignments
Message-Id: <358ACC12.48FA@angelfire.com>
I checked the FAQ but see this addressed, so here I am (if it is in
there, then it is buried well, or only gotten at obliquely, and I missed
the reference...)
I want to assign the contents of a printf to one element of an array,
like so:
$specs[$counter] = printf("\"%4s\", ", $variable);
This, obviously, doesn't work as $specs[$counter] is assigned a value
of 1 - the return value of a successful printf!
--
"Have you no sense of decency, sir?
At long last, have you left no sense of decency?"
Come join my web-ring! http://www.angelfire.com/nj/eglamkowski/null.html
------------------------------
Date: Fri, 19 Jun 1998 20:25:37 GMT
From: tallguy999@hotmail.com (Eric)
Subject: Re: Regular Expression Question
Message-Id: <6mehjc$qsa$1@news-1.news>
On Fri, 19 Jun 1998 10:09:01 -0700, Laura Morgan
<laura.morgan@itron.com> wrote:
>I have input parameters that can be file.name, *.ext, file.* or *.*
>I'm parsing through a file trying to match on this input and perform a
>function (i.e. if the user types in *.c, I want to match all files with
>a .c extension, etc).
>
>With the input variable name being $file, and the match against variable
>named $matchfile, is there a way I can make a comparison that will match
>$file with $matchfile, using the wildcard scenerio mentioned above?
>
>Still learning how regular expressions work...
>Thanks in advance
This works. It's a complete program, but I'm sure you can adapt it to
your purposes. It only looks for matches on the C:\ drive (root).
You shouldn't have a problem with unix.
#
# Note win32 bias!!
opendir (DIR,"c:\\");
@dir = readdir (DIR);
closedir (DIR);
$match =<STDIN>;
chomp $match;
$match =~ s|\.|\\\.|g; ## Convert . to \. for regexp
$match =~ s|\*|\.\*|g; ## Convert * to .* for regexp
$match = '^'.$match.'$'; ## Add ^ and $ to only match a full string.
foreach (@dir)
{
print $_ ."\n" if /$match/i;
## Note case insensitive! Might want to remove i for unix
}
------------------------------
Date: 19 Jun 1998 20:11:50 GMT
From: c.c.eiftj@54.usenet.us.com (Rahul Dhesi)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6megm6$ce0$1@samba.rahul.net>
In <6mb8q0$cuo1@eccws1.dearborn.ford.com> kfox@pt0204.pto.ford.com (Ken
Fox) writes:
>pudge@pobox.com (Chris Nandor) writes:
>> Here it is, your definition, which was already 100 percent inferrable
>> from the above information:
>>
>> an array is a variable. a list is not.
>Isn't an "array" a value and an "array variable" a variable? ;)
Careful, you may get killfiled.
>I've always thought of Perl's "lists" as synonymous with "argument
>lists."
I believe they are similar, except that you can add another level of
parentheses and then use subscript notation on perl lists; so they
behave like arrays too. And also, you can use a perl list on the left
hand side of an assignement, to assign to each element in turn.
I believe some of the confusion arises because the word 'list' is used
both for lists as rvalues and as lvalues. If we had a new word such as
'varlist' for a list when used on the LHS, we would have a cleaner set
of defintions.
list: when used to represent a sequence of rvalues, as on the RHS of an
assignment.
varlist: when used to assign into variables, as on the LHS or an
assignment.
--
Rahul Dhesi <dhesi@spams.r.us.com>
------------------------------
Date: Fri, 19 Jun 1998 20:26:05 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: Starting a Perl Mongers group in Dallas
Message-Id: <bkhiltonEutFFI.Bs1@netcom.com>
I'm still trying to gauge the interest in a Perl Mongers group
for Dallas. A few have responded so far, but I know there are
more of you out there. So, once again, if you live and/or work
in the Dallas area and are interested in periodically getting
together with other Perl afficionados, please drop me a line.
For more info on Perl Mongers groups, visit
http://www.pm.org
Brand
------------------------------
Date: Fri, 19 Jun 1998 19:12:03 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: String manipulation question?
Message-Id: <Pine.GSO.3.96.980619121054.15366L-100000@user2.teleport.com>
On Fri, 19 Jun 1998 camposj@ctc.com wrote:
> I'm currently revising a perl script that reads an html document into a
> variable and then split it up into 31k increments and then records each
> piece to my database.
> Problem: I have to make sure that before I create a piece that I do not
> split up a particular tag over two records. It has to be whole. The
> tag is <a .....> .... </a>
You'll need to parse the HTML to do this right. Try the HTML::Parser
module from CPAN. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 19 Jun 1998 14:32:06 -0500
From: Pierre Porter <pierre_porter@y2k1000.ps.compuware.com>
Subject: substr() behavior - -Solution?
Message-Id: <358ABCB6.7F01E56C@y2k1000.ps.compuware.com>
Fellow Perl users,
First of all thanks goes out to Stuart McDow and
Andy Lester for giving me some ideas for solving this problem.
They suggested using split(). This worked, but it really bugged me
that substr() didn't work when it used to in Perl 4.0. While
staring to write up a bug report on this I found an (the?)
answer.
The original problem:
The program below was designed to extract a column of
numbers found between two "|" characters. It works
fine in Perl for DOS version 4.0, Revision 4.0.1.8 2/5/93 Patch level 36
and Perl for NT version 4.0, Revision 4.0.1.8 Patch level 36.
# col1.pl
$ln=0;
while (<>){
chop;
if(substr($_,7,1) eq '|'){
print substr($_,11,8), "\n";
$ln++;
}
}
print "Number of lines=$ln\n";
However for the Win32 version 5.003_07 Build 313, it runs but
I get the following warning:
Use of uninitialized value at col1.pl line 6, <> chunk 111.
substr outside of string at col1.pl line 6, <> chunk 123.
My soultion:
while (<>){
if(length($_)>=30){
if(/\w/){
if (substr($_, 13,1) eq'|'){
print substr($_,14,15), "\n";
}
}
}
}
There seems to be different behavior between Perl 4.0 (for DOS and NT)
and Perl 5.003. I was getting the "substr outside of string" warning for
lines
that only had a CR-LF. This makes sense actually. It appears as though
the previous
version of Perl ignored this. Furthermore, if $_ is less than the total
of the
$start + $lenght +1, it will also be outside of the string. To flag this
as a
warning is probably actually a refinement of the previous version I
would imagine.
--
Mr. Porter does not speak
for Compuware Corporation
or any of its affiliates
------------------------------
Date: Fri, 19 Jun 1998 20:32:58 GMT
From: john.kelly@citicorp.com (John Kelly)
Subject: TELNET changing values of Timeout etc after they have been set?
Message-Id: <358cc9e1.23266074@news.citicorp.com>
Hi,
Is there a way to change the values of Timeout, and prompt in
your code after they have been set established with new
i.e. $rem_node= new Net::Telnet (Timeout => 10, Prompt =>'/\$ $/') ;
------------------------------
Date: Fri, 19 Jun 1998 15:11:22 -0500
From: Ying Peng <peng@cae.cig.mot.com>
Subject: Re: Writing to a file on the same line
Message-Id: <358AC5EA.84B7D616@cae.cig.mot.com>
Yasir:
I am sorry to ask you a related question instead. My question is how to
write $in{XXX}
data into a file. I received an error message from the Web.
Suppose users fill out a web form containing
reqname
reqdate
:
:
in request.cgi:
open(OUTFILE, ">/tmp/webinf");
print OUTFILE "$in{reqname}\n";
print OUTFILE "$in{reqdate}\n";
:
:
close OUTFILE;
The above script doesn't work for me. I might miss some points. It gave
me the following error messages:
Error code 500
Read error
WN/1.18.6
I would appreciate your help in advance.
--Ying
Yasir Khalifa wrote:
>
> Hi: This might be very trivial, but I would appreciate any help! I am
> writing some attributes and their values (on clicks) to a file.
> The writing is done through multiple web pages. Within one page, the
> the cgi can easily write the attributes and their values in one line.
> But once I go to the next page, it writes on a new line. Below is a sketch:
>
> # IN page1: the code below writes attributes/vals to a file...
> print "
> Name \t\t Date \t\t SSN \t Birthdate # static attributes
> $in{'First'} $in{'Middle'} $in{'Last'} \t $sub_date_time \t $in{'SSN'} ";
>
> #In Page2: I want to add the value of the attribute Birthdate (above)
> #NEXT to the value of SSN. The code for writing in page2 is:
>
> #open the same file from page1
> print "
> \t $in{'BDate'} ";
>
> So far No luck, it keeps writing it on a new line....
> The final output should look like:
>
> Name Date SSN Birthdate
> John Doe 6/18/98 999999999 January 27, 1998
> ^^^^^^^^^^^^^^^^^
> this value from pag 2 should be
> written here and not on a new line
> Any help is appreciated,
> -Yasir
--
************************************************************************
* Ying Peng Motorola *
* CAD/CAE/CAM Support Group Cellular Infrastructure Group *
* (V):(847)632-3069 (F):(847)-632-6436 1475 Shure Dr. MS:IL75/3G10 *
* email: ypeng1@email.mot.com Arlington Heights, IL 60004 *
************************************************************************
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2915
**************************************