[7577] in Perl-Users-Digest
Perl-Users Digest, Issue: 1203 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 21 02:07:19 1997
Date: Mon, 20 Oct 97 23:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 20 Oct 1997 Volume: 8 Number: 1203
Today's topics:
Re: @ + @ = % but how? (Martien Verbruggen)
@hash{@array} [was: Re: @ + @ = % but how?] <mgregory@asc.sps.mot.com>
Re: @hash{@array} [was: Re: @ + @ = % but how?] (Martien Verbruggen)
Re: @hash{@array} [was: Re: @ + @ = % but how?] (Daniel S. Lewart)
Re: ARGV question <kermit@ticnet.com>
Re: ARGV question <smantri@osf1.gmu.edu>
Re: Calling an executable file from within Perl <ase@seanet.com>
Re: Cancelled posts in comp.lang.perl.misc (Danny Aldham)
excel-files with perl? ender@mythen.ch
Re: fill out web form ? (Martien Verbruggen)
Find and kill process id on Win 95 <milamber@wavefront.com>
Re: Help in CGI- HTML form interface (Faust Gertz)
Re: HELP! perl and windows! (Faust Gertz)
Re: Most efficient way to parse large text files <wtansill@erols.com>
non-greedy regexps <ashraf@apollo3.com>
Re: non-greedy regexps (Iain Chalmers)
Re: Perl Bug Report <mgregory@asc.sps.mot.com>
Perl interface to Sun NIS+? (Tim Villa)
perl on vax <wuulong@alumni.nctu.edu.tw>
Re: wwwboard.pl & cookies ender@mythen.ch
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Oct 1997 02:49:40 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: @ + @ = % but how?
Message-Id: <62h584$mjf$2@comdyn.comdyn.com.au>
In article <344a7ba5.0@ispc-news.cableinet.net>,
"Richard Butcher" <mailus@web-uk.com> writes:
> I guess combining two arrays of equal length into one hash
> is such a frequently used routine that I have missed it somewhere
> in the first few pages of the book.
>
> So how do I do this?
#!/usr/local/bin/perl5 -w
use strict;
my @keys = qw( a b c d e f g h );
my @vals = qw( 1 2 3 4 5 6 7 8 );
my %hash;
@hash{@keys} = @vals;
foreach (keys %hash)
{
print "$_ $hash{$_}\n";
}
---
a 1
b 2
c 3
d 4
e 5
f 6
g 7
h 8
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In the fight between you and the world,
Commercial Dynamics Pty. Ltd. | back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: 20 Oct 1997 16:57:42 -0700
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: @hash{@array} [was: Re: @ + @ = % but how?]
Message-Id: <r8u3ec6l8p.fsf_-_@asc.sps.mot.com>
Can someone explain what this construct is doing:
@hash{@array} = @array2;
I don't mean "It's making keys of %hash from @array with values from @array2".
I know that: I just saw it doing that in an example post.
What I would like to know is syntactically what is is doing? Since
when can you use @foo to have an effect on %foo? Where is this
documented?
Thanks,
Martin.
------------------------------
Date: 21 Oct 1997 05:36:41 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: @hash{@array} [was: Re: @ + @ = % but how?]
Message-Id: <62hf19$nd9$1@comdyn.comdyn.com.au>
In article <r8u3ec6l8p.fsf_-_@asc.sps.mot.com>,
Martin Gregory <mgregory@asc.sps.mot.com> writes:
>
> Can someone explain what this construct is doing:
>
> @hash{@array} = @array2;
>
> I don't mean "It's making keys of %hash from @array with values from @array2".
>
> I know that: I just saw it doing that in an example post.
>
> What I would like to know is syntactically what is is doing? Since
> when can you use @foo to have an effect on %foo? Where is this
> documented?
from perldata.pod:
but entire arrays or array slices are denoted by '@', which
works much like the word "these" or "those":
@days # ($days[0], $days[1],... $days[n])
@days[3,4,5] # same as @days[3..5]
@days{'a','c'} # same as ($days{'a'},$days{'c'})
It's the last one you want. It means that the expression:
@a{'a','b'} = (1, 2);
evaluates to:
($a{'a'}, $a{'b'}) = (1, 2);
which of course is equivalent to:
$a{'a'} = 1;
$a{'b'} = 2;
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: 21 Oct 1997 03:33:55 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: Re: @hash{@array} [was: Re: @ + @ = % but how?]
Message-Id: <62h7r3$c0p$1@vixen.cso.uiuc.edu>
Martin Gregory <mgregory@asc.sps.mot.com> writes:
> Can someone explain what this construct is doing:
> @hash{@array} = @array2;
@hash{@array} is a hash slice which expands to a list (thus the @ prefix):
($hash{$array[0]}, $hash{$array[1]}, ...)
@array2 expands to:
($array2[0], $array2[1], ...)
Thus, the assignment is shorthand for a list assignment:
($hash{$array[0]}, $hash{$array[1]}, ...) = ($array2[0], $array2[1], ...);
Perl rules!
> Where is this documented?
Camel II, p. 37, and perldata(1).
Incapable to pronouncing "hash slice" correctly,
Daniel Lewart
d-lewart@uiuc.edu
------------------------------
Date: Fri, 17 Oct 1997 13:56:18 -0500
From: Kermit Tensmeyer <kermit@ticnet.com>
Subject: Re: ARGV question
Message-Id: <3447B4D2.8DFD1632@ticnet.com>
Alan wrote:
>
> Folks,
>
> I'm attempting to read some command line args into a program I'm
> writing. Now, it's my understanding that what will follow should work,
> given a command line that looks like:
> someprogram filename1 filename2 filename3.
>
> So, if I do:
>
> $count = 1;
> $len = @ARGV;
> until ($count == $len) {
> open (IN, $ARGV[$count]);
> #do some operations here
> close (IN);
> $count++;
> }
while (<>) {
#do some operations here
$count++;
}
for explanation of how these short cuts work
see page 103 of camel book.
yep, and you can pass in a whole 'passel of filenames
on the command line.
oh.. in unix Argv[0] is the Program Name, but not in Perl
it is the first parameter. '$0' is the script name.
and $1 is the first match pattern .....
-------
Kermit Tensmeyer (E & T - Networking)
Kermit@ticnet.com Dallas
------------------------------
Date: Mon, 20 Oct 1997 22:31:24 -0400
From: shiva mantri <smantri@osf1.gmu.edu>
To: Kermit Tensmeyer <kermit@ticnet.com>
Subject: Re: ARGV question
Message-Id: <Pine.OSF.3.95q.971020222757.16058A-100000@osf1.gmu.edu>
@ARGV has arguments given after the command at the command line
filex argv0 argv1 ...
so count should start from 0 and not 1
so $ARGV will start from 0 not 1 unless u change system variable for start
of the array to be 1 not 0..... ( i dont remember that system variable)
shiva..
On Fri, 17 Oct 1997, Kermit Tensmeyer wrote:
> Alan wrote:
> >
> > Folks,
> >
> > I'm attempting to read some command line args into a program I'm
> > writing. Now, it's my understanding that what will follow should work,
> > given a command line that looks like:
> > someprogram filename1 filename2 filename3.
> >
> > So, if I do:
> >
> > $count = 1;
> > $len = @ARGV;
> > until ($count == $len) {
> > open (IN, $ARGV[$count]);
> > #do some operations here
> > close (IN);
> > $count++;
> > }
>
> while (<>) {
> #do some operations here
> $count++;
> }
>
> for explanation of how these short cuts work
> see page 103 of camel book.
>
> yep, and you can pass in a whole 'passel of filenames
> on the command line.
>
> oh.. in unix Argv[0] is the Program Name, but not in Perl
> it is the first parameter. '$0' is the script name.
> and $1 is the first match pattern .....
>
>
>
>
> -------
> Kermit Tensmeyer (E & T - Networking)
> Kermit@ticnet.com Dallas
>
>
>
Shiva Mantri
---
7032738119,7039938736
------------------------------
Date: Mon, 20 Oct 1997 18:14:56 -0700
From: "Allen Evenson" <ase@seanet.com>
Subject: Re: Calling an executable file from within Perl
Message-Id: <62gvlj$a9n@q.seanet.com>
You need the system() command. See: perlfunc documentation or FAQ =
that
should have came with your distrubution.
Luck,
Jeff Girard wrote in article =
<01bcddb1$f9479860$78da1b8a@girardj.army.mil>...
>Im using Perl ver 5 on an NT 4.0 platform. I need to call and execute =
an
>executable from within perl. The file will execute but will not return =
a
>value to perl. =20
>
>Example:
>
>I want to call a freeware executable called zip from within perl.
>
>Command line syntax:
>
>zip target source1 source2 source3
>
>Can anybody help me with the syntax to make this call from within Perl?
>
>Jeff
------------------------------
Date: 20 Oct 1997 21:52:35 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: Cancelled posts in comp.lang.perl.misc
Message-Id: <62hcej$1hg$1@lennon.postino.com>
Martien Verbruggen (mgjv@comdyn.com.au) wrote:
: rgm@eyrie.org is the post-submission gateway for a moderated newsgroup
: (rec.games.mecha). it seems that some people got a bit upset with the
: moderation of this group, which is why they're cancelling posts all
: over usenet at the moment, forging the email address.
It looks like they have moved on to posting the cancels from a
different server. Attached is the header from the most recent
cancels. If anyone is reading this, what is happening to
track down the dirtbag?
>From news.postino.com!noc.van.hookup.net!hookup!solaris.cc.vt.edu!newsrelay.netins.net!uunet!in5.uu.net!dimensional.com!chippy.visi.com!news-out.visi.com!newsfeed.direct.ca!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody Mon Oct 20 21:39:18 1997
Control: cancel <3447B4D2.8DFD1632@ticnet.com>
Newsgroups: comp.lang.perl.misc
Path: news.postino.com!noc.van.hookup.net!hookup!solaris.cc.vt.edu!newsrelay.netins.net!uunet!in5.uu.net!dimensional.com!chippy.visi.com!news-out.visi.com!newsfeed.direct.ca!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <3447B4D2.8DFD1632@ticnet.com>
Approved: godmom@pagesz.net
Message-ID: <cancel.3447B4D2.8DFD1632@ticnet.com>
X-No-Archive: Yes
Sender: Kermit Tensmeyer <kermit@ticnet.com>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 02:28:16 GMT
Lines: 2
Xref: lennon.postino.com control:13428
This article cancelled within Tin.
--
Danny Aldham SCO Ace , MCSE , JAPH , DAD
I wak'd, she fled, and day brought back my night. jm
------------------------------
Date: Tue, 21 Oct 1997 05:47:04 GMT
From: ender@mythen.ch
Subject: excel-files with perl?
Message-Id: <344c4145.745842@news.unisource.ch>
Hi All
I wrote a small CGI script which creates a HTML table from an SQL
database. Now I would like also create a excel file "on the fly".
Does anyone know how to create excel file with perl?
Thanks.
Josi
------------------------------
Date: 21 Oct 1997 02:45:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: fill out web form ?
Message-Id: <62h4vg$mjf$1@comdyn.comdyn.com.au>
In article <62eiho$ea9$1@netnews.upenn.edu>,
steven@ccat.sas.upenn.edu (steven) writes:
> i would like to write a routine that goes to specific web page and
> fills out a web form. do you how i could do this? if the "method" of
> that form is "post" (i.e., it includes all the information submitted
> in the URL of the web it returns), then this is fairly trivial to
> do, you can include the information in the the URL you open. but the
> problem is that most of the pages i want to do this for use
> method=get (i.e., the pages they return have just standard
> whatever.cgi or whatever.pl filenames, not whatever.cgi?name=steven
> like the post method does). do you know how i could do this, or
> somewhere to point me to? i looked in the perl faq, but i couldn't
> find anything of this sort. thanks.
1) You seem to be a bit confused about GET and POST methods. It's the
other way around.
2) download the LWP modules from CPAN (http://www.perl.com/CPAN/)
3) install LWP, read the documentation, and use one of the examples.
Remember, you're looking for the POST method, not GET.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: 21 Oct 1997 05:01:24 GMT
From: "milamber" <milamber@wavefront.com>
Subject: Find and kill process id on Win 95
Message-Id: <01bcdddf$e7d9fe00$8df449cc@milamber>
I need to query the pid of a program and shut it down in Windows 95. I
know how to do it in NT, but not 95, and I would rather not write a C
routine calling an API.
If anyone has written a routine to do it, however (cool) I would love to
see it.
Thanks,
milamber@wavefront.com
------------------------------
Date: Tue, 21 Oct 1997 01:20:27 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Help in CGI- HTML form interface
Message-Id: <344e0063.19504142@news.wwa.com>
On Tue, 21 Oct 1997 09:35:41 +1000, Maya
<cc91ms@students.ballarat.edu.au> wrote:
> I am doing a project, in that I have got to interface the perl-cgi
> script with the HTML form to display the details on the web browser.
[snip]
> I have done the form, and will be able to write the perl script but
> need help in the interface. I will be thankful to anyone who can
> help me.
As you are not asking a perl question, but a Common Gateway Interface
question, this should be asked in comp.infosystems.www.authoring.cgi.
I also imagine you should look at both Lincoln Stien's CGI.pm
(http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html) and
Nick Kew's CGI FAQ (see below).
:0.3 Where to get this document
:
:The homes of this document on the Web are now
:* the WebThing Virtual Office, at http://www.webthing.com/
: URL http://www.webthing.com/tutorials/cgifaq.html
:* the Web Design Group, at http://www.htmlhelp.com/
: URL http://www.htmlhelp.com/faq/cgifaq.html
:
:NOTE - If you want to mirror the FAQ on your WWW site on a
:publicly-visible server, please make sure you keep it up-to-date.
:
:Other known sources are:
:
:(1) USENET: posted to newsgroups (TEXT)
: news:comp.infosystems.www.authoring.cgi
: news:comp.answers
: news:news.answers
:
:(2) RTFM and mirror sites (TEXT)
: ftp://rtfm.mit.edu/pub/usenet/news.answers/www/cgi-faq
:
:(3) RTFM WWW mirror sites, including (Partial HTML)
: Europe - http://www.cs.ruu.nl/cgi-bin/faqwais
: America - http://www.cis.ohio-state.edu/hypertext/faq/usenet/
:
:(4) By EMAIL from my autoresponder (HTML or TEXT)
: Send blank email to
: mailto:nick+cgi_text@webthing.com
: or
: mailto:nick+cgi_html@webthing.com
: (depending on which version you want)
:**** NOTE CHANGE FROM PREVIOUS AUTORESPONDER SETUP! ****
:
:(5) By EMAIL from the FAQserver at RTFM (TEXT)
: Send email to mailto:mail-server@rtfm.mit.edu with
: send usenet/news.answers/www/cgi-faq
: in the body of your message
HTH
Faust Gertz
Philosopher at Large
------------------------------
Date: Tue, 21 Oct 1997 01:05:24 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: HELP! perl and windows!
Message-Id: <344cfa17.17891653@news.wwa.com>
On Tue, 21 Oct 1997 01:47:41 +0100, "A.K" <nihonjin@cyberdude.com>
wrote:
>i'm new atthis tuff and I got perl5.004 but I don't know how to install
>it under windows NT4.0 or windows95 there's no reference for this in the
>book I bought (learning perl)
On page xx, under the section entitled 'Frequently Asked Questions',
which is under the section entitled 'Additional Resources', there are
pointers to the information you request. If you truly have the 5.004
release, then the FAQ is included with the standard distribution's
documentation. If you have a pre-5.004 release, then, as documented
in _Learning Perl_ you will have to look for the FAQ either in
comp.lang.perl.announce or on the Web at http://language.perl.com/faq/
Just as an aside, if you are working in a Win32 environment, why
didn't you buy _Learning Perl on Win32 Systems_ instead of just plan
old _Learning Perl_? According to the O'Reilly site:
:In this carefully paced course, leading Perl trainers and a Windows NT practitioner teach you to program in the language that
:promises to emerge as the scripting language of choice on NT. Based on the "llama" book, this book features tips for PC users and
:new, NT-specific examples, along with a foreword by Larry Wall, the creator of Perl, and Dick Hardt, the creator of Perl for
:Win32.
Sounds like a good book to me. Anyway, back to the task at hand. If
you look at the FAQ, you will find the following section.
:What machines support Perl? Where do I get it?
:
:The standard release of Perl (the one maintained by the perl development team) is distributed only in source code form. You can
:find this at http://www.perl.com/CPAN/src/latest.tar.gz, which is a gzipped archive in POSIX tar format. This source builds with
:no porting whatsoever on most Unix systems (Perl's native environment), as well as Plan 9, VMS, QNX, OS/2, and the Amiga.
:
:Although it's rumored that the (imminent) 5.004 release may build on Windows NT, this is yet to be proven. Binary distributions for
:32-bit Microsoft systems and for Apple systems can be found http://www.perl.com/CPAN/ports/ directory. Because these are not
:part of the standard distribution, they may and in fact do differ from the base Perl port in a variety of ways. You'll have to check
:their respective release notes to see just what the differences are. These differences can be either positive (e.g. extensions for the
:features of the particular platform that are not supported in the source release of perl) or negative (e.g. might be based upon a less
:current source release of perl).
:
:A useful FAQ for Win32 Perl users is http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html
When you look at the useful FAQ for Win32 Perl users, you will find a
section entitled '1. Availability and Installation'. In this section,
you will find the following information.
:1.5. How do I unzip the Perl for Win32 package?
:
:Because the Perl for Win32 package contains long file names (LFNs), normal zip file handlers like PKZip will not open them
:correctly. [Does the newest version of PKZip handle LFNs correctly? -ESP] You need to get a zip file opener that can work with
:LFNs, such as:
:
: WinZip, a shareware GUI unzipper, available at http://www.winzip.com/
: Info-Zip Unzip, a command-line free unzipper, available at ftp://ftp.uu.net/pub/archiving/zip/WIN32/
:
:To extract the archive, make a new directory on your hard drive that will become your new perl directory ("C:\Program
:Files\perl5" and "C:\perl5" are good candidates). Extract the archive to that directory, making sure that directory names are
:expanded from the archive (this is crucial!). See the documentation for your unzipper for details.
:
:1.6. How do I build Perl for Win32 from the source code package?
:
:The source code package includes make files for Visual C++ versions 2.x and 4.x. The following instructions are for Visual C++
:4.x. [Does anyone have instructions for VC++ 2.x? How about other Win32 C++ compilers? -ESP]
:
:The source distribution only includes Intel targets. If you're building for another platform, like DEC Alpha, you may have to fiddle
:with the build settings to get them to work. [Anyone done this? -ESP]
:
:First, make sure you unzipped the archive correctly into the destination directory. Then, open the perl100.mdp project file in the
:dll-src subdirectory of your perl directory with Microsoft Developers Studio.
:
:Build the "perl100 - Win32 Perl Intel DLL Release" target (Go have some lunch -- this will take a while). You'll end up with a
:perl100.dll file in your ntt subdirectory of your perl directory.
:
:Now, open the perl.mdp project file in the exe-src subdirectory of your perl directory. Build the "perl - Win32 Perl Intel Release"
:target. You also have to build the "perl - Win32 PerlGlob Intel Release" target. These will produce perl.exe and perlglob.exe,
:respectively, in your ntt directory.
:
:Optionally, you can build the extension files that come with the source distribution. These include:
:
: Fcntl: Fcntl.mak in the dll-src\Ext\Fcntl directory. See question 9.15.
: SDBM_File: sdbm_file.mdp in the dll-src\Ext\SDBM_File directory.
: Win32 extensions: Win32.mdp in the dll-src\Ext\Win32 directory. Consider doing a batch build of these, to save yourself
: some headaches.
: Win32::NetResource: NetResource.mak in the dll-src\Ext\Win32\NetResource\ directory. For some reason, this one isn't
: included with all the other Win32 modules. See also question 9.16.
:
:Note that the extensions look for perl100.lib in the dll-src\Release directory, which by default doesn't exist. You can either create
:the directory and copy the lib file there, or go through the build settings for the extensions and set them to point to the proper
:directory, dll-src\LibRel.
:
:Building the extensions will put the extension binaries (.pll files) in the proper place in the Lib subdirectory.
:
:1.7. OK, I've got it downloaded, unzipped, and optionally built. Now what?
:
:The last step is running install.bat, a perl program masquerading as a batch file found in your perl directory. Running install.bat will
:register the perl program and PerlIS with your system, as well as copy the binary files from the ntt subdirectory to the bin
:subdirectory.
:
:If you installed in a directory with long file names (like "C:\Program Files\perl5"), you may want to change directory to the DOS
:version of your directory (like "cd C:\PROGRA~1\perl5") before running install.bat. This ensures that you get only readable paths
:in your registry, and could avoid some annoying errors.
:
:1.8. What does installing do to my registry?
:
:Installing Perl for Win32 adds the following keys to your registry, if they don't already exist:
:
: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Resource Kit\PERL5: main registry key
: BIN: path to the perl binaries
: PRIVLIB: path to the library files
: HTML-DOCS: path to the HTML documentation
:
:The BIN and PRIVLIB values are probably used in the perl interpreter to find files for loading. The purpose of the HTML-DOCS
:value is unclear.
:
:Installing also adds your perl binary path to the PATH variable for your system, as well as "." (current directory), for historical
:reasons.
:
:Also, if you have Microsoft Internet Information Server (IIS) installed, install.bat will associate an extension of your choosing (.pl is
:the default) with PerlIS in the IIS script mapping registry key,
:HKEY_LOCAL_MACHINE\System\Services\W3SVC\Parameters\Script Map. See IIS documentation for more info on the
:script map.
Any more questions?
Faust Gertz
Philosopher at Large
------------------------------
Date: Mon, 20 Oct 1997 22:40:12 -0400
From: "William B. Tansill, III" <wtansill@erols.com>
To: Thomas Munn <munn@bigfoot.com>
Subject: Re: Most efficient way to parse large text files
Message-Id: <344C160C.79CC@erols.com>
Thomas Munn wrote:
>
> Here is the code for the previous post:
>
> So Far, it is just supposed to turn this line:
> Thu Oct 16 00:00:15 EDT 1997
> and turn it into 10/16/97 (which it does)
>
> Finally, The second part (so far) takes this line
> Bytes Sent: 107968967 bytes
> and assigns the # to BytesSent.
>
> I ran it on the HUGE textfile (300+K) and the intrepreter kept cycling:
>
> Use of uninitialized value at monthchanger.pl line 28, <> chunk 5.
> Use of uninitialized value at monthchanger.pl line 31, <> chunk 5.
> Use of uninitialized value at monthchanger.pl line 34, <> chunk 5.
> Use of uninitialized value at monthchanger.pl line 38, <> chunk 5.
> Use of uninitialized value at monthchanger.pl line 42, <> chunk 5.
> Use of uninitialized value at monthchanger.pl line 45, <> chunk 5.
> Use of uninitialized value at monthchanger.pl line 48, <> chunk 5.
> Use of uninitialized value at monthchanger.pl line 51, <> chunk 5.
> Use of uninitialized value at monthchanger.pl line 51, <> chunk 5.
>
> Code Follows:
>
> #!/usr/bin/perl -w
> while (<>) {
> if (/Mon|Tue|Wed|Thu|Fri|Sat|Sun|/) {
> @fields = split(/ /,$_);
> $DayOfMonth=$fields[2];
> $Year= $fields[5];
> $Year =~ s/19//;
> if ($fields[1] eq "Oct") {
> $Month=10;
> }
>
> if ($fields[1] eq "Nov") {
> $Month=11;
> }
>
> if ($fields[1] eq "Dec") {
> $Month=12;
> }
>
> if ($fields[1] eq "Jan") {
> $Month=1;
> }
>
> if ($fields[1] eq "Feb") {
> $Month=2;
> }
>
> if ($fields[1] eq "Mar") {
> $Month=3;
> }
> if ($fields[1] eq "Apr") {
> $Month=4;
> }
> if ($fields[1] eq "May") {
> $Month=5;
> }
>
> if ($fields[1] eq "Jun") {
> $Month=6;
> }
>
> if ($fields[1] eq "Jul") {
> $Month=7;
> }
> if ($fields[1] eq "Aug") {
> $Month=8;
> }
> if ($fields[1] eq "Sep") {
> $Month=9;
> }
> $OutPutDate=$Month . "/" . $DayOfMonth . "/" . $Year;
> print $OutPutDate;
> }
> if ("Bytes Sent") {
> $_ =~ s/\s{2,}//;
> #print $_;
> @fields = split(/ /,$_);
> $BytesSent = $fields[2];
> print $BytesSent
> }
> }
Yowza! Using a hash to associate month names with numbers would shorten
the code considerably, but that's already been pointed out in a previous
response, as has the year 2000 problem. As far as pulling the number of
bytes, this works:
my $ByteSent = 0;
$_ = "Bytes Sent: 107968967 bytes";
if (/Bytes Sent: \b(\d+)\b/) {
$BytesSent += $1;
print "$BytesSent\n";
}
The \b notation forces the match to begin and end on word boundaries.
The (\d+) sucks up all digits and backreferences tehm for later use.
The $1 is the remembered backref.
--
How do I set my laser printer to "stun"?
------------------------------
Date: 20 Oct 1997 21:29:45 -0700
From: Ashraf Ahmed <ashraf@apollo3.com>
Subject: non-greedy regexps
Message-Id: <cg9pvoz4u2u.fsf@apollo3.i-did-not-set--mail-host-address--so-shoot-me>
A perl regexp question ...
Let's say I have a string like this,
"meeabmooabmuuabheheabyum"
-- -- -- --
and let's say that I want to find the (first) *shortest* sub-string
which starts with "ab" and ends with "ab". In this case, the returned
string should be
"abmooab"
I can't use /ab.*ab/, since that will match
"abmooabmuuabheheab"
I tried to think about a solution using negated character classes, but
couldn't. Basically, is there any way to do something like this
/ab-*ab/
where the "-" would somehow represent non-occurences of the sub-string
"ab".
The FAQ suggests using the perl5 non-greedy constructs, but I seem to
remember reading somewhere that one should be careful when using
these. What should I be careful about when using the non-greedy
constructs? And is there some solution that works without using the
non-greedy constructs (which would also work in a language that
doesn't support these constructs)?
Thanks,
Ashraf
--
Ashraf Ahmed California Microprocessor Division Advanced Micro Devices
<Std. disclaimers> ashraf@SPAM.YUM.cmdmail.amd.com (remove anti-spam device)
----------------------------------------------------------------------------
PGP fingerprint : 90 C6 04 90 82 57 8D D0 BA 11 AC C0 22 7A D4 83
---------------------------------------------------------------------------
Experience should teach us to be most on our guard to protect liberty when
the Government's purposes are beneficent. The greatest dangers to liberty
lurk in insidious encroachment by men of zeal, well-meaning but without
understanding." - Justice Louis D. Brandeis, Olmstead v. US.
------------------------------
Date: Tue, 21 Oct 1997 14:57:15 +1000
From: bigiain@mightymedia.com.au (Iain Chalmers)
Subject: Re: non-greedy regexps
Message-Id: <bigiain-ya02408000R2110971457150001@news.ozemail.com.au>
In article
<cg9pvoz4u2u.fsf@apollo3.i-did-not-set--mail-host-address--so-shoot-me>
***oh yes you did!!!***
Ashraf Ahmed <ashraf@apollo3.com> wrote:
> A perl regexp question ...
>
>
> Let's say I have a string like this,
>
> "meeabmooabmuuabheheabyum"
> -- -- -- --
>
> and let's say that I want to find the (first) *shortest* sub-string
> which starts with "ab" and ends with "ab". In this case, the returned
> string should be
>
> "abmooab"
>
>
> I can't use /ab.*ab/, since that will match
>
> "abmooabmuuabheheab"
>
> I tried to think about a solution using negated character classes, but
> couldn't. Basically, is there any way to do something like this
>
> /ab-*ab/
>
> where the "-" would somehow represent non-occurences of the sub-string
> "ab".
>
try /ab.*?ab/
this is from the man page...
> By default, a quantified subpattern is "greedy", that is, it will match
> as many times as possible without causing the rest of the pattern not to
> match. The standard quantifiers are all "greedy", in that they match as
> many occurrences as possible (given a particular starting location)
> without causing the pattern to fail. If you want it to match the minimum
> number of times possible, follow the quantifier with a "?" after any of
> them. Note that the meanings don't change, just the "gravity":
>
> *? Match 0 or more times
> +? Match 1 or more times
> ?? Match 0 or 1 time
> {n}? Match exactly n times
> {n,}? Match at least n times
> {n,m}? Match at least n but not more than m times
> The FAQ suggests using the perl5 non-greedy constructs, but I seem to
> remember reading somewhere that one should be careful when using
> these. What should I be careful about when using the non-greedy
> constructs? And is there some solution that works without using the
> non-greedy constructs (which would also work in a language that
> doesn't support these constructs)?
hmmm, don't know...
hope this helps anyway???
cheers
iain
Iain Chalmers
bigiain@mightymedia.com.au
------------------------------
Date: 20 Oct 1997 17:22:11 -0700
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: Perl Bug Report
Message-Id: <r8sotw6k3w.fsf@asc.sps.mot.com>
Gary Howland <ghowland@hotlava.com> writes:
> Here's a bug in Perl. Quite a nasty one too, since it changes values
> for subsequent calls of a function:
>
> use strict;
>
> sub f
> {
> my $x = shift;
> my $y = shift;
> my $z = $y->{'1'} if defined $y;
> $z = $x unless defined $z;
>
> print "$x, $z\n";
> }
>
> f("a");
> f("b");
>
> I would expect the output:
>
> a, a
> b, b
>
> but instead I get:
>
> a, a
> b, a
>
This is nasty, isn't it! Have you noticed that the code below does
what you want anyhow(!!)....
(although I wonder whether some hash springs into existence when
$y->{'1'} is evaluated?)
use strict;
sub f
{
my $x = shift;
my $y = shift;
my $z = $y->{'1'};
$z = $x unless defined $z;
print "$x, $z\n";
}
f("a");
f("b");
~/bin/foo.pl
a, a
b, b
... so it's the interaction between 'if defined $y' and 'my' in one
statement that appears to be causing the bug!!
Martin.
------------------------------
Date: Tue, 21 Oct 1997 01:09:48 GMT
From: tim.villa@uwa.edu.au (Tim Villa)
Subject: Perl interface to Sun NIS+?
Message-Id: <62gvd4$pud$1@enyo.uwa.edu.au>
Hi all,
Not sure if such a beast exists but are there any Perl libraries around for
accessing Solaris NIS+ tables without having to use system() or ``? I'm
trying to speed up some routines that talk to the NIS+ a lot.
Thanks
Tim
--
Tim Villa Faculties of Economics & Commerce, Education and Law
Network/Systems Officer The University of Western Australia
Phone: +61-08-9380-1796 Fax: +61-08-9380-1068
<mailto:tim.villa@uwa.edu.au> <http://buck.ecel.uwa.edu.au/>
------------------------------
Date: Tue, 21 Oct 1997 12:28:27 +0800
From: Wuulong Sheu <wuulong@alumni.nctu.edu.tw>
Subject: perl on vax
Message-Id: <344C2F6B.920CC1FA@alumni.nctu.edu.tw>
can I use perl on vax?
--
"z"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"{
"x 3\*Z@s Email:wuulong@alumni.nctu.edu.tw "x
"|"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"w"}
------------------------------
Date: Tue, 21 Oct 1997 05:47:16 GMT
From: ender@mythen.ch
Subject: Re: wwwboard.pl & cookies
Message-Id: <344c4149.750079@news.unisource.ch>
On Sun, 19 Oct 1997 17:29:23 +0200, Mark Kronsbein
<MKronsbein@pop-stuttgart.net> wrote:
>I've a prob: i use the wwwboard and all works fine. now i want to use
>the cookie option and it doesnt work! i have the cookie.lib but i dont
>know how to configure it!
I'm using wwwboard on a NT with Netscape Server.I'm not sure, but I
remember there was a problem with the path to cookie.lib. Be sure that
you set the complete path to cookie.lib in wwwboard.pl.
cu, Josi
------------------------------
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 1203
**************************************