[21925] in Perl-Users-Digest
Perl-Users Digest, Issue: 4129 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 16 18:06:38 2002
Date: Sat, 16 Nov 2002 15:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 16 Nov 2002 Volume: 10 Number: 4129
Today's topics:
Re: [Q] Script to search auction sites? <wsegrave@mindspring.com>
Re: ActiveState perl install error Win98 <pajer@iname.com>
Adding mod_perl to Apache (Windows XP) (Digraph)
Re: Adding mod_perl to Apache (Windows XP) <randy@theoryx5.uwinnipeg.ca>
chomp isn't working as advertised - help, please! (Matt Oefinger)
Re: chomp isn't working as advertised - help, please! <paladin@techmonkeys.org>
Code Formatter for Perl? <dsolbach@web.de>
Re: Code Formatter for Perl? <tassilo.parseval@post.rwth-aachen.de>
Re: Code Formatter for Perl? <dsolbach@web.de>
correction to previous post - chomp, not chop! (Matt Oefinger)
Re: correction to previous post - chomp, not chop! <tassilo.parseval@post.rwth-aachen.de>
Re: correction to previous post - chomp, not chop! <bwalton@rochester.rr.com>
Re: CSV SQL <jeff@vpservices.com>
Re: dealing with multiple entires in a multi-dimensiona <nospam@rostie.net>
Re: Download TK module ? <rereidy@indra.com>
Re: Download TK module ? <mail@eircom.net>
Re: Download TK module ? <mail@eircom.net>
Re: Download TK module ? <tk@WINDOZEdigiserv.net>
Re: Download TK module ? (Jay Tilton)
Re: Download TK module ? <mail@eircom.net>
Re: Error reading the column names using DBI <bwalton@rochester.rr.com>
File::Find problem (scope of wanted)? <alceste@xmission.xmission.com>
Re: glob not working in dos (Tad McClellan)
Re: Ignoring Newlines (Tad McClellan)
leech <miner@arcor.de>
Re: leech (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 16 Nov 2002 10:59:35 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: [Q] Script to search auction sites?
Message-Id: <ar5tk6$jj2$1@slb6.atl.mindspring.net>
"Sir Loin of Beef" <NOSPAMmdknight@pacific.net.sg> wrote in message
news:3dd630fe.938857@news.pacific.net.sg...
<snip>
Look for my changes and employ similar changes in your code:
#!/usr/bin/perl -w
#> #!/usr/bin/perl
<snip>
my $content =
#> $content =
Runs fine here on IndigoPerl with shebang line:
#!perl -w
and one extraneous line-wrap (from news reader) deleted
Bill Segraves
------------------------------
Date: Sat, 16 Nov 2002 10:29:43 -0500
From: "Gary Pajer" <pajer@iname.com>
Subject: Re: ActiveState perl install error Win98
Message-Id: <POucnYHfBsX0-UugXTWcqg@comcast.com>
Nevermind. I just installed from the zip file and it works fine.
I don't see what the installer is doing for me, actually.
"Gary" <pajer@iname.com> wrote in message
news:4e47e24d.0211142031.201fdb15@posting.google.com...
> I tried to install ActiveState perl, but I get an error.
>
> I downloaded the latest MSI, and ActivePerl 5.6.1.633-MSWin32-x86.
>
> the installer opens, goes through the prelims about license etc, but
> when it gets down to business it pops a window with:
>
> Internal Error 2804. VerifyReadyDlg, Install,
> OutOfDiskSpace = 1 AND
> OutOfNoRbDiskSpace = 0 AND
> (PROMPTROLLBACKCOST="" OT
> PROMPTROLLBACKCOST)
>
> I don't know what this means, but I have 10 Gigs of free disk space.
> I've searched for a sol'n to this, but could find no mention of it.
>
> TIA,
> Gary
------------------------------
Date: 16 Nov 2002 12:01:35 -0800
From: ontheair@jps.net (Digraph)
Subject: Adding mod_perl to Apache (Windows XP)
Message-Id: <f9c151b4.0211161201.4dcd6693@posting.google.com>
After trying many things that didn't work or finding instructions that
were incomplete or inapplicable, I found an excellent tutorial at
http://www.thickbook.com/extra/php_apachephp4_win.phtml and got my
proxy server up and running (and PHP) pretty fast. Although I
had/have hopes of working in Perl, and not in PHP just yet, I can find
no similar instructions (easy to follow and get results with) for
mod_perl. I have looked many, many places for such information and
cannot find it.
Using as a model the PHP instructions in the tutorial noted above, my
best guess is to add a ScriptAlias like:
ScriptAlias /perl/ "C:/Perl"
or
ScriptAlias /perl/ "C:/Program Files/Apache Group/Perl"
(which would put the Perl directory/folder at the same level as the
Apache directory, under Apache Group)
or
?
. . . and then to include an AddType like:
AddType application/x-httpd-perl .pl [and .PL, in caps??]
AddType application/x-httpd-perl-source [is there such a thing as .pls
???]
. . . and then to include an Action like:
Action application/x-httpd-perl /perl/perl.exe [???]
Is any of this close? Could someone who has navigated this
circumstance already please advise me of the proper steps?
Thank you for any assistance you can provide.
------------------------------
Date: Sat, 16 Nov 2002 16:41:48 -0600
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Adding mod_perl to Apache (Windows XP)
Message-Id: <HQzB9.13155$b5.62588@news1.mts.net>
"Digraph" <ontheair@jps.net> wrote in message
news:f9c151b4.0211161201.4dcd6693@posting.google.com...
> After trying many things that didn't work or finding instructions that
> were incomplete or inapplicable, I found an excellent tutorial at
> http://www.thickbook.com/extra/php_apachephp4_win.phtml and got my
> proxy server up and running (and PHP) pretty fast. Although I
> had/have hopes of working in Perl, and not in PHP just yet, I can find
> no similar instructions (easy to follow and get results with) for
> mod_perl. I have looked many, many places for such information and
> cannot find it.
Were the Win32-specific docs at http://perl.apache.org/ on installing
and configuring mod_perl helpful?
best regards,
randy kobes
------------------------------
Date: 16 Nov 2002 12:39:40 -0800
From: oefinger@mit.edu (Matt Oefinger)
Subject: chomp isn't working as advertised - help, please!
Message-Id: <e9b08c9f.0211161239.123d142f@posting.google.com>
The following code works as expected when I remove the chomp line,
i.e. it prints out the file contents line by line. However, when I
include the chomp line I get NO output. Why is chomp eating the ENTIRE
line, not just the newline?
Thanks,
Matt
#!/usr/bin/perl
unless(open(TEMP, "./common_names.txt"))
{
die("Can't open common_names.txt for read\n");
}
@temp = <TEMP>;
foreach(@temp)
{
chop($_);
print $_;
}
------------------------------
Date: Sat, 16 Nov 2002 22:15:30 GMT
From: Alan Cameron <paladin@techmonkeys.org>
Subject: Re: chomp isn't working as advertised - help, please!
Message-Id: <glf6ra.mlq.ln@paladin>
On 16 Nov 2002 12:39:40 -0800, Matt Oefinger <oefinger@mit.edu> wrote:
> The following code works as expected when I remove the chomp line,
> i.e. it prints out the file contents line by line. However, when I
> include the chomp line I get NO output. Why is chomp eating the ENTIRE
> line, not just the newline?
> #!/usr/bin/perl
> unless(open(TEMP, "./common_names.txt"))
> {
> die("Can't open common_names.txt for read\n");
> }
> @temp = <TEMP>;
> foreach(@temp)
> {
> chop($_);
First, you don't have chomp here, you have chop, which does something
different from chomp.
> print $_;
> }
Secondly, if I run this code with either chop or chomp, it works
as expected.
ie. prints all the lines concatenated together in one big line.
Perhaps it has to do with your common_names.txt file. If you could provide
more information about that file, and anything else you may think is
important, perhaps someone will be able to find out what you are doing
wrong.
--
Mother is the name for GOD on the lips and
hearts of all children. - Eric Draven
------------------------------
Date: Sat, 16 Nov 2002 21:58:13 +0100
From: "David Solbach" <dsolbach@web.de>
Subject: Code Formatter for Perl?
Message-Id: <ar6bgq$3i2$03$1@news.t-online.com>
Hi, I'm searching for a code formatter for perl-scripts, any help?
Thnx, David.
------------------------------
Date: 16 Nov 2002 21:22:14 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Code Formatter for Perl?
Message-Id: <ar6cu6$6kn$1@nets3.rz.RWTH-Aachen.DE>
Also sprach David Solbach:
> Hi, I'm searching for a code formatter for perl-scripts, any help?
See http://perltidy.sourceforge.net/. It is probably the best tool
available but even this one only comes close at doing a proper job. So
don't expect perfect results. Perl is simply too hard to parse ("only
perl can parse Perl" is a common saying).
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Sat, 16 Nov 2002 22:28:51 +0100
From: "David Solbach" <dsolbach@web.de>
Subject: Re: Code Formatter for Perl?
Message-Id: <ar6da6$ev1$04$1@news.t-online.com>
well, I'll try it, tank you for your help.
David
------------------------------
Date: 16 Nov 2002 12:40:59 -0800
From: oefinger@mit.edu (Matt Oefinger)
Subject: correction to previous post - chomp, not chop!
Message-Id: <e9b08c9f.0211161240.338385b8@posting.google.com>
I am using chomp, not chop. I made a mistake in previous post.
#!/usr/bin/perl
unless(open(TEMP, "./common_names.txt"))
{
die("Can't open common_names.txt for read\n");
}
@temp = <TEMP>;
foreach(@temp)
{
chomp($_);
print $_;
}
------------------------------
Date: 16 Nov 2002 21:03:29 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: correction to previous post - chomp, not chop!
Message-Id: <ar6br1$60p$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Matt Oefinger:
> I am using chomp, not chop. I made a mistake in previous post.
>
> #!/usr/bin/perl
>
> unless(open(TEMP, "./common_names.txt"))
> {
> die("Can't open common_names.txt for read\n");
> }
>
> @temp = <TEMP>;
>
> foreach(@temp)
> {
> chomp($_);
> print $_;
> }
Perhaps an odd buffering-problem caused by the fact that your
print-statements contain no newlines. Try adding
$| = 1;
to the top of your script.
Also, you can do the chomp() in one go:
chomp(my @temp = <TEMP>);
But perhaps you do not even need to slurp at all. Going through a file
linewise is usually more efficient:
while (<TEMP>) {
chomp;
print;
...
}
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Sat, 16 Nov 2002 21:51:11 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: correction to previous post - chomp, not chop!
Message-Id: <3DD6BD86.30004@rochester.rr.com>
Matt Oefinger wrote:
> I am using chomp, not chop. I made a mistake in previous post.
>
> #!/usr/bin/perl
>
> unless(open(TEMP, "./common_names.txt"))
> {
> die("Can't open common_names.txt for read\n");
> }
>
> @temp = <TEMP>;
>
> foreach(@temp)
> {
> chomp($_);
> print $_;
> }
>
Hmmmm...your program runs verbatim with no problem on my system (Windoze
98SE, AS Perl build 633). With chomp, the output is all on one line
because the end-of-line characters got chomp'ed; without chomp, the
input file is simply echoed line by line. Are you perhaps dealing with
a text file with line endings other than what your OS uses? But that
wouldn't explain the symptoms you see [note: symptoms mentioned in OP's
previous note].
Also, note that you could simplify the program a bit:
open TEMP,"./common_names.txt" or
die "Can't open ./common_names.txt for read, $!";
@temp=<TEMP>;
chomp @temp;
print @temp;
would do the same thing.
--
Bob Walton
------------------------------
Date: Sat, 16 Nov 2002 11:16:45 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: CSV SQL
Message-Id: <3DD6999D.3070905@vpservices.com>
Benjamin Goldberg wrote:
> Lois wrote:
>
>>after the userdb file is created, how can I manually add records to
>>the file by using vi and yet recognised by the select statement to
>>retrieve record.
>>
>
> Add a line of comma seperated values to the file? It's not that hard.
True, but it's also not hard to overlook some basic things like
end-of-line settings, NULLs, escape characters, etc. For those with
less experience than Benjamin (a broad field, that), see my other post
in this thread about how to maintain consistency between hand-edited
files and script-generated files.
--
Jeff
------------------------------
Date: Sat, 16 Nov 2002 17:12:22 GMT
From: "Randy Rostie" <nospam@rostie.net>
Subject: Re: dealing with multiple entires in a multi-dimensional hash
Message-Id: <W%uB9.980$fY3.80117@newsread2.prod.itd.earthlink.net>
"Brian McCauley" <nobull@mail.com> wrote in message
news:u9d6p5kaz6.fsf@wcl-l.bham.ac.uk...
> Sorry I just don't get it. The english is plain but your
> understanding of what you are tring to ask is not.
>
> The way to do something dependant on if key $user is already in the
> index %users is just to test exists($users{$user}) as you do. There
> is no simpler way to do Y.
Ok, suppose that I do have multiple hashes with the same user
my @record_set = (
{ user => 'joe', file => '/home/joe/cgi-bin/script.cgi', safe => 'yes',
version => '1.92'},
{ user => 'joe', file => '/home/joe/cgi-lib/script.pl', safe=> 'no',
version => '1.9' },
{ user => 'jim', file => '/home/jim/cgi-lib/script.pl', safe=> 'no',
version => '1.6' }
);
I want to send 1 email to to each user:
One email to joe,
"You have the following files in your dir:
'/home/joe/cgi-bin/script.cgi' version 1.92 allowed : yes
'/home/joe/cgi-lib/script.pl' version 1.9 allowed: no"
The rest of the script will be something like:
for each %user{
if exists($users{$user}) {
do something
}
else {
do something else
}
How do I do this? Build a temporary hash or array for each user?
@joe=(
{ file => '/home/joe/cgi-bin/script.cgi', safe => 'yes', version =>
'1.92'},
{ file => '/home/joe/cgi-lib/script.pl', safe=> 'no', version => '1.9' }
);
Then I have a new foreach something to process each user hash/array and send
them an email (?)
Randy
------------------------------
Date: Sat, 16 Nov 2002 07:50:35 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Download TK module ?
Message-Id: <3DD65B3B.DB7F8C0C@indra.com>
Ireland wrote:
>
> Hi,
>
> Can someone tell me where I can download the TK module? I have got
> ActiveState Perl but I want to get TK.
The module name is 'Tk', not 'TK'. Use ppm to install it.
--
Ron Reidy
Oracle DBA
------------------------------
Date: Sat, 16 Nov 2002 16:04:45 -0800
From: "Ireland" <mail@eircom.net>
Subject: Re: Download TK module ?
Message-Id: <ar5mis$4j4$1@dorito.esatclear.ie>
Okay, Thanks
"Ron Reidy" <rereidy@indra.com> wrote in message
news:3DD65B3B.DB7F8C0C@indra.com...
> Ireland wrote:
> >
> > Hi,
> >
> > Can someone tell me where I can download the TK module? I have got
> > ActiveState Perl but I want to get TK.
> The module name is 'Tk', not 'TK'. Use ppm to install it.
> --
> Ron Reidy
> Oracle DBA
------------------------------
Date: Sat, 16 Nov 2002 16:13:30 -0800
From: "Ireland" <mail@eircom.net>
Subject: Re: Download TK module ?
Message-Id: <ar5n3d$4q5$1@dorito.esatclear.ie>
What command do I type in?? I cant find it anywhere in the Documents with
it. I open ppm and type what ???
------------------------------
Date: Sat, 16 Nov 2002 17:11:09 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: Download TK module ?
Message-Id: <hvuctucs737dse7g3mpq9j6d363qis5jus@4ax.com>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on Sat, 16 Nov 2002 13:49:44 -0800, "Ireland"
<mail@eircom.net> managed to scribble:
|
| Hi,
|
| Can someone tell me where I can download the TK module? I have got
| ActiveState Perl but I want to get TK.
|
I don't know about _all_ activestate releases of Perl, but in the
windoze one at least, it comes with the Tk modules with the installer.
Look in:
\path\to\perl\site\lib
I have:
Tk (dir)
Tk.pm
Tk.pod
These all came with the AS Perl disto.
HTH.
Regards,
tk
-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3
iQA/AwUBPdZ8cyjNZg8h4REKEQKKpgCg2SdPSfi/b2wZM3AC80PsxhRFdS4AoP90
aPSx+uB48IHxiRkm6ilsyKD1
=y1IO
-----END PGP SIGNATURE-----
--
+--------------------------+
| digiServ Network |
| Web solutions | Remove WINDOZE to reply.
| http://www.digiserv.net/ |
+--------------------------+
------------------------------
Date: Sat, 16 Nov 2002 17:27:06 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Download TK module ?
Message-Id: <3dd67cf2.80683379@news.erols.com>
"Ireland" <mail@eircom.net> wrote:
: What command do I type in?? I cant find it anywhere in the Documents with
: it. I open ppm and type what ???
C>ppm
PPM interactive shell (2.1.5) - type 'help' for available commands.
PPM>
Call me a risk-taker, but I'd bet typing 'help' would do something nice.
From the list of available commands it shows, the most useful-sounding
ones are "search" and "install."
The full documentation for PPM can be read by typing "perldoc ppm" at a
command prompt.
You still need to work on quoting material from the article you're
replying to.
------------------------------
Date: Sat, 16 Nov 2002 20:24:59 -0800
From: "Ireland" <mail@eircom.net>
Subject: Re: Download TK module ?
Message-Id: <ar65qq$ag6$1@dorito.esatclear.ie>
Okay. I got it.Thanks
"tk" <tk@WINDOZEdigiserv.net> wrote in message
news:hvuctucs737dse7g3mpq9j6d363qis5jus@4ax.com...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> In a fit of excitement on Sat, 16 Nov 2002 13:49:44 -0800, "Ireland"
> <mail@eircom.net> managed to scribble:
>
> |
> | Hi,
> |
> | Can someone tell me where I can download the TK module? I have got
> | ActiveState Perl but I want to get TK.
> |
>
> I don't know about _all_ activestate releases of Perl, but in the
> windoze one at least, it comes with the Tk modules with the installer.
>
> Look in:
>
> \path\to\perl\site\lib
>
> I have:
>
> Tk (dir)
> Tk.pm
> Tk.pod
>
> These all came with the AS Perl disto.
>
> HTH.
>
>
> Regards,
>
> tk
>
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGP Personal Privacy 6.5.3
>
> iQA/AwUBPdZ8cyjNZg8h4REKEQKKpgCg2SdPSfi/b2wZM3AC80PsxhRFdS4AoP90
> aPSx+uB48IHxiRkm6ilsyKD1
> =y1IO
> -----END PGP SIGNATURE-----
>
> --
> +--------------------------+
> | digiServ Network |
> | Web solutions | Remove WINDOZE to reply.
> | http://www.digiserv.net/ |
> +--------------------------+
------------------------------
Date: Sat, 16 Nov 2002 21:00:12 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Error reading the column names using DBI
Message-Id: <3DD6B197.80100@rochester.rr.com>
Thomas Theakanath wrote:
...
> I have problem reading column names after a query is executed using
> DBI module against a mySQL database. The program is similiar to the
> following:
>
> my $sth = $dbh->prepare("SELECT * from TEMP");
> $sth->execute or die "unable to execute query: $dbh->errstr\n";
> my $name = $sth->{NAME};
> print "@$name\n";
>
> At the last line, I get the following message:
> Can't set DBI::st=HASH(0x2a3ce0)->{NAME}: unrecognised attribute or
> invalid value
>
> What could I be doing wrong? Please help
>
> - Thomas.
>
Hmmmmm...I don't see anything wrong with your code. The following
complete program works fine:
use DBI;
use strict;
use warnings;
my $dbh=DBI->connect("DBI:CSV:f_dir=d:/junk")
or die "Oops, $DBI::errstr";
my $sth=$dbh->prepare("select * from junk231")
or die "Oops, $dbh->errstr";
$sth->execute or die "Oops, ".$sth->errstr();
my $names=$sth->{NAME};
print join ':',@$names;
where "junk231" is a text file with contents
col1,col2,col3
1,2,3
2,3,4
for example. This doesn't use MySQL, but illustrates that your code
ought to run fine.
--
Bob Walton
------------------------------
Date: Sat, 16 Nov 2002 22:08:18 +0000 (UTC)
From: Jeremy Smith <alceste@xmission.xmission.com>
Subject: File::Find problem (scope of wanted)?
Message-Id: <ar6fki$ut3$1@terabinaries.xmission.com>
perl 5.6.1
I'm having some issues with File::Find. I have a program that:
+calls find on a directory with a subroutine A
If the item is a directiory, A calls another subroutine B that contains
another find. That find's subroutine, C, does a bunch of work and finishes.
My problem is, that when the main program should again call A, it instead calls
_C_. That is, it seems that that the wanted subroutine has been overwritten.
The code is printed below.
The first time the first find loops through, it works.
find calls statmodule, finds a directory, runs javacount on the directory,
and then returns.
On the second time, find calls "javacount" not statmodule.
How do I make it call "statmodule".
Thanks in advance.
Jeremy Smith
#!/usr/bin/perl
#use strict;
use File::Find;
use File::Basename;
use Getopt::Std;
#checks options, v=verbose q=quiet d=directory name
getopts('vqd:');
$rootdir=".";
if ($opt_d){
$rootdir="$opt_d";
}
find ( \&statmodule, $rootdir);
sub statmodule {
if (-d && !/\.$/) { #this means, if it's a directory unless it's "."
print $File::Find::name . "\n"; #print the module name
$modulename = $File::Find::name;
codecounter($modulename);
$File::Find::prune = 1; #stop decending because we don't want to go down
}
}
sub codecounter {
$totallinecount = $totalcodecount = $totalcommentcount = 0;
if ($_[0]){
$countdir="$_[0]";
}
find (\&javacodecount, $countdir);
print $totallinecount . "," . $totalcodecount . "," . $totalcommentcount ."\n";
sub javacodecount {
if (/\.java$/) {
my $total = my $code_count = my $comments = my $file_contents = my $file_stripped = 0;
print "Now opening file $File::Find::name\n";
undef $/;
$file_stripped = $file_contents;
# strip lines containing only "{" or "}"
while ($file_contents =~ s/\n[ \t]*[\{\}][ \t]*\n/\n/) {}
# strip blank lines
while ($file_contents =~ s/\n\s*\n/\n/) {}
$file_contents =~ s/^\s*\n//;
# count the resulting number of lines
$total = ($file_contents =~ tr/\n/\n/);
# strip "//" and "/* */" style comments.
# HA! just try to figure out this regexp:
$file_stripped =~ s:(//.*)|(/\*([^*]*\*+[^*/])*[^*]*\*+/)::g;
# strip lines containing only "{" or "}"
while ($file_stripped =~ s/\n[ \t]*[\{\}][ \t]*\n/\n/) {}
# strip blank lines
while ($file_stripped =~ s/\n\s*\n/\n/) {}
$file_stripped =~ s/^\s*\n//;
# count the resulting number of lines
$code_count = ($file_stripped =~ tr/\n/\n/);
$comments = ($total - $code_count);
print "Total Lines: ". $total . "\n";
print "Comments: " . $comments . "\n";
print "Code: " . $code_count . "\n";
$totallinecount = $totallinecount + $total;
$totalcodecount = $totalcodecount + $code_count;
$totalcommentcount = $totalcommentcount + $comments;
print $totallinecount . "," . $totalcodecount . "," . $totalcommentcount ."\n";
}
}
}
sub readFileContents {
my($fileName) = shift;
my($buffer);
$fileName = basename("$fileName");
local($/) = undef;
open(FILE, $fileName)
or die "couldn't open $fileName for reading: $!\n";
$buffer = <FILE>;
close(FILE);
return($buffer);
}
------------------------------
Date: Sat, 16 Nov 2002 13:37:01 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: glob not working in dos
Message-Id: <slrnatd7it.64e.tadmc@magna.augustmail.com>
Graham Wood <Graham.T.Wood@oracle.com> wrote:
> I would have expected glob("*.c") to work but
> not glob("\*\.c")
They *must* behave identically, as they have the identical argument.
glob() never sees the backslashes, double quotes eats them first.
Maybe you meant to say "not glob('\*\.c')" instead?
> Why are you
> escaping the *?
The * is not being escaped (successfully).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 16 Nov 2002 14:06:40 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Ignoring Newlines
Message-Id: <slrnatd9ag.64e.tadmc@magna.augustmail.com>
Robert Zahm <zahm@uiuc.edu> wrote:
> I checked through the o'reilly perl book and also tried some google
> searches, but couldn't find the answer to this (what I assume is a)
> relatively simple question.
It is a Question that is Asked Frequently.
perldoc -q match
"I'm having trouble matching over more than one line.
What's wrong?"
> Is there any way to ignore newline
> characters in pattern matching?
No.
But I expect that you didn't ask the question you were meaning to ask.
In pattern matching, characters either "match" or "don't match".
"ignore" is not one of the choices available to you. :-)
If you truly want "ignore" then you can strip the character(s)
(maybe from a copy rather than the original string) before
attempting your pattern match.
> (so that I can have the first part of the
> pattern at the end of one line, and the remainder of the pattern at the
> beginning of the next line).
If you want to *match* newlines then use the \n sequence, since
patterns are "double quotish":
print "matched\n" if /end of one line\nbeginning of the next line/;
> Currently, I just go through the sequence
How do you "go through"?
Are you changing the value of the $/ variable for instance?
You might have the "probably" part of the FAQ's answer, but since
you didn't show us any code, we can't tell.
> and remove all the newlines...but there has to be a more efficient way
> to do this,
Not if you really meant "ignore" when you said "ignore".
> I was hoping there would be a flag I could attach to the end
> of s// which would tell it to ignore a certain character,
^^^
^^^ s/// has 2 parts
There *is* a flag you could attach to the end of s///
that makes dot match newline characters (that's the
"possibly" part of the FAQ's answer).
> Any suggestions?
Check the Perl FAQ before posting to the Perl newsgroup.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 16 Nov 2002 17:19:39 +0100
From: "Andi Weiss" <miner@arcor.de>
Subject: leech
Message-Id: <ar5qrh$2tu$01$1@news.t-online.com>
Hi,
I'm trying to get some links in a file. Say i searched for something in
google and want to save all the links on this page in a file. Anybody a
suggestion how to do it? I want to use Internet Explorer 6.
Thanks
------------------------------
Date: Sat, 16 Nov 2002 17:14:17 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: leech
Message-Id: <3dd67c84.80573859@news.erols.com>
"Andi Weiss" <miner@arcor.de> wrote:
: I'm trying to get some links in a file. Say i searched for something in
: google and want to save all the links on this page in a file. Anybody a
: suggestion how to do it?
use HTML::LinkExtor;
: I want to use Internet Explorer 6.
Why do you believe Perl cares what browser you use?
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4129
***************************************