[7131] in Perl-Users-Digest
Perl-Users Digest, Issue: 756 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 23 03:37:31 1997
Date: Wed, 23 Jul 97 00:02:05 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 23 Jul 1997 Volume: 8 Number: 756
Today's topics:
Re: Multiple Line Pattern Matching <sfairey@adc.metrica.co.uk>
Re: Need help with database <rootbeer@teleport.com>
Re: need perl v-4.035 <rootbeer@teleport.com>
newbie problem with $1 (Mueller Beat)
Oraperl and WinNT <jkinney@us.oracle.com>
Re: overwriting one line in txt file <rootbeer@teleport.com>
Re: perl V. HTML?? (Bob Wilkinson)
Re: Perl5 for IRIX 6.2!!! (Anton Dischner)
Re: Problem with HTML counter (J)
process handling (Alan Strassberg)
Re: process handling (Matti Kinnunen)
Q: Perl/Oracle across the net (Jeff Hecker)
Re: Questons <rootbeer@teleport.com>
Re: Re-Flowing ASCII Text (Matti Kinnunen)
Re: Re-Flowing ASCII Text <rootbeer@teleport.com>
regex problem <smalunjk@cisco.com>
Re: regex problem <rootbeer@teleport.com>
Re: Regex: Email format (A. Deckers)
Re: regular expression <rootbeer@teleport.com>
Re: regular expression (Tad McClellan)
Req help: Any easy way to CRC a file? (Brian - DKOnline)
Re: Syntax junkies ! <rootbeer@teleport.com>
Re: Syntax junkies ! <rootbeer@teleport.com>
System call for SGI IRIX please (Stephen Spence)
Re: Telnet & Perl, Reading Pictures xewj@odin.sunquest.com
Unique File Creation <steinkf@cs.purdue.edu>
unpack checksum ( Thomas Lachlan XMS x4206 )
Using Perl to Launch and Input to Program <jefpin@bergen.org>
Re: Using Perl to Launch and Input to Program (Tad McClellan)
Wanted ! <allied@pair.com>
Re: warnings under perl 5.004_01 that my script didn't (M.J.T. Guy)
WWWlib-perl5 module or a better way? (Mwebernet)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 21 Jul 1997 10:27:50 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
Subject: Re: Multiple Line Pattern Matching
Message-Id: <33D32B93.934750AC@adc.metrica.co.uk>
Tad McClellan wrote:
> Joseph June (jjune@miday.uchicago.edu) wrote:
>
> : I'm pretty new with Perl so my question is going to be pretty
> basic... but
> : I'm not sure how to do a pattern match on strings that are multiple
> : lines...
>
> : but is there a way to pattern match something like
>
> : ;coin
> : ;quarter
> : ;dime
> : and so on?
>
> So, the only specification you gave us is that we generate a 'match'
> for the above string?
>
> I can do that ;-)
>
> ---------------
> #! /usr/bin/perl -w
>
> $_=' ;coin
> ;quarter
> ;dime';
>
> if (/./) # this is silly, but it does answer the
> question.
> {print "matched\n"} # consider asking a better question...
> else
> {print "No match\n"}
> ---------------
>
> : Thank you for your help in advance!
>
> The value of the help you get here is often in direct proportion to
> the amount of thought given to phrasing the question ;-)
>
> --
> Tad McClellan SGML Consulting
> Tag And Document Consulting Perl programming
> tadmc@flash.net
In defense of the newbie ( I was one once and still am in many
respects, and I am sure you must have been many moons ago ) he did say
"something like" ;-)
Simon
------------------------------
Date: Mon, 21 Jul 1997 07:04:47 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Sanjeel Sheikh <ssheikh@netcomuk.co.uk>
Subject: Re: Need help with database
Message-Id: <Pine.GSO.3.96.970721070249.19811C-100000@kelly.teleport.com>
On Mon, 21 Jul 1997, Sanjeel Sheikh wrote:
> I would like to develolp an online catalogue. i do have a basic
> understanding of perl5 and cgi.
> i would like to know how to develop the database, which tools to use and
> if their is any software that would develop the datbase its name as
> well.
There are some modules on CPAN which may help you to use both databases
and the CGI interface.
http://www.perl.com/CPAN/
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 21 Jul 1997 17:36:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Djavad Amiri <amiri@ascinc.com>
Subject: Re: need perl v-4.035
Message-Id: <Pine.GSO.3.96.970721173552.6975D-100000@kelly.teleport.com>
On Mon, 21 Jul 1997, Djavad Amiri wrote:
> Is someone here who know where can I find the Perl version 4.035 or
> later
You can get the source for 5.004 and lots of other great stuff from CPAN,
the Comprehensive Perl Archive Network. Hope this helps!
http://www.perl.com/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 21 Jul 1997 14:42:58 GMT
From: mueller@iwf.bepr.ethz.ch (Mueller Beat)
Subject: newbie problem with $1
Message-Id: <5qvshi$4as$1@elna.ethz.ch>
consider the following short perl script :
#!/appl/bin/perl -w
$_ = "a sentence with __s__o__m__e highlithed __w__o__r__d__s is this.";
if (/((__.)+)/)
{
s//<b>$1<\/b>/g;
s/__//g;
}
print; print "\n";
exit 0;
the idea is a generate a string :
" a sentence with <b>some</b> highlithed <b>words</b> is this."
why does it exit with a segmentation fault ? i think the problem is
the $1 generated by the condition in if (). i could circumvent the
problem by using a variable other than $_ but $_ is here to be used.
i found nothing useful in the faq. (btw, i am using perl 5.0)
thanks a lot for your input...
BM
------------------------------
Date: Mon, 21 Jul 1997 16:37:52 GMT
From: Jamie Kinney <jkinney@us.oracle.com>
Subject: Oraperl and WinNT
Message-Id: <33D39060.2164ADB@us.oracle.com>
Does the installation of Oraperl or DBD/DBI for Perl 5.004 require
Microsoft Visual C++ for compilation? I have Borland C++ Dev Suite (v
5.0) and have had no luck installing DBD or DBI. Could anyone give me
some helpful advice on accessing an Oracle Database via Perl?
Thanks in advance,
Jamie Kinney
------------------------------
Date: Mon, 21 Jul 1997 13:22:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jodi Shephard <gt1295b@prism.gatech.edu>
Subject: Re: overwriting one line in txt file
Message-Id: <Pine.GSO.3.96.970721132221.7819Q-100000@kelly.teleport.com>
On Mon, 21 Jul 1997, Jodi Shephard wrote:
> What I want to do is update one line within the text file.
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq5/
How_do_I_change_one_line_in_a_fi.html
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 21 Jul 1997 14:57:19 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: perl V. HTML??
Message-Id: <b.wilkinson-2107971457190001@ip57-york.pindar.co.uk>
In article <01bc91e8$9bb4f860$6875e7c8@Term104>, "Sergio Stateri Jr"
<serginho@alpha.hydra.com.br> wrote:
> Fan Ng <FANNGMAIL@prodigy.net> escreveu no artigo
> <33cc36cf.489940@news.prodigy.net>...
> > Hello everybody:
> >
> > Can HTML do everything perl does??
> > Like Image or song or video??
> > Thanks
> >
> > fanng@prodigy.net
> >
>
> Of course that not. Perl is a language like any other High Level language,
> and HTML is a script language to do Home Pages.
>
No.
Perl is a computer language (unlike any other).
HTML is an SGML DTD which defines the order of tags in a valid HTML document.
Bob
--
.sig file on holiday
------------------------------
Date: Mon, 21 Jul 1997 15:45:01 +0200
From: dischner@_NO_SPAM_med.uni-muenchen.de (Anton Dischner)
Subject: Re: Perl5 for IRIX 6.2!!!
Message-Id: <dischner-ya02408000R2107971545010001@news.lrz-muenchen.de>
Hi John, Chris
i am no PERL expert. You may want to try this:
Make shure you used hintfile 6.0 and not 6.1 or something else.
Is your distribution OK. Yes, reload it, Look at 'df' as you extract it.
Make shure your / or /usr filesystem has enough space.
You may have permissions problems.
Use root-user as a brute force method.
I hope that helps,
Toni
In article <5qnvgl$sk3$1@nyheter.chalmers.se>, z93john@mtek.chalmers.se
(John I Quist) wrote:
> Anton Dischner (dischner@_NO_SPAM_med.uni-muenchen.de) wrote:
> : Hi Chris,
>
> : Why don't you make your own binaries ?
> : Get the source, use Irix 6.0 defaults.
> : The install is pretty straight-forward.
>
> May I disagree? :)
>
> Running 'make' gives this result:
>
> ...
> ./miniperl -Ilib pod/pod2text.PL
> Extracting pod2text (with variable substitutions)
> AutoSplitting perl library
> ./miniperl minimod.pl > tmp && mv tmp lib/ExtUtils/Miniperl.pm
> `sh cflags libperl.a perlmain.o` perlmain.c
> CCCMD = cc -n32 -DPERL_CORE -c -D_BSD_TYPES
-D_BSD_TIME -woff \
> 1009,1110,1184 -OPT:Olimit=0 -DLANGUAGE_C -O3
>
> Making DynaLoader (static)
> config: Cannot execute
> config failed, continuing anyway...
> all: Not found
> *** Error code 1 (bu21)
>
> Is there an easy answer to what's wrong?
> The machine in question is an SGI Indigo2.
> uname -a => IRIX64 ws935 6.2 06101031 IP28
> I tried to compile with thandard settings, using the hintfile you mention.
>
> /John.
--
A. Dischner, SGI&AIX sysadmin, Oracle DBA | Don't let friends
Institut fuer Klinische Chemie | use WinDose
Klinikum Grosshadern | Just say NO.
Ludwig Maximilians Universitaet Muenchen, GER | Please remove
Marchioninistr.15 81366 Muenchen 49-89-70953202 | _NO_SPAM for email.
------------------------------
Date: Sun, 20 Jul 1997 22:31:26 GMT
From: someone@test.net (J)
Subject: Re: Problem with HTML counter
Message-Id: <33d25dac.5788811@news.clara.net>
On Fri, 18 Jul 1997 13:08:43 +1000, Martien Verbruggen
<mgjv@comdyn.com.au> wrote:
>Katie Wright wrote:
>
>> I figure that I am going to have to some how add the gif files together
>> and then print but I don't know how.
>
>Yep, that is what you will have to do.
I have a CGI counter on my web page
(try http://users.ox.ac.uk/cgi-bin/safeperl/exet0068/cgicount.pl ) as
I can't guarantee that I will have fixed the page itself by then. It
just uses text (prints out the number). I originally wanted to have a
graphical counter, but then realised that a text would be better, as I
tend to surf with images off. With a text counter this doesn't matter,
and people can see very easily what its value is.
It's also easy to use font face tags on it as well (admittedly only
for >= netscape 3.0)
Joe Wickremasinghe
------------------------------
Date: 21 Jul 1997 09:55:59 -0700
From: alan@bali.seg.wj.com (Alan Strassberg)
Subject: process handling
Message-Id: <5r04av$sor@bali.seg.wj.com>
I want to test if a process has died, and restart it if it has.
A simple "ps ax | grep process" and restart if missing.
The script below works, but what's a "better" method ?
open (PROC, "ps -ax 2>&1 |") or die "cannot fork $!";
while (<PROC>) { push(@ps,$_); }
close(PROC);
# @ps array built, see if squid's in there
@sq = grep (/squid/,@ps);
system ('/u1/squid/bin/squid &') if ! @sq;
I've read perlfaq8 to no avail.
alan
--
alan@wj.com
------------------------------
Date: 21 Jul 1997 20:53:21 +0300
From: matti@universe.pc.helsinki.fi (Matti Kinnunen)
Subject: Re: process handling
Message-Id: <lzk9ikl2b2.fsf@universe.pc.helsinki.fi>
what do you think about:
{
open(SYS, "ps -ax| grep prog_to_check| grep -v grep |");
my($tmp) = <SYS>;
close <SYS>;
system ('prog_to_re-invoke') if ($tmp ne "");
}
--
- matti -
* matti.kinnunen@helsinki.fi
* +358-9-191 23978 / 621 44 02
* Ratakatu 11-13 B 19, 00120 Helsinki
* Finland
------------------------------
Date: 21 Jul 1997 18:22:28 -0400
From: jeff_h@cais2.cais.com (Jeff Hecker)
Subject: Q: Perl/Oracle across the net
Message-Id: <5r0nf4$c7a@cais2.cais.com>
Keywords: Oracle SQL Perl DBI DBD TCP/IP network
Greetings, I have a Perl/Oracle/network/DBI/DBD question:
We have two groups who want to share some data. One has an Oracle 7
database running on a NT server. The other group is a Unix group. I'd
like to be able to connect the Unix box as an Oracle client.
I've checked the DBI/DBD readme files and think I'm missing some
pieces. I don't have Oracle on my Unix boxes - not to mention a
development system. Is there a way around that? Our Oracle is an
umpti-ump client license... We have PC and Mac clients... Is the
need for an oracle development system technical or legal? What
prevents some pre-compiled DBD .o files in CPAN?
I hope I am missing something obvious. Any other ideas?
TIA / Jeff
___________________________________________________________________
Jeff Hecker / wb3bdy U.S. Senate Democratic Policy Committee
Jeff_h@cais.com Washington DC, 20510
(202) 224-3232 Working to be a Microsoft-free environment
------------------------------
Date: Mon, 21 Jul 1997 07:56:58 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ed Vander Bush <temp.ed.vanderbush@bentley.com>
Subject: Re: Questons
Message-Id: <Pine.GSO.3.96.970721074402.19811I-100000@kelly.teleport.com>
On Mon, 21 Jul 1997, Ed Vander Bush wrote:
> Subject: Questons
Please check out this helpful information on choosing good subject lines.
It will be a big help to you in making it more likely that your requests
will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> I just compiled the source code for Perl V 5.0004_01 on my Linux sys. In
> my usr/bin dir I now have , Perl, perl5.003 and perl5.0004 should I
> delete the first 2 and rename the last to 'perl' inorder to have my
> programs refer to that?
Could it be that you already have what you need? Use the -i option to ls
to look at the inode numbers of those three binaries, and you'll probably
find that /usr/bin/perl is the exact same binary as /usr/bin/perl5.004.
That way, when your script starts with the customary #!/usr/bin/perl line,
you'll get the latest version.
If, for some reason, you worry that you won't be able to update an old
script to work with 5.004 (which is a pretty simple update, if anything is
needed at all) simply keep everything as you have it, and just change that
script's header to refer to /usr/bin/perl5.003.
> Also If I wrtie a program in Vi or any editor and save it (Say
> as 'hello') then type chmod u+x hello then type hello all I get is bad
> command If I type perl hello it works What can I do about this?
Make sure that your PATH includes the current directory, '.', or include
it explicitly in the command line:
./hello
If you're unclear about inodes and your PATH, you'll find info about them
in any good intro to Unix, or in your system's docs. If you still have
questions about these things after reading the docs, a Unix newsgroup
would be a good place to ask.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 21 Jul 1997 15:58:25 +0300
From: matti@universe.pc.helsinki.fi (Matti Kinnunen)
Subject: Re: Re-Flowing ASCII Text
Message-Id: <lzn2nglfym.fsf@universe.pc.helsinki.fi>
Maybe the following script will meet your needs:
---------------------------------------------------------------
#! /usr/bin/perl
#
# To split after 1st $DELIM, which is after $LIMIT chars
#
# MJK 2.6.1997, for Ruurik thesis
$LIMIT = 10; # after how many char we split
$DELIM = ',' ; # delimiter ( Ruurik asked for comma)
# do not change anything below this line
while(<>) {
$line = $residual.$_;
if (length($line) <= $LIMIT) {
print $line;
$residual = "";
next;
}
else {
my($tmp) = substr($line,0,$LIMIT);
print $tmp;
my(@arr) = split (//,substr($line,$LIMIT));
while ($#arr != 0 ) {
print $arr[0];
last if ( $arr[0] eq $DELIM );
shift @arr;
}
print "\n";
shift @arr;
$residual = join '',@arr;
}
}
------------------------------------------------------------
--
- matti -
* matti.kinnunen@helsinki.fi
* +358-9-191 23978 / 621 44 02
* Ratakatu 11-13 B 19, 00120 Helsinki
* Finland
------------------------------
Date: Mon, 21 Jul 1997 07:17:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Marc Haber <s_haber@ira.uka.de>
Subject: Re: Re-Flowing ASCII Text
Message-Id: <Pine.GSO.3.96.970721071533.19811E-100000@kelly.teleport.com>
On Mon, 21 Jul 1997, Marc Haber wrote:
> I would like to have a perl program that takes a text file and
> re-flows it to some other line width while preserving paragraphs.
> Before writing it myself, I'd like to ask if this special kind of
> wheel already has been invented.
Good thinking! When you suspect that a particular Perl wheel has been
invented (and perhaps even documented and debugged) stop by the wheel
supply at CPAN, where the modules list can let you know what's going on.
If you ever find that your kind of wheel isn't in stock, feel free to
contribute. But I think you'll find something to your liking in the Text
modules department. Hope this helps!
http://www.perl.com/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 21 Jul 1997 14:44:00 -0700
From: Sanjay Malunjkar <smalunjk@cisco.com>
Subject: regex problem
Message-Id: <33D3D820.7A587A4@cisco.com>
Hi,
I had a quick look at the perl FAQ and couldn't find anything related
to my question.
I am sure others must have run into this problem too. Here goes my
problem:
#sample code
#!/usr/local/bin/perl5
$restricted_chars='@\^%\?~;<>\\\*\|`&\$!#\(\)\[\]\{\}:\'"';
#I am trying escape some characters in a string if that character is not
#already escaped.
map {print;~s/([^\\])([$restricted_chars])/$1\\$2/go;print
",escaped=$_\n"}
qw( sanjay sajasndasdj$%^@!*()[]{}\/ &;`'\"|*?~<>^()[]{}$);
When I run this code,it seems to only escapes every second character.
This is the output I get:
sanjay,escaped=sanjay
sajasndasdj$%^@!*()[]{}\/,escaped=sajasndasdj\$%\^@\!*\()\[]\{}\\/
&;`'\"|*?~<>^()[]{}$,escaped=&\;`\'\"\|*\?~\<>\^(\)[\]{\}$
Obviously,I seem to be missing something here. What is it?
thanks in advance
sanjay
------------------------------
Date: Mon, 21 Jul 1997 17:30:12 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Sanjay Malunjkar <smalunjk@cisco.com>
Subject: Re: regex problem
Message-Id: <Pine.GSO.3.96.970721172905.6975B-100000@kelly.teleport.com>
On Mon, 21 Jul 1997, Sanjay Malunjkar wrote:
> #I am trying escape some characters in a string if that character is not
> #already escaped.
Before anyone wades through your code to find the bug, could you tell us
whether quotemeta() might do what you need more simply? Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 22 Jul 1997 16:03:21 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: Regex: Email format
Message-Id: <slrn5t9me7.oq4.I-hate-cyber-promo@news.rediris.es>
In <33D4B73C.226C51D6@in.net>,
Mark Schwartz <mcs@in.net> wrote:
>I have written a regex to verify data input to the 'Email Address' field
>of a form I have written.
[...]
>Any assisstance in this matter would be greatly appreciated!
Just as long as you realise that there is not foolproof method of
"verifying" an email address, short of sending it a message and waiting
for a reply. (Search the Perl FAQ for 'email address'.)
If you are going to try and do this anyway, don't bother reinventing
the wheel. Use Tom Christiansen's ckaddr script. You'll find it on
CPAN.
(followups set to more appropriate group)
Alain
--
Perl information: <URL:http://www.perl.com/perl/>
Perl archive: <URL:http://www.perl.com/CPAN/>
Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<
------------------------------
Date: Mon, 21 Jul 1997 13:02:36 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jim Shi <jims@ss5mth44.franklin.com>
Subject: Re: regular expression
Message-Id: <Pine.GSO.3.96.970721125703.7819L-100000@kelly.teleport.com>
On Mon, 21 Jul 1997, Jim Shi wrote:
> Subject: regular expression
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> why the two following program prints diiferent results:
Because you asked them to do different things. :-)
> A.
> $line = "ababc";
> $line =~ /a|ab/;
> print $&;
>
> => "a"
Perl always stops at the first match it finds, rather than hunting around
(for what may be a _very_ long time) to find one that may be better. So,
it finds the a, and it's done.
> B.
> $line = "ababc";
> $line =~ /ab?/;
> print $&;
>
> => "ab"
But by default, if it can go further once its found a match, it's as
"grabby" as possible. So, since it could go on to match the b, it did.
For more information about regular expressions and why they are the way
they are, I heartily recommend the "Hip Owls" book. "Mastering Regular
Expressions" by Jeffrey Friedl, O'Reilly, ISBN 1-56592-257-3, $29.95 or
so. It's very entertaining and informative.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 21 Jul 1997 16:45:13 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: regular expression
Message-Id: <99l0r5.mbb.ln@localhost>
Jim Shi (jims@ss5mth44.franklin.com) wrote:
: why the two following program prints diiferent results:
: A.
: $line = "ababc";
: $line =~ /a|ab/;
: print $&;
: => "a"
: B.
: $line = "ababc";
: $line =~ /ab?/;
: print $&;
: => "ab"
Tom has pretty much answered the question in his followup.
Just let me add that to "fix" the first one, put the longer alternatives
first in the regex:
$line =~ /ab|a/;
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Tue, 22 Jul 1997 13:17:23 GMT
From: Brian@dkonline.com (Brian - DKOnline)
Subject: Req help: Any easy way to CRC a file?
Message-Id: <33d4b1ee.4384805@pub.news.uk.psi.net>
I'd like a way to uniquely identify a file (or be pretty certain) so
that I can flag duplicate files even if (and especially if) their
filename varies.
I'd like to use the "find" module to build up a hash of signatures and
report quickly if duplicate files are found. There's probably a module
out there that will generate a Cyclic Redundancy Check number or
signature for a file if only I can find it.
Can anyone help?
Please email as well as post a resonse so that I get the answer.
TIA
Brian@dkonline.com
------------------------------
Date: Tue, 22 Jul 1997 12:51:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bruce Davidson <allied@pair.com>
Subject: Re: Syntax junkies !
Message-Id: <Pine.GSO.3.96.970722124203.6115O-100000@kelly.teleport.com>
On Tue, 22 Jul 1997, Bruce Davidson wrote:
> Subject: Syntax junkies !
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> hi,
Hello to you, too.
> this kindly donated from this group.
That sentence no verb.
> My choice of opening and closing handles.
>
> #!/usr/bin/perl
>
> {
> open (SOURCE,"/mydir/file1.html");
> open (DESTINATION, ">/mydir/file2.html");
You should really check the return values from those operations.
> while (<SOURCE>) {
> print DESTINATION $_;
> }
> close (SOURCE);
> close (DESTINATION);
> }
> # end of file
>
> Purpose - to use a browser to copy one file over another at the server.
There are easier and more efficient ways to do that.
> Why - who cares :)
>
> Works on telnet login with free bsd C shell in cgi-bin using "perl
> script.pl".
> My other small scripts just need "script.pl" to operate.
> Don't understand why this needs the "perl" prefix.
Maybe you named it 'test' or the name of another shell built-in? Maybe you
don't have your PATH or permissions set right?
> I'd like to call this from my browser links, but when I try, the server
> reports an error so I don't even get as far as when on telnet.
Sounds like a server problem, instead of a perl problem. But what error
does the server report? "Insufficient permissions"? "File not found"?
"Script on fire"? Maybe it has something to do with the fact that you
haven't implemented the CGI protocol in your script.
> I'd also like the browser to print NEWFILE = OK chum, we overwrote file 2
> with file 1.
> Syntax needed.
After you've read the docs and FAQs, if you still have questions about
Perl, those questions are welcome here. The print operator is documented
in perlfunc(1).
> Any folks got a steer on this please.
> Could it be file permissions on the server.
Yes, it could be. If you're not sure of what permissions your server
needs, check its docs. If you're still not sure, a server newsgroup (or
their FAQ) should be of some help.
> The script is chmod 755.
That's a good start. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 22 Jul 1997 23:08:41 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Faust Gertz <faust@wwa.com>
Subject: Re: Syntax junkies !
Message-Id: <Pine.GSO.3.96.970722225859.23134H-100000@kelly.teleport.com>
On Tue, 22 Jul 1997, Faust Gertz wrote:
> >> this kindly donated from this group.
> >
> >That sentence no verb.
> Isn't 'donated' a verb?
Not the way I parsed that sentence.
One: 'This [code was] kindly donated from this group.'
Two: 'This [code? sentence?] kindly donated [some object]
from this group.'
I see it as the first option, which makes 'donated' a predicate adjective
participle. But I'm no grammarian, so I could be wrong. And someone will
soon tell me if I are. :-)
Followups to alt.usage.english, and I don't even have to change the
subject line!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 22 Jul 1997 10:54:49 +1000
From: sspence@mincom.com (Stephen Spence)
Subject: System call for SGI IRIX please
Message-Id: <5r10cp$hjj$1@pithy.mincom.oz.au>
Could somebody give me an example of a system call using SGI IRIX ?
Thx in Advance,
Stephen
This is an example from a SUN running 5.5.1:
#!/usr/local/bin/perl5.003
package main;
require "sys/syscall.ph";
$dir="/";
$fmt = "\0" x 512;
$res = syscall (&main::SYS_statvfs, $dir, $fmt) ;
($bsize, $frsize, $blocks, $bfree, $bavail, $files,
$ffree, $favail,$fsid,$fbasetype) = unpack ("L9C", $fmt);
printf STDOUT "A=#$fsid# B=#$fbasetype#\n";
Results : A=#8388632# B=#117#
------------------------------
Date: 21 Jul 1997 16:43:49 GMT
From: xewj@odin.sunquest.com
Subject: Re: Telnet & Perl, Reading Pictures
Message-Id: <5r03k5$aef$1@iggy.sunquest.com>
In article <33CACCEA.582B@ainet.com>,
Joseph M. Scott <jmscott@ainet.com> wrote:
>Alex `Taker` Pircher wrote:
>> open(output,">$Input");
>> print(output, "http://www.server.com/pic.jpg HTTP/1.1\n\n");
>> close(output);
>> open(telnet,"telnet wwwcache 80 <$Input 2>$Errors |");
>> binmode(telnet);
>> ...
>> It seems to work correct, if I test it within a shell, but as a CGI
>> the Picture is broken. But why? I think I made everything correctly.
>
>Probably because you don't have the full path given to telnet, or maybe
>permissions so that the webserver trying to run this can execute
>telnet. Although that seems like a lot of work for a cgi app, since
>including the image in the html is much easier :-)
It's simpler than that- telnet is defaulting to a 7-bit connection. The 8-bit
chars in the jpg are either getting stripped or translated.
You either need to explicitly set binary in the telnet session or don't use
telnet.
------------------------------
Date: 21 Jul 1997 19:12:37 GMT
From: "Karyl F. Stein" <steinkf@cs.purdue.edu>
Subject: Unique File Creation
Message-Id: <5r0cb5$549$0@206.85.222.24>
I am trying to write a subroutine that takes a seed, creates a unique
file based on that seed, and returns the nme and a filehandle to the new
file. What I did is this:
sub CreateFile {
my $File = $_[0];
my $Postfix = $$;
if (defined $File) { $File .= "." }
else { $File = "" }
while (1) {
sysopen FILEHANDLE, "$File$Postfix",
O_WRONLY | O_CREAT | O_EXCL, 0600;
if ($! != 0) {
if ($! eq "File exists") { ++$Postfix; $! = 0 }
else { print "Fatal Error: $!\n"; return }
} else { return ("$File$Postfix", \*FILEHANDLE) }
}
}
Unfortunately, if I call this subroutine twice without closing the file
created by the first call, the second call will return the existing
filehandle. Any ideas on how I could get a unique filehandle returned
for each call?
Thanks,
Karyl
------------------------------
Date: 22 Jul 1997 11:08:26 GMT
From: etltsln@etlxd30.ericsson.se ( Thomas Lachlan XMS x4206 )
Subject: unpack checksum
Message-Id: <5r24ba$l9n@newstoo.ericsson.se>
Hello,
I'm currently working on a software audit tool. One component
of this tool deals with calculating checksums for files of
interest/ importance. Calling the UNIX sum program continously
is slow and requires more of the systems resources i.e. memory etc.
For the rest of the auditing functions have been implemented in perl.
As a result I tried to solve the problem in perl using the
unpack function. Various examples, predominatley in the Camel
book and the perlfunc man page give inserts of how to achieve
this. Unfortunately the results obtained after using these
methods do not equate to those returned by sum. My knowledge
on this subject is very limited. However my assessment of the
problem would be that the way I read in the file is causing the
funny results. I.e. some files do not have end of line CTRL chars
etc.
I am trying to emulate the /usr/5bin/sum command on a Sun sparc
processor running SunOS 4.1 and perl 5.1.
The code I have come up with so far is as follows:
open(FILE,"<$absolute_entry") || die "$!\n";
for( read FILE, $_, 1092)
{
$sum += unpack("%16C*",$_);
}
$sum %= 65535;
close(FILE);
-----
I would be most grateful if someone could give me a few hints
or ideas as how to solve this problem. It would better still
if the solution did not read in whole files at once and was
as emeory efficient as poss.
Anyway thanks for reading this and all advice will be
graciously appreciated.
Regards and Thanks Tom
------------------------------
Date: Mon, 21 Jul 1997 12:43:43 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
Subject: Using Perl to Launch and Input to Program
Message-Id: <Pine.SGI.3.96.970721124232.13392A-100000@davinci.bergen.org>
I am doing sysadmin work for my school, and I would like to know how I
send commands to a program...
It is used for finding out how long people have been dialed-in.
Basically, what is the syntax for entering commands in a Perl script?
----------------
| "You care... but I don't care."
| - Ken Mayers
----------------
Jeff "TechMaster" Pinyan | http://www.bergen.org/~jefpin
HTML/CGI Designer and Consultant and JavaScripter
jefpin@bergen.org | TechMasterJeff@juno.com
Got a JavaScript/CGI/Perl question or problem? Let me know!
webXS - the new eZine for WebProgrammers! webXS@juno.com
Visit us @ http://www.bergen.org/~jefpin/webXS
------------------------------
Date: Mon, 21 Jul 1997 16:42:44 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Using Perl to Launch and Input to Program
Message-Id: <k4l0r5.mbb.ln@localhost>
TechMaster Pinyan (jefpin@bergen.org) wrote:
: I am doing sysadmin work for my school, and I would like to know how I
: send commands to a program...
Well, that kinda depends on where the 'program' reads commands from ;-)
: It is used for finding out how long people have been dialed-in.
: Basically, what is the syntax for entering commands in a Perl script?
Since you haven't told us where 'program' reads 'commands' from,
I will assume that it reads from STDIN:
---------------
#! /usr/bin/perl -w
open(PROG, "| program") || die "could not fork";
print PROG "first command\n";
print PROG "second command\n";
close(PROG) || die "problem running 'program'";
---------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Mon, 21 Jul 1997 19:29:37 GMT
From: "Bruce Davidson" <allied@pair.com>
Subject: Wanted !
Message-Id: <01bc9609$d7619560$0422989e@allied.demon.co.uk>
Any kind perly show me a script for "copy filename1 filename2"
easy I suppose but I haven't a clue
thanks
BD
allied@pair.com
------------------------------
Date: 21 Jul 1997 16:49:20 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: warnings under perl 5.004_01 that my script didn't give in perl 5.003
Message-Id: <5r03ug$epb@lyra.csx.cam.ac.uk>
In article <33D38F67.4C66@up.net>, Raymond K. Bush <rbush@up.net> wrote:
>Should i be concerned with the following:
>
>Value of <HANDLE> construct can be "0"; test with defined() at
>/usr/local/sbin/in.qpage.d line 49.
If you "use diagnostics;" you can get questions like this answered
automatically in seconds, instead of having to wait for a Usenet response:
%perl -Mdiagnostics -we 'while ($_=<>) {}'
Value of <HANDLE> construct can be "0"; test with defined() at - line 1 (#1)
(W) In a conditional expression, you used <HANDLE>, <*> (glob), each(),
or readdir() as a boolean value. Each of these constructs can return a
value of "0"; that would make the conditional expression false, which is
probably not what you intended. When using these constructs in conditional
expressions, test their values with the defined operator.
Mike Guy
------------------------------
Date: 22 Jul 1997 02:03:27 GMT
From: mwebernet@aol.com (Mwebernet)
Subject: WWWlib-perl5 module or a better way?
Message-Id: <19970722020300.WAA19423@ladder02.news.aol.com>
Do you know how to retrieve web pages on remote systems with perl? The
only way I know of is with the libwww module. Is there another way?
Thanks,
M. Weber
http://cow.dyn.ml.org/caboose/
------------------------------
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 756
*************************************