[10605] in Perl-Users-Digest
Perl-Users Digest, Issue: 4197 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 11 13:08:19 1998
Date: Wed, 11 Nov 98 09: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 Wed, 11 Nov 1998 Volume: 8 Number: 4197
Today's topics:
Re: 64-bit Perl? (Steffen Beyer)
Re: <<My Sort Problem>> dave@mag-sol.com
Re: <<My Sort Problem>> (Tad McClellan)
Re: <<My Sort Problem>> dccobb@yahoo.com
Re: Can A Perl/CGI Script prevent robots? <david.burt@worldnet.att.net>
Can I force format_TOP out w/o write? narins@my-dejanews.com
Re: continuation of backquoted lines (123) (Tad McClellan)
Re: continuation of backquoted lines (123) (Tad McClellan)
Re: CPAN "r" command is confused? (John G Dobnick)
Re: Error in script (Tad McClellan)
Re: Error in script <DeleteThisdev@stabiplan.nl>
Re: Exec Perl Offline with Webbrowser <computertech@clara.net>
Fun NYC job consulting/FT Perl/Tk/DBI/C++ jeans + Tshif <briansaltzman@pop.a001.sprintmail.com>
Help please - Testing if a substring in a certain posit <gomc0000@stud.uni-sb.de>
Re: Help please - Testing if a substring in a certain p <jdf@pobox.com>
Re: help:counting the number of occurences of a specifi (Tad McClellan)
Re: help:counting the number of occurences of a specifi jkane@my-dejanews.com
Re: help:counting the number of occurences of a specifi (bjjgann)
Re: info on files dave@mag-sol.com
Installing a Perl module to Active Perl (Damon Register)
Re: Installing a Perl module to Active Perl <msergeant@ndirect.co.uk_NOSPAM>
Re: Looking for a web site with good script examples (Steffen Beyer)
Need easy way to convert P4 scripts to P5 <girard@dontspamcig.mot.com>
Re: OOP or not? (for a Perl module) <keithmur@mindspring.com>
Re: Parsing HTML Tables (Matthew Bafford)
Re: Perl "Too Good" for UCLA's CSUA programming competi <cee123@ibm.net>
Re: Perl and Btrieve Support <lrouman@definity.com>
Perl and CGI wrap : a weird problem <krh2n@virginia.edux>
Re: perl, UNIX or sendmail permission problem? (Juan Gallego)
Re: Perl2exe <snif@xs4all.no.spam.nl>
Re: pwd without backticks? (Thomas)
Selena Sol's form_processor <cl@herningfolkeblad.dk>
Re: Selena Sol's form_processor <johnc@interactive.ibm.com>
Type glob in a CGI script <rkim@temple.edu>
Where to get Perl source?? <rmallett@rideau.carleton.ca>
Re: Win32::Process <keithmur@mindspring.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Nov 1998 16:01:14 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: 64-bit Perl?
Message-Id: <72ccca$qos$2@en1.engelschall.com>
Zenin <zenin@bawdycaste.org> wrote:
> Berend Ozceri <berend@istanbul.engr.sgi.com> wrote:
> : What's the status of Perl having native support for 64-bit integers (i.e. the
> : built-in integer type has 64-bit storage)?
> I thought it was already there on 64bit machines?
> If you need really big ints, Math::BigInt may be for you.
Or Bit::Vector - it allows Big Integer arithmetics as well.
--
Steffen Beyer <sb@engelschall.com>
Free Perl and C Software for Download:
http://www.engelschall.com/u/sb/download/
New: Build'n'Play 2.1.0 (all-purpose Unix batch installation tool)
------------------------------
Date: Wed, 11 Nov 1998 14:33:10 GMT
From: dave@mag-sol.com
Subject: Re: <<My Sort Problem>>
Message-Id: <72c776$m3p$1@nnrp1.dejanews.com>
In article <72bvn1$g6o$1@nnrp1.dejanews.com>,
dccobb@yahoo.com wrote:
> Hello all,
>
> I have the following problem:
>
> I have a list as shown below, I need to sort the list on the first column in
> alphabetical order. The list is currently in a file and would have to stuffed
> into an array. Is there any sort techniques I could use in Perl, e.g. Sort,
> incorporating a bubble sort technique?
>
> SJR-01 MR. F
> TCC-03 MR. G
> FFF-04 MR. J
> GHT-09 MR. X
> DCC-34 MR. Z
> SJR-01 MR. T
Perl does, indeed, have a built in sort function. It defaults to sorting in
standard string comparison order, which is what you want. It takes a list as
an argument and returns a sorted list. The most fleeting examination of the
documentation that came with your Perl distribution would have revealed the
name to you (it's a very obvious name for a 'sort' function).
Have a look in perldoc perlfunc and see if you can find it.
Getting your list from a file into a list is also a trivial operation in Perl
and one of the first things covered in any Perl book. Try perldoc perlop and
look for the I/O operators.
You may think that it would be easier for me to just tell you the answer to
your questions, the reason I don't goes back to the old adage about fishing
and eating.
hth,
Dave...
--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 11 Nov 1998 09:38:07 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: <<My Sort Problem>>
Message-Id: <v0bc27.jai.ln@flash.net>
dccobb@yahoo.com wrote:
: Subject: Re: <<My Sort Problem>>
^^^^
: I have the following problem:
Your root problem is that you did not spend the least little bit
of effort to try and solve your problem before posting.
You are expected to do this.
: I have a list as shown below, I need to sort the list on the first column in
^^^^
: alphabetical order.
I'll bet checking to see if maybe there is a function named 'sort'
in Perl would help with that. (perlfunc man page)
There are also a few Perl Frequently Asked Questions that have the
word 'sort' in them.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 11 Nov 1998 15:52:13 GMT
From: dccobb@yahoo.com
Subject: Re: <<My Sort Problem>>
Message-Id: <72cbrd$qcn$1@nnrp1.dejanews.com>
In article <72c776$m3p$1@nnrp1.dejanews.com>,
dave@mag-sol.com wrote:
> Perl does, indeed, have a built in sort function. It defaults to sorting in
> standard string comparison order, which is what you want. It takes a list as
> an argument and returns a sorted list. The most fleeting examination of the
> documentation that came with your Perl distribution would have revealed the
> name to you (it's a very obvious name for a 'sort' function).
>
> Have a look in perldoc perlfunc and see if you can find it.
>
> Getting your list from a file into a list is also a trivial operation in Perl
> and one of the first things covered in any Perl book. Try perldoc perlop and
> look for the I/O operators.
>
> You may think that it would be easier for me to just tell you the answer to
> your questions, the reason I don't goes back to the old adage about fishing
> and eating.
>
> hth,
>
> Dave...
I appreciate you telling me that Perl does have a command for sorting. I
would also not expect myself to tell someone the answer as research and
learning by yourself is the only way to find out how things work.
Cheers, Dave
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 11 Nov 1998 09:07:11 -0500
From: "Burt, David J" <david.burt@worldnet.att.net>
Subject: Re: Can A Perl/CGI Script prevent robots?
Message-Id: <01be0d7c$77147dd0$2611cfa8@oh02burtdj>
I would recomend making the areas of the site that you don't want the robot
to go a user interactive condition.
Vikram Pant <nospam@wam.umd.edu> wrote in article
<MPG.10b28d9366d47a0a9896a5@news.wam.umd.edu>...
>
> I have a simple script which is passed a wav file and returns the sound
> to be played by the browser.
>
> My question is can a web robot get this file?
> <a href="sounds.cgi?Heat+deniro.wav">Deniro</a>
>
> I implemented this small script thinking it would stop robots, only to
> realize that it is still a link and can be grabbed.
>
> Thanks,
> Vikram Pant
>
------------------------------
Date: Wed, 11 Nov 1998 15:55:26 GMT
From: narins@my-dejanews.com
Subject: Can I force format_TOP out w/o write?
Message-Id: <72cc1f$qo2$1@nnrp1.dejanews.com>
Using Perl5.004 on HP/UX
One of the guys on them team asked me if it is possible to force the
header of a format (like STDOUT_TOP) to be spit out even before any writes
are done.
We are always producing reports and I have just been accepting the fact that
an empty file indicates to records written. It might be better to have a
file with just the header, just for bookkeeping type stuff.
Of course I could ask him to undef his vars and do a blank write, but
maybe there is a better way, one I could not find in the Camel book
or in USENET?
" <- Is one of the only quotes I know, the other major one is -> '
Joshua Narins - UNIX/RDBMS - IMIS/UN DC2-1805-B - 212-963-6911
P.O.Box ????? narins@un.org
DHCC Home:212-???-????
NY,NY 10017 EY:'881
No opinions expressed reflect those of the United Nations nor any
part or parcel thereof, except by coincidence.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 11 Nov 1998 08:18:35 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: continuation of backquoted lines (123)
Message-Id: <rb6c27.rsh.ln@flash.net>
Nick Halloway (snowe@rain.org) wrote:
: How do you put a backquoted expresson on several lines?
: $Con = `echo '$Subject' | egrep -i '^ *cmsg +cancel +<.+>.*$' |sed 's/a/b/'`;
Use the shell's convention for continuing lines.
Since qx// is double-quoteish, you need to escape the escape
to get it through to the shell.
$Con = `echo '$Subject' | \\
egrep -i '^ *cmsg +cancel +<.+>.*$' | \\
sed 's/a/b/'`;
-----
Or build up the command in Perl before using the backticks (UNTESTED):
$cmd = "echo '$Subject' | " .
"egrep -i '^ *cmsg +cancel +<.+>.*$' | " .
"sed 's/a/b/'";
$Con = `$cmd`;
-----
Best, in your particular case, is to do it all within Perl,
and avoid spawning other processes ;-)
# UNTESTED
while ( $Subject =~ /(.*\n)/g ) { # for each line
$line = $1;
if ( $line =~ /^ *cmsg +cancel +<.+>.*$/ ) {
$line =~ s/a/b/;
$Con .= $line;
}
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 11 Nov 1998 09:32:14 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: continuation of backquoted lines (123)
Message-Id: <ulac27.l9i.ln@flash.net>
Tad McClellan (tadmc@flash.net) wrote:
: Nick Halloway (snowe@rain.org) wrote:
: : How do you put a backquoted expresson on several lines?
: : $Con = `echo '$Subject' | egrep -i '^ *cmsg +cancel +<.+>.*$' |sed 's/a/b/'`;
: # UNTESTED
: while ( $Subject =~ /(.*\n)/g ) { # for each line
: $line = $1;
: if ( $line =~ /^ *cmsg +cancel +<.+>.*$/ ) {
if ( $line =~ /^ *cmsg +cancel +<.+>.*$/i ) {
^
See?
I said it was untested ;-o
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 11 Nov 1998 15:53:05 GMT
From: jgd@alpha3.csd.uwm.edu (John G Dobnick)
Subject: Re: CPAN "r" command is confused?
Message-Id: <72cbt1$u0s$1@uwm.edu>
>From article <910770006.301186@thrush.omix.com>, by Zenin <zenin@bawdycaste.org>:
> John G Dobnick <jgd@alpha3.csd.uwm.edu> wrote:
> >snip<
> : I installed the TK::Pod module, and when I then issue a CPAN "r"
> : command (to obtain its idea of "reinstallation recommendations")
> : it tells me the following:
> :
> : Package namespace installed latest in CPAN file
> : Tk::Pod 3.14 3.14 ACH/Tk-Pod-0.10.tar.gz
>
> Did you run 'r' in the same session that you upgraded the module?
> CPAN seems to cache information, and often gets confused if you
> do something like this in the same session. Try exiting and
> starting the CPAN shell again and see if this persists.
Yes, and no. Showed the same both times. However...
> : o Is this a module problem?
>
> Maybe. I just tried to recreate your conditions, but it installed
> 3.15. Maybe 3.14 had some funky way of building a $VERSION?
I just re-installed it (v 3.15) and the problem vanished. I'm happy
now. :-)
> : o Where is the best place to ask about this?
> p5p, the perltk mailing lists, and/or the perltk newsgroup.
Thanks fo rthe above pointer.
And thanks for the reply.
--
John G Dobnick "Knowing how things work is the basis
Information & Media Technologies for appreciation, and is thus a
University of Wisconsin - Milwaukee source of civilized delight."
jgd@csd.uwm.edu ATTnet: (414) 229-5727 -- William Safire
------------------------------
Date: Wed, 11 Nov 1998 07:48:47 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Error in script
Message-Id: <vj4c27.rmh.ln@flash.net>
Martijn van der Kooij (DeleteThisdev@stabiplan.nl) wrote:
: The following doesn't work properly. What I want is to scan all lines, do
: several regular expressions on it and when 1 of those met add 2 tabs in
: front of the line, after cutting away spaces in front of that line.
: But the while loop is never entered. Do someone knowns what i'm doing wrong?
: open (TURN, "r024.txt");
: open (NEWTURN, ">r024_new.txt");
You should always, yes *always*, check the return value from
open() calls:
open (TURN, "r024.txt") || die "could not open 'r024.txt' $!";
: while (($#TempSearchLines => 0) && ($LineNotPrinted eq 1)) {
^^
^^
Maybe you want >= there?
-w warns about this.
You *are* using -w on every single script, right?
But if it was me, I would just use the array in a scalar context:
while (( @TempSearchLines ) && ...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 11 Nov 1998 15:03:52 +0100
From: "Martijn van der Kooij" <DeleteThisdev@stabiplan.nl>
Subject: Re: Error in script
Message-Id: <72c5l6$8ev$1@news.Kijfhoek.NL.net>
Thanks,
The while loop that was not entered:
while (($#TempSearchLines => 0) && ($LineNotPrinted eq 1)) {
What i was trying is to loop all items in @TempSearchLines.
I don't think a == will do the job, because it will problably / always
bigger than 1 element.
The open functions didn't give any trouble, it was just in development fase.
Martijn
Sam Holden wrote in message ...
>On Wed, 11 Nov 1998 08:18:40 +0100, Martijn van der Kooij
> <DeleteThisdev@stabiplan.nl> wrote:
>>The following doesn't work properly. What I want is to scan all lines, do
>>several regular expressions on it and when 1 of those met add 2 tabs in
>>front of the line, after cutting away spaces in front of that line.
>>
>>But the while loop is never entered. Do someone knowns what i'm doing
wrong?
>
>Which while loop?
>
>>
>>M.C. van der Kooij
>>
>>use strict;
>>my $regel;
>>my @SearchLines;
>>my @TempSearchLines;
>>my $searchLine;
>>my $LineNotPrinted;
>>
>>@SearchLines = ('^Galaxy Game', '^ *Status of Players', '^A');
>>
>>open (TURN, "r024.txt");
>>open (NEWTURN, ">r024_new.txt");
>You should always check the return value of open...
>open(TURN,"r024.txt") || die "Unable to open r024.txt : $!";
>and again for NEWTURN.
>This is probably the problem (although I must admit I never ran your code
>to check the rest).
>
>>while ($regel = <TURN>) {
>while(defined($regel = <TURN>)) {
>if you want to be more overtly paranoid.
>
>> $LineNotPrinted = 1;
>> @TempSearchLines = @SearchLines;
>> while (($#TempSearchLines => 0) && ($LineNotPrinted eq 1)) {
> ^^
>== would probably be better...
>
>Even better yet, would be to use last to get out fo the loop instead of
>doing an extra test everytime through...
>
>> $searchLine = shift @TempSearchLines;
>> print NEWTURN "$searchLine";
>Those quotes do nothing but confuse matters...
>And printing that seems a strange thing to do...
>
>> if ($regel =~ /$searchLine/i) {
>> $regel =~ s/^\s+//;
>use $regel =~ s/^\s*/\t\t/;
>and you can lose that $LineNotPrinted variable and the next line, and
>the test at the bottom. In other words modify $regel here if you need to
>and print it at the end always.
>
>
>> print NEWTURN "\t\t$regel";
>> $LineNotPrinted = 0;
>> };
>> };
>> if ($LineNotPrinted == 1) {
>> print NEWTURN $regel;
>> };
>>};
>
>You don't need all those semi-colons after the }s.
>>
>>close TURN;
>>close NEWTURN;
>
>I would probably use something like this :
>(in fact I would read from <> write to STDOUT, and probably eval a
>string containing the while loop with the regexes now embedded inside but
>that is another story)
>
>#!/usr/local/bin/perl -w
>use strict;
>my $regel;
>my @SearchLines = ('^Galaxy Game', '^ *Status of Players', '^A');
>
>open(TURN,"r024.txt") || die "Unable to open r024.txt : $!";
>open (NEWTURN, ">r024_new.txt") || die "Unable to open r024_new.txt : $!";
>
>while(defined($regel = <TURN>)) {
> for (@SearchLines) {
> print NEWTURN $_; # this makes the output file really messy
> if ($regel=~/$_/i)
> {
> $regel =~ s/^\s*/\t\t/;
> last;
> }
> }
> print NEWTURN $regel;
>}
>
>close(TURN);
>close(NEWTURN);
>
>
>in fact I did run that and with my input test it worked as I expected...
>not very useful with all those regexes on each line though.
>
>--
>Sam
>
>You can blame it all on the internet. I do...
> --Larry Wall
------------------------------
Date: Wed, 11 Nov 1998 13:45:16 +0000
From: Matthew Tillett <computertech@clara.net>
Subject: Re: Exec Perl Offline with Webbrowser
Message-Id: <364994EC.F975205B@clara.net>
Frank wrote:
>
> I need to find a method to test my scripts when I am offline. I know
> only the program perl.exe, but that isn't what I am looking for. It's
> debugging script, and it even doesn't debug very well (instead to good)
>
> --
If possible, could the person who provide an answer forward it on to me
aswell please. e-mail2u@usa.net
------------------------------
Date: Wed, 11 Nov 1998 10:42:09 -0500
From: Brian Saltzman <briansaltzman@pop.a001.sprintmail.com>
To: briansaltzman@sprintmail.com
Subject: Fun NYC job consulting/FT Perl/Tk/DBI/C++ jeans + Tshift
Message-Id: <3649B051.337C75D8@pop.a001.sprintmail.com>
Hi, I'm a technical director of a multimedia startup company. I'm
finding myself in a difficult spot because there seems to be few people
who have unix experience and want to work with PC software. I've worked
with unix ten years myself. What I'm looking for is someone who knows
about Perl/DBI/TK and emacs to manage data internally, is more clever
than the average bear and also likes the idea of a start-up company and
working with Microsoft's Visual C++. This could be a consulting position
or full time. The dress code is blue jeans and a T-shirt with the
office in mid-town manhattan. This is a cool opportunity for someone who
likes to create things from start to finish and see a product to market.
If you are interested please email your resume to
briansaltzman@sprintmail.com
thanks,
brian.
------------------------------
Date: Wed, 11 Nov 1998 16:42:05 +0100
From: Godfrey McLean <gomc0000@stud.uni-sb.de>
Subject: Help please - Testing if a substring in a certain position is equals to
Message-Id: <3649B04D.7ACB@stud.uni-sb.de>
I am learning Perl and using it in a project.
I would like to test if a substring in a specific position is equals to
a certain string - i.e. if character 2 and charter 3 = to "hi". I
cannot seem to find the right solution.
This is really urgent for me. Can anyone please help me with a small
code snippet?
I would appreciate it if you could send me the answer per mail since I
cannot always access the newsgroups.
Thank you very much.
Godfrey McLean
Mail: gomc0000@stud.uni-sb.de
------------------------------
Date: 11 Nov 1998 17:24:16 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Godfrey McLean <gomc0000@stud.uni-sb.de>
Subject: Re: Help please - Testing if a substring in a certain position is equals to
Message-Id: <m3g1bq9ozz.fsf@joshua.panix.com>
Godfrey McLean <gomc0000@stud.uni-sb.de> writes:
> I would like to test if a substring in a specific position is equals
> to a certain string - i.e. if character 2 and charter 3 = to "hi".
> I cannot seem to find the right solution.
Have you tried searching for the word "substring" in the
documentation? Try the perlfunc doc.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Wed, 11 Nov 1998 08:35:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: help:counting the number of occurences of a specified string in a file
Message-Id: <mb7c27.2uh.ln@flash.net>
bjjgann (bjjgann@liv.ac.uk) wrote:
: I am trying to count the number of times a string appears
: in a given file.
#UNTESTED
while (<>) {
$cnt++ while /string/g;
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 11 Nov 1998 14:58:59 GMT
From: jkane@my-dejanews.com
Subject: Re: help:counting the number of occurences of a specified string in a file
Message-Id: <72c8nj$nh5$1@nnrp1.dejanews.com>
In article <F2979A.616@liverpool.ac.uk>,
bjjgann@liv.ac.uk wrote:
> I am trying to count the number of times a string appears
> in a given file.
>
> So far I have managed to count the number of occurences on a particular line,
> the number of the line where the string occurs, and just about any other
> combination you care to imagine, except for the result I want.
>
> Is this an easy 3 liner, which am just missing or is it more complex.
> Any advice would be appreciated.
Having just learned perl, I wanted to see what I had done. With the help of
many here (search for "help with one liner" in this news group), I came up
with the following pieces of code that can be run like "grep|wc -l".
Note I did not implement all the suggestions, as this was a learning code, and
I wnated to see how many ways to do one thing, while keeping it as short as
possible. I also was not interested in making it work in all instances. Just
so it worked with what I had made.
# CODE STATISTICS: # # Must be regenerated manually after any changes. #
Unix commands are included that do this for you. # # 216 lines of real code
(except the #!/usr/contrib/bin/perl line). # perl -ne
'$n++unless/^\s*$|^\s*#/;END{print "$n\n"}' template_renumber # Print unless
blank or begins with #. # 388 lines of exclusive comments (nothing else on
the line). # perl -ne '$n++if/^\s*#/;END{print "$n\n"}' template_renumber #
Print if the first char (after white space) is #. # 445 lines of comments. #
perl -ne '$n++if/# |^\s*#/;END{print "$n\n"}' template_renumber # Print if
# followed by space or # first char. # 56 lines with both comments and code.
# perl -ne '$n++if/[;{}].*# /;END{print $n-1,"\n"}' template_renumber #
Count lines and subtract one for matching itself. # 199 lines without
anything (spacing). # perl -ne '$n++unless/;|{|}|\S|#/;END{print "$n\n"}'
template_renumber # (or) perl -ne '$n++if/^\s*$/;END{print "$n\n"}'
template_renumber # 803 lines total including comments and spacing. # perl
-ne '$n++;END{print "$n\n"}' template_renumber
You could wrap the code in
open(FILE,"/path/filename")
|| warn "Couldn't open /path/filename: $!\n";
while (<FILE>) {
$n++ if /Pattern_Match/;
}
print "$n\n";
close(FILE);
if you wanted to make it code rather than a one line command.
Good luck.
-Jeff Kane
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 11 Nov 1998 15:17:40 GMT
From: bjjgann@liv.ac.uk (bjjgann)
Subject: Re: help:counting the number of occurences of a specified string in a file
Message-Id: <F29JtG.Ctp@liverpool.ac.uk>
Thanks it worked a treat
>
> #UNTESTED
>
> while (<>) {
> $cnt++ while /string/g;
> }
>
------------------------------
Date: Wed, 11 Nov 1998 14:12:48 GMT
From: dave@mag-sol.com
Subject: Re: info on files
Message-Id: <72c611$l3b$1@nnrp1.dejanews.com>
There are a couple of misunderstandings in your code that I've corrected
below. You'll have to convert the number into a '-rwxr-xr-x' string yourself.
Printing the number in octal and reading man chmod may give you some clues on
this.
As regards Win32 Perl mailing lists, look at <http://www.activestate.com>
where they host a few.
hth,
Dave...
In article <72br7e$cnp$1@nnrp1.dejanews.com>,
meehanc@my-dejanews.com wrote:
> Hi,
> I was wondering if there`s a way to display just the file
> attributes of a list of files in Perl. for example, run a
> perl script passing it a list of files, and perl would then
> print out <filename> has the following permissions -rwx---r-x
> or whatever is relevant. I thought it could be done with stat
> and mode but mode only returns the numeric version of permissions,
> at least that was my understanding of it. I`ve included the script
> for what it`s worth, any help would be really appreciated.
> Secondly is there a mailing list version of this group, I know
> there`s a Win32 mailing list for general questions but all the
> UNIX perl mailing lists seem to focus on Perl specifics,
> tk, www, cgi etc. again thanks in advance.
> cathal
> <cathal.meehan@tecnomen.ie>
>
> #! /usr/bin/perl -w
> use File::stat;
# Don't think "while (<>)" does what you think it does, try printing out the
value of $_ each time round the loop and you'll see what I mean. You probably
want something more like
while (defined($_ = shift))
> while (<>)
> {
# If you correct the while loop, you don't need the chomp below.
> chomp; # eliminate the newline
> $file_perm = stat($_) -> mode;
# If you change this to
printf "$_ has the following permissions %o\n", $file_perm
# you might find it a little easier to interpret.
> print "$_ has the following permissions $file_perm\n";
# Maybe you should consider cheking the existance of the file *before*
# running 'stat' against it.
> print "$_ does not exist\n" unless -e;
> }
--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 11 Nov 1998 14:46:07 GMT
From: e247523@L10a.mar.lmco.com (Damon Register)
Subject: Installing a Perl module to Active Perl
Message-Id: <3649a1b8.4674387@news.mar.lmco.com>
All of the installation instructions for Perl modules that I have
seen so far seem to be written for unix systems and don't
cover the PC world. They all use a make command
that is not on my system. Is there a make for PCs or is there
some other way of installing Perl modules in the PC world?
I tried the Active State Perl web site but found nothing on
this subject. The help that comes with ActivePerl mention
installation but the distribution is missing the html file for this
information.
Damon Register
------------------------------
Date: Wed, 11 Nov 1998 16:44:05 +0000
From: Matt Sergeant <msergeant@ndirect.co.uk_NOSPAM>
Subject: Re: Installing a Perl module to Active Perl
Message-Id: <3649BED5.E2073538@ndirect.co.uk_NOSPAM>
Damon Register wrote:
>
> All of the installation instructions for Perl modules that I have
> seen so far seem to be written for unix systems and don't
> cover the PC world. They all use a make command
> that is not on my system. Is there a make for PCs or is there
> some other way of installing Perl modules in the PC world?
>
> I tried the Active State Perl web site but found nothing on
> this subject. The help that comes with ActivePerl mention
> installation but the distribution is missing the html file for this
> information.
>
> Damon Register
Type "ppm" and all will be revealed.
--
<Matt/>
| Fastnet Software Ltd | Perl in Active Server Pages |
| Perl Consultancy, Web Development | Database Design | XML |
| http://come.to/fastnet | Information Consolidation |
------------------------------
Date: 11 Nov 1998 15:59:23 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Looking for a web site with good script examples
Message-Id: <72cc8r$qos$1@en1.engelschall.com>
Jim Mosier <jim.mosier@mci.com> wrote:
> NE1?
Have you looked at http://reference.perl.com/?
--
Steffen Beyer <sb@engelschall.com>
Free Perl and C Software for Download:
http://www.engelschall.com/u/sb/download/
New: Build'n'Play 2.1.0 (all-purpose Unix batch installation tool)
------------------------------
Date: Wed, 11 Nov 1998 10:33:17 -0600
From: Jason <girard@dontspamcig.mot.com>
Subject: Need easy way to convert P4 scripts to P5
Message-Id: <3649BC4D.37F8@dontspamcig.mot.com>
Greetings,
I need to convert a bunch of Perl4 scripts to run with
Perl5. Is there a module out there that will do this
conversion effortlessly? I have not yet found one.
Thanks in advance.
To reply, remove 'dontspam'
--
\|||/
|. .|
-----------ooO---0---Ooo----------
Jason Girard
o Motorola SW Engineer by day
o Car Audio Enthusiast, Webmaster,
and Spam 'nuker by night
--------------||--||--------------
ooO Ooo
------------------------------
Date: Wed, 11 Nov 1998 10:14:55 -0600
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: OOP or not? (for a Perl module)
Message-Id: <3649B7FF.723F3AB1@mindspring.com>
Paul Winkler wrote:
>
> #!/usr/bin/perl -w
> use Csound::Pscore;
>
> pattern_from_file(Verse1, "some-score-file.sco", [ 4 .. 10 ]);
> # We keep stuff in a big data
> # structure: a hash of list refs. of list refs. The hash keys
> # are pattern names; the first-level list is of line numbers; the
> # second-level list contains each line's pfields.
> # pattern_from_file() would take three args: a name to give this
> # pattern, a file to read score events from, and a reference to an
> # array tells which lines we want. In this case it's an anonymous
> # array which says use lines 4 to 10. The array could as easily be
> # generated by a function... Anyway, moving on:
>
> play(Verse1, 2); # Plays Verse1 twice.
> rewind(); # Set time to whatever it was when the last function was
> # called.
> play(Verse2); # Plays Verse2 at same start time as the first
> # Verse1. If rewind() hadn't been there, it would
> # come after the Verse1's...
> # and there's lots of ways to do things like that.
>
> select_pat(Verse2); # load it but don't do anything yet.
> shuffle_pfield (pfield(5, beats(4 to 9), *= 2));
> play();
>
> # set Verse2 as the "current pattern", do some interesting things
> # to it (but don't save the changes!), and play the modified version.
> # Here's what the shuffle_pfield(... line does:
> # Read the fifth "p-field", a.k.a. p5,
> # from any events occurring between
> # beats 4 and 9 in the current pattern, and then multiply those p5's
> # by 2, and then shuffle them randomly back into the lines they came
> # from. Fun stuff! We can do this because shuffle_pfield expects
> # an int (the pfield) followed by an array ref. (which line numbers?)
> # as its arguments, and that's exactly what
> # pfield() returns...
>
I'd use OOP, but also consider modifying the data structure to make it
easier to do things without writing complex procedures or methods. I'm
not sure at all that I understand how all your data structures fit
together, but supposing (for the sake of argument) your composition is
made up different verses, verses of beats, pfields are just named
collections of beats:
Let's introduce the concept of a "Composition", so we'll have an object
that refers to the whole, and a "Voice", made up of verses. These
concepts perhaps simplify by getting rid of stuff like "rewind".
Doesn't it make more sense to play a composition, not a verse?
-------
$comp = new Composition;
$verse1 = new Verse("some-score-file.sco", [ 4 .. 10 ]); #new can take
parameters: why not use 'em?
$verse2 = new Verse("other-file.sco", [ x .. y ]); #notice new's going
to have to create the 'Beats'
push @{@{$comp->{'Voices'}}[0]->{'Verses'}} , $verse1; #'Verses' is
just a list of verses
push @{@{$comp->{'Voices'}}[0]->{'Verses'}} , $verse1; #stick it on
twice
push @{@{$comp->{'Voices'}}[1]->{'Verses'}} , $verse2; #verse2's
played in the other voice
$comp->Play; #no rewind - the composition knows what's in it
-------
Now what about that pfield manipulation?
-------
pfield = new Pfield( @{$verse2->{'Beats'}}[4..9] );
foreach (@{pfield->{'Beats'}}) {$_ *= 2}; #I'll bet your shuffle_pfield
was complicated...
shuffle(@{pfield->{'Beats'}}); #shuffle here is some simple routine
that shuffles *any* list
-------
Probably some of my syntax is wrong (all that dereferencing), and no
doubt I'm oversimplifying your structure, but I hope you get the basic
idea:
Hashes let you name the different parts of your structure to make the
code clearer and the structure more extensible. (A lot of folks would
write some class methods instead of directly manipulating the structure
contents, like I'm doing here, but the idea stays the same).
If you're really careful with the data structure, you can get away from
complicated methods or functions. (Does the term "data-driven" mean
anything?)
Oh, yes, to address some of the other issues: you'll need to have a
"deepcopy" function that lets you copy your structures in toto so that
you can manipulate the copies without affecting the source structures.
I have one I wrote, but there's probably other (and better) ones out
there.
Good luck! Sounds like a great project.
------------------------------
Date: Wed, 11 Nov 1998 11:42:41 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Parsing HTML Tables
Message-Id: <MPG.10b33bd1627a735998970b@news.south-carolina.net>
In article <36490AE3.8160AC36@earthlink.net>, Chris Lambrou
<cglcomputer@earthlink.net> pounded in the following:
=> What is the most *efficient* way to parse values in table cells in
=> HTML?
=> [snip]
=> I did come up with a way that works, but it's kinda ugly.
Subject: Parsing HTML Tables
^^^^ ^^^^
Reverse them. :)
HTML::Parser
HTH,
--Matthew
------------------------------
Date: Wed, 11 Nov 1998 10:41:16 -0500
From: Charles Engelke <cee123@ibm.net>
Subject: Re: Perl "Too Good" for UCLA's CSUA programming competition...
Message-Id: <3649B01C.D7737C79@ibm.net>
> Rich Morin wrote:
> > >From http://www.perl.org/advocacy/chiem.html
> >
> > Perl "Too Good"
> > [text omitted]
> > But if you're a UCLA undergraduate contemplating entering the contest and
> > using Perl, don't bother. After Keith's conquest, Perl was banned from
> > the contest.
My wife is a judge in the International Collegiate Programming Contest,
and I have judged some regional contests. I suspect UCLA's local
prohibition on Perl comes from the International contest's rules: teams
can use Pascal, C++, or Java. At times, other languages have also been
allowed: Visual Basic (when Microsoft was sponsoring the contest), and
Smalltalk (when IBM took it over).
The contests are run by academics who are pretty much clueless about
things like Perl. I submitted some possible problems for next year's
contest, and solved them in Perl, then in Pascal. I don't think the
judges knew what I was doing with the Perl solutions. (I was surprised
that the Pascal solutions weren't a lot harder than the Perl ones, but I
think that's because I did all the hard work of figuring things out with
Perl first.)
Perl would be a perfect language for programming contests. Maybe IBM
will push it, since they seem to be very open to things like that
nowadays.
Charlie
------------------------------
Date: Wed, 11 Nov 1998 08:26:28 -0800
From: Lee Rouman <lrouman@definity.com>
Subject: Re: Perl and Btrieve Support
Message-Id: <3649BAB3.61A76E23@definity.com>
Jeffery, thanx for your response. I am aware and have used the ODBC functionality with Btrieve and other ODBC-compliant data structures.
I was hoping for a more direct solution ala Db::Ctree or DBD::XBase. Anyone out there working on this type of module?
Lee.
Jeffrey R. Drumm wrote:
> [ posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
> author ]
>
> On Tue, 10 Nov 1998 17:19:38 -0800, Lee Rouman <lrouman@definity.com> wrote:
>
> [ rewrapped because of Lee's improperly configured news reader ]
>
> >Anyone completed (or working on) a database interface for Btrieve? I don't see one
> >on http://reference.perl.com/query.cgi?database but I'm hopeful that this is a
> >problem that has already been solved.
> >
> >Lee Rouman
>
> If you've got ODBC drivers for Btrieve, you can use Win32::ODBC or the DBI/DBD
> ODBC module. See CPAN at www.perl.com.
>
> --
> Jeffrey R. Drumm, Systems Integration Specialist
> Maine Medical Center - Medical Information Systems Group
> drummj@mail.mmc.org
> "Broken? Hell no! Uniquely implemented!" - me
------------------------------
Date: Wed, 11 Nov 1998 23:27:41 -0500
From: Kevin Hirst <krh2n@virginia.edux>
To: patrickr@virginia.edu
Subject: Perl and CGI wrap : a weird problem
Message-Id: <364A63BC.23B11361@virginia.edux>
(Remove the x from the end of my E-mail address to reply)
Using perl with cgiwrap, I am experiencing a weird problem. Of
course you know cgiwrap allows su execution of cgi scripts. I use the
following virtual path to execute a discussion group perl script:
/cgi-bin/cgiwrap/casecomp/disctest/discuss.pl.
If you use /cgi-bin/cgiwrap/casecomp/disctest/discuss.pl/SomePath
to execute the program it will set the $ENV{'PATH_INFO'} to SomePath and
execute discuss.pl.
The problem is, when I do that to create a new discussion group, I
create a new discussion group under the directory
/home/casecomp/public_html/disctest/messages/SomePath
and output the new main page (which includes all discussion groups)
If there are any image tags in the main page, however like <img
src="SomeImage">
a directory called
/home/casecomp/public_html/disctest/messages/SomeImage
ALSO gets created, and this happens as a result of every image tag.
All I'm doing is making a call
open (HEADER, "mheader");
print <HEADER>;
close (HEADER);
If these lines are commented out (and the title image is not displayed,
therefore) the problem never occurs.
Anyone have any ideas? BTW, if the src="SomeImage" is taken out then
the problem no longer exists as well.
Kevin
------------------------------
Date: 11 Nov 1998 15:46:03 GMT
From: juan@physics.mcgill.ca (Juan Gallego)
Subject: Re: perl, UNIX or sendmail permission problem?
Message-Id: <72cbfr$3t7@sifon.cc.mcgill.ca>
In article <72a02e$rgh$1@nnrp1.dejanews.com>
read on comp.mail.sendmail on Tue, 10 Nov 1998 18:18:53 GMT,
michalk2395@my-dejanews.com wrote:
: I have a virtual domain alias such as:
: @foo.com foodaemon
: an alias entry such as:
: foodaemon : "|\foodir\foodatabase"
\? *ponder*
: my foodatabase is a perl program that looks something like:
: $dbfile = foousers.db;
so you know what the working directory is when the script is invoked,
right?
: tie %dweebdata, DB_File, $dbfile, O_RDWR|O_CREAT, 0640 , $DB_HASH;
yikes! no error checking?! Change that to:
tie %dweebdata, DB_File, $dbfile, O_RDWR|O_CREAT, 0640 , $DB_HASH or
die "tie $dbfile: $!\n";
that should give you a hint as to what the problem might be...
(`permission denied/cannot create' would be my guess, as the working
directory is / most likely).
HTH,
--
Juan Gallego
Little ({sys,net}-{admin,hacker}) Boss
------------------------------
Date: Mon, 9 Nov 1998 08:00:39 +0100
From: "Sander Jonkers" <snif@xs4all.no.spam.nl>
Subject: Re: Perl2exe
Message-Id: <726jo0$aj6$1@news.gns.getronics.nl>
Chris Liley wrote in message <721jb9$2sp$1@plug.news.pipex.net>...
>Trying to use Perl2exe I keep getting the error message:
<snip>
Perl2exe is commercial software, isn't it? If so, I expect them to support
it and you should be able to contact them
Sander
------------------------------
Date: 11 Nov 1998 07:22:58 -0800
From: nouser@nohost.nodomain (Thomas)
Subject: Re: pwd without backticks?
Message-Id: <tz87lx2s17x.fsf@aimnet.com>
In article <72bajk$29g$1@mathserv.mps.ohio-state.edu> ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> IZ> Right. This is why 'pwd' must be suid.
>
> wrong. if you got into below strange dir which has only execute perms,
> you should know where you are. as i said on solaris, pwd is not suid.
This is a bug of Solaris's pwd.
I have used all the BSD releases (VAX, PDP), most of the SunOS and
Solaris releases, IRIX, AIX, Linux, and a few others, and I have never
seen pwd to be suid. In fact, many shells now have it as a built-in.
Perhaps you have decided for yourself that pwd ought to involve
suid and that therefore every version of UNIX that doesn't do it
your way is buggy, but I have to disagree with that reasoning.
Traditionally, if it can't read all the parent directories, "pwd" will
fail. In fact, a directory may not even have a parent directory at
all (mkdir x; cd x; rmdir ../x; /bin/pwd), and making pwd suid
won't help that.
If this kind of thing matters to a UNIX program, it should know how to
deal with it. In modern versions of UNIX, in the presence of NFS
automounts and symlinks, in fact, there are lots of other potential
problems callers of "pwd" have to deal with anyway.
Thomas.
------------------------------
Date: Wed, 11 Nov 1998 10:11:16 +0100
From: Claus Larsen <cl@herningfolkeblad.dk>
Subject: Selena Sol's form_processor
Message-Id: <36495480.9D058E1E@herningfolkeblad.dk>
Hallo
I'm looking for Selena Sol's form processor 4.0 or something like it. I
want the users to be able to specifie their own forms, with the fields
they want, and then have "only one" cgi-script which handles all the
forms by use of hidden entries.
Does anyone know where I can find and download such a script?
Thanks in advance
Claus Larsen
------------------------------
Date: Wed, 11 Nov 1998 09:24:28 -0500
From: John Call <johnc@interactive.ibm.com>
Subject: Re: Selena Sol's form_processor
Message-Id: <36499E1C.C063369B@interactive.ibm.com>
Claus Larsen wrote:
> then have "only one" cgi-script which handles all the
> forms by use of hidden entries.
> Does anyone know where I can find and download such a script?
>
> Thanks in advance
> Claus Larsen
Depending on what you are going to do with the values of the fields I have
two words for you:
Taint Checking!
Don't process CGI without it.
John Call
------------------------------
Date: Wed, 11 Nov 1998 10:13:26 -0500
From: Richard Kim <rkim@temple.edu>
Subject: Type glob in a CGI script
Message-Id: <Pine.OSF.4.02.9811111006160.32440-100000@thunder.ocis.temple.edu>
I don't know if there is another way to do this, but here it goes.
I am currently trying to get a listing of certain files from a directory
using glob. I am able to get the list into an array if I just run the
function from a command prompt, but when I try to run it from a
CGI-BIN,the array does not populate. The only time the array will
popoulte is when there are 20 or less files in the directory.
When the directory holds too many files glob doesn't want to work through
the CGI.
Any suggestions would be great.
The function below is what I am trying to accomplish.
sub showalldraft
{
@cutzsm = glob("/home/zsmmkt/drft*.rpt");
$x = 0;
print("<body bgcolor=white>");
print("<font color=red>All Draft Reports:");
print("</font><font color=navy size=+0>Please select a Draft report you would like to view.");
print("<font color=navy size=+0>");
print("<PRE>");
while( $x <= $#cutzsm )
{
@filename = split (/\//, $cutzsm[$x]);
print("<form name=showdraft$x method=post action=/cgi-bin/case>");
print("<input type=hidden name=file value=$cutzsm[$x]>");
print("<a href=javascript:document.showdraft$x.submit()>$filename[3]</a><br>\n");
print("</form>");
$x++;
}
}
Thanks,
Rich
rkim@temple.edu
------------------------------
Date: 11 Nov 1998 15:19:02 GMT
From: Rick Mallett <rmallett@rideau.carleton.ca>
Subject: Where to get Perl source??
Message-Id: <72c9t6$b0s$1@bertrand.ccs.carleton.ca>
I downloaded the latest stable version of perl, presumably 5.002_02
from www.perl.com, using lynx with a suggested filename of stable.tar.gz
and a file size of 3470355 bytes. I later discovered that 5.0005_02 also
appears to be available on the gnu machine at mit (prep.ai.mit.edu) with
the name perl-5.005.02.tar.gz and a file size of 3491732 bytes. Anyone
know why the two are different and which should I use??
----------------------------------------------------------------------
Rick Mallett
Computing and Communications Services,
Carleton University, Ottawa, Ontario, Canada.
Email address: rmallett@ccs.carleton.ca
----------------------------------------------------------------------
------------------------------
Date: Wed, 11 Nov 1998 10:35:57 -0600
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Win32::Process
Message-Id: <3649BCED.62DE87CC@mindspring.com>
ljkbrost@my-dejanews.com wrote:
>
> Hello,
>
> I am trying to write a Perl script on a Windows95 machine. I am using the
> Win32::Process module to spawn a process and I would like to capture the
> "spawned" process's output to an array so that the parent process can later
> manipulate it.
>
> Can someone please offer a way in which I can do this?
>
Have you tried:
(1) Open a temporary file in the parent process. Change STDOUT to go to
it.
(2) Spawn the process with the flag set to inherit handles.
(3) When the subprocess finishes, change your STDOUT back, and read in
the temp file.
I've never tried this, but seems like it ought to work.
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4197
**************************************