[7101] in Perl-Users-Digest
Perl-Users Digest, Issue: 726 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 12 12:28:01 1997
Date: Sat, 12 Jul 97 09:00:21 -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 Sat, 12 Jul 1997 Volume: 8 Number: 726
Today's topics:
Re: $1 trashed on nested s///: feature or bug (M.J.T. Guy)
Re: $1 trashed on nested s///: feature or bug <jbc@west.net>
Re: $ENV{'QUERY_STRING"} problem (Tung-chiang Yang)
Re: 'use strict' with CGI.pm (Randy J. Ray)
Re: 'use strict' with CGI.pm (Randy J. Ray)
Re: 'use strict' with CGI.pm (Honza Pazdziora)
Re: cgi.pm converting help (M.J.T. Guy)
Re: Deleting all spaces at the beginning of a line. (Craig Berry)
hash ref from list <cmason@ti.com>
Re: How to return an image from perl <jbokma@caiw.nl>
Re: How to return an image from perl <jbokma@caiw.nl>
Re: Need advice on a good Perl Book (Gabor)
Re: OOP question (Randy J. Ray)
Re: Perl 5.004 binary for Solaris 2.5 <andy@cyberware.co.uk>
Re: please help me modify this perl script <rootbeer@teleport.com>
Printing first portion of a variable. <buck@huron.net>
Re: Regular experssions and delimiters. (Honza Pazdziora)
script going zombie, missing read... <guitarweb@hotmail.com>
Re: Setting TARGET variable from Perl Script (Quentin Fennessy)
Re: Strategies for dealing with the 'Use of uninitializ (M.J.T. Guy)
syswrite vs. select S;$|=1;print S (Keith Kong)
Re: UUDECODE Mailer program in Perl 5 (Matthew Burnham)
while.problem (Fan Ng)
Re: while.problem (Tad McClellan)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Jul 1997 13:32:46 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: $1 trashed on nested s///: feature or bug
Message-Id: <5q811u$k2b@lyra.csx.cam.ac.uk>
Eli the Bearded <usenet-tag@qz.little-neck.ny.us> wrote:
>
>So is this a feature or a bug? If it is a feature, I'll slap a
>while loop around the outer s/// and remove the /g from it. If
>it's a bug I'll report it with perlbug.
Bug. Mended in the current maintenance release 5.004_01
(i.e. latest.tar.gz on CPAN).
Mike Guy
------------------------------
Date: Sat, 12 Jul 1997 02:37:01 -0700
From: John Callender <jbc@west.net>
To: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: $1 trashed on nested s///: feature or bug
Message-Id: <33C7503D.88AF23AA@west.net>
Eli the Bearded wrote:
>
> while(<>) {
> s+\b(x-mac-(?:type|creator)=")([\da-f]{8})"+
> ($e=$1,$e) .
> ($f=$2, $f=~ s<([\da-f][\da-f])><chr(hex($1))>ige, $f)
> . qq^"^ +ige;
> print ;
> }
>
> I know I am not using -w, that was just for the sample above. With it
> It tells me I am using $1 uninitialized somewhere in the second
> substitution pass of the outer s///. Meanwhile $2 clearly has not
> been reset either for the second pass.
I'm probably missing something (I usually am), but I thought you were
supposed to use \1 and \2, rather than $1 and $2, to reference an
earlier match within the same regexp.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Fri, 11 Jul 1997 22:19:10 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: $ENV{'QUERY_STRING"} problem
Message-Id: <tcyangED6Dzy.7uu@netcom.com>
You can check out the mouse book published by O'Reilly by Shishir
Gundavaram, which provides a solution.
=====================================
Trang Ngo wrote after zapping the scum of the universe:
: Hello
: when I am passing the data to my perl cgi. If the data has more than
: 1 word, I
: will lose everything except the first word.
: Example: State=48&Div=0&Indu=Total Nonfarm.
: I saw it on the location with my my programe name and the example
: above.
: However, inside my cgi:
: $my_input=$ENV{'QUERY_STRING'};
:
: ==>my_input only contains State=48&Div=0&Indu=Total. I lost Nonfarm.
: Would anyone know how to solve the problem? Please direct me. I use
: Perl5.003 on UNIX(SunStation).
--
====== Try the low-crossposting robomoderated 'alt.culture.taiwan' ======
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: 11 Jul 1997 11:24:35 -0600
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Re: 'use strict' with CGI.pm
Message-Id: <uowyb7da4do.fsf@tremere.ecte.uswc.uswest.com>
>>>>> "Bernard" == Bernard Cosell <bernie@rev.net>
>>>>> wrote the following on Thu, 10 Jul 1997 20:38:26 GMT
Bernard> Hi-- I'm fond of using 'use strict', but I run into trouble
Bernard> when I try to use various modules. The problem de jour is
Bernard> with CGI.pm. First sign of trouble is when I went to do:
Bernard> use CGI shortcuts;
Problem here is that under strict, "shortcuts" as a bareword is not allowed.
You need to quote it, either with '' or something like qw().
Bernard> and got a 'bareword' error. And
Bernard> throughout I get errors like:
Bernard> Unquoted string "startform" may clash with future reserved
Bernard> word at checkhours.pl line 43.
This is because the shortcuts error above prevented the import of the relevant
routines from CGI. Fix the above and these will go away.
Randy
--
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)595-2869
Denver, CO rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin
------------------------------
Date: 11 Jul 1997 17:45:22 -0600
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Re: 'use strict' with CGI.pm
Message-Id: <uowyb7di25p.fsf@tremere.ecte.uswc.uswest.com>
>Honza Pazdziora (adelton@fi.muni.cz) wrote:
>: use CGI 'shortcuts';
>:
>: The error is reported before the use CGI is even called.
>:
>This will get rid of the first error message but not the "unquoted string"
>error messages (and others). You need to fully qualify those constructs.
Actually, it will. If the import associate with "use CGI 'shortcuts'" succeeds,
then those method names will be exported into the calling scope. I use the
CGI shortcuts all the time without instantiating a CGI object.
Randy
--
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)595-2869
Denver, CO rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin
------------------------------
Date: Fri, 11 Jul 1997 08:48:45 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: 'use strict' with CGI.pm
Message-Id: <adelton.868610925@aisa.fi.muni.cz>
bernie@rev.net (Bernard Cosell) writes:
> Hi--
>
> I'm fond of using 'use strict', but I run into trouble when I try to
> use various modules. The problem de jour is with CGI.pm. First sign
> of trouble is when I went to do:
> use CGI shortcuts;
> and got a 'bareword' error. And throughout I get errors like:
>
> Unquoted string "startform" may clash with future reserved word at
> checkhours.pl line 43.
>
> Is there some general way to arrange 'tidy' access to CGI.pm so that
> use strict; will be happy? Thanks!
I think it's not problem with CGI.pm. Try
use CGI 'shortcuts';
The error is reported before the use CGI is even called.
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 12 Jul 1997 11:11:20 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: cgi.pm converting help
Message-Id: <5q7ooo$ea8@lyra.csx.cam.ac.uk>
In article <33C1E0E4.1571@sirius.com>, Mike Aarset <mikus@sirius.com> wrote:
>
>but, the server that the script is going to run on does not have CGI.pm
>installed. I started learning cgi perl scripts with CGI.pm. Is there an
>easy way to convert the script to use the old way of doing cgi. I
>figured
>CGI.pm was the wave of the future and pretty much anyone running perl5
>would have it. I emailed root to see if they could install it. So now I
>guess i have to either see if they will install it or change my script.
>Where on the web can I learn how to do cgi scripts not using CGI.pm.
>Mike (juggy) Aarset
Looks like it would be worth checking what version of Perl they are
running. Maybe they've got something ancient (like Perl4) which doesn't
support CGI.pm. Also, sufficiently modern Perls (since 5.004) come with
CGI.pm automatically installed.
Mike Guy
------------------------------
Date: 11 Jul 1997 21:52:25 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Deleting all spaces at the beginning of a line.
Message-Id: <5q69up$sce$1@marina.cinenet.net>
Dana W. Edwards (dedwards@homeaccount.com) wrote:
: I am having trouble deleting all the white space at the beginning of a
: line of text. How would I do this without chomping the rest of line?
Have you read the Llama and/or Camel books and/or the incredibly copious
online doc, the latter having been both shipped with your Perl
installation *and* made available on the web? Any of these would have
answered this rather elementary question faster than asking here.
In your case, you want:
$line =~ s/^\s+//;
Which in English might be read, "In the string named $line, substitute one
or more whitespace characters at the beginning of the line with nothing."
---------------------------------------------------------------------
| 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: Fri, 11 Jul 1997 17:44:40 -0500
From: Chris Mason <cmason@ti.com>
Subject: hash ref from list
Message-Id: <33C6B758.3C9E@ti.com>
All-
I know I'm exceeding my question quota here, but this is ticking me
off. I'm writing a function which takes a colon seperated list and
turns it into a hash reference. I have a global hash of hashes
(%HASHES) under which all of the data lives. For example,
makehashref("ahash:somehash:anotherhash:akey");
would return a reference to
$HASHES{'ahash'}{'data'}{'somehash'}{'anotherhash'}{'akey'}
I know this is kind of complex, but hey, perl's cool like that. This is
what I have:
# utility routine to make colon separated hash name into hash ref
sub makehashref {
my ($name) = @_; # colon seperated hash specification
my @parts = split /:/, $name;
# all data lives under %HASHES{...}{'data'}
my $ref = \$HASHES{$parts[0]}{'data'};
foreach $part (@parts) {
if (ref $ref !~ /HASH/) {
debugmsg("makehashref(): $ref not a ref.\n");
return undef;
} elsif (!exists ${$ref}{$part}) { # line 247
debugmsg("makehashref(): error on $part.\n");
return undef;
}
$ref = \${$ref}{$part};
}
return $ref;
}
"Not a HASH reference at ./hashserver.pl line 247."
Any ideas? Suggestions? Style comments?
-c
--
Chris Mason <cmason@ti.com> -- Sterling Software - COOL:Cubes Dev
"...the monstrous thing is not that men have created roses out of
this dung heap, but that...they should _want_ roses." -H. Miller
------------------------------
Date: 11 Jul 1997 22:25:28 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: How to return an image from perl
Message-Id: <01bc8e49$76958b00$d20ab2c2@Tschai>
Chris Hostetter <me@anon.com> wrote in article
<33BD7945.5F51E561@anon.com>...
> > <IMG SRC="/cgi-bin/thescript.cgi">
> >
> > thescript.cgi:
> >
> > #!/usr/local/bin/perl
> >
> > $| =1; # no buffering
> >
> > print "Content-type: image/gif\n\n";
> >
> > open(FILE, "yourimage.gif") || die;
> >
> > while(<FILE>) { print; }
> >
> > close(FILE);
>
> while this example is kinda silly for one static image, it is also
silly
> for any quantity of N static images of which you want 1, because
you can
> also just say;
>
> print "Location: yourimage.gif\n\n";
It is not always silly: Suppose you want to show a user n sample
images, which are
kept away in a special "out of reach" directory to prevent users from
getting (stealing)
all the sample images in one go...
John
--
----------------------------------------------------------------------
Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)
http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]
email: jbokma@caiw.nl phone: +31 10 4291827
------------------------------
Date: 11 Jul 1997 22:29:19 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: How to return an image from perl
Message-Id: <01bc8e4a$00254d60$d20ab2c2@Tschai>
Chris Hostetter <me@anon.com> wrote in article
<33BD7945.5F51E561@anon.com>...
> > <IMG SRC="/cgi-bin/thescript.cgi">
> >
> > thescript.cgi:
> >
> > #!/usr/local/bin/perl
> >
> > $| =1; # no buffering
> >
> > print "Content-type: image/gif\n\n";
> >
> > open(FILE, "yourimage.gif") || die;
> >
> > while(<FILE>) { print; }
> >
> > close(FILE);
>
> while this example is kinda silly for one static image, it is also
silly
> for any quantity of N static images of which you want 1, because
you can
> also just say;
>
> print "Location: yourimage.gif\n\n";
AFAIK there are (old) browsers which don't support Location, or isn't
this true?
John
--
----------------------------------------------------------------------
Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)
http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]
email: jbokma@caiw.nl phone: +31 10 4291827
------------------------------
Date: 11 Jul 1997 17:53:37 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: Need advice on a good Perl Book
Message-Id: <5q5rv1$5qn$1@flint.sentex.net>
Mark (mrstevens@monmouth.com) wrote:
: Hello,
: I want to start programming in Perl 5 and would like to
: know if anyone has read "Perl 5 by Example" published by Que?
: This book (published 7/97) has receive great reviews from the
: press, but I would like to know some opinions of the subscribers
: of this group.
: If you have any recommendations of books for beginners, please
: post them..
: Thank you
: Mark
I learned Perl from 'Programming Perl'. Make sure you get the second
edition with the bluish(turquoise?) color front.
It's like K&R2 for C, it's the Bible!
--
Gabor Egressy : gabor@quickweb.com
No, I am not going to explain it. If you can't figure it out, you
didn't want to know anyway... -- Larry Wall, 1991
------------------------------
Date: 11 Jul 1997 11:31:41 -0600
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Re: OOP question
Message-Id: <uowwwmxa41u.fsf@tremere.ecte.uswc.uswest.com>
[Courtesy Cc of this post sent to original author]
>>>>> "Joshua" == Joshua Marotti <jpm@iti-oh.com>
>>>>> wrote the following on 10 Jul 1997 20:44:28 GMT
Joshua> I have several objects.. I use the same reference for those
Joshua> objects.. example (pseudo code)
Joshua> loop...
Joshua> ref = new Object "Name that changes each loop";
Joshua> endloop...
Joshua> now I want to go
Joshua> back to one of those previous references... How would I
Joshua> accomplish this?
Based on what you shared with us, you can't. When you created the object
within the loop, unless you saved the reference somewhere, it was lost when
the variable was re-assigned (it was freed when there were no longer any
references to it). Even if your constructor (new()) built the initial instance
variables as direct functions of the value of the string you pass to it, any
work done on that object during the loop's duration would still be lost.
If you want to come back to them, you have to save the objects somewhere.
Randy
--
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS Phone: (303)595-2869
Denver, CO rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin
------------------------------
Date: 12 Jul 97 11:10:14 GMT
From: "Andy Fletcher" <andy@cyberware.co.uk>
Subject: Re: Perl 5.004 binary for Solaris 2.5
Message-Id: <01bc8eb7$ee1145c0$0fdd4ac2@194.74.221.2>
Andy Fletcher <andy@cyberware.co.uk> wrote in article
<01bc89fc$d6a78d00$0edd4ac2@194.74.221.2>...
> I am looking for a perl 5.004 binary for our Netra to run under Solaris
> 2.5.
Thanks to those who responded. I am now the proud owner of 5.001 binary.
My problem is lack of disk space and no compiler on the sun. Both are soon
to be rectified so it will not be a problem much longer.
If anyone has similar problems then I have put a copy of the binary on:
ftp://ftp.cyberware.co.uk/pub/SystemUtils/perl/bin_5.001/perl.gz
Andy Fletcher
andy@cyberware.co.uk
------------------------------
Date: Sat, 12 Jul 1997 08:16:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ron Ablang <labinfo@gaia.csus.edu>
Subject: Re: please help me modify this perl script
Message-Id: <Pine.GSO.3.96.970712080456.2012Q-100000@kelly.teleport.com>
On Fri, 11 Jul 1997, Ron Ablang wrote:
> Could someone please help me modify this perl script that I just
> inherited?
Sure. Would you like me to send you information on my hourly rates? Or are
you willing to do some of the work yourself? :-)
> I would like it to do 2 things: 1) allow one to backspace when it
> prompts me for data
That's the Term::ReadLine module, available on CPAN.
> and 2) eliminate those fork errors that I somehow don't get when I split
> the distribution list in half and run the script for each.
> while ($field = <SOURCE>) {
> chop($field);
> unless (fork) {
> exec("mailx -s '$subject' $field < $distribution_file");
> }
Well, you "somehow" don't get them because you're not running out of
processes! When you need to fork more than once (and probably even then)
you should expect to have fork fail because you're running out of
available process slots. (Scold the author of that code for not expecting
that. Also, you should know that there are better ways to do what that
code does.)
There's some example fork code in the docs that can easily be turned into
a subroutine called &my_fork. Making that line call &myfork instead of
fork will then make it safe from that error.
Cleaning up that code's other problems should keep you busy for a
while. :-) Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 12 Jul 1997 11:33:45 -0400
From: Stephen Hill <buck@huron.net>
Subject: Printing first portion of a variable.
Message-Id: <33C7A3D2.F99F5495@huron.net>
How can i print the first 100 characters of a variable?
I can chop off the last character till it is the right length, but that
doesn't seem to efficient.
Please email your response to.......buck@huron.net
Thanks..
------------------------------
Date: Fri, 11 Jul 1997 08:39:50 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Regular experssions and delimiters.
Message-Id: <adelton.868610390@aisa.fi.muni.cz>
carinhas@gde.GDEsystems.COM (Dr. Philip Carinhas) writes:
> I just ran across a strange problem where my regular expression
> would always match false if I would pass the delimters in via a string:
>
> $reg_exp = "/$some_other_exp/" ;
>
> if ($string =~ $reg_exp) .. # Wrong ?
> if ($string =~ /$some_other_string/) .. # Right ?
>
I am not SuPerLative but try to answer. The thing in the first if is
not reg_exp. You simply try to apply =~ operator on two strings and
even if I am not sure what happens next, I am sure that it's not a
pattern matching. If it worked, you could even write
if ($reg_exp) {
and expect that it will do something else that just checking the value
of the $reg_exp string. Remember, this is not shell with multiple
variable interpolation and expansion.
Also, consider
$a = "./.";
$b = <>;
print "1\n" if $b =~ /$a/;
Now if you feed it sdf/dfg, it will correctly answer 1. Even if you
can specify regular expression inside of a variable, you cannot easily
escape out of the delimiters.
> Anyway It gave me big greif.. I tried al sorts of metaquote and
> alternate combinations.. Now it works ok... Of course it could be that I am
> using
>
> &GetOptions(
> "from=s" => \$from,
> "to=s" => \$to,
> "db=s" => \$db,
> "password=s" => \$passwd,
> "loginame=s" => \$loginame,
> "reg_exp=s" => \$reg_exp,
You should decide if your users shall pass the reg exp in with the
slashes or not, and you could even do s!^/(.*)/$!$+! to accept both
semantics. But in your program, you have to supply your own pair of
delimiters.
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Sat, 12 Jul 1997 05:37:48 -0700
From: perl guy <guitarweb@hotmail.com>
Subject: script going zombie, missing read...
Message-Id: <33C77A9C.4863@hotmail.com>
I'm going nuts (more then I already am!)..
Please read, this is just what's goign on, it *is* a perl problem -- I
think!??? This is why I am seeing if anyone knows..
I have a chat script, and it worked great for a long time, then, my
server admin installed a new version of Apache, and had the chat message
files wrote to a RAM disk, because the hard drive is old and failing.
Somehow, it makes my chat scripts go zombie (not all the time).. but
enough, and when it starts, it gets worse! Anyway, we have moved the
files to write to the hard drive again, and that didn't help. So we
installed the other version of apache again, and it's still screwing up.
People are missing messages.. it IS writing the messages to the RAM disk
and/or hard drive (depending on what we're doing, but not making a
differnce!). Anyway, people are chatting to each other fine, and after
a few hours. (could be the memory?, or the RAM disk messing up after it
gets over 1 MEG stored?), then after a few hours, people start missing
messages!?! I look at the directories, and the files ARE writing, and
other people (some of the time) can read what others say at that point,
but a lot of the time, they can't even see the messages they are
posting!.. I don't know what to do!? I worked great before! I assume,
this is because my chat only shows the newest messages, and when the
script misses, it assumes they've already read the message #, and
doesn't show it... whish would make sense, but I can't figure out how
it's actually reading the messages they see as already being read?
Coulkd this happen from a zombie process?. It starts happening to
everyone in the rooms at different times, then to everyone when it gets
really bad. it seems to happen all the time. I modified a Selena Sol
chat script. Maybe that's the problem? Please, if you have any advice on
how to read and or write it better, or if the Selena Sol thing is just
garbage, tell me.. Here is the main parts of the script. (or rather, the
parts that matter)
$how_many_old = $in{ 'how_many_old' };
$user_last_read = 0;
$session = &MakeSessionFile($chat_username, $chat_email, $refresh_rate,
$how_many_old, "0");
($user_name, $user_email, $how_many_old, $user_last_read, $high_message)
= &GetSessionInfo($session, $fsubmit, $frames);
# prints chat message, then
&PruneOldMessages($chat_room_dir);
$old_last_read = $user_last_read;
($user_name, $user_email,
$refresh_rate, $how_many_old,
$user_last_read, $high_message) =
&GetSessionInfo($session, $fsubmit, $frames);
$user_last_read = $old_last_read;
## prints the actual message..
$msg_to_read = $user_last_read + 1;
$msg_to_read -= $how_many_old;
if ($msg_to_read < 1)
{
$msg_to_read = 1;
}
if ($high_message >= $msg_to_read)
{
for ($x = $high_message; $x >= $msg_to_read; $x--)
{
$x = sprintf("%6d",$x);
$x =~ tr/ /0/;
if (-e "$chat_room_dir/$x.msg")
{
open(MSG,"$chat_room_dir/$x.msg") ||
&CgiDie("Could not open $x.msg");
$msg_from_user = <MSG>;
#blah blah blah...
&PrintChatScreen($chat_buffer, $refresh_rate,
$session, $chat_room, $setup,
$frames, $fmsgs, $fsubmit);
The rest is the way it actually reads and delets the message files,
etc..
I don't know is this is just a poor script or what?. Sorry for all the
code, but I need you to know what's happening if anyone will offer to
tell me.. thank you!!
------------------------------
Date: 11 Jul 1997 19:51:43 GMT
From: quentin@hendrix.amd.com (Quentin Fennessy)
Subject: Re: Setting TARGET variable from Perl Script
Message-Id: <5q62sf$77e$1@amdint2.amd.com>
In article <33C3D1A0.19F8@ix.gen.com>,
Steve Moyer <solutions@ix.gen.com> wrote:
>How can you set the TARGET window from within a Perl Script?
Steve- I suggest you use CGI.pm, which is included in the current
Perl distribution. Check out the docs with 'perldoc CGI' for a
section like this:
The argument -target allows you to provide a default target
frame for all the links and fill-out forms on the page. See
the Netscape documentation on frames for details of how to
manipulate this.
-target=>"answer_window"
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: 12 Jul 1997 13:03:14 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Strategies for dealing with the 'Use of uninitialized value' warning.
Message-Id: <5q7vai$irc@lyra.csx.cam.ac.uk>
Danny Yarbrough <dyarbrou@clark.net> wrote:
>
>Use of uninitialized value at myscript line xxx
>
>First off, is there a logical reason why it doesn't tell you what
>value (or variable) is undefined?
Not exactly a _logical_ reason, but it's because it isn't easy to do.
In general (as your wording implies) the undefined value is of an
arbitrary subexpression, rather than a simple variable. And there is
no record kept in the compiled code of how bits of code correspond to
source expressions.
It might be possible to do something for special cases, such as simple
variables. Perhaps you might like to suggest a patch?
>In a script where line xxx may contain serveral variable referances,
>it can be a bit tricky to narrow down which one is the offending one.
>I know about initializing all variables before they are used, of
>course, but sometimes that doesn't always work, especially if some
>routine or other has returned an undefined variable.
>
>I've gone so far as to rewrite the line in question as multiple lines,
>each using only one or two of the variables; this isn't always
>practical.
There isn't really any easy way. I've also had to split up expressions
like that on occasion. Some alternatives:
i) Put tests for "undef" and/or diagnostic print statements before the
offending line.
ii) Use debug. Put a breakpoint at the offending line, then try
evaluating various subexpressions with the "x" command.
But it's all rather tedious.
Mike Guy
------------------------------
Date: 12 Jul 1997 00:26:38 GMT
From: kkong@ece.ucdavis.edu (Keith Kong)
Subject: syswrite vs. select S;$|=1;print S
Message-Id: <5q6ivu$vr$1@mark.ucdavis.edu>
Keywords: buffer, buffering, flush, autoflush
I'm writing a server/client application using perl 5.002 on
an SGI machine, and I'm having a heck of a time figuring out
buffering problems associated with the print command.
The following does NOT force 'C' to be printed out to the
socket S:
$_ = 'C';
select S; $|=1;
print S $_;
The following, however, does work:
$_ = 'C';
syswrite S, $_, 1;
I'd like to use print for everything, but if syswrite is
the only way I can flush characters, I'll have to use it.
Any ideas why the first block of code does not work?
By the way, I've also tried select((select(S), $| = 1)[0]);
in place of select S; $|=1, and that still doesn't work.
Keith
------------------------------
Date: Sat, 12 Jul 1997 10:37:22 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: UUDECODE Mailer program in Perl 5
Message-Id: <33cad74d.4971713@194.72.192.4>
Bart.Dhaenens@kahoslg.be (Bart D'haenens) wrote:
>Does anyone know if a perl script exists that is used in a .forward file on a
>user account and parses e-mail messages containing UUENCODED attachments to a
>uudecoder program and sends a reply of the message to the original sender
>containing a MIME attachment.
>
>e.g. I receive a message containing a uuencoded document. I forward it to
>decode@my.organization and a while after I get a reply from decode containing
>the same document but as a binary MIME attachment.
Have a look at the MIME modules on CPAN and pack().
--
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.mindweb.co.uk/
------------------------------
Date: Sat, 12 Jul 1997 02:07:27 GMT
From: FANNGMAIL@prodigy.net (Fan Ng)
Subject: while.problem
Message-Id: <33cae658.33936516@news.prodigy.net>
Hi all:
I don't know what is while(<>) means.
I know that while(1), while will be loop.
and if while(0) wouldn't loop.
so what's <> means.
fanngmail@prodigy.net
------------------------------
Date: Sat, 12 Jul 1997 07:41:09 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: while.problem
Message-Id: <51u7q5.dk.ln@localhost>
Tim Gim Yee (tgy@chocobo.org) wrote:
: On Sat, 12 Jul 1997 02:07:27 GMT, FANNGMAIL@prodigy.net (Fan Ng)
: wrote:
: >Hi all:
: >
: >I don't know what is while(<>) means.
: >I know that while(1), while will be loop.
: >and if while(0) wouldn't loop.
: >so what's <> means.
: <> is the same as <STDIN>. Since it's the only thing in the while
: condition, it automatically assigns to $_. These are equivalent:
: print while $_ = <STDIN>;
: print while <STDIN>;
: print while <>;
Those are similiar, not equivalent.
The first two will read ONLY from STDIN.
The diamond operator will read from filenames given as arguments if
any. It will read from STDIN if no filename args where provided.
Additionally, the diamond operator also does a defined() check on
the file read. So it is more like:
print while defined($_ = <STDIN>);
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
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 726
*************************************