[13220] in Perl-Users-Digest
Perl-Users Digest, Issue: 630 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 24 13:07:27 1999
Date: Tue, 24 Aug 1999 10:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 24 Aug 1999 Volume: 9 Number: 630
Today's topics:
ASK for Perl Cookie Password protection script <97237927d@polyu.edu.hk>
Re: Books , Reccomend? <cory.h.phillips1@jsc.nasa.gov>
CGI newsgroups? <karpat@eeh.ee.ethz.ch>
desperate NEWBIE <wablief@freemail.nl>
Re: desperate NEWBIE <gellyfish@gellyfish.com>
Re: Desperately searching for perl lint (Abigail)
Re: Desperately searching for perl lint (Eric Bohlman)
Re: Desperately searching for perl lint <gellyfish@gellyfish.com>
Re: Desperately searching for perl lint <scottle@mr.net>
DISREGARD!!! I made a VERY stupid mistake <akelingos@petrosys-usa.com>
Environment variables (Lee Mulleady)
Re: Environment variables <rassmann@sdm.de>
Re: help on semaphores in perl (Bill Moseley)
Hex from a file <joerg.pinn@gmd.de>
Re: I just don't get the hash thing.. <ccoving@uhc.com>
Is anyone using PerLDAP with PerlScript on IIS/NT? <jm908@columbia.edu>
New Perl Book "Object Oriented Perl" not really availab gmmengel@my-deja.com
newbi: Registry Help under NT <andy@aholmes.u-net.com>
Re: newbie: need help,LEARNING FROM A BOOK <madebeer@igc.apc.org>
newbie: problem with hash of arrays PLEASE HELP <akelingos@petrosys-usa.com>
Overwrite the middle of a file. (Greg Miller)
Re: Overwrite the middle of a file. (Eric Bohlman)
Perl Book <jyoyoliu@hotmail.com>
Re: Perl Book <jimmy@blackhole-designs.com>
Re: Perl Book (Eric Bohlman)
Perl don't stop cls@quotient.net
Re: PERL EDITOR <cory.h.phillips1@jsc.nasa.gov>
Re: Perl won't compile (gcc 2.8, AIX) <kperrier@blkbox.com>
Possible h2xs enhancement? <pds@datcon.co.uk>
Re: Referencing Questions (M.J.T. Guy)
Re: Regular Expression: overlapped words (Eric Bohlman)
Script to delete 'What's New' entries over 30 days old. dkp01@my-deja.com
Re: Script to delete 'What's New' entries over 30 days <hove@ido.phys.ntnu.no>
Re: Script to delete 'What's New' entries over 30 days <hove@ido.phys.ntnu.no>
Send to ICQ with perl <jimk@gate-way.net>
Re: session management <tzadikv@my-deja.com>
Re: split inside split - can it be done ? (Eric Bohlman)
Storing/retrieving PerlIO filehandle in/from object <sjohns17@uic.edu>
Re: String problem! (Abigail)
Re: The logic of curly braces (Bart Lateur)
Re: The Perl debugger (Dan Wilga)
Re: The Perl debugger <scottle@mr.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Aug 1999 22:49:49 +0800
From: "Ricky Lai" <97237927d@polyu.edu.hk>
Subject: ASK for Perl Cookie Password protection script
Message-Id: <7pubj0$nio1@hkpa05.polyu.edu.hk>
ASK for Perl Cookie Password protection script.
Use for user authentication. User need to enter the password once only.
Anyone have this kind of script?
Please email to me. Thanks very much.
best regard,s
Ricky Lai
------------------------------
Date: Tue, 24 Aug 1999 11:20:38 -0500
From: Cory Phillips <cory.h.phillips1@jsc.nasa.gov>
Subject: Re: Books , Reccomend?
Message-Id: <37C2C656.1CF20F31@jsc.nasa.gov>
I like the "Perl Cookbook" by O'Reilly.
www.oreilly.com
Tim wrote:
> Hello,
>
> I have read "PERL and CGI for the world wide web" by elizabeth castro.
> It was a great book, I learned a lot, but it is just a start. Can
> someone recommend a book tha twould be a good step up?
>
> Thanks,
>
> Tim
> --
>
> -------------------------------------------------------
> | TBE: http://tbe.virtualave.net |
> | * 3:2 Ratio + 100 Free credits! * |
> | Tim's Chat Doors: http://www.connect.ab.ca/~mundy/ |
> -------------------------------------------------------
------------------------------
Date: Tue, 24 Aug 1999 16:10:15 +0200
From: Andrei Karpatchev <karpat@eeh.ee.ethz.ch>
Subject: CGI newsgroups?
Message-Id: <37C2A7C7.DD8DAD20@eeh.ee.ethz.ch>
Can somebody say which newsgroups are there for the questions on CGI?
------------------------------
Date: Tue, 24 Aug 1999 17:11:11 +0200
From: GiN <wablief@freemail.nl>
Subject: desperate NEWBIE
Message-Id: <37C2B60E.D5F52F0C@freemail.nl>
the following sub should return 1 when port is open and 0 when port is
closed or if something times out ( port filtered).
but it won't work!!!
who can help me out??
please reply to this message by e-mailing to no.spam-gin@dds.nl (without
"no-spam" ofcourse) or by posting a reply into
this newsgroup.
thanks advanced!!
sub scan
{
my ($port) = @_;
eval {
local $SIG{ALRM} = sub { return(0) };
alarm 2;
chop($hostname = 'hostname');
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port,'tcp')
unless $port =~ /^\d+$/;
($name, $aliases, $type, $len, $thisaddr) =
gethostbyname($hostname);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($target);
socket(S, AF_INET, SOCK_STREAM, $proto);
bind(S, $this);
$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, 0, $thisaddr);
$that = pack($sockaddr, AF_INET, $port, $thataddr);
if (connect(S, $that)) {
close (S);
return(1);
}
else {
return(0);
}
alarm 0;
};
}
--
#phreak.nl http://www.casema.net/~gin
------------------------------
Date: 24 Aug 1999 16:24:46 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: desperate NEWBIE
Message-Id: <37c2b93e_1@newsread3.dircon.co.uk>
GiN <wablief@freemail.nl> wrote:
> the following sub should return 1 when port is open and 0 when port is
> closed or if something times out ( port filtered).
> but it won't work!!!
> who can help me out??
>
You have already posted this question.
/J\
--
"Buzz Aldrin was the second man to walk on the moon and the first to
fill his pants" - Violet Berlin, The Big Bang
------------------------------
Date: 24 Aug 1999 09:13:15 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Desperately searching for perl lint
Message-Id: <slrn7s5a5d.kr1.abigail@alexandra.delanet.com>
T. Alex Beamish (talexb@tabsoft.on.ca) wrote on MMCLXXXIV September
MCMXCIII in <URL:news:37c29f88.141743940@news1.on.sympatico.ca>:
;; Hello,
;;
;; My background (such as it is) in software development in C has taught
;; me that it's always a good idea to use good indentation practices,
;; lint your code and run it under a debugger to make absolutely sure
;; that you, the compiler and the machine code agree on what's supposed
;; to happen.
;;
;; Since moving over to perl a year ago I've tried to follow the same
;; practices, but I do not see a perl lint anywhere. Before I attempt to
;; write one myself (in perl, naturally), is there a tool that anyone can
;; suggest?
perl -MO=Lint -Mstrict -w
See man B::Lint.
Note that B::Lint is very, very, very experimental. A simple:
perl -MO=Lint,all -wle 'for (1..4) {print}'
gives 2 warnings from Lint, and 16 warnings from Perl itself about B::Lint.pm.
Go figure.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 24 Aug 1999 14:39:00 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Desperately searching for perl lint
Message-Id: <7puaq4$g9m@dfw-ixnews21.ix.netcom.com>
T. Alex Beamish (talexb@tabsoft.on.ca) wrote:
: Since moving over to perl a year ago I've tried to follow the same
: practices, but I do not see a perl lint anywhere. Before I attempt to
That's because it's built into perl itself. If you look at the perlbug
manpage, you'll see that the first listed item has to do with the fact
that you have to explicitly ask for it :)
------------------------------
Date: 24 Aug 1999 15:44:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Desperately searching for perl lint
Message-Id: <37c2afc7_1@newsread3.dircon.co.uk>
T. Alex Beamish <talexb@tabsoft.on.ca> wrote:
> Hello,
>
> My background (such as it is) in software development in C has taught
> me that it's always a good idea to use good indentation practices,
> lint your code and run it under a debugger to make absolutely sure
> that you, the compiler and the machine code agree on what's supposed
> to happen.
>
> Since moving over to perl a year ago I've tried to follow the same
> practices, but I do not see a perl lint anywhere. Before I attempt to
> write one myself (in perl, naturally), is there a tool that anyone can
> suggest?
>
the -w switch and 'use strict;'
(and possibly the -c switch if you dont want to actually run the program)
/J\
--
"Tony Blair is reported to be detained indefinitely under plans unveiled
by the Home Secretary" - Corrupt Teletext Page
------------------------------
Date: Tue, 24 Aug 1999 11:02:45 -0500
From: scottle <scottle@mr.net>
Subject: Re: Desperately searching for perl lint
Message-Id: <37C2C225.C2110F4E@mr.net>
Abigail wrote:
>
> T. Alex Beamish (talexb@tabsoft.on.ca) wrote on MMCLXXXIV September
> MCMXCIII in <URL:news:37c29f88.141743940@news1.on.sympatico.ca>:
> ;; Hello,
> ;;
> ;; My background (such as it is) in software development in C has taught
> ;; me that it's always a good idea to use good indentation practices,
> ;; lint your code and run it under a debugger to make absolutely sure
> ;; that you, the compiler and the machine code agree on what's supposed
> ;; to happen.
> ;;
> ;; Since moving over to perl a year ago I've tried to follow the same
> ;; practices, but I do not see a perl lint anywhere. Before I attempt to
> ;; write one myself (in perl, naturally), is there a tool that anyone can
> ;; suggest?
>
> perl -MO=Lint -Mstrict -w
>
> See man B::Lint.
>
> Note that B::Lint is very, very, very experimental. A simple:
>
> perl -MO=Lint,all -wle 'for (1..4) {print}'
>
> gives 2 warnings from Lint, and 16 warnings from Perl itself about B::Lint.pm.
> Go figure.
I am interested in more rigorously testing and debugging my programs.
However, not having a strong background in C (I took one course on the
C programming early in my undergraduate career), I am not familiar
with lint. What would 'perl -MO=Lint -Mstrict -w' have to offer over
using strict and -w? I read the man page you mentioned, but I still
not certain I under stand lint.
Also, is lint something new with Perl 5.005? I was unable to find it
for the Perl 5.004 on my site. I have had problems before with a
misconfigured Perl, so I do not know if it is the result of a
misconfiguration or that it was introduced with Perl 5.005.
Your help is appreciated,
Scott.
--
"I don't mind going nowhere as long as it's an interesting path."
-- Ronald Mabbitt
------------------------------
Date: Tue, 24 Aug 1999 16:45:18 GMT
From: "Alec Kelingos" <akelingos@petrosys-usa.com>
Subject: DISREGARD!!! I made a VERY stupid mistake
Message-Id: <01beee50$b3a3bf80$0664a8c0@psusa6.petrosys-usa.com>
It was just a dump syntax error!!
------------------------------
Date: Tue, 24 Aug 1999 15:14:32 GMT
From: lemull@unx.sas.com (Lee Mulleady)
Subject: Environment variables
Message-Id: <37c2b66c.93604921@newshost.unx.sas.com>
Is there any way to set Environment variables (on Unix), so that they
stay set after the script ends?
Thanks for any help,
-Lee
lemull@unx.sas.com
------------------------------
Date: Tue, 24 Aug 1999 18:37:16 +0200
From: Thomas Rassmann <rassmann@sdm.de>
Subject: Re: Environment variables
Message-Id: <37C2CA3C.A76A4FB6@sdm.de>
Lee Mulleady wrote:
>
> Is there any way to set Environment variables (on Unix), so that they
> stay set after the script ends?
>
That couldn't work, because of the perl-script runs in a new shell. It's
exactly the same problem as in a normal shell. Variable definition only
works for the shell and (with export) also for childs of that shell.
When your perl-script ends, the shell which called the script doesn't
know anything about the defined variables.
Sorry, don't know a better method/ answer.
Tom
--
Thomas Rassmann mailto:Thomas.Rassmann@sdm.de
sd&m AG http://www.sdm.de
software design & management
Thomas-Dehler-Str. 27, D-81737 Muenchen, Germany
Tel +49 89 63812-346 Fax -410
------------------------------
Date: Tue, 24 Aug 1999 07:26:18 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: help on semaphores in perl
Message-Id: <MPG.122c4b60944e70179896d0@nntp1.ba.best.com>
Samir Jain (sjain@uswest.com) seems to say...
> but more then one user can call this executable from the CGI program,
> and i want to prevent that so that only one instance of that executable
> is running.
check out perldoc -f flock
and look at the FAQ as there's a bit on file locking
perldoc -q lock
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Tue, 24 Aug 1999 16:46:39 +0200
From: =?iso-8859-1?Q?J=F6rg?= Oliver Pinn <joerg.pinn@gmd.de>
Subject: Hex from a file
Message-Id: <37C2B04F.1EC5B31D@gmd.de>
Hi,
how can I read hex-values from a file?
--
------------------------------------------
Jörg Oliver Pinn
Mail jpinn@ieee.org
------------------------------------------
------------------------------
Date: Tue, 24 Aug 1999 09:08:48 -0500
From: Chris Covington <ccoving@uhc.com>
To: Paul Dobbs <pdobbs@home.com>
Subject: Re: I just don't get the hash thing..
Message-Id: <37C2A770.D5D76455@uhc.com>
Paul,
You could think of a hash as being an array that is indexed by names
instead of numbers. For instance instead of saying array[1]="pizza" and
$array[2]="chips", you could say $hash{bob}="pizza" and
$hash{alice}="chips". Which might make sense if you were writing a
script that associates one thing with another thing.
Here is an example of using a hash, using it to associate a username
with a userid:
-------------------------------------------------------------------
open (passwd, "/etc/passwd"); #open the password file
while (<passwd>){ #do something with each line
# Make a hash called userid. This associates each username with a
# userid. We could say $hashname{USERNAME}=USERID. This lets us
# quickly look up a userid for a given username.
# split each line of the password file into a temporary variable
@fields=split (/:/, $_);
# Create a hash, for example: $userid{bob}=101, $userid{alice}=102
$userid{$fields[0]} = $fields[2];
} #end of while loop
# Loop, with the $username variable being equal to a different
# username each time. "Keys" creates a list/array out of a hash.
foreach $username (keys %userid) {
print "User ($username)'s userid is $userid{$username}\n";
}
# Quickly look up a userid for a given user:
print "Quick lookup of the user root: root = userid $userid{root} \n";
# Close the open file
close passwd;
-------------------------------------------------------------------
Paul Dobbs wrote:
>
> Not an emergency need to know, but I'm certain I'm missing
> out on
> fun/simplified methods by not using any hashes in my little
> programs.
> I just don't get the whole damn thing.. I've been reading
> Perl Annotated
> Archives, the ActivePerl web site, this newsgroup.. I just
> don't seem to
> get it though (or the foreach concept either).
>
> If someone has an explanation that really made it clear for
> them and think
> it will help here please feel free to share.
>
> For the time being, I'm stick'n to If, then and goto to get
> the job done
> for what I want, and so far it works well. I just want to
> learn how to use
> other commands. I've worked with Vic20, C64, C128,
> Quickbasic, VB and VBA
> over the years to various degrees for personal intrests, so
> do have a good
> base to build from. Just get stuck on the new math sometimes
> :-)
--
Chris Covington,
ccoving@uhc.com
------------------------------
Date: Tue, 24 Aug 1999 12:32:38 -0400
From: "John Moschetto" <jm908@columbia.edu>
Subject: Is anyone using PerLDAP with PerlScript on IIS/NT?
Message-Id: <7puhcm$ld8$1@newsmaster.cc.columbia.edu>
I am using PerLDAP from regular perl (perl.exe) just fine.
I am wondering if I can use PerLDAP with PerlScript under IIS4.
I've tried several other modules Win32::ODBC, etc. and they work fine.
PerLDAP just craps out when run with PerlScript
>use Mozilla::LDAP::Conn; error '80004005'
>
>Internal Error
>
>?
Anyone who is doing this who could lend some assistance would be greatly
appreciated.
------------------------------
Date: Tue, 24 Aug 1999 16:06:59 GMT
From: gmmengel@my-deja.com
Subject: New Perl Book "Object Oriented Perl" not really available ...yet
Message-Id: <7pufuu$4l6$1@nnrp1.deja.com>
Just a note to let all know that Manning publishers has opened the door
via their web site (www.manning.com) to order the new book "Object
Oriented Perl" by Damian Conway. The printer is NOT ready yet. If you
order the book, you will get "Object Oriented Application Frameworks".
Not what the doctor ordered..
You might want to wait another week or so if you want this book. By
the way, the distributor Bookmasters Distribution Service, has been
more than helpful. My emails to Manning though were not answered, sad
to say.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 24 Aug 1999 15:48:58 +0100
From: "Andrew C. Holmes" <andy@aholmes.u-net.com>
Subject: newbi: Registry Help under NT
Message-Id: <Alyw3.1266$wV2.126105@newsr2.u-net.net>
Hello all,
I am trying to extract a value from an NT Server registry.
When I run this I get "Query: Cannot create a file when that file already
exists."
Obviously the QueryValue is failing, but why. any ideas anybody???
Thanks V much
Andy Holmes
<snip>
# Its getting scary....now to update the servers registry.
$main::HKEY_LOCAL_MACHINE->Open("SOFTWARE\\a\\b\\c", $key) ||
die "Create: $!";
$key->QueryValue("Sync Level", $current_level) ||
die "Query: $!";
print "Current: $current_level\n";
$next_level = $current_level + 1;
$next_update = sprintf("upd.%06d",$next_level);
print "Next: $next_level\n";
rename ("updates","update_files/$next_update");
# Now set the registry key to the new value
$key->SetValueEx("Sync Level", 0, REG_SZ, $next_level);
</snip>
------------------------------
Date: Tue, 24 Aug 1999 02:50:48 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: newbie: need help,LEARNING FROM A BOOK
Message-Id: <APC&1'0'50775d95'cb0@igc.apc.org>
>I dont understand the concepts, of perl,when do you use " this and when
>do you use 'this,.?
Perl usually thinks of $ as indicating a variable. a single ' is perl's
ways of saying, don't think of stuff as variables. For example, say you
have a string with the following content:
I have $10 dollars
print "I have $10 dollars\n"; #outputs only part of what you want:
dollars
because perl thinks $10 is a variable name, does not have a value for
this variable and so prints nothing for the $10 part.
print 'I have $10 dollars\n"; # But this does not think $10 is a
# variable and so outputs
I have 10 dollars
The perlfaq says this better by:
The Perl parser will expand $variable and @variable references in
... expressions unless the delimiter is a single quote.
> 2.) what means,exponentation,?
This is a mathematical word.
For example, 2 ^ 4 means 2 to the power of 4,
or 2 * 2 * 2 * 2 ( which is 16) .
In mathematical jargon, the thing on the right of the ^
is the exponent. So, in my example, 4 is the exponent.
exponentiation is the act or process of raising a
quantity to a power (per Webster's dictionary).
> and precedence?
Precedence relates to what happens first.
For example, lets say we have an expression
2 + 2 * 3
What should happen first, the 2 + 2 (addition)
or the 2 * 2 (multiplication) ??
Let's call the addition-first case a))
2 + 2 * 3 = (2 + 2) * 3 = (4) * 3 = 12
Let's call the multiplication-first case b))
2 + 2 * 3 = 2 + ( 2 * 3) = 2 + (6) = 8
Precedence is the concept of saying what things should happen first. It
matters because if you add first, 2 + 2 * 2 is 12, but if you multiply
first, then it is only 8.
All languages need to have precedence of some sort, to decide
between, for example, case a)) and case b))
In perl's case, if there aren't parantheses determining precedence,
multiplication has more precedence than addition, so perl will treat it
2 + 2 * 3 like case a)) , not case b)). In programming lingo, this means
multiplication has high precedence, and addition low precedence.
> . am learning from the book
> perl 5 interactive course,i hope i can do it,
Good luck. I hope you will enjoy the hard work that learning
programming entails.
>with the communitys WEB help!
The two concepts you've asked about are fairly mathematical/abstract,
but you don't seem to have a very advanced math background.
My advice is that you write lots of little programs, using the perl that
you _do_ understand. Ignore my advice if you think it isn't wise.
You might find it easier to learn by giving yourself fairly simple tasks
and writing programs to do it. You'll learn concepts like ' and ", and
how to use perl documentation in the process of concrete task. Most
people I know, including me, learn faster this way.
>does any perl programmer want to help me with corresponding
>through e-mail,?if i have any questions?on my journy,to become a perl,
>programmer,! THANK YOU!!!!!!
No thanks.
-Michael
------------------------------
Date: Tue, 24 Aug 1999 16:33:22 GMT
From: "Alec Kelingos" <akelingos@petrosys-usa.com>
Subject: newbie: problem with hash of arrays PLEASE HELP
Message-Id: <01beee4f$08d5a9c0$0664a8c0@psusa6.petrosys-usa.com>
First experience with data structures. Problems with hashes of arrays. In
a new subroutine I want to create a new hash of arrays (%data). Below, the
print "$col $fields[$columns{$col}[1]]\n";
statements works fine. But when I try to use $fields[$columns{$col}[1] to
populate %data I get a syntax error. Get the same syntax error even if I
don't populate %data with a reference to this thing.
Error is:
syntax error at junk line 19, near "%data ("
syntax error at junk line 19, near "]]"
line 19 is the line labled *** syntax error. What the devil is going on.
If I can print the thing then why can't I use the thing to populate a
hash?????
Thanks in advance,
Alec
sub processA {
my $fieldsRef = shift;
my $columnsRef = shift;
my @fields = @$fieldsRef;
my %columns = %$columnsRef;
# %data is a hash of arrays. It is a 2 dimensional array that contains the
# data to be dumped to the final file. The columns are specified by the
# keys in %columns. Each row is a new well. Create the %data hash for the
# first well. Append to it for all others.
foreach $col ( keys %columns ) {
if ( $columns{$col}[0] eq 'A' ) {
if ( $wellCount == 1 ) {
print "$col $fields[$columns{$col}[1]]\n";}
# %data ( $col => [ $fields[$columns{$col}[1]] ]; } # *** syntax
error
# else {
# push @{ $data{$col} }, $fields[$columns{$col,[0]];
# }
}
}
}
------------------------------
Date: Tue, 24 Aug 1999 15:52:16 GMT
From: gmiller@iglou.com (Greg Miller)
Subject: Overwrite the middle of a file.
Message-Id: <37c2bf0d.297508@news.iglou.com>
Does perl have a mechanism for overwriting part of a file,
without having to read/re-write the whole thing? (I.e. a database
table).
------------------------------
Date: 24 Aug 1999 16:09:56 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Overwrite the middle of a file.
Message-Id: <7pug4k$g9m@dfw-ixnews21.ix.netcom.com>
Greg Miller (gmiller@iglou.com) wrote:
: Does perl have a mechanism for overwriting part of a file,
: without having to read/re-write the whole thing? (I.e. a database
: table).
Not built in. This is really a function of the operating system, and
none of the commonly-used operating systems have facilities to do this
except in the special case where the new data is exactly the same length
as the old data. There are ways to simulate this, but they generally
either involve behind-the-scenes copying and rewriting of files, or the
use of pages or other structures within files.
For overwriting fixed-length data, look at the documentation for the
seek() and tell() functions, as well as the various file modes for open().
For managing simple delimited database files, look into the DBI and
DBD::CSV modules. For managing line-structured files, look into the
DB_RECNO mode supported by the DB_File module. The latter two options
use the "behind the scenes" strategy.
Also see perlfaq4.
------------------------------
Date: Tue, 24 Aug 1999 10:00:00 -0500
From: "James Liu" <jyoyoliu@hotmail.com>
Subject: Perl Book
Message-Id: <%oyw3.392$UR5.66855@news.corecomm.net>
Hash: SHA1
I said before that i'm broke, but i've scraped up enough money for 1
oreilly book. I already have llama, so i need to decide whether to
get cookbook or camel.
Version: PGPfreeware 6.5.1 for non-commercial use <http://www.pgp.com>
iQA/AwUBN8KzbhlrzTx6g1omEQLAYACgiu0PJBc0V8uP9eoRCUMqWTNaPjcAnA9h
uGZzZRS1XFYA9K6fTX888RvA
=9QDM
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 24 Aug 1999 15:01:15 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Re: Perl Book
Message-Id: <37C2B462.F43371BD@blackhole-designs.com>
cookbook
Jimmy
James Liu wrote:
>
> Hash: SHA1
>
> I said before that i'm broke, but i've scraped up enough money for 1
> oreilly book. I already have llama, so i need to decide whether to
> get cookbook or camel.
>
>
> Version: PGPfreeware 6.5.1 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBN8KzbhlrzTx6g1omEQLAYACgiu0PJBc0V8uP9eoRCUMqWTNaPjcAnA9h
> uGZzZRS1XFYA9K6fTX888RvA
> =9QDM
> -----END PGP SIGNATURE-----
------------------------------
Date: 24 Aug 1999 16:01:41 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Perl Book
Message-Id: <7pufl5$g9m@dfw-ixnews21.ix.netcom.com>
James Liu (jyoyoliu@hotmail.com) wrote:
: I said before that i'm broke, but i've scraped up enough money for 1
: oreilly book. I already have llama, so i need to decide whether to
: get cookbook or camel.
If you're already very comfortable with Perl's supplied documentation, or
willing to get into an intimate relationship with it, I'd suggest the
Cookbook. Most of what the Camel offers can be found, though not as well
organized, in the supplied documentation, and in many cases the supplied
documentation is more up-to-date. Most of the Cookbook, OTOH, isn't
available anywhere else.
------------------------------
Date: Tue, 24 Aug 1999 14:18:56 GMT
From: cls@quotient.net
Subject: Perl don't stop
Message-Id: <7pu9ka$ff$1@nnrp1.deja.com>
Hello
When I launch a cgi script with my browser and I stop it by closing the
browser, perl.exe is always running and takes all the ressources
I use Netscape Entreprise Server 3.5 on NT 4.0 SP3
Please help me !
Thanks
Claude
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 24 Aug 1999 11:17:39 -0500
From: Cory Phillips <cory.h.phillips1@jsc.nasa.gov>
Subject: Re: PERL EDITOR
Message-Id: <37C2C5A3.5ECC49E5@jsc.nasa.gov>
I like UltraEdit. It supports syntax highlighting for Perl and many
others. It has the built in FTP. If you have Perl on the same machine
running UltraEdit, you can execute your Perl code from within the editor and
it will open a output window to display the results. I also like its
bookmark feature, which allows you to jump to a designated line of code with
a single key press. It will also match braces which is handy when writing
any code. It also functions as a hex editor.
It cost around $30, but it's well worth it. You can download a trial
version at:
http://www.ultraedit.com/
hoz wrote:
> >Does anyone of you know an good and nice editor for writting perl code?
>
> for a windows editor I recommend editplus, its shareware
> -hoz
------------------------------
Date: 24 Aug 1999 10:49:43 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: Perl won't compile (gcc 2.8, AIX)
Message-Id: <BD4088DE482998D3.50560F1770586F0E.CE4D8FD3B745ED57@lp.airnews.net>
Chris Covington <ccoving@uhc.com> writes:
> I am trying to compile perl5.005_03 on AIX 4.3.2 using gcc 2.8.1.
>
I don't know if this has anything to do with your problem, but I have
had problems building perl on AIX that isn't statically linked, when
I used gcc (and egcs).
Kent
------------------------------
Date: Tue, 24 Aug 1999 17:10:11 +0100
From: "Paul D.Smith" <pds@datcon.co.uk>
Subject: Possible h2xs enhancement?
Message-Id: <7pug48$jn8$1@soap.pipex.net>
I've had my first taste of h2xs and was wondering about an enhancement which
might speed up the block of switch/if code which is produced for #define
processing.
My 'C' code contains a lot of #defines with names such as XYZ_DEFINE_1,
XYZ_ANOTHER, XZY_YET_ANOTHER etc. i.e. a standard prefix. This immediately
identifies the #define as being for the XYZ system. Now h2xs translates
this to (some code omitted for clarity)...
switch (*name)
{
case 'A':
break;
...
case 'X':
if (strEQ(name, "XYZ_DEFINE_1"))
return XZY_DEFINE_1;
if (strEQ(name, "XZY_ANOTHER"))
return XYZ_ANOTHER;
...
break;
...
}
Note that _all_ the #defines are in the 'X' case arm and potentially every
string is compared using strEQ(). I wonder whether faster code would result
from the following:
if (strnEQ(name, "XYZ_, 4))
{
switch (name[4])
{
case 'A':
if (strEQ(name, "XZY_ANOTHER"))
return XYZ_ANOTHER;
break;
...
case 'D':
if (strEQ(name, "XYZ_DEFINE_1"))
return XZY_DEFINE_1;
break;
...
case 'Y':
if (strEQ(name, "XYZ_YET_ANOTHER"))
return XZY_YET_ANOTHER;
break;
}
}
Note that I do _not_ want to remove the XYZ_ prefix. There are plenty of
"name pollution" warnings about and this is one way of ensuring no nasty
name overlaps or surprises.
Anyone have any thoughts on this? If its a good idea, who would I forward
this to?
Regards,
Paul DS.
------------------------------
Date: 24 Aug 1999 16:20:08 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Referencing Questions
Message-Id: <7pugno$bq4$1@pegasus.csx.cam.ac.uk>
In article <1dwnlir.13wxi4g1bwzqj9N@p183.tc2.state.ma.tiac.com>,
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
>Matthew Forder <matthew_j_forder@notes.seagate.com> wrote:
>
>> In the main code of the perl program, I create a instance of my object,
>> and open the socket. Now I need to use the FH to listen and send, I
>> think I should be able to do this:
>>
>> print $instance->{'filehandle'} "socket message\n";
>> $reply <$instance->{'filehandle'}>;
>>
>> but, perl doesn't like it. I have found (through trial and error) that I
>> send using:
>>
>> print { $instance->{'filehandle'} } "socket message\n";
>>
>> but this doesn't work when trying to read.
>>
>> If anyone can help, or at least nudge me in the right direction, I would
>> be very greatful.
>
>perlop explains that within angle brackets <>, a filehandle must be
>either a bareword or a simple scalar. Anything else means the <> is
>treated as the globbing operator.
>
>Solution: When you want to read from the filehandle with the <>
>operator, copy it to a simple scalar variable first.
>
>my $fh = $instance->{filehandle};
>$input = <$fh>;
Or perhaps better
$input = readline($instance->{filehandle});
perldoc -f readline
Mike Guy
------------------------------
Date: 24 Aug 1999 14:29:05 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Regular Expression: overlapped words
Message-Id: <7pua7h$g9m@dfw-ixnews21.ix.netcom.com>
Guideline Chan (yoursguideline@hotmail.com) wrote:
:
: $_ = 'applelen';
: s/^(?=.*apple)(?=.*len)/=$&=/g;
: print $_;
:
: The result is =applelen=. It is fine. However, the problme occurs if I
As Ilya pointed out, that isn't the result.
: change the value of $_ to 'applen'. It gives me ==applen.
:
: Does anyone know how to make the result become =applen= ????
Your problem is that your regex consists of nothing but zero-width
lookahead assertions, and therefore $& is always going to have zero width
(i.e. be the empty string) when it matches, since lookaheads don't move
the match position; the "string" you've matched is actually the empty
string before the first character of $_.
For your substitution to work, you need to put *something* in the regex
that actually "gobbles" the text it matches. If your objective is to put
equal signs around the entire content of $_ if it contains both "apple"
and "len" as substrings, then stick a '.*' at the end of the regex; this
will cause the regex to match the entire string if and only if it contains
the two substrings.
------------------------------
Date: Tue, 24 Aug 1999 15:10:56 GMT
From: dkp01@my-deja.com
Subject: Script to delete 'What's New' entries over 30 days old.
Message-Id: <7puclq$2l2$1@nnrp1.deja.com>
I am new to Perl and have been asked to write a script that will create
a 'Whats New' page with entries of up to 30 days old. It was suggested
that new entries could be entered into a form which would add the new
listing at the top of the 'What's New' page. Somehow in this process any
current enteries which are over 30 days old should not be included in
the new page. I have created the form and there is a date field, but I
am not sure how Perl handles dates for comparison.
Any thoughts on this?
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 24 Aug 1999 17:37:31 +0200
From: Joakim Hove <hove@ido.phys.ntnu.no>
Subject: Re: Script to delete 'What's New' entries over 30 days old.
Message-Id: <k0nu2ppfav8.fsf@ido.phys.ntnu.no>
dkp01@my-deja.com writes:
> I am new to Perl and have been asked to write a script that will create
> a 'Whats New' page with entries of up to 30 days old. It was suggested
> that new entries could be entered into a form which would add the new
> listing at the top of the 'What's New' page. Somehow in this process any
> current enteries which are over 30 days old should not be included in
> the new page. I have created the form and there is a date field, but I
> am not sure how Perl handles dates for comparison.
What exactly your Perl problem is is not entirely clear, but I guess
perldoc -f time
perldoc -f localtim
perldoc -f stat
would be a good start.
HTH - Joakim
--
=== Joakim Hove www.phys.ntnu.no/~hove/ ======================
# Institutt for fysikk (735) 93637 / 352 GF | Skøyensgate 10D #
# N - 7034 Trondheim hove@phys.ntnu.no | N - 7030 Trondheim #
=====================================================================
------------------------------
Date: 24 Aug 1999 17:39:47 +0200
From: Joakim Hove <hove@ido.phys.ntnu.no>
Subject: Re: Script to delete 'What's New' entries over 30 days old.
Message-Id: <k0nso59farg.fsf@ido.phys.ntnu.no>
Joakim Hove <hove@ido.phys.ntnu.no> writes:
> perldoc -f localtim
^^
Sorry, that should be localtime. In addition you might want to look at
perldoc -f unlink
to delete files.
:-) Joakim
--
=== Joakim Hove www.phys.ntnu.no/~hove/ ======================
# Institutt for fysikk (735) 93637 / 352 GF | Skøyensgate 10D #
# N - 7034 Trondheim hove@phys.ntnu.no | N - 7030 Trondheim #
=====================================================================
------------------------------
Date: Tue, 24 Aug 1999 11:02:27 -0400
From: "Jim Karsten" <jimk@gate-way.net>
Subject: Send to ICQ with perl
Message-Id: <rs5cq56hdmc22@corp.supernews.com>
Is there a method of sending a message to an ICQ number via a perl script? I
know that I can send an email to 12345678@pager.mirabilis.com, for example,
where 12345678 is the ICQ number, but the message is full of garbly-gook. I
would like the message to be like that received if I had typed it manually
using my ICQ. Any ideas?
------------------------------
Date: Tue, 24 Aug 1999 13:56:52 GMT
From: Tzadik Vanderhoof <tzadikv@my-deja.com>
Subject: Re: session management
Message-Id: <7pu8b1$vlv$1@nnrp1.deja.com>
Thanks! Will Apache::Session work even if you're not using the Apache
server? We have IIS on WinNT.
Intuitively, I don't see how a regular "module" or extension could
solve the problem of session management, since modules do not persist
beyond the invokation of the script...some kind of daemon would seem to
be necessary unless you take advantage of web-server-specific features.
In article <G2ew3.245$u07.1835@news.colt.net>,
Jon Peterson <jpeterson@office.colt.net> wrote:
> Tzadik Vanderhoof <tzadikv@my-deja.com> wrote:
> > Is there any Perl module to do CGI "session management",
> Apache::Session will do this
--
Tzadik
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 24 Aug 1999 14:49:05 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: split inside split - can it be done ?
Message-Id: <7pubd1$g9m@dfw-ixnews21.ix.netcom.com>
Philip 'Yes, that's my address' Newton (nospam.newton@gmx.net) wrote:
: How about:
: open (CUST, $custFile) or die "ERROR: Cannot open $custFile: $!";
: while (<CUST>) {
: if (/CUSTOMER/) {
: ($cust,$id) = /CUSTOMER\[([^-]*)-([^]]*)]/;
if (/CUSTOMER\[(.*?)-(.*?)]/) {
$cust=$1;
$id=$2;
or if it's OK to trash $cust and $id while reading subsequent non-matching
lines:
if (($cust,$id) = /CUSTOMER\[(.*?)-(.*?)]/) {
The main point is to avoid invoking the regex engine twice for matching
lines.
: print "$cust:$id\n";
: }
: }
------------------------------
Date: Mon, 23 Aug 1999 15:34:13 -0500
From: Seth David Johnson <sjohns17@uic.edu>
Subject: Storing/retrieving PerlIO filehandle in/from object
Message-Id: <Pine.A41.4.10.9908231455030.561748-100000@tigger.cc.uic.edu>
I'd like to use the PerlIO abstraction interface for a module I'm writing.
What I need to be able to do is to run an "init" method on an object,
which opens a character device, does some ioctl stuff, then stores a file
descriptor/handle in the object for future reference (specifically, I
want to be able to call read/write methods which extract the file
descriptor/handle from the object calling them and (surprise) read/write
to the character device).
So, say I have a key called "file_descriptor" in the hash to which the
object refers. I need to give it an SV* value. Normally, I could store an
integer file descriptor here using newSViv(fd) and retrieve it using
something like SvIV(*hv_fetch(thehash,"file_desc",9,0)). No problem there,
since libc read/write take an integer file descriptor as their first
argument. However, PerlIO_read/PerlIO_write require a PerlIO * type as
their first argument.
How can I pass this PerlIO * pointer to/from the object? It would seem I
need some way of translating the PerlIO * type into and out of an SV*. I
can't find anything about this in the pods.
Any brave takers?
Thanks in advance,
-Seth Johnson
------------------------------
Date: 24 Aug 1999 09:25:01 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: String problem!
Message-Id: <slrn7s5arj.kr1.abigail@alexandra.delanet.com>
Andy (o_k@mailexcite.com) wrote on MMCLXXXIV September MCMXCIII in
<URL:news:37C2639B.BCB717F@mailexcite.com>:
## Hi,
##
## I want to know how to get the size of a string in Perl?
## -----------------------------------------------------
## e.g.
## $test="abcde";
my $l = 0;
{length chop $test and ++ $l and redo}
print "The size is: $l\n";
HTH. HAND.
Abigail
--
sub J::FETCH{Just }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
sub P::FETCH{Perl }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 24 Aug 1999 15:03:18 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: The logic of curly braces
Message-Id: <37c3b371.589949@news.skynet.be>
Irwin Feuerstein wrote:
>First, is $var the same as ${var}?
Yes it's the same.
>Is there a rationale for using one over the other?
Yes.
>On page 41 of Programming Perl, there is "how ${verb}able". Why is it
>coded like that?
Because now it will come out as "how ".$verb."able". Drop the curly
braces and you'd get "how $verbable" (= "how ".$verbale). See the reason
for the curly braces? It allows you to show where the variable's name
stops, and the literal text begins again, which is only necessary if the
literal text starts with a "word" character (letter, digit or
underscore).
Bart.
------------------------------
Date: Tue, 24 Aug 1999 10:39:43 -0400
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: The Perl debugger
Message-Id: <dwilgaREMOVE-2408991039430001@wilga.mtholyoke.edu>
In article <7ptj3q$hv2$1@nnrp1.deja.com>, steveeq1@earthlink.net wrote:
> 1) once I set the breakpoint. How do I tell Perl to "run through the
> rest of the lines without prompting until the breakpoint. Then stop and
> prompt."
c (continue)
> 2) Let's say I find a line that I want to change in Perl while the
> debugger is running. Can I open it in Emacs and change it there real
> time and have the debugger "know" I made the change?
Not that I'm aware of. I think you can edit the file and use R to restart
the script with the new version, though.
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Tue, 24 Aug 1999 10:47:17 -0500
From: scottle <scottle@mr.net>
Subject: Re: The Perl debugger
Message-Id: <37C2BE85.829A3709@mr.net>
Dan Wilga wrote:
>
> In article <7ptj3q$hv2$1@nnrp1.deja.com>, steveeq1@earthlink.net wrote:
>
> > 2) Let's say I find a line that I want to change in Perl while the
> > debugger is running. Can I open it in Emacs and change it there real
> > time and have the debugger "know" I made the change?
>
> Not that I'm aware of. I think you can edit the file and use R to restart
> the script with the new version, though.
Also, you can have the debugger execute Perl code that you enter at
the debugger prompt, which might give you a little bit of what you
want.
Scott.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 630
*************************************