[16695] in Perl-Users-Digest
Perl-Users Digest, Issue: 4107 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 23 14:10:44 2000
Date: Wed, 23 Aug 2000 11:10:30 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967054230-v9-i4107@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 23 Aug 2000 Volume: 9 Number: 4107
Today's topics:
Re: negative lookahead assertions in Perl Regex (Neil Kandalgaonkar)
Re: negative lookahead assertions in Perl Regex (Neil Kandalgaonkar)
Re: negative lookahead assertions in Perl Regex <lr@hpl.hp.com>
Re: newbie question - dont flame me (Abigail)
Re: newbie question - dont flame me filosmith@my-deja.com
Re: newbie question - dont flame me <amonotod@netscape.net>
Re: newbie question - dont flame me filosmith@my-deja.com
Re: newbie question - dont flame me <lr@hpl.hp.com>
Re: newbie question about "uninitialized variables" (Jon S.)
Re: newbie question about "uninitialized variables" (Jon S.)
Re: newbie question about "uninitialized variables" (Jon S.)
Re: newbie question about "uninitialized variables" <iltzu@sci.invalid>
Re: newbie question about "uninitialized variables" (Jon S.)
Re: Newbie: Help with Fork on NT box (Jonny)
newbie:? string sub through an array coughlan@gothaminteractive.com
Re: newbie:? string sub through an array <lr@hpl.hp.com>
Re: NT drive mappings-newbee question <amonotod@netscape.net>
Re: Perl and dates <lr@hpl.hp.com>
perl books <alikbm@tx.technion.ac.il>
Re: perl books (Andreas Kahari)
Re: perl books <amonotod@netscape.net>
perl hash code <guest@yale.edu>
Re: Perl/MySQL vs ASP/MS-SQL (Anthony Peacock)
Re: Perl/MySQL vs ASP/MS-SQL (Jon S.)
Please help, 1024 char limit writing to DB's? perlnewbie@my-deja.com
Re: Print buffering (WAS: Cookie problem (chrs in value <lr@hpl.hp.com>
Re: self writing program <todd@mrnoitall.com>
Strict and Binary Image Upload <ewald@electronicfrontiers.com>
Re: User ID - someone explain? <gellyfish@gellyfish.com>
Re: User ID - someone explain? nobull@mail.com
using network drives-newbee question dwilson6660@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 23 Aug 2000 15:46:35 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: negative lookahead assertions in Perl Regex
Message-Id: <8o0r93$ak7$1@localhost.localdomain>
In article <8o0agh$3sc$1@nnrp1.deja.com>,
Dermot McGahon <dmcgahon@iol.ie> wrote:
> $document =~ s{(<!--.*?-->)(?!\s*</script>)}{}gim;
By the way, you have the wrong regex modifier. You wanted s, not m.
Common mistake. This would have caused any recipe to fail.
Remember:
s affects what . matches
m affects what ^ and $ match
Anyone have a mnemonic for this? I am always forgetting.
Back to your problem. It doesn't work because when the negative part
matches, perl backtracks to see if there is another way to make the
whole match succeed. So it tries matching more in your first .*?.
So, we add a no-backtrack condition to the negative lookahead:
$document =~ s{<!--.*?-->(?=>(?!\s*</script>)}{}gis;
This worked for me, but I didn't test it extensively.
The truly Right Thing would be a negative lookbehind before
the beginning of the comment, but perl does not (yet) support
variable-length negative lookbehinds.
In general, however, I would give up on regexes for a problems like this.
Get a real HTML parsing module from the CPAN.
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: Wed, 23 Aug 2000 16:12:19 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: negative lookahead assertions in Perl Regex
Message-Id: <8o0spb$anr$1@localhost.localdomain>
In article <8o0r93$ak7$1@localhost.localdomain>,
Neil Kandalgaonkar <neil@brevity.org> wrote:
>So, we add a no-backtrack condition to the negative lookahead:
>
>$document =~ s{<!--.*?-->(?=>(?!\s*</script>)}{}gis;
>
>This worked for me, but I didn't test it extensively.
Graah. Screw up. This one is the correct one:
$document =~ s{(?><!--.*?-->)(?!\s*</script>)}{}gis;
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: Wed, 23 Aug 2000 10:45:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: negative lookahead assertions in Perl Regex
Message-Id: <MPG.140dad7779d321e198acc9@nntp.hpl.hp.com>
In article <8o0r93$ak7$1@localhost.localdomain> on Wed, 23 Aug 2000
15:46:35 GMT, Neil Kandalgaonkar <neil@brevity.org> says...
> In article <8o0agh$3sc$1@nnrp1.deja.com>,
> Dermot McGahon <dmcgahon@iol.ie> wrote:
>
> > $document =~ s{(<!--.*?-->)(?!\s*</script>)}{}gim;
>
> By the way, you have the wrong regex modifier. You wanted s, not m.
> Common mistake. This would have caused any recipe to fail.
>
> Remember:
>
> s affects what . matches
> m affects what ^ and $ match
>
> Anyone have a mnemonic for this? I am always forgetting.
The Perl dcumentation provides mnemonics, in two places.
perlop:
Options are:
...
m Treat string as multiple lines.
...
s Treat string as single line.
perlre:
m
Treat string as multiple lines. That is, change ``^'' and ``$'' from
matching the start or end of the string to matching the start or end of
any line anywhere within the string.
s
Treat string as single line. That is, change ``.'' to match any
character whatsoever, even a newline, which normally it would not match.
...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 23 Aug 2000 15:56:16 GMT
From: abigail@foad.org (Abigail)
Subject: Re: newbie question - dont flame me
Message-Id: <slrn8q7suv.tj3.abigail@alexandra.foad.org>
Greg Bacon (gbacon@HiWAAY.net) wrote on MMDXLIX September MCMXCIII in
<URL:news:sq7mpcjqt9115@corp.supernews.com>:
@@
@@ You didn't give much information about your datastructures, but should
@@ you have written the following instead?
@@
@@ foreach $displayName (keys %serverList) {
@@ foreach $uName (keys %{ $serverList{$displayName} }) {
@@ print $serverList{$displayName}->{$uName}, "\n";
@@ }
@@ }
Urg.
This should save big time on hash lookups:
while (my ($displayName, $list) = each %serverList) {
while (my ($uName, $whatever) = each %$list) {
print $whatever, "\n";
}
}
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Wed, 23 Aug 2000 17:15:01 GMT
From: filosmith@my-deja.com
Subject: Re: newbie question - dont flame me
Message-Id: <8o10q1$ujd$1@nnrp1.deja.com>
I'm sorry, but none of those suggestions worked for me, although I've
filed them all away for future use. Here is the rest:
%serverList = qw ( DOMAIN WinNT://DOMAIN
NWFS1 NWCOMPAT://NWFS1
NWFS2 NWCOMPAT://NWFS2
NWFS3 NWCOMPAT://NWFS3
NWPS1 NWCOMPAT://NWPS1
);
foreach $displayName (keys %serverList)
{
$adsDomain = Win32::OLE->GetObject($serverList{$displayName});
$domainEnumerator = Win32::OLE::Enum->new($adsDomain);
while (defined($domainObject = $domainEnumerator->Next))
{
if ($domainObject->Class eq "User")
{
$uName = $domainObject->Name;
$uFName = $domainObject->FullName;
$displayName{$uName} = $uFName;
###############
#### if i print at this point it comes out fine.
###############
}
}
}
#############
#### I've replaced the following with what you all said, with no luck:
#############
foreach $displayName (keys %serverList)
{
foreach $uName (keys %{$displayName})
{
print "$displayName->{$uName}\n";
}
}
I really appreciate yall's help.
In article <8o0l0f$fkj$1@nnrp1.deja.com>,
filosmith@my-deja.com wrote:
> Can someone help me please? this doesn't even attempt to do anything
> with the second foreach...
>
> foreach $displayName (keys %serverList)
> {
> foreach $uName (keys %{$displayName})
> {
> print "$displayName{$uName}\n";
> }
> }
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 23 Aug 2000 17:25:16 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: newbie question - dont flame me
Message-Id: <8o11d3$vj3$1@nnrp1.deja.com>
In article <8o10q1$ujd$1@nnrp1.deja.com>,
filosmith@my-deja.com wrote:
> I'm sorry, but none of those suggestions worked for me, although I've
> filed them all away for future use. Here is the rest:
> %serverList = qw ( DOMAIN WinNT://DOMAIN
> NWFS1 NWCOMPAT://NWFS1
> NWFS2 NWCOMPAT://NWFS2
> NWFS3 NWCOMPAT://NWFS3
> NWPS1 NWCOMPAT://NWPS1
> );
> foreach $displayName (keys %serverList)
> {
> foreach $uName (keys %{$displayName})
> {
> print "$displayName->{$uName}\n";
> }
> }
>
Well, we all thought that you had a hash of hashes. All yo really have
is a hash, or keyed array. Try this:
foreach my $displayName (keys %serverList) {
print "$displayName \= $serverList{$displayName}\n";
}
HTH,
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 23 Aug 2000 17:42:19 GMT
From: filosmith@my-deja.com
Subject: Re: newbie question - dont flame me
Message-Id: <8o12dl$ko$1@nnrp1.deja.com>
That's awesome. Each of these server names is supposed to be the name
of a hash too, though. each key name in the hash is supposed to be the
username, and each value of the hash is supposed to be the user's full
name. if i print it during the same foreach the hash is populated in it
works. thereafter, it doesn't print anything and doesn't give an error
with -w.
Thanks again.
Filo
In article <8o11d3$vj3$1@nnrp1.deja.com>,
amonotod <amonotod@netscape.net> wrote:
> In article <8o10q1$ujd$1@nnrp1.deja.com>,
> filosmith@my-deja.com wrote:
> > I'm sorry, but none of those suggestions worked for me, although
I've
> > filed them all away for future use. Here is the rest:
> > %serverList = qw ( DOMAIN WinNT://DOMAIN
> > NWFS1 NWCOMPAT://NWFS1
> > NWFS2 NWCOMPAT://NWFS2
> > NWFS3 NWCOMPAT://NWFS3
> > NWPS1 NWCOMPAT://NWPS1
> > );
> > foreach $displayName (keys %serverList)
> > {
> > foreach $uName (keys %{$displayName})
> > {
> > print "$displayName->{$uName}\n";
> > }
> > }
> >
> Well, we all thought that you had a hash of hashes. All yo really
have
> is a hash, or keyed array. Try this:
>
> foreach my $displayName (keys %serverList) {
> print "$displayName \= $serverList{$displayName}\n";
> }
>
> HTH,
> amonotod
>
> --
> `\|||/ amonotod@
> (@@) netscape.net
> ooO_(_)_Ooo________________________________
> _____|_____|_____|_____|_____|_____|_____|_____|
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 23 Aug 2000 10:50:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: newbie question - dont flame me
Message-Id: <MPG.140daeb8b33cb0fc98acca@nntp.hpl.hp.com>
In article <slrn8q7suv.tj3.abigail@alexandra.foad.org> on 23 Aug 2000
15:56:16 GMT, Abigail <abigail@foad.org> says...
> Greg Bacon (gbacon@HiWAAY.net) wrote on MMDXLIX September MCMXCIII in
> <URL:news:sq7mpcjqt9115@corp.supernews.com>:
> @@
> @@ You didn't give much information about your datastructures, but should
> @@ you have written the following instead?
> @@
> @@ foreach $displayName (keys %serverList) {
> @@ foreach $uName (keys %{ $serverList{$displayName} }) {
> @@ print $serverList{$displayName}->{$uName}, "\n";
> @@ }
> @@ }
>
> Urg.
>
> This should save big time on hash lookups:
>
> while (my ($displayName, $list) = each %serverList) {
> while (my ($uName, $whatever) = each %$list) {
> print $whatever, "\n";
> }
> }
This should save big time on typing also:
for my $list (values %serverList) {
for my $whatever (values %$list) {
print $whatever, "\n";
}
}
In another current thread, there is evidence that this may actually be
faster, provided the hashes aren't extraordinarily large.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 23 Aug 2000 15:41:36 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <39a3f0a8.8705252@news.earthlink.net>
On 22 Aug 2000 17:38:19 +0100, nobull@mail.com wrote:
>jonceramic@nospammiesno.earthlink.net (Jon S.) writes:
>
>> On Mon, 21 Aug 2000 16:11:46 -0700, Larry Rosler <lr@hpl.hp.com>
>> wrote:
>>
>> >In article <39a19a64.28263165@news.earthlink.net> on Mon, 21 Aug 2000
>> >21:39:28 GMT, Jon S. <jonceramic@nospammiesno.earthlink.net> says...
>> >> I've been declaring my "my" variables at the start of my scripts with
>> >> a my($foo1, $foo2); declaration.
>> >
>> >Many people prefer to declare them where they are first needed.
>>
>> I've chosen to put them "up top"
>
>Nothing wrong with declaring your variable at the beginning of the
>enclosing scope (like in C) rather than all over the place (like in
>C++), except it's unfashionable :-)
>
>However, decaring all your variables uncessarily at the outermost
>lexical scope nulifies much of the beniefit of using lexical varaibles
>in the first place.
Well, I'm just doing simple HTML forms and outputs with my Perl
scripts, and as such, I haven't had the need for any lexical scoping
as of yet. In fact, since I load my param variables at the start, and
use those results almost through the whole script, it hasn't been a
big deal.
As my SQL statements get more complicated and specific, I'll probably
use lexical scoping for them.
<some snipped>
>If a large number your variables really _are_ needed at the outermost
>lexical scope then maybe your design needs some re-thinking. Maybe
>you have several separate variables that should really be rolled into
>some structure (hash, array, object...).
Yes, I've considered that a few times. But, it didn't make much sense
because, to keep track of my variables, I still had to type in the
hash reference names which were the same as my variable names. Again,
I'm still getting my programming legs back, so I figured I'd save the
optimization for later. (I converted a few scripts to hash references
once, and it worked fine. But, it was pretty quick to do with a
search and replace, and I was getting too confused keeping track of
variable names, that I went back to straight scalars for most of it.)
>> because I loose track of what variables I have without it.
>
>Eventually as your script grows even with all the variables declared
>up top you'll loose track anyhow.
:) Yep. But, again, since I'm loading in a param() set at the top and using those variables throughout, I need the full scope anyway.
>> > my ($foo1, $foo2) = ("") x 2;
>>
>> That will help. Is there any way to do a '("") x all'?
>
>No but it doesn't matter if the number is a bit too big so if you know
>you've got 10-12 variables on the LHS you can safely put ('') x 15 on
>the RHS.
Great.
Thanks nobull.
Jon
------------------------------
Date: Wed, 23 Aug 2000 15:41:51 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <39a3f0ca.8740072@news.earthlink.net>
On Tue, 22 Aug 2000 19:07:31 +0200, Abe Timmerman
<abe@ztreet.demon.nl> wrote:
>On Tue, 22 Aug 2000 15:26:39 GMT, jonceramic@nospammiesno.earthlink.net
>(Jon S.) wrote:
>...
>> Is there a way to make these warnings show up "pretty" in my returned
>> html? I've got CGI::Carp going with fatalstoBrowser and a few warn
>> and die statements, but I'd like to have my warnings go to the browser
>> also. Right now, they get placed oddly in the output. (Like, in
>> between words no where near the error in the script.) The only way to
>> find them is to scan the output on either my telnet prompt or returned
>> source, and I miss them half the time. Plus, with my forms heavy
>> pages, entering 20 variables on the command line is a pain.
>
>Have a look at the CGI::Carp documentation. There is a subsection
>"Changing the default message" in the section "MAKING PERL ERRORS APPEAR
>IN THE BROWSER WINDOW".
>
>The problem will be, that your script can die() in the middle of some
>HTML code that could already have been outputed but wasn't finished
>logically.
Thanks Abe,
I was just looking at the perl in a nutshell listing which is too
concise. I'll check it out.
Jon
------------------------------
Date: Wed, 23 Aug 2000 15:41:55 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <39a3f0cd.8742282@news.earthlink.net>
On Tue, 22 Aug 2000 11:22:51 -0700, Larry Rosler <lr@hpl.hp.com>
wrote:
>In article <39a297e2.6817880@news.earthlink.net> on Tue, 22 Aug 2000
>15:26:39 GMT, Jon S. <jonceramic@nospammiesno.earthlink.net> says...
>> On Mon, 21 Aug 2000 16:11:46 -0700, Larry Rosler <lr@hpl.hp.com>
>> wrote:
>
>...
>
>> Is there a way to make these warnings show up "pretty" in my returned
>> html? I've got CGI::Carp going with fatalstoBrowser and a few warn
>> and die statements, but I'd like to have my warnings go to the browser
>> also. Right now, they get placed oddly in the output. (Like, in
>> between words no where near the error in the script.) The only way to
>> find them is to scan the output on either my telnet prompt or returned
>> source, and I miss them half the time. Plus, with my forms heavy
>> pages, entering 20 variables on the command line is a pain.
>
>You might write your own $SIG{__WARN__} handler, which could gather up
>all the messages so you can print them all later when you choose.
Okay, I finally found this in the docs. Sheesh. The www.perl.com
search wasn't working at all, but I finally tracked it down to
http://www.perl.com/pub/doc/manual/html/pod/perlvar.html at the very
end of the predefined variables section. And, now that I look for it,
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/warn.html also
has a little bit about it. I always forget to look in perlfunc. But,
even then, I'm not sure I would have understood what they were talking
about with that function.
Thanks again Larry.
Jon
------------------------------
Date: 23 Aug 2000 16:42:45 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <967048775.28995@itz.pp.sci.fi>
In article <967039775.3266@itz.pp.sci.fi>, Ilmari Karonen wrote:
>In article <39a297e2.6817880@news.earthlink.net>, Jon S. wrote:
>>Is there a way to make these warnings show up "pretty" in my returned
>>html? I've got CGI::Carp going with fatalstoBrowser and a few warn
>>and die statements, but I'd like to have my warnings go to the browser
>>also. Right now, they get placed oddly in the output. (Like, in
>
>The latest version of CGI::Carp (1.20) includes a patch I wrote that
>adds this feature. See http://search.cpan.org/search?dist=CGI.pm
Looking at your post more closely, I may have misread it. If you
already have that version and use warningsToBrowser(), please ignore
the previous post. I'm not cancelling it since somebody else might
find it useful, however.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: Wed, 23 Aug 2000 17:05:09 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: newbie question about "uninitialized variables"
Message-Id: <39a403ac.13574088@news.earthlink.net>
On 23 Aug 2000 14:20:37 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
>In article <39a297e2.6817880@news.earthlink.net>, Jon S. wrote:
>>Is there a way to make these warnings show up "pretty" in my returned
>>html? I've got CGI::Carp going with fatalstoBrowser and a few warn
>>and die statements, but I'd like to have my warnings go to the browser
>>also. Right now, they get placed oddly in the output. (Like, in
>
>The latest version of CGI::Carp (1.20) includes a patch I wrote that
>adds this feature. See http://search.cpan.org/search?dist=CGI.pm
Yep, warningsToBrowser... cool!
Thanks for writing that, and the true/false calling of it is really a
smart implementation.
Now let's see if my webhoster has that version installed. *sigh*
Thanks again,
Jon
------------------------------
Date: 23 Aug 2000 16:04:20 GMT
From: jonnydeja@my-deja.com (Jonny)
Subject: Re: Newbie: Help with Fork on NT box
Message-Id: <8o0sm4$en$1@news.cadence.com>
What does autoflush do?
>
>>Turn on autoflush.
>>$| = 1;
>>--
>
------------------------------
Date: Wed, 23 Aug 2000 16:39:46 GMT
From: coughlan@gothaminteractive.com
Subject: newbie:? string sub through an array
Message-Id: <8o0uof$s04$1@nnrp1.deja.com>
What's the easiest way to do a string subtritution of "A" for "B"
throughout an array @myarray?
TIA,
MC
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 23 Aug 2000 10:57:12 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: newbie:? string sub through an array
Message-Id: <MPG.140db0539fd45a1398accb@nntp.hpl.hp.com>
[Not a good idea to filter your message out of many newsreaders by
including 'newbie' in the Subject.]
In article <8o0uof$s04$1@nnrp1.deja.com> on Wed, 23 Aug 2000 16:39:46
GMT, coughlan@gothaminteractive.com <coughlan@gothaminteractive.com>
says...
> What's the easiest way to do a string subtritution of "A" for "B"
> throughout an array @myarray?
Perl Golf winner:
y/B/A/for@myarray;
For readability:
tr/B/A/ foreach @myarray;
See perlsyn (for the 'foreach' loop) and perlop (for the 'tr' operator).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 23 Aug 2000 16:32:53 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: NT drive mappings-newbee question
Message-Id: <8o0ubk$rj6$1@nnrp1.deja.com>
In article <8o0o28$jkc$1@nnrp1.deja.com>,
dwilson6660@my-deja.com wrote:
> I map a network drive usint the following script:
<snip>
> I can see the T: drive in a net use but the problem is that I can't
> figure out how to change directoried to it. I used system s\:\\; and
> various syntexes of it, chdir and serveral other ways but when I do a
> system dir in the script it gives me the directory of where the script
> is runnung.
#!perl -w
use Cwd;
use strict;
my $dir = cwd();
print "$dir\n";
chdir "/perl/lib";
$dir = cwd();
print "$dir\n";
HTH,
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 23 Aug 2000 10:24:01 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl and dates
Message-Id: <MPG.140da88bb624ff2698acc7@nntp.hpl.hp.com>
In article <8o0h8i$b40$1@nnrp1.deja.com> on Wed, 23 Aug 2000 12:49:29
GMT, zideon@my-deja.com <zideon@my-deja.com> says...
> Hello,
>
> How can I get the week of the year with a Perl script. My webhost
> provider hasn't installed the CPAN DATE::CALC module.
Tony Curtis pointed you to POSIX::strftime in response to your follow-up
question. In response to this question, strftime() also offers
specifiers '%U' and '%W' for the week number, with different origins.
But neither of them is the same as the ISO-8601 standard week number,
which has yet another origin. For formulas to compute the ISO-8601 week
number from the year and day-of-the-year, see Section 5.8. "How can I
calculate the week number?" in
http://www.faqs.org/faqs/calendars/faq/part3/
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 23 Aug 2000 19:02:19 +0200
From: alik <alikbm@tx.technion.ac.il>
Subject: perl books
Message-Id: <39A4039B.B11F2C1@tx.technion.ac.il>
Hi i am required to learn perl
is there some nice and extensive online books or staff
on the internet
I know there are tons of stuff on perl but i don't really
know what to choose and where to start
reply to : alikbm@tx.technion.ac.il
thanks
------------------------------
Date: 23 Aug 2000 18:20:40 +0100
From: andkaha@hello.to.REMOVE (Andreas Kahari)
Subject: Re: perl books
Message-Id: <39a3f9d8@merganser.its.uu.se>
In article <39A4039B.B11F2C1@tx.technion.ac.il>,
alik <alikbm@tx.technion.ac.il> wrote:
>Hi i am required to learn perl
>
>is there some nice and extensive online books or staff
>on the internet
>I know there are tons of stuff on perl but i don't really
>know what to choose and where to start
> reply to : alikbm@tx.technion.ac.il
>
>thanks
>
A great tutorial at available on-line at
<URL:http://www.ebb.org/PickingUpPerl/>
The "Learning Perl" book from O'Reilly is also really good, see
<URL:http://perl.oreilly.com/>.
See <URL:http://www.perl.com/> for everything else and ask this forum
about stuff you don't find there.
/A
--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# ...brought to you from Uppsala, Sweden.
# All junk e-mail is reported to the appropriate authorities.
# Criticism, cynicism and irony available free of charge.
------------------------------
Date: Wed, 23 Aug 2000 16:34:36 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: perl books
Message-Id: <8o0ues$rkf$1@nnrp1.deja.com>
In article <39A4039B.B11F2C1@tx.technion.ac.il>,
alik <alikbm@tx.technion.ac.il> wrote:
> Hi i am required to learn perl
>
> is there some nice and extensive online books or staff
> on the internet
http://www.perl.com/reference/query.cgi?section=books&x=15&y=17
HTH,
amonotod
--
`\|||/ amonotod@
(@@) netscape.net
ooO_(_)_Ooo________________________________
_____|_____|_____|_____|_____|_____|_____|_____|
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 23 Aug 2000 13:16:12 -0400
From: Guest <guest@yale.edu>
Subject: perl hash code
Message-Id: <39A406DC.8C5779A7@yale.edu>
I was wondering if someone could give me a basic outline in perl to do
the
following:
I have 2 files "A and B" whereby file B has the same information as
file A just different values. File B has much less information than file
A.
All I want to do is run a script that compares file A and file B and if
the lines in file B match what is file A then just replace those lines
in File A with the values in File B leaving the unmatched lines in file
A
alone.
Here would be an example of file A:
assign (segid a and resid 11 and name H1')
(segid a and resid 11 and name H3') 3.7 0.3 0.3
assign (segid a and resid 11 and name H1')
(segid a and resid 12 and name H8) 3.8 0.8 0.8
assign (segid a and resid 11 and name H4')
(segid a and resid 11 and name H5) 2.7 0.1 0.1
assign (segid a and resid 12 and name H1')
(segid a and resid 12 and name H2') 1.9 0.1 0.1
An example of file B:
assign (segid a and resid 11 and name H1')
(segid a and resid 11 and name H3') 2.0 0.3 0.4
assign (segid a and resid 12 and name H1')
(segid a and resid 12 and name H2') 6.2 0.5 0.5
thank you for any tips that you can lend.
earle
adams@mrclin1.med.yale.edu
------------------------------
Date: 23 Aug 2000 15:40:32 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: Perl/MySQL vs ASP/MS-SQL
Message-Id: <8o0r9g$kfq$1@uns-a.ucl.ac.uk>
In article <8o09v8$394$1@nnrp1.deja.com>, af778@iname.com says...
>
>Thank you very much Malcom and Steve.
>My hosting provider only support the "bundle" CGI-Perl/MySQL or
>ASP/MSSQL, but I always loved the freedom and I feel that MS is
>anything but freedom.
>But the lack of subselects in MySQL is frustrating...
>I hope it will be supported in next version of the engine. (I saw it
>somewhere)...
>Do you know of any "big-real-and-know" implementation using MySQL?
>Thank you again
This question was asked last month on the mySQL mailing list, and there were a
lot of big names cmoe up.
Do a search on the mailing list archives found at: http://www.mysql.com/
------------------------------
Date: Wed, 23 Aug 2000 17:21:36 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: Perl/MySQL vs ASP/MS-SQL
Message-Id: <39a40710.14441933@news.earthlink.net>
On Wed, 23 Aug 2000 10:44:59 GMT, af778@iname.com wrote:
>Thank you very much Malcom and Steve.
>My hosting provider only support the "bundle" CGI-Perl/MySQL or
>ASP/MSSQL, but I always loved the freedom and I feel that MS is
>anything but freedom.
>But the lack of subselects in MySQL is frustrating...
>I hope it will be supported in next version of the engine. (I saw it
>somewhere)...
>Do you know of any "big-real-and-know" implementation using MySQL?
>Thank you again
I'm just a newbie, but...
For a high pull volume vs. low edit volume (mostly just inserts),
www.slashdot.org seems to do very well. It's mainly slow because it
gives you 300k pages with tables, but the data rolls in very quickly.
Lots of customized queries going on there also.
Code is at www.slashcode.com.
If you go to www.mysql.com, they tell about some of what MySQL is
being used for in the wild.
IMHO, the nice thing about the Perl/MySQL route is that it's really
more like the Perl/DBI route. So, if you've learned DBI, modifying
your code to work with any other database in the future is much easier
if you transfer to a different webhoster or get your own server.
That, and between the docs at mysql.com, the book Programming the Perl
DBI, and the newsgroups. You've got tons of support.
Jon
------------------------------
Date: Wed, 23 Aug 2000 16:44:11 GMT
From: perlnewbie@my-deja.com
Subject: Please help, 1024 char limit writing to DB's?
Message-Id: <8o0v0l$sbn$1@nnrp1.deja.com>
I am encountering an error when I try and write to a DB file in WinNT
using Active Perl. Here is the error message I receive:
"Tue Aug 22 09:54:07 2000: sdbm store returned -1, errno 22,
key "92"..."
It seems that I am only allowed to write a maximum of 1024 characters.
I was wondering if there is any way to work around this limitation?
Below is a code snippet of the function which is writing to the DB
file. I am trying to migrate an existing site in Unix environment to
WinNT and I am running Active Perl.
use Fcntl;
use AnyDBM_File;
use strict;
package DB;
@DB::fields=('name','catlist','ingredients','instructions','servings',
'footnotes','calories','fat','cholesterol','sodium','carbohydrat
e',
'fiber','protein','image','caption');
$DB::delim="\002";
sub createRecipe {
my($data)=@_;
my($recdata)=join($DB::delim,map {$data->{$_}} @DB::fields); my($id)
=$data->{'id'};
&::timeout_write_lock("DB::DBMFILE", $config::recipedbm); dbmopen(%
DB::RECIPEDBM, $config::recipedbm, 0644)
|| &Fatal("dbmopen of $config::recipedbm: $!\n");
$DB::RECIPEDBM{$id}= $recdata;
dbmclose(%DB::RECIPEDBM);
&::unlock("DB::DBMFILE");
close("DB::DBMFILE");
&Almond::Log("Created REC#$id: $data->{'name'} EOF = $endofline");
}
Thanks in advance for any help I can get. I am stuck!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 23 Aug 2000 10:09:40 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Print buffering (WAS: Cookie problem (chrs in value))
Message-Id: <MPG.140da530f68d464898acc6@nntp.hpl.hp.com>
In article <mll7qssshun4an1li7mqula4jo6k0n7e54@4ax.com> on Wed, 23 Aug
2000 13:54:56 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Larry Rosler wrote:
>
> >You'd end up doing a lot of small writes to files, which
> >> isn't optimal, since each takes quite an overhead.
> >
> >Why is that? What about buffering in the output routines?
>
> Just experiment with setting $\. With $\ set to "\n", for example, I
> noitice a slowdown of about 20% in my code, on a Win32 PC. Only part of
> it (the largest part) is printing.
That is quite surprising. Can you share a benchmark?
> Now, there a re basically two ways of printing with $\ set (that I can
> think of):
>
> A) Copy the scalar to print and appending the value of $\ to it.
> B) First print the string, then print $\.
>
> I think it's version 2 being used; it sounds smartest. But the overhead
> is not negligable.
I can't see how it should matter significantly.
> It has been suggested that ALL system calls have a significant overhead,
> switching from user mode to supervisor (kernel?) mode and back. Even if
> the system call barely does anything.
Nevertheless, each call to Perl's print() function isn't a system call.
All the buffering should be taking place in user mode, and the
occasional calls to write(2) with full buffers are the only ones that
require context switching.
As Abigail said, all this should be mediated by the C stdio library.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 23 Aug 2000 11:02:30 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: self writing program
Message-Id: <39A403A4.CB542CD2@mrnoitall.com>
Stephen Montgomery-Smith wrote:
> I wanted to write a program in perl that when invoked
> prints out a copy of exactly itself.
>
> The shortest I could come up with was:
>
> $_='$_=X;s/X/\x27$_\x27/;print
> ';s/X/\x27$_\x27/;print
>
> Has anyone come up with anything shorter?
>
> (Is this a FAQ?)
>
> --
> Stephen Montgomery-Smith
> stephen@math.missouri.edu
> http://www.math.missouri.edu/~stephen
Just save your script as "script.html" and let her fly
------------------------------
Date: Wed, 23 Aug 2000 12:11:40 -0400
From: Ed Waldspurger <ewald@electronicfrontiers.com>
Subject: Strict and Binary Image Upload
Message-Id: <MPG.140dc1c34b531d59989684@news.mtcibs.com>
I am trying to upload a binary image file using CGI.pm and am having
trouble with strict. Here is what I am trying:
open (SAVE,">/imagepath/image.gif") ||
die "Can't Open Save Location $!";
while (read($q->param('imageupload'),$data,1024)) {
print SAVE $data;
}
close SAVE;
Using this, I get the message "Can't use string as a symbol ref while
"strict refs" in use". After reading perlref and perldoc strict, I
tried this:
while (read(\$q->param('imageupload'),$data,1024)) {
The message I get now is "Not a GLOB reference". Using ref, I found
that \$q->param('imageupload') is a SCALAR. The CGI.pm docs say to
"treat the returned value as a filehandle", but strict does not seem to
let this to happen.
I have uploaded text files with CGI.pm and "use strict" with no problem.
What is the difference between while(<$filehandle>) and while(read
($filehandle,$data,1024)) that strict finds objectionable?
-Ed
------------------------------
Date: Wed, 23 Aug 2000 16:21:36 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: User ID - someone explain?
Message-Id: <kSSo5.164$pD2.10139@news.dircon.co.uk>
On Wed, 23 Aug 2000 14:26:37 GMT, amonotod Wrote:
> In article <39A3D49A.88F2ECE6@hursley.ibm.com>,
> Derek Fountain <nomail@hursley.ibm.com> wrote:
>> I have Perl 5.005 and Perl 5.6 on my SuSE-6.4 Linux machine.
>> I'm trying to work out the behaviour of the user id. I
>> understand user ids, effective user ids (or at least I think
>> I do) but can't understand what Perl will and won't do.
>>
>> To start with, I have this:
>>
>> > ls -l test
>> -rwsr-sr-x 1 root root 260 Aug 23 14:29 test*
> <snip>
>> So, the questions are, what is the difference between 5.005
>> and 5.6 in this respect? and can I run a script with the
>> setuid bit set?
>>
> I may get lots of argument on this, but it seems to me that the Perl
> binary would have to be setuid, not the script. Hence the setuid Perl
> that is shipped with many versions of Linux.
>
Some OS will support setuid scripts directly (or can be configured to do
so) and some dont and require some wrapper or facility such as suidperl.
It should be borne in mind that there has been a recent advisory regarding
an exploit against suidperl - it probably shouldnt be used without the
issued patch removing the exploitable feature (see the archive of p5p for
more).
If considering making a Perl program setuid one should be familiar with
the perlsec manpage before doing so.
/J\
------------------------------
Date: 23 Aug 2000 17:52:35 +0100
From: nobull@mail.com
Subject: Re: User ID - someone explain?
Message-Id: <u9em3f6ht8.fsf@wcl-l.bham.ac.uk>
Jonathan Stowe <gellyfish@gellyfish.com> writes:
> On Wed, 23 Aug 2000 14:26:37 GMT, amonotod Wrote:
> > In article <39A3D49A.88F2ECE6@hursley.ibm.com>,
> > Derek Fountain <nomail@hursley.ibm.com> wrote:
> >> I have Perl 5.005 and Perl 5.6 on my SuSE-6.4 Linux machine.
>
> Some OS will support setuid scripts directly (or can be configured to do
> so) and some dont and require some wrapper or facility such as suidperl.
>
> It should be borne in mind that there has been a recent advisory regarding
> an exploit against suidperl - it probably shouldnt be used without the
> issued patch removing the exploitable feature (see the archive of p5p for
> more).
I don't know if this is the same exploit you are talking about but it
should be noted that Linux lacks statvfs() so it is not possible for
a suid-wrapper program like suidperl to detect that the script it is
about to run is mounted on a filesystem with SUID disabled.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 23 Aug 2000 14:55:20 GMT
From: dwilson6660@my-deja.com
Subject: using network drives-newbee question
Message-Id: <8o0okb$kcm$1@nnrp1.deja.com>
I connect to a NT network drive wusin the following script:
Connect_MD001();
sub Connect_MD001
{
use Win32::NetResource;
$server = "xxx1";
$adminshare = "D";
%NetResource = (LocalName => 'T:',
RemoteName => "\\\\$server\\$adminshare\$", );
} #end sub MD001
This works fine, I can do a net use and the T: drive is mapped. The
problem I'm having is getting the script to change to that that drive.
I've used the system command chdir even chroot and if I list the
directory it displays the directory which perl is running in. What am
I missing. Also I found that the above script will only allow 1 drive
being mapped. If I run:
$server = "xxx2";
$adminshare = "D";
%NetResource = (LocalName => 'S:',
RemoteName => "\\\\$server\\$adminshare\$", );
right after it T: is no longer there and S: is.
Is there a better way to connect to NT devices than using
Win32::NetResource
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4107
**************************************