[7767] in Perl-Users-Digest
Perl-Users Digest, Issue: 1392 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 30 16:17:27 1997
Date: Sun, 30 Nov 97 13:00:26 -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 Sun, 30 Nov 1997 Volume: 8 Number: 1392
Today's topics:
Re: , but I can't go to bed now. REGEXPS question - TI <mchase@ix.netcom.com>
Re: 2 things are the same yet not equal. <rootbeer@teleport.com>
[BUG] Plain <> fails in Win32 native port <mchase@ix.netcom.com>
Re: Backquote in Perl (Tad McClellan)
Re: Backquote in Perl <mchase@ix.netcom.com>
Breaking out of an app (Mark Lloyd)
dbase IV files to comma delimited files <j.a.d.@worldnet.att.net>
Re: How To Test if number is ODD or EVEN? (Brian Wheeler)
Re: last element in an array? (Andrew M. Langmead)
Re: last straw in an array? (Andrew M. Langmead)
Passing LIST parameters to die() (Peter Murray)
Perl -> Java (script) (Bert Tijhuis)
Re: Perl 5.004 on a SPARC <rootbeer@teleport.com>
perlop clarification request <billg@networkapparel.com>
Re: Q: Learning perl with no progr. experience (I R A Aggie)
Re: Q: Learning perl with no progr. experience (Tushar Samant)
Re: Q: Learning perl with no progr. experience (I R A Aggie)
Re: Resource Kit Anomaly (brian d foy)
Re: Resource Kit Anomaly <rra@stanford.edu>
size of a DB <mortensi@idt.ntnu.no>
Telnet 3270 (Bert Tijhuis)
Trying to parse referer_log??? <prog@wallybox.cei.net>
Re: Trying to parse referer_log??? (brian d foy)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 30 Nov 1997 10:38:45 -0800
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: , but I can't go to bed now. REGEXPS question - TIA
Message-Id: <65si4m$kv1@sjx-ixn3.ix.netcom.com>
You could say, "I'll always use -w.". One hundred times. <G>
It would have pointed out the problem immediately.
--
Mac :}) mchase@ix.netcom.com
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/IT/O d s+:+ a+ C++$ ULUHSC*++$ P++$ L+(++) E- W++ N++ o? K-? w+
O M- V- PS+@ PE Y+ PGP+ t+ 5++ X R tv b+++(++++) DI++(+++) D? G e++ h---
r+++ y+
------END GEEK CODE BLOCK------
$m~c%l&l!h#n@worldnet.att.net <$m~c%l&l!h#n@worldnet.att.net> wrote in
message <65mltj$bkn@mtinsc05.worldnet.att.net>...
>On 28 Nov 1997 16:48:41 +0200, jari@iki.fi (Jari Mdkeld) wrote:
>
>Thanks Jari!
>I don't know what to say........
>
>>$m~c%l&l!h#n@worldnet.att.net writes:
>>
>>> # Why none of these are working?
>>
>>> $s_ = "bah baah baaah ";
>>
>>> print "Go to bed now.\n" if (/a{1,3}/) ;
>>
>>[...]
>>
>>Perhaps You should try to match the regex to $s_ and not to $_ like
>>this:
>>
>>print "Go to bed now.\n" if ($s_ =~ /a{1,3}/) ;
>>
>>Or perhaps You should go to bed and try again after a good night
>>sleep?
------------------------------
Date: Sun, 30 Nov 1997 12:42:00 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: The White Rabbit <sbachman@saveware.com>
Subject: Re: 2 things are the same yet not equal.
Message-Id: <Pine.GSO.3.96.971130124028.8797F-100000@usertest.teleport.com>
On Sat, 29 Nov 1997, The White Rabbit wrote:
> They both look the same when I output them (STDOUT).
Here's my way to see what a variable really contains:
print "foo in hex is ", unpack("H*", $foo), "\n";
This works well for finding embedded nuls or other control characters.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sun, 30 Nov 1997 12:23:22 -0800
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: [BUG] Plain <> fails in Win32 native port
Message-Id: <65si4p$kv1@sjx-ixn3.ix.netcom.com>
Congratulations (I think). You appear to have found a bug in Win32
native builds (Borland C++ at least) of the standard distribution. I am
forwarding your message along with my results to perlbug@perl.com.
I recreated your problem with both Perl 5.004_02 (compiled by Gurusamy
Sarathy) and Perl 5.004_04 (compiled by me with Borland C++ 5.02) and
confirmed it didn't occur with the ActiveState port (Build 310) or my
Cygwin32 build of the Perl 5.004_04 (trial 4) standard distribution.
I tried using File::DosGlob to override glob() in the non-ActiveState
builds, but it had no effect.
When I ran perlglob.exe and perlglob.bat they returned the correct list
of files. Perlglob.exe does not exist in Gurusamy's binary distribution,
but is in my build.
The output from perl -V for each version of perl I used is after Greg's
initial message.
Test Script: perl gtest.pl *.bat
#! /perl5/bin/perl -w
print "\@ARGV = '", join( "'", @ARGV ), "'\n";
foreach $file (<@ARGV>) { print "File: '$file'\n"; }
print "\@ARGV = '", join( "'", @ARGV ), "'\n";
while ( <> ) { print "$. $_"; }
print "\@ARGV = '", join( "'", @ARGV ), "'\n";
__END__
Results (Perl 5.004_02 and 5.004_04 native compiles):
@ARGV = '*.bat'
File: 'p_AS.bat'
File: 'p_gs.bat'
File: 'p_my.bat'
@ARGV = '*.bat'
Can't open *.bat: No such file or directory
@ARGV = ''
Results: (ActiveState port and Cygwin32 port):
@ARGV = 'p_AS.bat'p_gs.bat'p_my.bat'
File: 'p_AS.bat'
File: 'p_gs.bat'
File: 'p_my.bat'
@ARGV = 'p_AS.bat'p_gs.bat'p_my.bat'
1
@PATH=c:\wbin;c:\menu;c:\perl5.32\bin;c:\bc5\bin;C:\WINNT\system32;C\WINN
T;d:orant\bin
2
@PATH=c:\wbin;c:\menu;c:\perl5.004.bc\bin;c:\bc5\bin;C:\WINNT\system32;C:
\WINNT;d:\orant\bin
3
@PATH=c:\wbin;c:\menu;c:\perl5\bin;c:\bc5\bin;C:\WINNT\system32;C:\WINNT;
d:\orant\bin
@ARGV = ''
--
Mac :}) mchase@ix.netcom.com
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/IT/O d s+:+ a+ C++$ ULUHSC*++$ P++$ L+(++) E- W++ N++ o? K-? w+
O M- V- PS+@ PE Y+ PGP+ t+ 5++ X R tv b+++(++++) DI++(+++) D? G e++ h---
r+++ y+
------END GEEK CODE BLOCK------
Greg McDermid wrote in message <01bcfa60$fde92250$89ba0ccb@gregii>...
>Hi,
>
>until recently I have been using the activestate (ex hip communications)
>perl, then I switched to the standard perl distribution (V 5.004 Win32
>under NT 4). At this point a lot of my scripts started failing, most
have a
>very basic structure like:
>
>while (<>)
>{
> ...
>}
>
>The problem is that if the input is a specified list of files, or
>redirected input it works OK, but if I use wildcards it fails, e.g.
perl
>x.pl *.err, the error being like "Can't open *.err". Is there something
>silly I missed here?
Summary of my perl5 (5.0 patchlevel 4 subversion 04) configuration:
Platform: (my build with Borland C++ 5.02)
osname=MSWin32, osvers=4.0, archname=MSWin32
uname=''
hint=recommended, useposix=true, d_sigaction=undef
bincompat3=undef useperlio=undef d_sfio=undef
Compiler:
cc='bcc32', optimize='-O', gccversion=
cppflags='-DWIN32'
ccflags ='-D_RTLDLL -DWIN32'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='tlink32', ldflags =''
libpth=r:\bc5\lib
libs=import32.lib cw32mti.lib odbc32.lib odbccp32.lib
libc=cw32mti.lib, so=dll
useshrplib=undef, libperl=undef
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags='', lddlflags='-Tpd'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING
Built under MSWin32
Compiled at Nov 14 1997 20:33:17
%ENV:
PERL5LIB="c:\home\mchase\Boeing\perllib\1.0"
@INC:
c:\home\mchase\Boeing\perllib\1.0
c:\perl5\lib\site
c:\perl5\lib
c:\perl5\lib
c:\perl5\lib\site
c:\perl5\lib\site
.
Summary of my perl5 (5.0 patchlevel 4 subversion 02) configuration:
Platform: (Gurusamy Sarathy's binary)
osname=MSWin32, osvers=4.0, archname=MSWin32
uname=''
hint=recommended, useposix=true, d_sigaction=undef
bincompat3=undef useperlio=undef d_sfio=undef
Compiler:
cc='bcc32', optimize='-O', gccversion=
cppflags='-DWIN32'
ccflags ='-D_RTLDLL -DWIN32'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=n, randbits=15
Linker and Libraries:
ld='tlink32', ldflags =''
libpth=r:\bc5\lib
libs=import32.lib cw32mti.lib odbc32.lib odbccp32.lib
libc=cw32mti.lib, so=dll
useshrplib=undef, libperl=undef
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags='', lddlflags='-Tpd'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING
Built under MSWin32
Compiled at Aug 9 1997 21:42:37
%ENV:
PERL5LIB="c:\home\mchase\Boeing\perllib\1.0"
@INC:
c:\home\mchase\Boeing\perllib\1.0
c:\perl5.004.bc\lib\site
c:\perl5.004.bc\lib
c:\perl\lib
c:\perl\lib\site
c:\perl\lib\site
.
Summary of my perl5 (patchlevel 1) configuration:
Platform: (ActiveState Build 310)
osname=MSWin32, osver=3.51, archname=i386-win32
uname=''
hint=recommended
Compiler:
cc='cl', optimize=''
cppflags=''
ccflags =''
ldflags =''
stdchar='char', d_stdstdio=, usevfork=false
voidflags=15, castflags=0, d_casti32=, d_castneg=
intsize=4, alignbytes=4, usemymalloc=n, randbits=15
Libraries:
so=dll
libpth=
libs=
libc=
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=pll, d_dlsymun=
cccdlflags='', ccdlflags='', lddlflags=''
Characteristics of this binary (from libperl):
Built under MSWin32
Compiled at Sep 4 1997 19:24:08
@INC:
c:\home\mchase\Boeing\perllib\1.0
C:\perl5.32\lib\i386-win32
C:\perl5.32\lib
c:\perl\lib
c:\perl5\lib
c:\perl5\lib\site
.
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform: (my Cygwin32 build)
osname=cygwin32, osvers=4.0, archname=cygwin32
uname='cygwin32_nt prog01744070-3 4.0 17.6 i586 '
hint=recommended, useposix=false, d_sigaction=define
bincompat3=n useperlio=undef d_sfio=undef
Compiler:
cc='/port0/cygperl5.004m4t4/cygwin32/gcc2', optimize='-O',
gccversion=cygnus
-2.7.2-970404
cppflags=''
ccflags =''
stdchar='char', d_stdstdio=undef, usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=4, usemymalloc=y, prototype=define
Linker and Libraries:
ld='/port0/cygperl5.004m4t4/cygwin32/ld2', ldflags
=' -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib
libs=-lcygwin -lm -lkernel32
libc=, so=dll
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_cygwin32.xs, dlext=dll, d_dlsymun=undef,
ccdlflags='-buildperl '
cccdlflags='-DDLLIMPORT ',
lddlflags=' -L../.. -lperlexp -lcygwin -L/usr/loc
al/lib'
Characteristics of this binary (from libperl):
Locally applied patches:
MAINT_TRIAL_4 - 5.004_04 maintenance release trial 4
Built under cygwin32
Compiled at Oct 25 1997 11:41:49
%ENV:
PERL5LIB="/home/mchase/Boeing/perllib/1.0"
@INC:
/home/mchase/Boeing/perllib/1.0
/usr/local/lib/perl5/cygwin32/5.00404
/usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/cygwin32
/usr/local/lib/perl5/site_perl
.
------------------------------
Date: Sun, 30 Nov 1997 12:12:52 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Backquote in Perl
Message-Id: <4bas56.ia1.ln@localhost>
venkat5@hotmail.com wrote:
: could someone help in ,how to use cd(change directory) within backquotes.
: print `cd \dir1`; is not working.
Backticks spawn a new (child) process. Children process cannot effect
the environment of their parent process, only their own (and their
children's) environment.
Use perl's builtin chdir() instead. It is more portable, faster, and
more importantly, it works ;-)
: other commands like dir are working.
: i am using Perl 5.001 under WinNT 4.0
^^^^^^^^^
I don't know if this even applies to Bill's stuff...
Perl FAQ, part 8:
"I {changed directory, modified my environment} in a perl script.
How come the change disappeared when I exited the script?
How do I get my changes to be visible?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 30 Nov 1997 09:08:59 -0800
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: Backquote in Perl
Message-Id: <65si4l$kv1@sjx-ixn3.ix.netcom.com>
The backquotes are working fine.
The problem is that directory changes (and environment variable changes)
in the subshell invoked by the backquotes are not returned to the program
(perl in this case) that called the subshell.
--
Mac :}) mchase@ix.netcom.com
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/IT/O d s+:+ a+ C++$ ULUHSC*++$ P++$ L+(++) E- W++ N++ o? K-? w+
O M- V- PS+@ PE Y+ PGP+ t+ 5++ X R tv b+++(++++) DI++(+++) D? G e++ h---
r+++ y+
------END GEEK CODE BLOCK------
venkat5@hotmail.com wrote in message <880523064.10150@dejanews.com>...
>could someone help in ,how to use cd(change directory) within
backquotes.
>print `cd \dir1`; is not working. other commands like dir are working.
>i am using Perl 5.001 under WinNT 4.0
------------------------------
Date: Sun, 30 Nov 1997 19:57:14 GMT
From: mlloyd@baynetworks.takethisout.com (Mark Lloyd)
Subject: Breaking out of an app
Message-Id: <3481c4b8.4860712@news>
I have a perl script which calls another app. This app unfortunately
does not end with a single call and waits for another entry at the
command line. What I need to do is break out of this app. Suggestions?
Mark Lloyd
Professional Services
Bay Networks Canada
------------------------------
Date: Sun, 30 Nov 1997 12:43:13 -0500
From: "Akira" <j.a.d.@worldnet.att.net>
Subject: dbase IV files to comma delimited files
Message-Id: <65s8vd$r1d@bgtnsc03.worldnet.att.net>
Does anyone have a script that will take a dbase IV file and convert it to a
comma delimited file using Perl 5??
Any comments or suggestions would be welcomed.
Thanx in advance
Akira
------------------------------
Date: 30 Nov 1997 15:29:45 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <65s0p9$4gi$1@dismay.ucs.indiana.edu>
In article <65l587$pi$1@comdyn.comdyn.com.au>,
mgjv@comdyn.com.au (Martien Verbruggen) writes:
> In article <65f5pv$kj$1@dismay.ucs.indiana.edu>,
> bdwheele@indiana.edu (Brian Wheeler) writes:
>> In article <comdog-ya02408000R2411971501330001@news.panix.com>,
>> comdog@computerdog.com (brian d foy) writes:
>>> In article <01bcf675$0ea174c0$c82da8c0@akilles.ittek.org>, "Robert Friberg" <robert.friberg@your_clothes.eductus-vast.com> wrote:
>>>
>>>>print $number && 1 ? 'Odd!': 'Even!', "\n";
>>>
>>> i guess you didn't bother to test this. thanks for posting crap.
>> Nice manners. Probably a typo, because
>>
>> print $number & 1 ? 'Odd!' : 'Even!', "\n";
>>
>> works as advertised.
>
> That is NOT what the poster submitted though. What the poster
> submitted was not correct, even if it was CLOSE.
Yeah, and you never typo? Looking at it, you can see what he's
trying to do, and since you know what && vs & means, then you can figure out
why its not working.
>
>> && is shortcut AND. It would only show up as Even if $number was undefined
>> or 0. & is logical AND.
>
> && is logical and (with higher precedence than the keyword and)
> & is bitwise and
>
> what is 'shortcut and'?
Ooops. I meant "short circuit".
shot circuit logic is where the operands will be evaluated from left to
right ...until an answer is known. I.E. && will
stop evaluating when it sees the first false, because no matter what the 2nd
argument is, the expression will be false. In the case of ||, as soon as a
true is seen, it doesn't matter if the next operand is true or false. This
is why
open(...) || die
works. die is not evaluated if open returns a 'true' value.
>
>> Before go and criticize people's __FREELY GIVEN HELP__, why don't you try to
>
> Something being free is no reason for it being incorrect. It takes about
> three seconds to test something like that, so why not do that?
>
>> figure it out on your own? odd/even is probably the most trivial problem
>> there is. Sorry if I'm ragging, but it really irks me when people get shitty
>> with free advice.
>
> It might be trivial, but the original poster obviously didn't know how
> to do it, so the original poster probably also wouldn't have been able
> to figure out that the answer was wrong, and why it was wrong.
>
> Martien
------------------------------
Date: Sun, 30 Nov 1997 19:59:39 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: last element in an array?
Message-Id: <EKH67F.BtK@world.std.com>
, snailgem@aol.com writes:
>> But what you probably really want to be doing is using the push()
>> function to append elements to an array. See the entry for push() in
>> the perlfunc man page.
>>
>I intentionally didn't want to use push. I eventually want to change the
>file I'm reading in appending something to the end of @matches. This
>array can be pretty big, and by using push I would have to substitute
>the whole old @matches with @matches plus the element I just pushed in.
>Instead I just wanted to find the last element of matches
>($last_match) and substitute it with $last_match . $tackedon_stuff. But
>maybe I'm wrong about this too (I'm wrong a lot these days).
You aren't really gaining anything by doing that.
push @matches, $tackedon_stuff;
Doesn't do anything to the current elements of @matches. It will be
faster than concatinating data only the last element.
Also, you might be better of storing only the elements that match,
rather than reading all of the lines and then sifting through them for
matches.
while(<FILE>) {
push @matches, $_ if /line\d_/;
}
push @matches, $tackedon_stuff;
--
Andrew Langmead
------------------------------
Date: Sun, 30 Nov 1997 20:13:23 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: last straw in an array?
Message-Id: <EKH6uC.IMK@world.std.com>
, snailgem@aol.com writes:
>> This is described in the 'perldata' (where else?) man page:
>>
>Yes, this is fine.
>But how did you know to look for it in the perldata manpage?
>This is one of the problems beginners encounter, I think, with PERL:
>we're constantly being referred to the FM, but it seems to me that you
>have to know quite a bit to make the perl man pages useful to you.
Start with the perl man page.
For ease of access, the Perl manual has been split up into
a number of sections:
perl Perl overview (this section)
perldelta Perl changes since previous version
perlfaq Perl frequently asked questions
perldata Perl data structures
perlsyn Perl syntax
perlop Perl operators and precedence
perlre Perl regular expressions
perlrun Perl execution and options
perlfunc Perl builtin functions
perlvar Perl predefined variables
[followed by other man pages]
Now I know that you still might not be sure which page to start
reading (perl might have provided an operator or function to determine
the last element of an array), but there are immediately a number of
pages whose description would tell you that they can be skipped for
your current question. I'd guess that it would be narrowed down to
"perldata", "perlop", and "perlfunc". And perldata is the one that is
suggested for reading first.
And its been pointed out to use that text searching tools are very
useful.
--
Andrew Langmead
------------------------------
Date: Sun, 30 Nov 1997 12:50:04 -0500
From: pem@po.cwru.edu (Peter Murray)
Subject: Passing LIST parameters to die()
Message-Id: <pem-3011971250040001@tier3-004.tier3.cwru.edu>
According to the man page for die(), it takes a LIST as a parameter. When
it gets to my handler, though, it comes out as a single scalar (all of the
list values concatinated into one):
$SIG{'__DIE__'}="handleDie";
die ('Param1','Param2');
sub handleDie {
my(@params) = @_;
print scalar(@params)." parameters found\n";
print join('|',@params)."\n";
exit;
}
Which outputs:
1 parameters found
Param1Param2 at ./temp.pl line 3.
Tried with 5.004_03 on Solaris 2.6 and 5.004_01 under Digital UNIX 4.0a.
All examples I've seen of die() and associated handlers assume a single
scalar as a parameter. Maybe there is a good reason for this?
Peter
--
Peter Murray, Library Systems Manager pem@po.cwru.edu
Digital Media Services http://www.cwru.edu/home/pem.html
Case Western Reserve University, Cleveland, Ohio W:216-368-5888
------------------------------
Date: Sun, 30 Nov 97 20:22:57 GMT
From: B.Tijhuis@inter.nl.net (Bert Tijhuis)
Subject: Perl -> Java (script)
Message-Id: <65sgj3$n3$1@news.NL.net>
Does anyone already write a program that translates Perl (programs/scripts)
into Java (Programs/Applets) or JavaScripts
When No.
Is there a C to Java translater?
An 1 to 1 translation is maybe not possible but 90% is already very nice.
kind regards, Bert Tijhuis
------------------------------
Date: Sun, 30 Nov 1997 12:38:47 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Joshua Pincus <froboz@cif.rochester.edu>
Subject: Re: Perl 5.004 on a SPARC
Message-Id: <Pine.GSO.3.96.971130123725.8797E-100000@usertest.teleport.com>
On 30 Nov 1997, Joshua Pincus wrote:
> I'm having lots of trouble installing Perl 5.004_04 on my Sparc 1,
When you find out what you're doing wrong, please add an explanatory note
to the hints file for your configuration. Then send the patch to the Perl
developers by using the perlbug program, so that it can help others.
Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sun, 30 Nov 1997 15:14:43 -0500
From: Bill Guindon <billg@networkapparel.com>
Subject: perlop clarification request
Message-Id: <3481C933.F0C6080@networkapparel.com>
Ok, I'm doing what we are all told to do, R'ingTFM.
I've made it as far as PERLOP without hitting anything that seemed too
unfathomable, but everyone has their limits.... here are some of mine:
----------------------------------------------------------------------
Multiplicative Operators:
"@ones = (5) x @ones; # set all elements to 5"
Why does this work? Why does it 'seem' that the second reference to
'@ones' is giving the number of elements in the array? I thought you
had to use something along the lines of either '$#days' or
'scalar(@whatever)' to achieve that.
----------------------------------------------------------------------
C-style Logical (And/Or):
"Scalar or list context propagates down to the right operand if it is
evaluated."
It sounds like they are saying a scalar could become a list. Could
someone give me an example of what they mean by this?
----------------------------------------------------------------------
Comma Operator:
"Binary ``,'' is the comma operator."
Too funny! That one's almost biblical. Left me expecting the next
sentence to be "and the comma operator is binary ``,''". Just a
stupid thought, the questions follow.
"In a scalar context it evaluates its left argument, throws that value
away, then evaluates its right argument and returns that value."
What would be the purpose of that? If it's going to throw it away,
why burn CPU cycles evaluating it? If it's going to be thrown away,
why would you burn keystrokes putting something before the comma?
I thought that meant the following code would print 'Second' (it
didn't). Could someone give me an example of it in use?
$value = 'First', 'Second';
print $value;
----------------------------------------------------------------------
Quote and Quotelike Operators
Perl provides customary quote characters for these behaviors, but also
provides a way for you to choose your quote character for any of them.
If you don't use the 'customary' quotes, does it follow the same rule
that it does for pattern matching (see below)?
"you can use any pair of non-alphanumeric,
non-whitespace characters as delimiters"
----------------------------------------------------------------------
Regexp Quotelike Operators /PATTERN/gimosx: "If the PATTERN evaluates
to a null string, the last successfully executed regular expression is
used instead."
Sounds like I can't trust the results. I thought it would return a
value of 'false' when the PATTERN is null. It looks like it always
returns 'true'?
The sample code below seems to confirm this fear (unless I screwed it
up). It even returned 'true' when NO other re had been evaluated yet!
if ($thisisa =~ //) {print 'This is a '.$thisisa.'\n'}
$thisisa = 'test';
if ($thisisa =~ /test/) {print 'This is a '.$thisisa.'\n'}
if ($thisisa =~ //) {print 'This is a '.$thisisa.'\n'}
The first line produced 'This is a ', and the last two produced 'This
is a test'. WHY? What's the benefit (how can I take advantage) of it
resorting to 'old' results?
If it does mean it's always true, should I consider it as meaning "ALL
strings contain 'NULL'"? If not, could someone give an example of
when it wouldn't return a 'true' value?
----------------------------------------------------------------------
btw... IMVHO, a lot of the examples seem a bit advanced (and/or) Unix
specific for an introductory example. For example, diving into
advanced regular expressions in perlop, when the 'suggested reading
order' has me reading perlre AFTER I've read perlop.
Hopefully, soon I'll appreciate that instead of 'whining' about it ;-)
Also IMHO, showing the results of the examples (seems most don't)
could also drastically reduce the learning curve.
I'm sure I'll have more, but I'll read perlre, then perlop again,
before I ask anything else.
----------------------------------------------------------------------
PLEASE POST ALL REPLIES TO COMP.LANG.PERL.MISC, As I'm sure there are
others who 'WANT TO KNOW' but are 'AFRAID TO ASK'.
Sincere apologies to those I've overwhelmed (or annoyed), and thanks
(in advance) to all who help me understand these things.
Bill Guindon
------------------------------
Date: Sun, 30 Nov 1997 12:06:12 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Q: Learning perl with no progr. experience
Message-Id: <-3011971206120001@aggie.coaps.fsu.edu>
In article <65rv45$1bj$0@204.179.92.81>, youngej@magpage.com wrote:
+ I R A Aggie wrote:
+ > <Pine.SUN.3.95q.971129105815.17988C-100000@napier.uwaterloo.ca>, Cindy
+ > Wong <ckpwong@undergrad.math.uwaterloo.ca> wrote:
+ > + Speaking of books, does anyone know what's the "Advanced Perl Programming"
+ > + book called? leopard? ;)
+ > Yes. I suppose it could be called the 'black and blue leopard'... :)
+ "panther book" is what struck me, I usually think of a leapord with
+ rosettes...
According to the colophon, its a black leopard. I also thought it was
a panther...
James - panther, catamount, mountain lion, whatever... :)
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 30 Nov 1997 12:00:56 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: Q: Learning perl with no progr. experience
Message-Id: <65s9ko$15m@shoga.wwa.com>
fl_aggie@thepentagon.com writes:
>James - panther, catamount, mountain lion, whatever... :)
^^^^^^^^^
Please watch your language.
I call it "panther". Everyone I have heard calling it anything
has called it "panther".
------------------------------
Date: Sun, 30 Nov 1997 15:06:10 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Q: Learning perl with no progr. experience
Message-Id: <-3011971506110001@aggie.coaps.fsu.edu>
In article <65s9ko$15m@shoga.wwa.com>, scribble@shoga.wwa.com (Tushar
Samant) wrote:
+ fl_aggie@thepentagon.com writes:
+ >James - panther, catamount, mountain lion, whatever... :)
+ ^^^^^^^^^
+ Please watch your language.
Sorry. It's a regional name for mountain lion:
cat a mount (kat'e mount') n.
1. a wild cat, esp. the cougar or the lynx.
2. CATAMOUNTAIN .
[1655-65; short for CATAMOUNTAIN]
+ I call it "panther". Everyone I have heard calling it anything
+ has called it "panther".
And according to the Colophon in the back, they'd all be wrong. Not that
I got it right, either, but I went and looked because O'Reilly always
includes a descripton of the critter on the cover.
James - and hopefully the FSU Bookstore has it in stock, since I can get
a 20% discount two days this week... :) :) :)
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Sun, 30 Nov 1997 13:06:30 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Resource Kit Anomaly
Message-Id: <comdog-ya02408000R3011971306300001@news.panix.com>
In article <3481685f.57817817@news.magibox.net>, pschon@baste.magibox.net (Peter J. Schoenster) wrote:
>clay@panix.com (Clay Irving) wrote:
>
>>In <34801903.48387327@news.magibox.net> pschon@baste.magibox.net (Peter J. Schoenster) writes:
>>
>>>Is this resource kit worth buying? I saw it for $112.00 at some
>>>discount computer store online.
>>
>>I think so. :)
>>
>>>Why do they not tell us what is in the book(s)?
>>
>>Did you look at: http://perl.oreilly.com/prk_index.html
>And now O'Reilly is putting out this package and there is no website
>at all! This is only what I would call glib statements on there
>website.
what - did CPAN disappear?
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 30 Nov 1997 12:38:19 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Resource Kit Anomaly
Message-Id: <m3k9dqw210.fsf@windlord.Stanford.EDU>
Peter J Schoenster <pschon@baste.magibox.net> writes:
> I will try not to be rude. You just say what is said at the O'Reilly
> site. What modules? Just a bunch of good modules?? Sure.
My understanding is that they just grabbed most of CPAN. A pretty
thorough search of it, too, given that they included my (with help from
Zenin) Term::ANSIColor module among other things.
Shame I didn't get PGP::Sign out in time to make it.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 30 Nov 1997 19:25:25 GMT
From: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: size of a DB
Message-Id: <65sej5$qti$1@due.unit.no>
Hi
I have made a DB which consists of a key: <a_number:name> and
a attribute <a_name>. Together each tuple is about 30 byte. 50000
entries of this makes me a DB of 32 740 352 byte, which is way beyond
(30 * 50000) = 1.5 MB. I am using SBM_File (I think (using dbmopen)),
if that has anything to do with it.. The dir-file is small (4K).
Does it have to be this way? Why? It seems to me, like this is very
space inefficient?
Any comments?
Morten Simonsen
------------------------------
Date: Sun, 30 Nov 97 20:27:06 GMT
From: B.Tijhuis@inter.nl.net (Bert Tijhuis)
Subject: Telnet 3270
Message-Id: <65sgqs$n3$2@news.NL.net>
Does anyone has some experience with Telnet to a IBM Mainframe which is
running TCP/IP.
I'want to automate some processes to catch some values from the Mainframe.
Using telnet to another system is not so difficult when it is a UNIX system.
Does anyone have a sample script that communicates with the mainframe.
kind regards, bert Tijhuis
------------------------------
Date: 30 Nov 1997 17:08:39 GMT
From: <prog@wallybox.cei.net>
Subject: Trying to parse referer_log???
Message-Id: <65s6in$mcu@news.cei.net>
Hello,
I'm trying to parse the /var/log/httpd/referer_log file, but I'm not sure
I know what I'm doing. :-) So far I've been able to get the information
that I want, but I do have one error, and a couple of questions.
First the error....for some reason, every once in awhile I get simply a
"->" printed on a line. No host, etc. I'm sure it's b/c my code stinks,
but I'm very new to perl (currently 5.003).
As for my other questions, is there anyway to strip out all the "blanks"
from the end of a line. The host names that I'm pulling out obviously
vary in length, so formatting isn't very pretty. Anyhow, here's the code
that I've written this far followed by a small chunk of my referer_log
file.
Thanks for any assistance!
Best Regards,
Tim
Code Begins:
#!/usr/bin/perl
# Set configuration parameters
$file = "/var/log/httpd/referer_log";
# First open my database. Complain if unable.
open(STUFF, "$file") || die "Can't open $file: $!\n";
# Now process each line
while (<STUFF>) {
# Split the record into its fields.
# from=host, filler='->', $file=what they are looking at
($from, $filler1, $file) = split(' ', $_);
if (/wallybox.cei.net/) { # I don't care to know my site
} # probably ugly, but I don't know another way....
else { # we've gotten past wallybox, no show the others.
# Write a formatted record to STDOUT.
write;
}
}
exit;
###############################################################
# Here is the top of form format, with column headings.
format STDOUT_TOP =
Sites that have referred people to http://wallybox.cei.net
==========================================================
.
# Here is the format
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$from, $file
.
Chunk of referer_log file:
news://sun001/pycola.880733894.26567@liw.clinet.fi -> /dipc
news://sun001/pycola.880733894.26567@liw.clinet.fi -> /dipc/index.html
http://wallybox.cei.net/dipc/ -> /dipc/dipc.html
http://www.xnet.com/~blatura/linapp6.html#text -> /dipc
http://www.xnet.com/~blatura/linapp6.html#text -> /dipc/index.html
http://wallybox.cei.net/dipc/ -> /dipc/dipc.html
http://orchid.home.il:8080/index/wallybox.cei.net?mtime -> /dipc
http://www.redhat.com/linux-info/linux-app-list/new_apps.html -> /dipc
http://lhqtest-test.jimpick.com/patch/20-p0809.html -> /dipc
Thanks Again!
------------------------------
Date: Sun, 30 Nov 1997 13:36:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Trying to parse referer_log???
Message-Id: <comdog-ya02408000R3011971336010001@news.panix.com>
In article <65s6in$mcu@news.cei.net>, <prog@wallybox.cei.net> wrote:
>I'm trying to parse the /var/log/httpd/referer_log file, but I'm not sure
>I know what I'm doing. :-) So far I've been able to get the information
>that I want, but I do have one error, and a couple of questions.
>
>First the error....for some reason, every once in awhile I get simply a
>"->" printed on a line. No host, etc. I'm sure it's b/c my code stinks,
>but I'm very new to perl (currently 5.003).
> ($from, $filler1, $file) = split(' ', $_);
from that method of parsing the input, i would guess that one some
of your input lines the $from is missing (i.e. no referer):
-> /foo/bar.html
so the bits get put into the wrong scalars.
since you know the bits that separate the referer and the target,
you can split on that:
($from, $file) = split /\s+->\s+/;
> # Here is the format
>format STDOUT =
>@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>$from, $file
since you actually do very little formatting, you might want to simply
use
print "$from\n$file\n";
or however you would like it printed.
good luck :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
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 1392
**************************************