[7722] in Perl-Users-Digest
Perl-Users Digest, Issue: 1348 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 20 14:17:25 1997
Date: Thu, 20 Nov 97 11:00:36 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 20 Nov 1997 Volume: 8 Number: 1348
Today's topics:
Re: "perl aware" vi editor? (Jeremy D. Zawodny)
Re: $a='001' ; $a++ ; print$a <usenet-tag@qz.little-neck.ny.us>
Re: -e switch <jamesr@aethos.co.uk>
Re: -e switch <jamesr@aethos.co.uk>
Re: -e switch <tchrist@mox.perl.com>
Re: any GUI modules? <cmargoli@world.northgrum.com>
Re: Best way to find directory of a given file <merlyn@stonehenge.com>
Binary file attachments? <erixred@IDT.NET>
Curses based module for editing tables? <joe@ispsoft.de>
Re: exclusive file rights (Bart Lateur)
Re: exclusive file rights <merlyn@stonehenge.com>
File attachments using sendmail <dave@docsoftware.com>
Re: File attachments using sendmail (Jeremy D. Zawodny)
Re: File attachments using sendmail <erixred@IDT.NET>
Re: Here's a simple one <keson@uswest.com>
Re: max size of cookie? (Jeremy D. Zawodny)
Re: No value for $OSNAME under Windows <mhazen@franklin.uga.edu>
open/read/close in PERL <accu-scan@worldnet.att.net>
Re: pass by reference? what is wrong? (Tina Marie Holmboe)
Re: Perl Programmer needed (Jeremy D. Zawodny)
Re: Problem with localtime and timelocal (getting the W <keson@uswest.com>
Ques: <yju2@cs.umbc.edu>
Re: Ques: (Jeremy D. Zawodny)
s/// Question <paulp@jumper.mcc.ac.uk>
Safe use of flock() -- was Re: giving up on flock <luutran@geocities.com>
Socket Problems mchorgh@ike.com
Splice() and until() <leurmy@akula.com>
Re: System call on Dos/Win Perl - How To? <helgek@berlin.snafu.de>
Re: Win32::EventLog problems... <leberre@bandol.grenoble.hp.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 Nov 1997 17:59:58 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: "perl aware" vi editor?
Message-Id: <34747a96.9540728@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On 19 Nov 1997 22:22:39 GMT, "T.E.Dickey" <dickey@clark.net> wrote:
>Patrick <patrickq@hotmail.com> wrote:
>: VIM (VI iMproved) version 5 is in both categories. Currently in alpha
>: but very close to beta, and is ported to most all platforms. Also,
>: VIM is to replace nvi as the freeBSD vi editor (?)
>well, that's a shame. nvi is a much better piece of work.
In what ways?
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: 20 Nov 1997 18:35:48 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: $a='001' ; $a++ ; print$a
Message-Id: <eli$9711201421@qz.little-neck.ny.us>
Honza Pazdziora <adelton@fi.muni.cz> wrote:
> Koos Pol <koos_pol@bigfoot.com> writes:
> > $a='001';
> > $a++;
> > print $a;
> > This nicely yields '002'. I was very positively shocked about this:-) !
> > Is this correct behaviour ?
> You might want to check man page perlop, section about auto-increment.
> The ++ is magical on strings.
:r! perl5.00401 -we '$section="4.2.07"; $section++; print "$section\n";'
5.2
Not what one might expect reasonably....
"4.2.10" or "4.2.08", I could expect reasonably.
Elijah
------
your expectations may vary
------------------------------
Date: 20 Nov 1997 17:14:31 GMT
From: "James Richardson" <jamesr@aethos.co.uk>
Subject: Re: -e switch
Message-Id: <01bcf5d7$db246320$26c0a4c1@kitkat.aethos.co.uk>
Joseph Kewish <jsrk@pipeline.com> wrote in article
<34739DD8.812C1DFB@pipeline.com>...
> I'm having the damndest time trying to figure out how to use perl
> straight from the command line. There are times when I just need a
> little loop or what have you, but I've not been able to find a clear
> example of how the -e switch is used.
>
> Anyone care to give me an example?
>
> Thanks a lot...
>
>
Urm... you just type in some perl...
% perl -e 'print scalar(localtime)'
Of course it gets more powerful if you use -n etc etc...
James Richardson
------------------------------
Date: 20 Nov 1997 17:47:10 GMT
From: "James Richardson" <jamesr@aethos.co.uk>
Subject: Re: -e switch
Message-Id: <01bcf5dc$6af23640$26c0a4c1@kitkat.aethos.co.uk>
James Richardson <jamesr@aethos.co.uk> wrote in article
<01bcf5d7$db246320$26c0a4c1@kitkat.aethos.co.uk>...
> Joseph Kewish <jsrk@pipeline.com> wrote in article
> <34739DD8.812C1DFB@pipeline.com>...
> > I'm having the damndest time trying to figure out how to use perl
> > straight from the command line. There are times when I just need a
> > little loop or what have you, but I've not been able to find a clear
> > example of how the -e switch is used.
> >
> > Anyone care to give me an example?
> >
> > Thanks a lot...
> >
> >
I should have added something about the -n and -i switches etc...
Heres one from the man page
find . -mtime +7 -print | perl -nle 'unlink;'
Finds all files that havent been touched for a week and deletes them
or
perl -p -i -e 's/Dollars/Pounds/;' *.txt
for an instant US->UK price list translation facility.
James Richardson
------------------------------
Date: 20 Nov 1997 18:27:11 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: -e switch
Message-Id: <651vdv$5n2$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Clark Dorman <clark@s3i.com> writes:
:Below is the "Canonical List of One-Liners", that really isn't but when I
:once asked for such a list I got the following (from Jeff Stampes).
FYI: That's my list, BTW.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
echo "ICK, NOTHING WORKED!!! You may have to diddle the includes.";;
--Larry Wall in Configure from the perl distribution
------------------------------
Date: Thu, 20 Nov 1997 17:24:05 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: any GUI modules?
Message-Id: <34747235.3C2E@world.northgrum.com>
mhempel@select.net wrote:
>
> Are there any modules to make those swell boxes and buttons in X
> windows and/or Windows 95/NT? Would anybody have any use for such
> a thing if I went about trying to make some?
>
Yes! Look in CPAN for Tk, which is derived from Tcl/Tk.
We use it on Unix with X and it works great. There is a new version
for Windows 95/NT also, but I have not tried that.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: 20 Nov 1997 09:57:12 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Brad Fitzpatrick" <usenet_post@bradfitz.com>
Subject: Re: Best way to find directory of a given file
Message-Id: <8cvhxnec5z.fsf@gadget.cscaper.com>
>>>>> "Brad" == Brad Fitzpatrick <usenet_post@bradfitz.com> writes:
Brad> Suppose that I known the full path to a given file... I want to find that
Brad> file's directory so I can chdir() to it.
[...]
Brad> Is there a Perl function to give me this information or is the
Brad> regex method acceptable?
It's not built in, but it's in the standard shipped-with-Perl library:
use File::Basename qw(dirname);
$directory = dirname $filename;
This appears to be portable to the non-Unix ports as well.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 284 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 20 Nov 1997 18:47:57 GMT
From: eric bucher <erixred@IDT.NET>
Subject: Binary file attachments?
Message-Id: <6520kt$q9s@nnrp2.farm.idt.net>
OK, so I know how to attach a text file to the sendmail program, but how
are binaries handled?
My code looks like this:
open(MAIL,"|$mailprog -t");
print MAIL "To: $someguy\n";
print MAIL "From: $theman\n";
print MAIL "Subject: $something\n";
open(INPUT,"$your_file_path")||&error;
while (<INPUT>) {
chop $_;
print MAIL $_,"\n";
}
close (INPUT);
close (MAIL);
But how do I specify seperate attachments for binary data?
Any help would really make my day.
later,
eric
------------------------------
Date: Thu, 20 Nov 1997 17:06:54 +0100
From: Jochen Wiedmann <joe@ispsoft.de>
Subject: Curses based module for editing tables?
Message-Id: <3474601E.53AD1461@ispsoft.de>
Hello,
I'd like to implement a functionality into an SQL shell that could
look similar to a spreadsheet program: You see a table in front of
you and have the ability to edit a single column by just moving the
cursor to it. This should be Curses based, as it would be used on terminals
typically.
Is there any module that aids me in writing this, ideally a module
like "Data::EditTable"? If not, can anyone recommend a package for
building on, perhaps above "Curses"?
Thanks,
Jochen
--
Jochen Wiedmann joe@ispsoft.de
07123 14887
------------------------------
Date: Thu, 20 Nov 1997 17:15:17 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: exclusive file rights
Message-Id: <34756b63.8266542@news.tornado.be>
Cameron Dorey <camerond@mail.uca.edu> wrote:
>> You did miss the beginning of the thread. flock() is advisory on
>> Unix, but
>> is(?) mandatory on Win32.
>
>Except flock() is *missing* in Win95 (see my two minutes earlier post
>somewhere on another branch in this thread).
Hi Cameron,
Perhaps you might better forget about locking your file, and try a
different approach. This might not work on Unix, but on PC's I'm pretty
sure it should work. (It does on Win3.1).
Use another new file, next to the one you're trying to lock, as a
semaphore (= a signalling flag). On PC's, a file can be opened for
writing by only one program at a time. You don't need to put anything
into it, just opening it is enough.
If any other program tries to write to this file while it's open, it
will fail. That way, it "knows" the datafile is in use. It should then
wait (sleep) until it can succesfully open the semaphore file.
If for some reason, the program that opened the file crashes, the file
will automatically be closed and thus freed, by the OS.
Of course, this scenario can only work reliably for programs that behave
"nicely", and respect this file locking. But if you're dealing with a
small set of programs (preferably written by yourself), or multplie
copies of one program, you should be able to make this work.
HTH,
Bart.
------------------------------
Date: 20 Nov 1997 10:24:35 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: exclusive file rights
Message-Id: <8chg97eawc.fsf@gadget.cscaper.com>
>>>>> "Bart" == Bart Lateur <bart.mediamind@tornado.be> writes:
Bart> Perhaps you might better forget about locking your file, and try a
Bart> different approach. This might not work on Unix, but on PC's I'm pretty
Bart> sure it should work. (It does on Win3.1).
Let me be *very* clear. The described method does *not* work on Unix,
because many processes can have a file open for writing at once.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 284 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 20 Nov 1997 13:04:21 -0500
From: Dave <dave@docsoftware.com>
Subject: File attachments using sendmail
Message-Id: <34747BA5.2FF5@docsoftware.com>
How can I attach a file to a mail message using sendmail in a perl
script?
Here is the script I am using.
open(MAIL,"|$mailprog -t");
print MAIL "To: $CONFIG{'eaddress'}\n";
print MAIL "From: $CONFIG{'recipient'}\n";
print MAIL "Subject: Confirmation\n";
print MAIL "\n...etc\n";
close (MAIL);
Please e-mail me directly it you have any ideas.
Thanks!
--Dave
dave@docsoftware.com
------------------------------
Date: Thu, 20 Nov 1997 18:18:51 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: File attachments using sendmail
Message-Id: <347a7eea.10649022@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On Thu, 20 Nov 1997 13:04:21 -0500, Dave <dave@docsoftware.com> wrote:
>How can I attach a file to a mail message using sendmail in a perl
>script?
>
>Here is the script I am using.
>
>open(MAIL,"|$mailprog -t");
>print MAIL "To: $CONFIG{'eaddress'}\n";
>print MAIL "From: $CONFIG{'recipient'}\n";
>print MAIL "Subject: Confirmation\n";
>print MAIL "\n...etc\n";
>close (MAIL);
>
>Please e-mail me directly it you have any ideas.
This is covered in the SMTP and/or MIME RFCs. It's *not*
Perl-specific. Check there.
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: 20 Nov 1997 18:44:36 GMT
From: eric bucher <erixred@IDT.NET>
Subject: Re: File attachments using sendmail
Message-Id: <6520ek$q9s@nnrp2.farm.idt.net>
Dude, try this little snippet of code:
open(MAIL,"|$mailprog -t");
print MAIL "To: $someguy\n";
print MAIL "From: $theman\n";
print MAIL "Subject: $something\n";
open(INPUT,"$your_file_path")||&error;
while (<INPUT>) {
chop $_;
print MAIL $_,"\n";
}
close (INPUT);
close (MAIL);
It works for me, hope it treats you well.
later,
eric
Dave <dave@docsoftware.com> wrote:
: How can I attach a file to a mail message using sendmail in a perl
: script?
: Here is the script I am using.
: open(MAIL,"|$mailprog -t");
: print MAIL "To: $CONFIG{'eaddress'}\n";
: print MAIL "From: $CONFIG{'recipient'}\n";
: print MAIL "Subject: Confirmation\n";
: print MAIL "\n...etc\n";
: close (MAIL);
: Please e-mail me directly it you have any ideas.
: Thanks!
: --Dave
: dave@docsoftware.com
------------------------------
Date: Thu, 20 Nov 1997 10:08:17 -0700
From: Kevin Eson <keson@uswest.com>
To: Myles Lawrence <myleslawrence@email.msn.com>
Subject: Re: Here's a simple one
Message-Id: <34746E81.2E64677B@uswest.com>
Myles Lawrence wrote:
> I've got a script that has a name and password field on it. When I run the
> form, I verify the values. If the name is verified, I would like to call
> form1.pl, if not I'd like to call form2.pl. Whats more I'd like to send the
> name to form1.pl?$name. Is this possible?
> myleslawrence@msn.com
Yes it is. With javascript doing the up-front verification and then it decides
which server process to call.
Kevin Eson
--
The view presented here are mine and mine alone. They
do not relect the views of my employer nor do I speak
for them. My employer's involvement to my post is only
as a provider of equipment and connection.
------------------------------
Date: Thu, 20 Nov 1997 18:08:35 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: max size of cookie?
Message-Id: <34767c8f.10045424@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On Thu, 20 Nov 1997 15:20:12 GMT, bart.mediamind@tornado.be (Bart
Lateur) wrote:
>Eli the Bearded <usenet-tag@qz.little-neck.ny.us> wrote:
>
>>kim slack <kas5670@vaxb.isc.rit.edu> wrote:
>>> How much data can you fit in a cookie? Geoff
>>
>>What kind of cookie? I saw a great shortbread recipe the other day,
>>but is is off-topic here.
>
>Maybe it's a Chinese fortune cookie. That would alow for, eh..., one
>tiny piece of paper. How many bytes is that?
One.
But I have a big mouth. :-)
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Thu, 20 Nov 1997 12:27:20 -0500
From: Mark Hazen <mhazen@franklin.uga.edu>
To: rjk@coos.dartmouth.edu
Subject: Re: No value for $OSNAME under Windows
Message-Id: <347472F8.7B382EB6@franklin.uga.edu>
Chipmunk wrote:
> I've run into a problem with the special variable $OSNAME under Windows.
> Basically, the variable has no value.
Try the special variable $^O instead; it holds the os for which that version
of Perl was built.
-mh.
----
. _+m"m+_"+_ Mark Hazen Network Administrator, Dean's Office
d' Jp qh qh The Franklin College of Arts & Sciences
Jp O O O The University of Georgia (706)542-1546
Yb Yb dY dY
O "Y5m2Y" " even the mightiest wave starts out as a ripple.
"Y_ why make waves when it's easier to nurture ripples?
------------------------------
Date: Thu, 20 Nov 1997 11:15:32 -0600
From: Mike Snyder <accu-scan@worldnet.att.net>
Subject: open/read/close in PERL
Message-Id: <651rf2$88h@bgtnsc02.worldnet.att.net>
Greetings!
Thanks to everybody who answered my first post concerning getting
started with Perl. In less than a week, I've already begun to develop
Perl that WORKS and is useful to me (although probably not very
optimized). For example, I've writting a Perl prog which accepts a
players name, score, and level (for a game) and opens a high scores list
and places him if necessary, then writes back a "high score board." I'm
learning at home (for games) and also at work (for our web site) and
it's going well.
What prompted me to start learning is the need for a serial number's
file that can be used to validate a serial number and see if the date
has expired yet compared to today's date. It's working great and the
whole thing executes from start to finish in about 1 second which is
very reasonable (for how I've done it) considering it's a 50k file of
numbers/dates it's processing)
My question is this, considering this code:
####
open FILE, "sn.dat";
read FILE, $buffer,100000;
close FILE;
@pairs = split(/&/, $buffer);
####
The file is really only about 53000 bytes (not 100000) but it might grow
in the future. I haven't seen any side effects from trying to read MORE
bytes than are in the file. It seems to work just fine and $#pairs ends
up being the correct number of records.
Does anybody see any ill-effects that might be caused from this. I've
tested it all morning and it's working wonderfully. I then perform a
second split on the contents of each $pair[] in itterations though a
hand-made binary search. (only have to split around 13 records total to
find any serial number in the list).
Thanks in advance!
Mike Snyder
Accu-Scan/Meal Tracker
http://www.accu-scan.com/
------------------------------
Date: 20 Nov 1997 17:46:02 GMT
From: tina@scandinaviaonline.se (Tina Marie Holmboe)
Subject: Re: pass by reference? what is wrong?
Message-Id: <651t0q$4jp$1@news1.sol.no>
In article <34746774.9044CF39@uswest.com>,
Kevin Eson <keson@uswest.com> writes:
> <smile>Tina you took the code right out of my mind.</smile>
Oh, sorry... now stand still... *stuffs it back inside* >:)
> Using the reference "->" arrow has always been my method of
> dealing with the reference variables.
Ditto. Besides, it looks soooo much more professional :)
--
Tina Marie Holmboe tina@mail.scandinaviaonline.se
The opinions expressed above are mine, and should in no way or under any
circumstances be associated with Scandinavia Online AB unless this disclaimer
is explicitly revoked.
------------------------------
Date: Thu, 20 Nov 1997 18:06:09 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Perl Programmer needed
Message-Id: <34757bf1.9888198@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On 20 Nov 1997 05:16:36 GMT, mosey@alpha3.csd.uwm.edu (John Mosey)
wrote:
>The projects range from a simple poll script with a cookie (I know, that's
>javascript)
You known a falsehood, then.
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Thu, 20 Nov 1997 10:05:27 -0700
From: Kevin Eson <keson@uswest.com>
Subject: Re: Problem with localtime and timelocal (getting the Weekday)
Message-Id: <34746DD7.633CD8D@uswest.com>
Using your own code this is what I found:
[/home/keson]> perl
use Time::Local;
$day = 20;
$month = 11;
$year = 97;
$hour = 12;
$tmday = timelocal(0,0,$hour,$day,$month,$year);
print "$tmday\n";
exit;^D
882640800
[/home/keson]> perl
print scalar localtime(882640800);
print "\n";
exit;^D
Sat Dec 20 12:00:00 1997
[/home/keson]>
This tells me that the $month parameter to the timelocal function is not the
actual numeric month but the zero-indexed month (0=January, 11=December).
The results you get for the day of the week (6) would be correct, December 20,
1997 is a Saturday.
Kevin Eson
+=========================================================+
| The view presented here are mine and mine alone. They |
| do not relect the views of my employer nor do I speak |
| for them. My employer's involvement to my post is only |
| as a provider of equipment and connection. |
+=========================================================+
Bertrand Le Guen wrote:
> Hi every body,
> in fact, i need to find the week number of any specific day, knowing
> the day, the month and the year.
>
> i wrote something like this but it doesn't work !
>
> use Time::Local;
> #for example
> $day = 20;
> $month=11;
> $year =97
> #hours = 12 (half of a day)
> $tmday = timelocal(0,0,12,$day,$month,$year);
> ($scds,$mnts,$hrs,$day,$dtmonth,$dtyear,$weekday,$yearday,$sdst)
> = localtime($tmday);
> $weekday = 6 !!!!! (6 is Saturday)
>
> it may be equal to 4 ? (tuesday is 4 no ?)
>
> time give me
> $test = time results 880037296 (at 16:45 the 11/20/97)
> timelocal for timelocal(0,0,12,20,11,97);
> TimeLocal = 88261560 (at 12:00 the 11/20/97) (might be less no?)
> what's wrong ?
>
> could someone explain that to me or show me an example on how to get
> the weekday number from a date !
>
> i didn't find anything in the FAQ so i wish someone could help !
>
> thanks
------------------------------
Date: Thu, 20 Nov 1997 12:23:15 -0500
From: yu ju <yju2@cs.umbc.edu>
Subject: Ques:
Message-Id: <Pine.SGI.3.91.971120122116.1146A-100000@spike.cs.umbc.edu>
Hello,
Can anyone tell me what does the following code mean?
%states = ($startNode => ["user"],
"kernel" => ["kernel"],
"idle" => ["idle"],
"sync" => ["sync"]
);
I can find the description of "=>" and "[ ]".
Thanks!
------------------------------
Date: Thu, 20 Nov 1997 18:17:45 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Ques:
Message-Id: <34797ea4.10578240@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On Thu, 20 Nov 1997 12:23:15 -0500, yu ju <yju2@cs.umbc.edu> wrote:
>Hello,
>Can anyone tell me what does the following code mean?
>
>%states = ($startNode => ["user"],
> "kernel" => ["kernel"],
> "idle" => ["idle"],
> "sync" => ["sync"]
> );
>
>
>I can find the description of "=>" and "[ ]".
Pick yourself up a copy of Learning Perl or read the on-line manual
pages.
Rather than give you a fish, I figure it's better to learn to fish for
yourself. :-)
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Thu, 20 Nov 1997 17:54:32 -0800
From: Paul Plowman <paulp@jumper.mcc.ac.uk>
Subject: s/// Question
Message-Id: <3474E9D8.35F5@jumper.mcc.ac.uk>
I know that when you do a substitution using s/// you can use a matched
pattern in the substitution by using $1, $2 etc. For Example:
$test =~ s/My (.*) is small/My $1 is big/g;
Is there any way of using the result of a match in the match itself? For
instance, if you want to search for a capital letter, followed by a
number, followed by the same letter. Could you do something like:
$test =~ s/([A-Z])[0-9]$1/whatever/g;
If not, how would you do this?
Paul.
------------------------------
Date: 20 Nov 1997 17:25:12 GMT
From: "Luu Tran" <luutran@geocities.com>
Subject: Safe use of flock() -- was Re: giving up on flock
Message-Id: <35754.3929988426luutrangeocitiescom@207.217.243.19>
On Wed, 19 Nov 1997, Mark Mielke <markm@nortel.ca> wrote:
> here's some pseudo-type code..
>
> sub append_to_file
> {
> if (open_the_file_for_writing) {
> if (request_exclusive_lock_on_the_open_file) {
> seek_to_the_end_of_the_file; <-- NECESSARY!!!!!!!!!!!!!!!
> print_your_stuff_to_the_filehandle;
> release_the_lock_on_the_open_file; <-- OPTIONAL
> } else {
> error_trying_to_lock_file!!!!
> }
> close_the_file;
> } else {
> error_trying_to_open_file!!!!
> }
> }
>
Is it necessary to check whether flock is successful? Here's the example
from man perlfunc
$LOCK_SH = 1;
$LOCK_EX = 2;
$LOCK_NB = 4;
$LOCK_UN = 8;
sub lock {
flock(MBOX,$LOCK_EX);
# and, in case someone appended
# while we were waiting...
seek(MBOX, 0, 2);
}
sub unlock {
flock(MBOX,$LOCK_UN);
}
open(MBOX, ``>>/usr/spool/mail/$ENV{'USER'}'')
or die ``Can't open mailbox: $!'';
lock();
print MBOX $msg,"\n\n";
unlock();
It's not checking the flock operation. I've always followed this example
and have had no problem. Maybe I've just been lucky?
-- luu
------------------------------
Date: Thu, 20 Nov 1997 11:02:09 -0600
From: mchorgh@ike.com
Subject: Socket Problems
Message-Id: <880002694.7375@dejanews.com>
I'm having newsgroup post problems at my ISP.
There may be duplicate posts, plus I am new to Perl.
I think I have exhausted reading all the newsgroups and FAQ for the past
2+ weeks that now I am seeking help.
I am writing a perl script to establish a tcp connection with a VM ESA
server. The script is only using the socket.pm module. I have been
successful in establishing the socket and the connection but the problem
lies when I try to print.
socket(S,AF_INET,SOCK_STREAM,$proto);
select(S); $|=1; select(STDOUT);
unless(connect(S, $that_addr))
{Error("No Connection");}
$reply = <S>;
print "$reply";
while (S){print S "$UID\n";}
$reply2 = <S>;
print "$reply";
The connection hangs forever after/at print S. $UID is specified.
Debug (-w) states
"Probable precedence problem on logical and at " ( the line with print S)
I have demonstrated the logon sequence with telnet, though I have seen
similar problems when CR to CR+LF is not turned on some telnet programs,
all other things
equal. Assuming that was the problem, I substituted \r and \f and
combinations thereof, to no avail.
I am currently using ActiveState's Perl 5.003.07.313 on NT4/SP3. Any help
will be appreciated. Thanks in advance.
Richard <mchorgh@ike.com> Please CC: directly.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Wed, 19 Nov 1997 00:43:04 -0500
From: Francois <leurmy@akula.com>
Subject: Splice() and until()
Message-Id: <34727C68.36F77A1D@akula.com>
Using a HTML form I need to delete paragraphs from an HTML file. Each
paragraph starts with an <li> tag and has lots of other tags (but only
one <li>). This code works but not the until loop. Any idea ???? Thanks
open(DOCS,"$basedir/my_file.html");
@lines = <DOCS>;
close(DOCS);
for ($i = 0; $i <= @lines; $i++) {
if ($lines[$i] =~ /<li>/) {
while (($key,$value) = each %FORM) {
if ($value eq "delete" && $lines[$i] =~ /<li>.*$key/) {
splice(@lines, $i, 1);
until ($lines[i] =~ /<li>/) { #
splice(@lines, $i, 1); # This until does not work
} #
}
}
}
}
foreach $lines (@lines) {
print "$lines";
}
------------------------------
Date: 20 Nov 1997 19:06:26 +0100
From: Helge Kruse <helgek@berlin.snafu.de>
Subject: Re: System call on Dos/Win Perl - How To?
Message-Id: <wk90ujl9st.fsf@bercos.de>
dhawk@best.com (David Hawkins) writes:
> But I can't get the system call for net use g: \\$machine\d$
> to work. It complains about the \'s no matter how I escape them.
did you try:
system ("net use g: \\\\$machine\\$d") || die "cannot map drive G:";
?
Helge
------------------------------
Date: Thu, 20 Nov 1997 18:24:41 +0100
From: Philippe Le Berre <leberre@bandol.grenoble.hp.com>
To: Richard Mayston <maystonr@ihug.co.nz>
Subject: Re: Win32::EventLog problems...
Message-Id: <34747259.96CD2361@bandol.grenoble.hp.com>
Hi
This is well known bug :( ... you need to a shift statement at the
beginning of the open method in the eventlog.pm.
For more info on the eventlog check my homepage at :
<http://www.inforoute.cgs.fr/leberre1/>.
--
Philippe Le Berre
SSG - CSBU R&D
Advance Technology Lab, Europe
----------------------------------------------------------------
Hewlett-Packard <leberre@bandol.grenoble.hp.com>
5 av Raymond Chanas Tel : 33 4 76 14 66 05
38053 Grenoble Cedex 9, France Fax : 33 4 76 14 14 65
------------------------------
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 1348
**************************************