[7151] in Perl-Users-Digest
Perl-Users Digest, Issue: 776 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 25 03:27:14 1997
Date: Fri, 25 Jul 97 00:00:40 -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 Fri, 25 Jul 1997 Volume: 8 Number: 776
Today's topics:
Re: "Use of uninitialized value" without using a value <rootbeer@teleport.com>
Re: "Use of uninitialized value" without using a value (Ilya Zakharevich)
Re: ?? mail bouncer (Alan K. Jackson)
Arrays, FILEHANDLES, and Efficiency (J. Paul Reed)
Re: Can't match = <rootbeer@teleport.com>
Re: CGI.PM Form refreshing (Greg Zevin)
Re: Creating directories? <mikec@dlpco.com>
cross compiling <falcon+@CMU.EDU>
Re: eval causing core dump in Perl5 but not in Perl4 (Charles DeRykus)
help on perl accessing database (Zhigang Xu)
Re: how to do system(@array) with backticks <sfairey@adc.metrica.co.uk>
how to reverse substitution order ? <proux@geocities.com>
Re: how to reverse substitution order ? (Abigail)
Re: How to set precision <rootbeer@teleport.com>
Re: Integer arrays in an XS extension.. <marius@funcom.com>
Re: Matching lowercase in regexp? <rra@stanford.edu>
Re: MD5 in PERL? <broomberg@ccgroupnet.com>
mysqlperl on BSDI 3.0 (Brent)
Newbie Post! Heads up! (file question) <jamie@comet.net>
Number of records in a Berkley DBM file (Yves Dagenais)
problem with simultaneous calls to same script <awhitehead@netmart.co.uk>
Re: Q: empty elements in arrays (Honza Pazdziora)
Re: Req help: Any easy way to CRC a file? <broomberg@ccgroupnet.com>
Re: socket help (brian d foy)
Sorting a database by date (Jye Tucker)
Re: string length (Nathan V. Patwardhan)
Re: Stumped by a regexp <rootbeer@teleport.com>
System call doesn't work right! (Jack Tran)
thorny little regexp problem (Nick Tonkin)
Re: Unique File Creation <sfairey@adc.metrica.co.uk>
Win32 and NFS on a win95 pc (Gary Broxterman)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 24 Jul 1997 18:57:49 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Larry D'Anna <ldanna@hotmail.com>
Subject: Re: "Use of uninitialized value" without using a value - why?
Message-Id: <Pine.GSO.3.96.970724185153.25109J-100000@kelly.teleport.com>
On Thu, 24 Jul 1997, Larry D'Anna wrote:
> You have to do it like this:
>
> perl -w -e die
>
> perl doesn't let you put a bunch of options together after one dash like
> ls.
Actually, that turns out not to be the case.
perl -we die
That's the same as separating the -w and -e options, since -w doesn't
expect anything special to follow it. But if you reverse the order, things
are different:
perl -ew die
Now, we're executing the script 'w' (which is a valid, although useless,
statement in Perl!) and 'die' is a parameter to the script(!).
Perl does what you ask it to do, even when you don't know what you've
asked it to do.... :-)
--
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: 25 Jul 1997 02:05:32 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: "Use of uninitialized value" without using a value - why?
Message-Id: <5r91lc$e28@agate.berkeley.edu>
In article <Pine.GSO.3.96.970724185153.25109J-100000@kelly.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
> perl -ew die
>
> Now, we're executing the script 'w' (which is a valid, although useless,
> statement in Perl!) and 'die' is a parameter to the script(!).
>
> Perl does what you ask it to do, even when you don't know what you've
> asked it to do.... :-)
Just to clarify a little bit: it executes a "script" which *contains*
a simple letter 'w'. It got me a little bit confused until I
understood that Tom knew what he was explaining... ;-)
monk:~->perl -w -ew die
Unquoted string "w" may clash with future reserved word at -e line 1.
Useless use of a constant in void context at -e line 1.
Ilya
------------------------------
Date: 23 Jul 1997 12:06:31 GMT
From: ajackson@mactra.brc.shell.com (Alan K. Jackson)
Subject: Re: ?? mail bouncer
Message-Id: <slrn5tbsu4.lkv.ajackson@mactra.brc.shell.com>
In article <01bc96ba$e84a5400$0701de89@null.bris.ac.uk>, Alex Matthews wrote:
> Could anyone make any suggestions where I might find or maybe go about
> writing a perl script that bounces incoming mail to my virtual domain if
> the To: header does not contain my preferred email address(es).
>
> Alex Matthews
> alex@darkfire.com
> http://darkfire.com/alex
I use Zfilter. Since it is in perl, I could hack it to "do more"
to bounce and complain about spam.
Look at http://www.oasis.leo.org/perl/scripts/net/mail/00-index.html
for a copy of it and other resources...
--
Alan K. Jackson - BTC - Quantitative AVO Team
Shell E&P Technology Co (a wholly owned subsidiary of Shell Oil Co)
voice :(713)245-7355 fax :(713)245-7492 snail :Box 481,Houston,Tx 77001
UUCP: ...!{uupsi}!shellus!ajackson INTERNET: ajackson@shellus.com
------------------------------
Date: 23 Jul 1997 07:29:11 GMT
From: preed@psd.k12.co.us (J. Paul Reed)
Subject: Arrays, FILEHANDLES, and Efficiency
Message-Id: <5r4bs7$fss$1@mercury.psd.k12.co.us>
That subject really doesn't do my question justice, but here it is anyway:
I need to modify one line of a large file that has a format somewhat
similar to /etc/passwd (i.e. fields separated by a separator character,
one entry per line).
I need to have the functionality of changing one line. Is there anyway to
do this?
Currently, I do this:
1. Open file, read it into an array, one entry per line.
2. Find what I want, modify it in the array.
3. Write the entire array back out to the file.
But, this is memory and processor intensive and then people have to wait
for this function to end before they can add entries to that file.
Is there some kind of cool open() statment I can use to tell perl to both
read in the file and write to it at the same time. I've looked in the perl
faqs, specifically the "How do I" section and didn't find anything
helpful.
Your help would be appreciated.
Thanks for your time!
Later,
Paul
-------------------------------------------------------------------
J. Paul Reed preed@psd.k12.co.us || paul@619pro.com
Such a noble creature; a quality we sometimes lack...
--Borg Queen; Star Trek: First Contact
Geek Code and various other frivolities at www.psd.k12.co.us/~preed
------------------------------
Date: Tue, 22 Jul 1997 23:26:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Roberto L. Dorich" <rdorich@allegro.cs.tufts.edu>
Subject: Re: Can't match =
Message-Id: <Pine.GSO.3.96.970722232036.23134L-100000@kelly.teleport.com>
On 22 Jul 1997, Roberto L. Dorich wrote:
> I'm trying to process all the lines in a file with the following format:
>
> SOME_ID = some_num,
> ^--- the , is optional.
>
> So I do:
>
> while ($line = <file>)
Actually, although this is irrelevant to your problem, that line should
look something like this.
while (defined($line = <FILE>)) {
> {
> next if ($line =~ /\w+\b*=/);
That's odd. \b is a word boundary, but it's a zero-width assertion. So,
\b* would be you either have a word boundary or you don't. Since that's
always true, you could leave it out, making the pattern /\w+=/. So, you're
skipping any line with an equals sign immediately after a word character.
Is that what you want to be doing? Maybe you want this?
next unless $line =~ /\w+\s*=/;
Or this?
next unless $line =~ /\w+\s*=\s*\d+,?/;
> process($line);
> }
>
> Now the problem is that none of the lines get processed!
Do they all have an equals sign immediately after a word character? If
not, try using the debugger and stepping through your script. I think
you'll find that Perl is doing as you ask. Good luck!
--
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: 25 Jul 1997 10:25:27 +1000
From: greg@turing.une.edu.au (Greg Zevin)
Subject: Re: CGI.PM Form refreshing
Message-Id: <5r8rpn$ieu@turing.une.edu.au>
Gip <gibsonc@aztec.asu.edu> writes:
>After the user hits the 'submit' button, I want the browser to refresh
>the form, not post the new form after it. (Based on what the user has
>entered, I auto-fill the remaining portion of the form, but the new form
>is posted after the old form)
>What do I have to do to do this?
>(I've just started using CGI.PM on nt 3.51)
>Thanks for your time.
Well, the easiest solution would be using JavaScript event handlers.
There are events onClick (for the button) and onSubmit for the form
which could be used for this purpose.
Greg Zevin
------------------------------
Date: 22 Jul 1997 20:45:57 GMT
From: "Mike Cloppert" <mikec@dlpco.com>
Subject: Re: Creating directories?
Message-Id: <01bc96df$5484bd30$058d48ce@mikec>
Rei Baker <rxt117@psu.edu> wrote in article <33B41ADA.48B4@psu.edu>...
> Is there any way I can create new directories with Perl?
>
> Rei
>
You can do a
$command="mkdir new_dir";
system(command);
if you're running under UNIX. Obviously, if you're under DOS, that command
would be "md new_dir".
- - - - - - - - - - - - - - - - - - - - - - - - - -
Mike Cloppert mikec@dlpco.com
Internet Development/ http://www.dlpco.com/
Software Support Engineer
DLP Technologies, Inc.
SCO Premier Service & Support
------------------------------
Date: Fri, 25 Jul 1997 00:04:41 -0400
From: Chen Ling <falcon+@CMU.EDU>
Subject: cross compiling
Message-Id: <Enq2LNa00YUq0K3lk0@andrew.cmu.edu>
Hi, I am trying to cross compile Perl for a platform
that I just can't put a C compiler on.
I know that perl does not support cross compiling,
but does anyone here know how I can do it anyways?
thanks, and please reply by email.
Chen
+--------------------------------------------------------------------------+
| Chen Ling -- falcon@cmu.edu -- http://falcon.res.cmu.edu |
| Carnegie Mellon University |
| SMC 833 P.O.Box 3210 |
| Pittsburgh, PA 15230-3210 |
+--------------------------------------------------------------------------+
| "You have the option of insanity. I do not. And that makes me crazy!" |
| -- Brian, to Angela, My So-Called Life |
+--------------------------------------------------------------------------+
------------------------------
Date: Fri, 25 Jul 1997 01:10:25 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: eval causing core dump in Perl5 but not in Perl4
Message-Id: <EDuoLE.Atr@bcstec.ca.boeing.com>
In article <33D7EA70.5531@interlog.com>,
Rick Delaney & Sara Colman <rdelaney@interlog.com> wrote:
> I am using version 4.0, Revision: 4.0.1.7, Patch level: 36 and
> version 5.003 with EMBED built under dgux.
>
> Here is my code fragment:
>
> $net="12,14,16..18";
> @net=eval "($net)";
> print "@net\n";
>
> Under Perl4 I get
> 12 14 16 17 18
>
> but under Perl5 I get Segmentation Fault: core dumped.
>
> I would really like to get this working in perl5 so I can use its
> features for the rest of my script. The value of $net can change in the
> full script (or I wouldn't be using eval).
>
> Is there some (short) way of coding this without eval?
> Am I using eval incorrectly?
> Do I need to get perl5.004 to fix this?
>
You could do this:
for (split(/,/,$net)) { push(@net, /\.\./ ? $`..$' : $_) }
perl5.004 would be an even better choice though.
HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com
------------------------------
Date: 25 Jul 1997 04:01:47 GMT
From: zhigangx@lab41.eng.auburn.edu (Zhigang Xu)
Subject: help on perl accessing database
Message-Id: <5r98fb$6ch@ultranews.duc.auburn.edu>
I just installed perl5 on Linux. I am trying to biuld an appliction that using perl to access databse. There ae some database modules at/usr/lib/perl5, such as DB_File.pm, SDBM_File.pm .. How do I use these module? How do build database tables?
And Also There is database server engine called mSQL which can run on Linux. Is there any interface availiable between Perl and mSQL?
Please send your reply to zhigang@eng.auburn.edu
Thanks
Richard
------------------------------
Date: Tue, 22 Jul 1997 12:28:04 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: marek.rouchal@HL.Siemens.DE
Subject: Re: how to do system(@array) with backticks
Message-Id: <33D49944.C72BA9DE@adc.metrica.co.uk>
Marek Rouchal HL CAD SYS Tel. 25849 wrote:
> I'd like to execute a command (e.g. `date') without invoking an extra
> shell AND
> capture the standard output.
>
> The first requirement is met by system(@array), where array consists
> of the command
> name and the arguments.
>
> The second requirement is met by backticks like `command`, but this
> seems to invoke
> a shell to execute "command" no matter what.
>
> Any pointers are appreciated!
>
> Cheers,
>
> Marek
>
> PS. To reply by mail, please remove -nospam- from the address.
> Thank You.
>
> +--------------------------------------------------------------------+
>
> Marek Rouchal
> SIEMENS AG Phone : +49 89/636-25849
> HL CAD SYS Fax : +49 89/636-23650
> Balanstr. 73 mailto:Marek.Rouchal@-nospam-hl.siemens.de
> 81541 Muenchen
> PCmail:Marek.Rouchal.PC@-nospam-hl.siemens.de
> +--------------------------------------------------------------------+
How about opening a pipe as follows:
open DATE, "date|";
while(<DATE>){
chomp;
print "\nCmd returned:<$_>";
}
close DATE;
Hope this gives you something to look into.
Simon
------------------------------
Date: Wed, 23 Jul 1997 11:08:01 +0200
From: Proux Jean-Philippe <proux@geocities.com>
Subject: how to reverse substitution order ?
Message-Id: <33D5C9F1.41C6@geocities.com>
hi,
I don't find in faq.
I don't find in man.
so how to reverse order of substitution in pattern matching in perl
for instance:
$chemin=toto/titi/tutu/../dudu/./data
My goal is to obtain:
$chemin=toto/titi/dudu/tata
like in ls unix !
if I use:
$chemin =~ s/\/\w*\/\.\.//g;
$chemin =~ s/\.\///g;
every think all right, but if my string is like:
toto/titi/tutu/../../dudu/./data
I hope
toto/dudu/data
but perl return
toto/titi/.dudu/data
because order is from the right to the left
so how to reverse order ?
thanks.
------------------------------------------------------------------------
Proux Jean-Philippe
E-Mail: Proux@idris.fr
------------------------------
Date: Fri, 25 Jul 1997 03:31:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how to reverse substitution order ?
Message-Id: <EDuv4y.1p7@nonexistent.com>
Tom Phoenix (rootbeer@teleport.com) wrote on 1422 September 1993 in
<URL: news:Pine.GSO.3.96.970723074010.14902A-100000@kelly.teleport.com>:
++
++ I think you're saying that you have a file or directory path and you wish
++ to reduce it to eliminate redundant references to . and .. within it. You
++ should know that symbolic links can make the parent directory of
++ foo/bar/.. something other than foo. So, one way to do what you want may
++ be to use the readlink() function to resolve symbolic links.
Uhm, I've yet to encounter a program that doesn't resolve foo/bar/..
to foo/, even if foo/bar is a symlink to /something/else.
Even doing cd foo/bar; stuff; cd ..; brings me to foo, while
doing stuff in /something/else.
Or am I just lucky?
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Thu, 24 Jul 1997 19:08:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: urs@isnogud.escape.de
Subject: Re: How to set precision
Message-Id: <Pine.GSO.3.96.970724190754.25109K-100000@kelly.teleport.com>
On 24 Jul 1997, Urs Thuermann wrote:
> Is there also a module for 64bit integers or arbitrarily sized ints?
Maybe you're thinking of Math::BigInt, which comes with Perl. 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: 23 Jul 1997 11:14:46 +0200
From: Marius Kjeldahl <marius@funcom.com>
Subject: Re: Integer arrays in an XS extension..
Message-Id: <52zprem8op.fsf@ace.funcom.com>
>>>>> "Erik" == Erik Assum <erik@scandinaviaonline.se> writes:
Erik> [ Marius Kjeldahl ] | Could somebody give me a hint what
Erik> kind of types I need to define in | typemap, and the
Erik> necessary routines for translating the data back and | forth
Erik> in perl?
Erik> You might want to take a look at
Erik> http://www.cs.utah.edu/~beazley/SWIG/
Thanks, I have just looked at it. However, I am still not able to do
the thing I want to do. After working my way through the "Converting a
Perl5 array to a char **" and doing the necessary modifications to
work with a int * instead of the char **, I now have the following
problem:
How to determine the length of a C integer array? The example in SWIG
uses the fact that the array is terminated by a zero string, and
therefore it can not be directly modified to suit my purpose.
Basically, what I want to be able to do is to call some function from
perl, like this:
Mymodule::somefunc (\@arraytobemodified);
..where the C function will modify the array and return it back to
perl.
Now, if I spend some more time digging into the perl internals, I am
sure I will get it in the end, but surely, someone most have done this
before.
Does anyone have an example of an perl extension that can deal with
integer arrays which work both as input and output variables?
Thanks in advance,
Marius Kjeldahl
------------------------------
Date: 23 Jul 1997 04:15:55 -0700
From: Russ Allbery <rra@stanford.edu>
To: j.elbaum@ic.ac.uk
Subject: Re: Matching lowercase in regexp?
Message-Id: <m3u3hmxbmc.fsf@windlord.Stanford.EDU>
[ Posted and mailed. ]
Jason H Elbaum <jhelbaum@holly.mr> writes:
> Is there a regexp meta-character which will match only an uppercase or
> only a lowercase letter?
There isn't currently. There has been some discussion on perl5-porters
about whether or not it would be a good idea to change that, but so far as
I know nothing has actually come out of that discussion yet.
> Or should I use [A-Z] and [a-z]? I would have thought the latter not to
> be recommended due to potential locale issues.
Right.
Probably the best thing at the moment would be to do something along the
lines of:
if (lc $variable eq $variable) { }
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 25 Jul 1997 02:22:43 GMT
From: "Barry Roomberg" <broomberg@ccgroupnet.com>
Subject: Re: MD5 in PERL?
Message-Id: <01bc989c$50abfca0$LocalHost@seawolf>
Point your browser to WWW.PERL.ORG, and then follow the CPAN to the
security and encryption routines.
------------------------------
Date: 23 Jul 1997 02:16:56 GMT
From: brent@ime.net (Brent)
Subject: mysqlperl on BSDI 3.0
Message-Id: <5r3pio$ftv$2@news.ime.net>
Has anyone been able to get mysqlperl to compile on a BSDI 3.0 box? I
have managed to get mysql up and running but the perl API tool barfs
during testing. It errors out from the DynaLoader, so I'm thinking it's
some sort of C thing on 3.0. I have it compiled on 2.1 OK (but the mysql
wasn't too happy there so I'd rather have it ont he 3.0 box)
--
Brent
------------------------ Internet Maine ISP --------------------------
info@ime.net 207-780-0416 voice
http://www.ime.net 207-879-1416 fax
------------------------ Fixed Rate Access --------------------------
------------------------------
Date: Fri, 25 Jul 1997 02:07:03 -0400
From: jamie <jamie@comet.net>
Subject: Newbie Post! Heads up! (file question)
Message-Id: <Pine.BSF.3.95.970725015145.2541A-100000@atlas.comet.net>
Ok, pardon the shroud of ignorance here and/or if this is a Frequently
Questioned Answer.....
when I (or you or we) say:
open(SOMEFILE,">disfile") || die "no can do"
open(TINCAN,"tincan") || die "tincan won't open"
are the files (disfile and tincan) always assumed by perl to be in the
directory that the script is in? I'd think the answer is yes, unless
specified otherwise (as in /etc/passwd, /etc/aliases or by some variable).
Is there ever a case when it's otherwise? Or am I fulla worms here? I'm
fairly new to perl, so again pardon my SOI.
Emailed answer would be much appreciated, as our news server expires like
every 14 minutes or something...
thanks in advance,
jamie jamie@comet.net
***************************************************************************
For PGP public key, mail me with Subject:GET KEY
For random Ambrose Bierce quote, Mail me with Subject: ambrose
Support the anti-Spam amendment - Join at http://www.cauce.org/
"Microsoft was invented by domestic terrorists. Remember, it's
no longer an import industry."
------------------------------
Date: Wed, 23 Jul 1997 05:00:59 GMT
From: yves@streamwave.com (Yves Dagenais)
Subject: Number of records in a Berkley DBM file
Message-Id: <33d58f12.48974884@news.synapse.net>
Hello,
I am working with Berkley DBM's under FreeBSD using Perl 5. Is there
a quick way to know the number of records there are in a DBM file? I
could have a counter increment as I go through each record at a time
but that doesn't seem the right way to do it as it would be slow. Is
there a simpler way of doing this?
Thanks,
Yves
yves@streamwave.com
------------------------------
Date: 25 Jul 97 04:14:33 GMT
From: "Andrew Whitehead" <awhitehead@netmart.co.uk>
Subject: problem with simultaneous calls to same script
Message-Id: <01bc98b0$dc2af4c0$70fe4ac2@awhitehead>
I wondered if anyone could help me out with some advice about a Perl Script
I am currently writing....
It is basically a link/banner swap scheme handling set of scripts. The
script itself works just fine until I start trying to invoke it through
several banners all at once (i.e. placing 8 or so on a page).
The setup uses cookies to store code numbers which inform the system which
url to link to from the displayed banner. This should not be a problem in
itself as each banner on the page has an additional value which tags the
name of the cookie which relates to the banner (in other words if there are
8 banners on a page there are 8 associated cookies). Anyway, I am pretty
convinced that the problem does not rest here.
What I think is causing the problem are multiple accesses to the same files
(text files which store details of hits, credits etc. for each simulated
'member' of the scheme. Plus a central 'control' file which totals up
numbers of hits, keeps ratios monitored etc.
As I mentioned, when I run one banner on its own, there is no problem, when
I put several on the page these files start to become corrupted and my
guess is that it is because multiple calls to the script are causing
read/write operations to get muddled up.
Is there anything I can do to ensure that if one instance of the CGI script
is running, the other calls to it have to wait until it has finished before
they can use it.
The strategy I had hoped would work is that I open all the text files
needed by the script as soon as it is invoked and keep them open until the
very end. I had hoped that whilst a file was open, it could not be accessed
by other instances of the script but this appears not to be the case!
Anybody got any brainwaves? Help would be greatly appreciated - presumably
chat-room type scripts have to deal with this very same problem.
Please send any ideas direct to awhitehead@ndirect.co.uk
------------------------------
Date: Wed, 23 Jul 1997 13:25:15 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Q: empty elements in arrays
Message-Id: <adelton.869664315@aisa.fi.muni.cz>
Uwe Lammers <Uwe.Lammers@astro.estec.esa.nl> writes:
> Hi,
>
> looking for the most efficient way to determine whether a string array
> contains empty entries, i.e.,
>
> ('1', '2', '3') -> no
> ('1', '2', '', '3') -> yes
>
> one ugly, non-fail-safe way would be
>
> if (join("@", @list) !~ /\@\@|^\@|\@$/) {
> print "no ";
> }
> print "empty elements\n";
>
> Alternative suggestions?
if (grep { $_ eq ''} @list)
{ print "no "; }
__END__
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
European RC5 56 bit cracking effort -> http://www.cyberian.org/
------------------------------
Date: 25 Jul 1997 02:21:01 GMT
From: "Barry Roomberg" <broomberg@ccgroupnet.com>
Subject: Re: Req help: Any easy way to CRC a file?
Message-Id: <01bc989a$fc6cb720$LocalHost@seawolf>
Why would you say MD5 would be overkill?
I found that CRC implementations to be horrendously slow, where MD5 worked
nicely. What am I missing?
------------------------------
Date: Thu, 24 Jul 1997 23:30:59 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: socket help
Message-Id: <comdog-ya02408000R2407972330590001@news.walrus.com>
In article <01bc9840$0c0e6490$6e6fa1cd@www>, "Ryan" <rmcguigan@ramresearch.com> wrote:
> Hi, I'm planning on writing a script that will search through all the files
> in a website and check for broken links. All it will do is connect to the
> server and try to retrieve each file. I've done this with telnet and I've
> figured out basically how to do it, but the only problem I have is, I've
> never done any socket programming in perl, and I cannot find any
> documentation that explains how to do it. I have a perl book, but it
> doesn't even mention socket programming. If it comes down to it, I can
> write an external program to communicate with the servers, but I'd rather
> not. Thanks for any help I get.
someone has already done all of the hard work for you and put it into
the LWP module. however, if you have your heart set on doing it yourself,
take a look at the documentation for the Socket module.
good luck :)
--
brian d foy <comdog@computerdog.com>
------------------------------
Date: Tue, 22 Jul 1997 20:48:05 +1000
From: odeon@mailbox.uq.edu.au (Jye Tucker)
Subject: Sorting a database by date
Message-Id: <odeon-ya023180002207972048050001@news.uq.edu.au>
I am only starting out with Perl programming and am writing a script that
sorts entries in a file by date. The entries are in the form;
$key:$day:$month:$year:$band:$venue:$band_url:$venue_url:$info \n
I figured since I was sorting the data, the sort() function would come in
handy, however I am not sure how to use the sort() function (or any other
function for that matter:) to sort the info by the $day, $month and $year
fields. I wish to read the entries from a file, sort the data
chronologically and then write it back to the file. Any help with this
would be greatly appreciated.
In addition to posting a reply to the newsgroup, could you please also
email me a copy as I only occassionally get to check newsgroups.
Thanks in advance,
Jye Tucker
--
Odeon Designs - http://www.odeon.com.au
------------------------------
Date: 25 Jul 1997 05:01:38 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: string length
Message-Id: <5r9bvi$bbl@fridge-nf0.shore.net>
Anshul Dhir (dhir@cs.purdue.edu) wrote:
: I guess it is because of the length of the key. How much actually is the
: maximum key length?
You should probably read the docs about ndbm which cover the max
length - I don't recall off the top of my head.
: I have a scaler containing a string and would like to find the length of
: that string. If the length is more than 256 i would like to cut it to 256.
Use the length() function to get the length of the scalar, and substr()
to get the first 256 characters. Both are documented in perlfunc.
Hope this helps!
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Tue, 22 Jul 1997 23:32:14 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Anneke Floor <anneke@intranet.org>
Subject: Re: Stumped by a regexp
Message-Id: <Pine.GSO.3.96.970722232739.23134M-100000@kelly.teleport.com>
On Tue, 22 Jul 1997, Anneke Floor wrote:
> Is there any way to ensure the regexp doesn't look
> further than the first "::"?
Lots of ways. You can go to some trouble to make sure that the pattern
can't accidentally step over a double colon, but that can be a lot of
work. Or, does this do anything for you? (You may want one more statement
if a string might not have a double colon.)
$double_colon = index($string, '::');
next unless substr($string, 0, $double_colon) =~ /some pattern/;
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: Thu, 24 Jul 1997 19:10:00 -0700
From: Jacktran@webtv.net (Jack Tran)
Subject: System call doesn't work right!
Message-Id: <5r91to$hqb$1@newsd-106.bryant.webtv.net>
I am using the following system call with Perl 5.004:
system("/usr/bin/cp", "/tmp/bootptab", "/etc/bootptab") == 0 or print
"failed to copy\n";
The file in /etc is always several lines shorter than the original, and
the last line doens't have a carriage retuen? /tmp and /etc are
different filesystems on a Sparc 5, running Solaris 2.5.1.
Has anyone else come across this strange situation???
------------------------------
Date: Fri, 25 Jul 1997 04:01:58 GMT
From: tonkin@silcom.com (Nick Tonkin)
Subject: thorny little regexp problem
Message-Id: <33d82325.33021041@news.silcom.com>
Hello,
Anyone figure this out?
It is supposed to go through a long string of text (arg1, arg2) and
look for a match with a small string ($str) . Then it is supposed to
substitute $str with <B>$str</B> (html bold) but ONLY if $str is a
whole word within arg1 or arg 2. (A previous check has made sure that
the first char of $str is the first char of a word).
It works beautifully for $str_bits eq "1", when there is only one
$str, but it makes every instance of $str_bit bold (even when not a
whole word) in the while loop underneath.
What am I too dense to spot??
Thanks,
Nick
_________________________
&make_bold(arg1,arg2);
sub make_bold {
if ($str_bits eq "1") {
$_[0] =~ s/$str(\W)/<B>$str<\/B>\1/g;
$_[1] =~ s/$str(\W)/<B>$str<\/B>\1/g;
} else {
foreach $str_bit(@strs) {
$_[0] =~ s/$str_bit(\W)/<B>$str_bit<\/B>\1/g;
$_[1] =~ s/$str_bit(\W)/<B>$str_bit<\/B>\1/g;
}
}
}
__________________________
============================
Nick Tonkin
webmaster@web-ignite.com
http://www.web-ignite.com
------------------------------
Date: Tue, 22 Jul 1997 10:01:50 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: "Karyl F. Stein" <steinkf@cs.purdue.edu>
Subject: Re: Unique File Creation
Message-Id: <33D476FD.BDAC6579@adc.metrica.co.uk>
Karyl F. Stein wrote:
> 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
Just a thought but how about supplying the filehandle to the
subroutine as a parameter, that way you won't suffer from the problem.
Simon
------------------------------
Date: 25 Jul 1997 03:48:47 GMT
From: beaplayer@earthlink.net (Gary Broxterman)
Subject: Win32 and NFS on a win95 pc
Message-Id: <5r97mv$sd0@suriname.earthlink.net>
I can not access any file which is on a NFS.
I can access it thru a system("xxx") command.
For example: Drive O: is mapped to a unix nfs.
To the PC it looks simply like drive O: However, when using
say open() unlink(), functions, the file is never found.
Is this a limitation of Perl for win32?
Thanks in Advance
------------------------------
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 776
*************************************