[7638] in Perl-Users-Digest
Perl-Users Digest, Issue: 1264 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 3 08:24:09 1997
Date: Mon, 3 Nov 97 05:00:44 -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 Mon, 3 Nov 1997 Volume: 8 Number: 1264
Today's topics:
Re: again -- multi-line minimal match text replacement <ajohnson@gpu.srv.ualberta.ca>
Re: call for bids--perl mSQL CGI programming (Danny Aldham)
Re: counting lines in a file?? <jgostin@shell2.ba.best.com>
Fun with pipes <amias@mindless.com>
Re: Fun with pipes (brian d foy)
Grabbing Pixels <ryanr@poolpros.com>
Re: Help want to create a Perl script executable for Wi <cornelio@home.com>
Re: Inserting characters into a string. (Tad McClellan)
Re: Inserting characters into a string. (brian d foy)
newbie question - auto rotating of pages on fixed dates <davidb@os.gulf.or.jp>
Re: newbie question - auto rotating of pages on fixed d (brian d foy)
Re: Newbie: CGI incantations for Mac (Chris Nandor)
Re: perl and gifs or ftp <root@u-topia.com>
Re: Perl for OS/2 (Dan B.)
Re: persistence problems using DB_File and MLDBM (Paul Marquess)
Problems with strings <jesmond@keyworld.net>
Re: Problems with strings (Tad McClellan)
Re: QUESTION: Perl, Selena Sol's db_Search, Netware Web <amias@mindless.com>
sockets on win95 <palme@softing.com>
sub-totaling lines in a file?? (Burt Lewis)
Re: sub-totaling lines in a file?? (brian d foy)
Re: sub-totaling lines in a file?? (Tad McClellan)
THE POP module! <gurra@imneverwrong.com>
Re: Warning when starting perl. What is it ? <qdtcall@esb.ericsson.se>
Re: What to do with Bitwise operators? (Dean Inada)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 03 Nov 1997 01:22:09 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: again -- multi-line minimal match text replacement
Message-Id: <345D7BA1.7B505991@gpu.srv.ualberta.ca>
Dave Kaufman wrote:
!
[snip]
! Bill, you're in luck. I just saw this in the camel book, 2nd
! edition, a very good read, BTW. You need to use the new perl5
! don't-be-so-greedy-modifier, which is ? (called a minimal pattern
! match). It says, match this pattern as soon as as you can in as
! few characters, not as thoroughly as you can, like you usually
! do.
!
! s/(STARTSTRING.*ENDSTRING)?/replace string/s;
that's incorrect. By itself the ? just means match zero or
one of the previous item (or 'atom')... to get the minimal
matching aspect you use the ? in conjunction with one of the
quantifiers * or + or {n,m} so you want something more like:
s/STARTSTRING.*?ENDSTRING/replacement/s;
see the perlre manpage for further information.
regards
andrew
------------------------------
Date: 2 Nov 1997 20:07:35 -0800
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: call for bids--perl mSQL CGI programming
Message-Id: <63jim7$f4c$1@lennon.postino.com>
Cliff Landesman (cland@netbox.com) wrote:
: We intend to create a web site, called "ListHelper", which will help
: people interact with email list servers. The most basic feature of
: ListHelper will allow people to subscribe and unsubscribe from lists
: without having to know the syntax appropriate to a particular list
: server.
Please tell me that you will implement some sort of mail back
security, to prevent John Doe from subscribing Jane Doe to every
list server on the planet.
--
Danny Aldham SCO Ace , MCSE , JAPH , DAD
I wak'd, she fled, and day brought back my night. jm
------------------------------
Date: 3 Nov 1997 08:02:05 GMT
From: Jeff Gostin <jgostin@shell2.ba.best.com>
Subject: Re: counting lines in a file??
Message-Id: <63k0dt$dh0$1@nntp1.ba.best.com>
brian d foy <comdog@computerdog.com> wrote:
: is 'case' something new?
Um, I sure hope so. If not, I just made a big fool outta myself. :) Well,
ok... checking "Programming", there's a case-ish structure ("SWITCH"),
p103-105. That's what I was thinking of. *sigh* I've been switch-hitting
between shell scripts and perl lately.
Sorry for the confusion. :(
--Jeff
------------------------------
Date: Mon, 03 Nov 1997 10:25:52 +0000
From: Amias <amias@mindless.com>
Subject: Fun with pipes
Message-Id: <345DA6B0.62D6@mindless.com>
Hello out there ,
I'm having a problem with pipes , In a CGI script i'm trying to get perl
to send information to PGP and then to blat to mail it ( yes i am using
nt) via standard input , PGP and blat will except this as i can do it on
the ecommand line . There seems to be a problem closing pgp after input
. All that happens is the browser waits for information and an NVDM
entry appears in my process table . I'm opening the pipe as follows
open(OUTPUT,"|pgp -feast -z passphrase keyname|blat - -t recipient");
print OUTPUT, "This is the email message";
This is driving me up the wall , can any body point out where i've gone
wrong .
TIA
Toodle-pip
Amias
http://www.homeusers.prestel.co.uk/amias
ICQ 3099152
Anyone spamming me _will_ have problems with their server
------------------------------
Date: Mon, 03 Nov 1997 07:08:11 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Fun with pipes
Message-Id: <comdog-ya02408000R0311970708110001@news.panix.com>
In article <345DA6B0.62D6@mindless.com>, REMOVE THIS <amias@mindless.com> wrote:
>I'm having a problem with pipes , In a CGI script i'm trying to get perl
>to send information to PGP and then to blat to mail it
>open(OUTPUT,"|pgp -feast -z passphrase keyname|blat - -t recipient");
>print OUTPUT, "This is the email message";
one of the classic CGI goofs is to assume that the script knows where
PGP is. i would change that to a full path (or whatever NT does).
you might also look into IPC::Open3 if that works on NT. see some of
my recent posts on PGP for a snippet of Open3 used with PGP.
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: Mon, 03 Nov 1997 01:42:45 -0800
From: Ryan Rose <ryanr@poolpros.com>
Subject: Grabbing Pixels
Message-Id: <345D9C94.CA6ED654@poolpros.com>
I'm looking to open up a graphic file (either jpg, or gif), grab a few
pixels, and determine the average RGB value. Is there anyway to do
something like this?
Ryan
------------------------------
Date: Sun, 02 Nov 1997 23:37:10 -0800
From: Michael Cornelio <cornelio@home.com>
To: Licensed User <hobo@alumni.stanford.org>
Subject: Re: Help want to create a Perl script executable for Win95
Message-Id: <345D7F26.BCC4AB51@home.com>
Try ...
Perl2exe: http://www.demobuilder.com/
Perl: http://www.activeware.com/
Licensed User wrote:
>
> Can anyone help me create a perl script executable for win95... I've seen
> Malcolm Beattie's directory on www.perl.com but I didn't see anything
> regarding a Windows solution.... Is there anyone out there who can help
> me... or direct me to a link that can help me?
>
> thanks
> Stan
--
---------------------------------------------------
Michael Cornelio
cornelio@home.com
------------------------------
Date: Sun, 2 Nov 1997 21:18:47 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Inserting characters into a string.
Message-Id: <nqfj36.2i8.ln@localhost>
Andy Rutledge (andyrut@usa.net) wrote:
: Ok, how would I go about inserting a certain character after every fourth
: letter in a string?
s/(....)/$1X/g;
: **NO E-Mail please! I was overwhelmed by the wonderful e-mail I received
: from my last post! :o)
This one you should have been able to figure out from reading the
perlre and perlop man pages that come with the perl distribution.
Ask questions here if you don't understand the docs.
Please don't ask here without even _trying_ to find the answer yourself first.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 02 Nov 1997 22:51:49 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Inserting characters into a string.
Message-Id: <comdog-ya02408000R0211972251490001@news.panix.com>
In article <andyrut-0211971958570001@lnk1-ppp-24.binary.net>, andyrut@usa.net (Andy Rutledge) wrote:
>Ok, how would I go about inserting a certain character after every fourth
>letter in a string?
>
>Like turning "firefighter" into "fireXfighXter" or something.
#!/usr/bin/perl -w
use strict;
$_ = 'just another new york perl hacker';
my $character = 'X';
s/(.{4})/$1$character/g;
print "$_\n";
__END__
or if you want to have a little more fun
#!/usr/bin/perl -w
use strict;
$_ = 'just another new york perl hacker';
my $character = 'X';
my $length = ( length($_) - (length($_)%4) ) / 4;
foreach my $position ( reverse 1 .. $length )
{
substr($_, $position * 4, 0) = $character;
}
print "$_\n";
__END__
>**NO E-Mail please! I was overwhelmed by the wonderful e-mail I received
>from my last post! :o)
well, that's a first ;)
--
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: Mon, 03 Nov 1997 13:49:15 +0900
From: Dave <davidb@os.gulf.or.jp>
Subject: newbie question - auto rotating of pages on fixed dates
Message-Id: <63jl68$r4s@ns.gulf.or.jp>
Hi,
I'd like to write a scriot which would automatically change pages at
set dates in the future. Baically, I want to pre-write a lot of updates
to my hompage before I go on holiday, and then have a script to rotate
through them on specified dates. Any ideas or example scripts I could
look at would be welcome.
Thanks
Dave
------------------------------
Date: Mon, 03 Nov 1997 00:04:42 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: newbie question - auto rotating of pages on fixed dates
Message-Id: <comdog-ya02408000R0311970004420001@news.panix.com>
In article <63jl68$r4s@ns.gulf.or.jp>, Dave <davidb@os.gulf.or.jp> wrote:
> I'd like to write a scriot which would automatically change pages at
>set dates in the future. Baically, I want to pre-write a lot of updates
>to my hompage before I go on holiday, and then have a script to rotate
>through them on specified dates. Any ideas or example scripts I could
>look at would be welcome.
sounds like a cron job to me - no scripting necessary ;)
--
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: Mon, 03 Nov 1997 06:55:46 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Newbie: CGI incantations for Mac
Message-Id: <pudge-ya02408000R0311970655460001@news.idt.net>
In article <345CF28B.C056F66D@geocities.com>, frogkisser@geocities.com wrote:
# What incantations need to go before the #/whatever/bin/perl line for
# MacPerl CGI scripts? I'm running the freeware server Quid Pro Quo 2.0
# which should support the same cgi stuff as MacHTTP or WebStar. Thanks!
No #! line is even required, depending on your preferences (you can set
preferences to check for the #! line). Most people either use whatever
they use on their Unix boxes (i.e., #!/usr/bin/perl) or just put #!perl.
You should also use -Tw after that, too, if you are using CGIs. NOTE: -T
is not working in MacPerl 5.1.4r4 due to changes in the taint mechanism in
perl5.004, but it should be working again in MacPerl 5.1.5 to some degree.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: 30 Oct 1997 17:49:24 GMT
From: "U-Topia S.r.l." <root@u-topia.com>
Subject: Re: perl and gifs or ftp
Message-Id: <01bce55c$85e8a6e0$0206b8c2@www.u-topia.com>
On Tue, 28 Oct 1997, Andrew Taylor wrote:
> I would like to be able to read in a manipulate a gif file in perl!
> Does anyone know of any perl modules that already allow you to do this?
There's an excellent c library ported to perl.
It's called gd , i used it to create counters on the fly.
You can found it at
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/GD.html
Valerio Verde
------------------------------
Date: Mon, 03 Nov 1997 05:33:57 -0300
From: tvfs@thezone.net (Dan B.)
Subject: Re: Perl for OS/2
Message-Id: <1xYX0M4nBJVX089yn@thezone.net>
In article <63aqt8$gks$2@news00.btx.dtag.de>,
GEBiernat@t-online.de (Gunther E. Biernat) wrote:
>On Wed, 29 Oct 1997 18:28:56, "Billy Boone" <bboone@lexmark.com>
>wrote:
>
>> Where can I find a version of perl for OS/2?
>
>For the source have a look at
>http://www.perl.com/CPAN/src/latest.tar.gz
>
>it should build fine under OS/2. If you need a binary go to
>
>Hobbes
>http://hobbes.nmsu.edu/
The version at hobbes is 5.02b, and no longer being updated by the
guy that compiled it.
Compiled 5.004_+ binaries for OS/2 are available at the CPAN sites.
Try
http://www.perl.com/CPAN-local/ports/os2/ilyaz/
--
Dan B. tvfs@thezone.net
Maintainer, OS/2 Warp on the 'Net.
\ http://www.nfwa.com/os2/
\ The index of OS/2 Internet sites.
------------------------------
Date: 2 Nov 1997 21:54:38 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: persistence problems using DB_File and MLDBM
Message-Id: <63isqu$69b$1@pheidippides.axion.bt.co.uk>
[Posted & Mailed ]
gtuckerkellogg@genetics.com wrote:
: This is a weird situation, but I'm hoping that I've overlooked a simple
: answer.
: I have a bunch of objects stored in a hash tied to a DB_File via
: MLDBM, but they keep getting "lost". By that I mean if I *know*
: the name of the key, I can get the value, but not all the keys
: show in "keys %tiedhash".
: Some simple code below demonstrates the problem. In it, I just copy the
: members of one tied hash to another, and then find that the number of
: keys aren't the same. When run, it produces the following output:
: 140 keys in Project.DB
: 0 keys in New.DB to start
: 140 keys in New.DB when built
: 13 keys in New.DB when reopened
: J00127
: J00128
: J02908
: J05213
: L10347
: L10349
: L13616
: M32313
: M81104
: U37022
: U37028
: U95299
: X68452
: ProbeSet=HASH(0x1400415b8)
: Here's the code:
: #!/usr2/local/bin/perl -w
: use lib qw(/usr2/users/gtk/lib/perl5);
: use strict;
: use Carp;
: use Data::Dumper;
: use DB_File;
: use MLDBM;
: $MLDBM::UseDB = 'DB_File';
: # %STARTLIST contains a bunch of objects that I've
: # placed before. Just open this puppy up.
: my ($startlist,%STARTLIST);
: $startlist = tie (%STARTLIST,'MLDBM',"Project.DB",
: O_RDWR,0664,$DB_HASH) or croak $!;
: print (scalar keys %STARTLIST, " keys in Project.DB\n");
: # Now copy the elements into %NEWLIST, which should be a new
: # file.
: my %NEWLIST;
: my $newlist;
: $newlist = tie (%NEWLIST,'MLDBM',"New.DB",
: O_RDWR | O_CREAT,0664,$DB_HASH) or croak $!;
: print (scalar keys %NEWLIST, " keys in New.DB to start\n"); # This
: should be zero
: my $name;
: foreach $name (sort keys %STARTLIST) {
: $NEWLIST{$name} = $STARTLIST{$name};
: $newlist->sync; # for good measure, apparently makes no difference
: }
: print (scalar keys %NEWLIST, " keys in New.DB when built\n");
: # This should be equal to the number of keys in %STARTLIST;
: undef $newlist;
: untie %NEWLIST;
: undef %NEWLIST;
: my %CHECKLIST; # This will be identical to %NEWLIST, right?
: my $checklist;
: $checklist = tie (%CHECKLIST,'MLDBM',"New.DB",
: O_RDWR,0664,$DB_HASH) or croak $!;
: print (scalar keys %CHECKLIST, " keys in New.DB when reopened\n");
: print join("\n",sort keys %CHECKLIST), "\n";
: if (defined $CHECKLIST{'U49844'}) { print $CHECKLIST{'U49844'}, "\n"; }
: # Huh? Why should this be defined if it isn't found in
: # keys(%CHECKLIST)?
This sounds like a known problem with the version of Berkeley DB you
are using. I would guess it is 1.85.
If you upgrade to 1.86 the problem should go away.
Paul
ps 1.86 is available on the Berkeley DB home page www.sleepycat.com
------------------------------
Date: Mon, 3 Nov 1997 12:06:57 +0100
From: "Jesmond Navarro" <jesmond@keyworld.net>
Subject: Problems with strings
Message-Id: <63karo$7ne@news.keyworld.net>
Hi everyone,
I am a beginner to Perl. I am trying to parse my password file according
to an expiry date. My problem is that when I enter a year like for example
1997, it works. But when I enter Dec, it ignores it. (The full string is Dec
05 1997). Here is my code:
#! /usr/bin/perl
die 'Usage: active_users.pl <password file> '
if $#ARGV < 0;
$pwfile = '';
$infile = '';
%sup = ();
$acl_valid = 0; # is acl valid in gid field?
$pwfile = shift(@ARGV);
while ($#ARGV >= 0) {
local($arg) = shift(@ARGV);
next if ($arg eq '-i');
$infile = $arg;
}
open(PASSWD, $pwfile) || die "Can't read $pwfile -- $!";
while(<PASSWD>) {
chop;
next if ($_ eq '');
local($user, $pass, $uid, $gid, $gcos, $home, $exp) = split(/:/);
$users{$user} = 2;
$year = substr($exp, 7, 4);
$month = substr($exp, 0, 3);
if ($month == Dec || $year == 1997) {
print "$user\@company.com|";
print "$gcos";
print "\n";
}
}
close(PASSWD);
exit 0
Can please someone help me. If so, please reply me at my own email address
(jesmond@keyworld.net)
Thanks
------------------------------
Date: Mon, 3 Nov 1997 06:44:30 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Problems with strings
Message-Id: <evgk36.di1.ln@localhost>
Jesmond Navarro (jesmond@keyworld.net) wrote:
: Hi everyone,
: I am a beginner to Perl. I am trying to parse my password file according
: to an expiry date. My problem is that when I enter a year like for example
: 1997, it works. But when I enter Dec, it ignores it. (The full string is Dec
: 05 1997). Here is my code:
: #! /usr/bin/perl
You should ALWAYS use the -w switch:
#!/usr/bin/perl -w
: die 'Usage: active_users.pl <password file> '
: if $#ARGV < 0;
^^^^^^^^^^^^^
I think it will be easier to understand when you try to figure out
what you were doing when you revisit this script in a few weeks if
you replaced that part with:
unless @ARGV > 0;
: if ($month == Dec || $year == 1997) {
^^^^^^
^^^^^^ that's a 'bareword'. barewords are Not Good.
if ($month eq 'Dec' || $year == 1997) {
Use == to compare numbers, eq to compare strings
Are you sure you want OR there? You need AND (&&) if you want to
find only Dec 1997...
: Can please someone help me. If so, please reply me at my own email address
: (jesmond@keyworld.net)
Please find the reply in the newsgroup where you asked the question.
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 03 Nov 1997 10:14:49 +0000
From: Amias <amias@mindless.com>
To: dreeves@fix.net
Subject: Re: QUESTION: Perl, Selena Sol's db_Search, Netware Web Server and You.
Message-Id: <345DA419.2877@mindless.com>
Cliff Campbell wrote:
>
> I am trying to use Selena Sol's db_search.cgi script on my
> Netware 4.11 server running Web Server 3.1. I always get back a
> document contains no data, this error can occur when I specify the
> wrong file name even. I think I don't have it installed in the right
> directory and that is why this is happening. Does anyone know the
> correct directory to install this script tree structure into?
> TIA
> Cliff CAmpbell
> dreeves@fix.net
Have you set the read permissions for you cgi-bin directory to execute
(it's a good idea to have read access disabled to stop people pinching
your scripts) and make sure the script returns the http header properly
, i've had this problem on NT servers and it's usally the header , you
need to make sure your script returns 'HTTP/1.0 200 OK' on it's first
line . If you still can't get it to work i have a database script you
could use for a small consideration .
--
Toodle-pip
Amias
http://www.homeusers.prestel.co.uk/amias
ICQ 3099152
Anyone spamming me _will_ have problems with their server
------------------------------
Date: Mon, 03 Nov 1997 11:32:31 +0100
From: Dirk Palme <palme@softing.com>
Subject: sockets on win95
Message-Id: <345DA83F.3D4@softing.com>
i would connect two computers (one as client and the other as server )
on win95 by sockets.
but the instruction
socket( SERVER, $AF_INET, $SOCK_STREAM, $proto) or
die "Could not open socket : $!\n";
never opens a socket.
there is no problem on winnt.
is there a way to open a socket on win95 ?
------------------------------
Date: 3 Nov 1997 10:45:06 GMT
From: burt@ici.net (Burt Lewis)
Subject: sub-totaling lines in a file??
Message-Id: <63k9vi$b2o$1@bashir.ici.net>
Hi,
This is an update to an original file.
This is what my file looks like:
cell1.gif - Sat Jul 19 14:42:28 EDT 1997 - 207.180.9.135
amsoil.gif - Sat Jul 20 14:42:28 EDT 1997 - 207.180.9.135
freitas.gif - Sat Jul 20 14:43:26 EDT 1997 - 207.180.9.135
coopbank.gif - Sat Jul 20 14:43:27 EDT 1997 - 207.180.9.135
morseins.gif - Sat Jul 21 14:50:56 EDT 1997 - 207.180.9.135
morseins.gif - Sat Jul 21 14:50:57 EDT 1997 - 207.180.9.135
coopbank.gif - Sat Jul 22 14:52:21 EDT 1997 - 207.180.9.135
freitas.gif - Sat Jul 22 14:52:22 EDT 1997 - 207.180.9.135
freitas.gif - Sat Aug 19 14:52:22 EDT 1997 - 207.180.9.135
I need to find all the same groupings of the month and day and count how
many in the groups.
The results I'm looking for is something like:
Jul 19 = 1 line
Jul 20 = 3 lines
Jul 21 = 2 lines
Jul 22 = 2 lines
Aug 19 = 1 lines
The result needs to be sorted in this order.
Appreciate any help on this.
Burt Lewis
burt@ici.net
------------------------------
Date: Mon, 03 Nov 1997 07:21:46 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: sub-totaling lines in a file??
Message-Id: <comdog-ya02408000R0311970721460001@news.panix.com>
In article <63k9vi$b2o$1@bashir.ici.net>, burt@ici.net (Burt Lewis) wrote:
has:
>cell1.gif - Sat Jul 19 14:42:28 EDT 1997 - 207.180.9.135
>amsoil.gif - Sat Jul 20 14:42:28 EDT 1997 - 207.180.9.135
>freitas.gif - Sat Jul 20 14:43:26 EDT 1997 - 207.180.9.135
>coopbank.gif - Sat Jul 20 14:43:27 EDT 1997 - 207.180.9.135
wants:
>Jul 19 = 1 line
>Jul 20 = 3 lines
if you look back at the earlier suggestions, you see that you just
need to modify the field(s) with which you choose to count.
in my earlier example, i split on whitespace, then used one of the
elements as the key in a hash. here we can do a similar thing with
a bit more work:
we split on whitespace again (we'll assume the current line is in $_):
@array = split;
looking at the data, we see that we want the month and date, which
will be in $array[3] and $array[4], so we can count like this:
$count{$array[3] . ' ' . $array[4]}++;
the only thing left is to sort the results nicely. my earlier example
had
foreach( sort keys %count )
but that's a little simplistic here. we'll want something like [0]
foreach( sort by_month keys %count )
where we write a subroutine named "by_month" to define the sorting. i'll
spare you the details and refer you to Learning Perl [1] and Programming
Perl [2]. if you run in trouble you can always ask a more specific
question.
good luck :)
[0] this could get really slow and memory intensive if there are
a lot of dates.
[1] see p. 156, Advanced Sorting
Learning Perl
Randal L. Schwartz & Tom Christiansen
ISBN 1-56592-284-0
<URL:http://www.oreilly.com>
[2] see pp. 217-9
Programming Perl
Larry Wall, Tom Christensen & Randal L. Schwartz
ISBN 1-56592-149-6
<URL:http://www.oreilly.com>
--
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: Mon, 3 Nov 1997 06:36:14 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: sub-totaling lines in a file??
Message-Id: <ufgk36.dh1.ln@localhost>
Burt Lewis (burt@ici.net) wrote:
: This is an update to an original file.
What does that mean?
: This is what my file looks like:
[ snip data, repeated in script below ]
: I need to find all the same groupings of the month and day and count how
: many in the groups.
: The results I'm looking for is something like:
: Jul 19 = 1 line
: Jul 20 = 3 lines
: Jul 21 = 2 lines
: Jul 22 = 2 lines
: Aug 19 = 1 lines
: The result needs to be sorted in this order.
------------------------------------------
#!/usr/bin/perl -w
while (<DATA>) {
$date = $1 if /(\w+ \d+)/;
# $date = join ' ', (split)[3,4]; # alternate way to extract the date
$cnt{$date}++; # count each entry
push(@order, $date) unless grep $_ eq $date, @order; # remember the order
}
foreach (@order) {print "$_ = $cnt{$_} lines\n"}
__DATA__
cell1.gif - Sat Jul 19 14:42:28 EDT 1997 - 207.180.9.135
amsoil.gif - Sat Jul 20 14:42:28 EDT 1997 - 207.180.9.135
freitas.gif - Sat Jul 20 14:43:26 EDT 1997 - 207.180.9.135
coopbank.gif - Sat Jul 20 14:43:27 EDT 1997 - 207.180.9.135
morseins.gif - Sat Jul 21 14:50:56 EDT 1997 - 207.180.9.135
morseins.gif - Sat Jul 21 14:50:57 EDT 1997 - 207.180.9.135
coopbank.gif - Sat Jul 22 14:52:21 EDT 1997 - 207.180.9.135
freitas.gif - Sat Jul 22 14:52:22 EDT 1997 - 207.180.9.135
freitas.gif - Sat Aug 19 14:52:22 EDT 1997 - 207.180.9.135
------------------------------------------
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 03 Nov 1997 12:10:19 +0100
From: Gustaf Edgren <gurra@imneverwrong.com>
Subject: THE POP module!
Message-Id: <345DB11B.2D82E753@imneverwrong.com>
I am currently developing a web-interface for a pop-mailbox. To do this
I am using the POP module that you can download at www.perl.com.
Anyway I haven't got any problems with the module itself, but how do you
get who its from?
Could anyone help me with this, please!
Gustaf Edgren
gustaf@bengt-martins.com
------------------------------
Date: 03 Nov 1997 11:37:14 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Warning when starting perl. What is it ?
Message-Id: <isk9eqs1ph.fsf@godzilla.kiere.ericsson.se>
PBUhauck@t-online.de (Uwe Hauck) writes:
> warning:setlocale(LC_TYPE,"") failed.
> warning: LC_ALL =3D "(null)", LC_TYPE =3D "(null)", LANG =3D "De_DE.ASCII=
",
> warning: falling back to the "C" local.
Your locale information doesn't work. Either install the correct
locale information (how to do that is severely OS dependent) or use
the C locale at all times. The latter solution has the disadvantage
that Perl will do the wrong thing when sorting and upper/lowercasing
things that are letters in your language but not in US english (like =E4
and =FC, in your case).
--
=09=09 Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: 3 Nov 1997 03:47:46 GMT
From: dmi@delta1.deltanet.com (Dean Inada)
Subject: Re: What to do with Bitwise operators?
Message-Id: <63jhh2$5ti$1@news01.deltanet.com>
In article <345cfe76.5885817@news.one.net>, dave <over@the.net> wrote:
>tmalloy@boley.escape.com () wrote:
>
>>Hi. First, I am beginner just learning perl. Can someone provide
>> an explaination of the practical use of bitwise operators.
>> ( &, |, ^, ~, <<,>>)
>>Please note that I am not asking for an explaination of what the operators
>> do. I can read. It is just difficult for me to envision any practical
>> use for them. In what situation might I need to use them They must have
>> some utility. I just don't see it. I would like to understand.
>>Perhaps I could be referred to some example code.
Well, it's hard to guess what use you might have for them without knowing
what kinds of things you're doing, but here's an example of using them to
substitute preserving case:
s/(foo)/"\Lbar"^"\L$1"^$1/ie;
or, if the substituted string may be a different length:
s/(foo\w*)/
my($f,$b)=($1,"b.ar");
substr($f,-1) x= length($b);
(lc($f)^$f)&(lc($b)^uc($b))^lc($b)
/ie;
(BTW, the documentation doesn't seem to specify exactly what this does,
so I'm not sure if it will continue to work with new versions of perl)
------------------------------
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 1264
**************************************