[11799] in Perl-Users-Digest
Perl-Users Digest, Issue: 5399 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 16 12:07:30 1999
Date: Fri, 16 Apr 99 09:00:19 -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, 16 Apr 1999 Volume: 8 Number: 5399
Today's topics:
Re: Calling a function from s/// (Larry Rosler)
Re: FAQ 1.10: When shouldn't I program in Perl? (Mike Wescott)
Re: FAQ 2.7: Is there an ISO or ANSI certified version (Larry Rosler)
Re: flocking question - worried (Daniel Beckham)
Re: flocking question - worried (Daniel Beckham)
Re: FREE Certifications Offered Online to perl programm (Leo Schalkwyk)
goto or recursion? <vinger@ford.com>
Hiding scheduled perl scripts in Win NT <jacques.poulin@nospam.intellia.com>
interesting hash problem (EXCHANGE:SKY:1Z22)
Re: natural language vs. computer language <julien.couvreur@polytechnique.fr>
Perl and MySQL error return code <gpl@gamestats.com>
Re: perlcc on NT <rkoehler@osmre.gov>
Reading File to a Scalar? <rdsys@inficad.com>
Re: Reading File to a Scalar? (Sami Rosenblad)
Re: Reading File to a Scalar? (Larry Rosler)
Re: Reading File to a Scalar? <gellyfish@gellyfish.com>
Re: Reading File to a Scalar? <vinger@ford.com>
Re: Reading File to a Scalar? (Daniel Beckham)
Re: Recursion not working properly <aqumsieh@matrox.com>
Re: Uploading script. <gellyfish@gellyfish.com>
why won't this statement work @array=<*.*> <dscapin@harris.com>
Re: why won't this statement work @array=<*.*> <gellyfish@gellyfish.com>
Re: why won't this statement work @array=<*.*> <vinger@ford.com>
Re: Would anyone care to teach me perl? (Daniel Beckham)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 Apr 1999 07:27:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Calling a function from s///
Message-Id: <MPG.1180e8868e8a8029898c4@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37172332@news.uk.ibm.net> on Fri, 16 Apr 1999 13:49:27
+0200, Vincent Vanbiervliet <vvb@ibm.net> says...
>
> <hassanov@yahoo.com> wrote in message
> news:7f5nb8$aao$1@nnrp1.dejanews.com...
> > to absolute URL, but I can't do: $HtmlBuffer=~
> > s/(<\s*A\s*.*HREF\s*=\s*)\"([^"]*)\"/$1\"&AbsoluteUrl($2)\"/gi; Instead, I
Congratulations on reading the post in the first place.
It was so poorly formatted that I passed it by.
> using the -w switch, and 'use diagnostics;' could tell you a lot about what
> is going wrong.
That is always good advice.
> It is perfectly possible to use a function in s///, just try using one with
> only $1, e.g. s/<expression with brackets in>/myfunction($1)/gi; it will
> work.
That is not good advice. It will *not* work unless you add the /e
modifier. (Function calls are not interpolated otherwise -- but see
below.)
> The problem lies in the concatinating of several strings in the second part
> of the expression.
> Basically, you're trying to substitute the left part by a concatination of 4
> strings: $1, ", AbsoluteUrl($2) and "
> Instead of using
> $1\"&AbsoluteUrl($2)\"
> use
> $1.'"'.AbsoluteUrl($2).'"'
>
> Remarks:
> 1. '"' is single, double, single quote, so ' " ' (but with more spaces)
> 2. You don't need the & before you function, since it has an argument,
> so Perl recognizes it as a function. But it still works with the '&'.
True -- with the /e modifier.
Another Way To Do It (for the syntactically strong at heart only)
without the /e modifier is to use an interpolation that *does* invoke
the function.
s/ ... /$1"${\AbsoluteUrl($2)}"/gi
or
s/ ... /$1"@{[AbsoluteUrl($2)]}"/gi
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Apr 1999 11:03:49 -0400
From: wescott@cygnus.ColumbiaSC.NCR.COM (Mike Wescott)
Subject: Re: FAQ 1.10: When shouldn't I program in Perl?
Message-Id: <x4zp48li96.fsf_-_@cygnus.ColumbiaSC.NCR.COM>
In article <37154637@cs.colorado.edu> Tom Christiansen writes:
> When your manager forbids it -- but do consider replacing them :-).
Shouldn't that be "him"? Or is this a bit of gender neutrality?
--
-Mike Wescott
mike.wescott@ColumbiaSC.NCR.COM
------------------------------
Date: Fri, 16 Apr 1999 07:57:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 2.7: Is there an ISO or ANSI certified version of Perl?
Message-Id: <MPG.1180ef9f5bcb907d9898c5@nntp.hpl.hp.com>
In article <3716ec47@cs.colorado.edu> on 16 Apr 1999 01:52:39 -0700, Tom
Christiansen <perlfaq-suggestions@perl.com> says...
> (This excerpt from perlfaq2 - Obtaining and Learning about Perl
> ($Revision: 1.31 $, $Date: 1999/04/14 03:46:19 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq2.html
> if your negligent system adminstrator has been remiss in his duties.)
>
> Is there an ISO or ANSI certified version of Perl?
>
> Certainly not. Larry expects that he'll be certified before Perl
> is.
As an old language standards guru, I find it interesting to conjecture
why this is so. It is *not* because of The (Other) Larry's strength of
personality.
Essentially -- because of the available-for-free perl core and CPAN
modules -- no entrepreneur has found a way to make money by offering
proprietary extensions that distinguish their Perl from anyone else's
Perl. (Proprietary IDEs do not change the language.)
For a current comparison, observe the sorry state of Java, with the tug-
of-war between Sun and Micro$oft fueling the standards effort.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 16 Apr 1999 10:10:45 -0500
From: danbeck@scott.net (Daniel Beckham)
Subject: Re: flocking question - worried
Message-Id: <MPG.11810ede1150a9b8989697@news.idt.net>
Also, I've always been concerned with this situation:
An external program periodically writes data to a file. My program
periodically checks to see if that file exists and if it does, extracts
the data and removes the file.
open
flock(ex)
read
flock(un)
close
unlink
Now, this external program will append data to the end of the file if my
program hasn't removed it. That way, if my program isn't up and runnig
for some reason, I don't lose data.
What happens if the external program opens the file between my close and
unlink? I'm assuming that my unlink will fail and the external program
will write new data to the end of old data that I already have. How can
I prevent that from happening? The only work around I see is to keep
track of old data and make sure I don't read any of it back into my
program... not the most elegant way I would think.
Daniel
In article <3716857e@cs.colorado.edu>, tchrist@mox.perl.com says...
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, danbeck@scott.net (Daniel Beckham) writes:
> :ooh, can you do that? That race condition has always bothered me. I was
> :under the assumption that you had to unlock it first...
>
> What race condition?
>
> --tom
>
------------------------------
Date: Fri, 16 Apr 1999 11:38:10 -0500
From: danbeck@scott.net (Daniel Beckham)
Subject: Re: flocking question - worried
Message-Id: <MPG.11810f96a2d340bf989698@news.idt.net>
Thanks, you learn something new every day, eh?
I have a lot of code to modify. =)
Daniel
In article <o086f7.m89.ln@magna.metronet.com>, tadmc@metronet.com says...
> Daniel Beckham (danbeck@scott.net) wrote:
> : ooh, can you do that? That race condition has always bothered me. I was
> : under the assumption that you had to unlock it first...
>
>
> Ack!
>
> The act of unlocking before the close is what *creates*
> the race condition.
>
> If you just close, then there _is_ no race to worry about.
>
>
>
> : In article <slrn7ha4l9.j6n.billynospam@wing.mirror.bt.co.uk>,
> : >
> : > are there any fully portable solution to this problem? I'm currently not
> : > bothering unlock files, but am letting close() do it for me.
>
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
>
------------------------------
Date: 16 Apr 1999 15:52:13 GMT
From: schalkwy@minnie.RZ-Berlin.MPG.DE (Leo Schalkwyk)
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <7f7mbd$4jm$1@fu-berlin.de>
Well I know at most a tenth as much as Uri and I got 4.17 -- many of the
questions are of the form "what does the following code do?", so you can
just run it and see (legitimate perl skill, no?). You should definitely
not anyone with the "Cretified perl Programmer" (ie <4) level.
Leo Schalkwyk
Uri Guttman (uri@home.sysarch.com) wrote:
: >>>>> "l" == ludlow1435 <ludlow1435@my-dejanews.com> writes:
: l> To qualify as a Certified perl Programmer, you must pass the
: l> examination with a score of 2.75 or higher. To be certified as a
: l> Master perl Programmer, you must obtain a score of 4.00 or higher.
: this is a fairly bogus test. i just got a 4.25 (or 34/40 right) score so
: i am certified as a master perl hacker. hell i BOUGHT for $3 a
--
------------------------------------------------------------
schalkwy@mpimg-berlin-dahlem.mpg.de
Max-Planck-Institut f|r molekulare Genetik
------------------------------
Date: Fri, 16 Apr 1999 11:32:34 -0400
From: Slav Inger <vinger@ford.com>
Subject: goto or recursion?
Message-Id: <37175812.1E3E3663@ford.com>
Hello,
I have a situation where a sub1 calls sub2. Upon return from sub2, sub1
should re-execute (sentinnel loops don't apply in this case). I'm not a
big fan of goto statements, so I'm trying to decide whether it's better
to use a goto to send control to the beginning of sub1, or to make a
recursive call from sub1 to itself - I wonder if I'm going to run out of
stack space sooner or later with the recursion approach.
Any ideas?
Thanks.
- Slav Inger.
--
Ford Motor Co., FSIC
UNIX Server Group
Phone: 1-313-594-0216
E-mail: vinger@ford.com
------------------------------
Date: Fri, 16 Apr 1999 14:18:01 GMT
From: "Jacques Poulin" <jacques.poulin@nospam.intellia.com>
Subject: Hiding scheduled perl scripts in Win NT
Message-Id: <tEHR2.26$9G3.222@198.235.216.4>
(If you reply by mail, you'll have to remove the "nospam." from my email
address)
Hello,
I have a couple of Perl scripts that are to be run every few minutes on my
NT workstation.
I want to run them in the background, e.g. I don't want a window to pop on
the screen when they are executed.
So far, my solution has been to use Scott McMahan's "hide" utility, which
when executed hides a window from the desktop. In other words, if I have a
script called "hello.pl" to be run every 5 minutes, I call a wrapper batch
file which looks something like this :
------------------------------------------------------
hide "C:\WINNT\System32\CMD.exe"
start /LOW /B perl c:\hello.pl
------------------------------------------------------
The problem with this solution is that when the scheduled script is being
invoked, the window I'm currently working on loses its focus (the focus is
given to the console when the wrapper is invoked).
Is there a workaround in order for my current window to not lose its focus ?
Or is there an altogether different solution to running perl scripts in the
background (without a window) on NT ?
Thanks.
------------------------------
Date: Fri, 16 Apr 1999 10:17:45 -0400
From: "Soulier, Michael (EXCHANGE:SKY:1Z22)" <msoulier@americasm01.nt.com>
Subject: interesting hash problem
Message-Id: <37174689.2642BAFF@americasm01.nt.com>
Hey guys. I'm having an interesting confusion about hashes (well, it's
interesting to me anyway). I was under the impression that I could add
levels to a hash dynamically, all I wanted. For example, if I had:
my %myHash = ();
I could say
$myHash{'key1'} = 1;
Then, I could later say
$myHash{'key1'}{'key2} = 1;
And continue all I wanted. I've been doing this for a while and never
run into a problem, until now. Here's a code snippet:
# Loop over each context. For each context, loop over each lineup.
foreach my $context (reverse sort keys %lineupsByContext) {
foreach my $lineup (sort keys %{
$lineupsByContext{$context}{'lineups'} }) {
# Now we must put together a hash of data about each load. Use the
# %lineupsByContext hash, and add another level.
# First, check to see if the context is rebuilding.
print "Checking the build status of $lineup in $context\n";
# $lineupsByContext{$context}{'lineups'}{$lineup}{'build_status'} =
checkBuildStatus($context, $lineup);
$lineupsByContext{$context}{'lineups'}{$lineup} = {'build_status' =>
checkBuildStatus($context, $lineup) } ;
debug "build status of context $context, lineup $lineup, is
$lineupsByContext{$context}{'lineups'}{$lineup}{'build_status'}\n";
}
}
Now, the commented $lineupsByContext line is what I was originally
using. The line immediately following is what I had to change that line
to, to make it work. My intention was to have the scalar returned by
checkBuildStatus stored as a value, accessed by the four keys, but that
didn't work. Each iteration of the loop clobbered the previous value.
The really interesting part is that while I have to use said syntax to
make it work, I use the syntax of the commented line to dereference it
and get to the values. Any insights as to the problems with the syntax
of the commented line?
Thanks,
Mike
--
Michael P. Soulier
1Z22, SKY
Tel: 613-765-4699 (ESN: 39-54699)
Email: msoulier@nortelnetworks.com
Carrier Packet Solutions
Nortel Networks Corporation
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort."
-Harley Hahn, A Student's Guide to UNIX
------------------------------
Date: Fri, 16 Apr 1999 10:20:25 -0400
From: Julien Couvreur <julien.couvreur@polytechnique.fr>
Subject: Re: natural language vs. computer language
Message-Id: <37174729.F425F6C3@polytechnique.fr>
Hi,
You should try LISP-like languages : if you want to add an "unless" fom and
whatever form you like, you just can do it...
But the basic Lisp (or Scheme) has very few special forms, so that it can be
easily interpreted or compiled.
The trouble with rich languages as Perl is that the compiler has to know all
those synonyms and it get more complex for only little benefit.
And somebody who learns it might be confused with all those different
syntaxes.
Julien
------------------------------
Date: Fri, 16 Apr 1999 10:44:46 -0500
From: "John" <gpl@gamestats.com>
Subject: Perl and MySQL error return code
Message-Id: <7f7lpr$mdh$1@news.onramp.net>
Does anyone know how to get a numeric error return code from MySQL using
Perl?
When I used to work with COBOL I could get an error return code from the DB2
database. For example if a table was locked I would get a -911 error return
code. I would like to be able to do the same in my Perl programs with MySQL
so that I can properly act on an error. If anyone has some code on how to do
this I would much appreciate it!
Thanks,
John
------------------------------
Date: Fri, 16 Apr 1999 15:01:16 GMT
From: "Rick K" <rkoehler@osmre.gov>
Subject: Re: perlcc on NT
Message-Id: <FAAF1n.4oo@igsrsparc2.er.usgs.gov>
Ramanujam Parthasarathi asked:
[small snip]
>I would like to know the equivalent of 'perlcc' on NT ('perlcc' usually
>comes on Unix).
>Thanks for the info.
[another small snip]
Are you looking for perlcc, as in Drive:\perl\bin\perlcc.bat ... the perlcc.bat
file included in the typical Activestate builds such as 509 (5.005_02)?
May not do exactly what you think/wish it should/could do, though.
Snippet follows:
C:\>perlcc
Usage: D:\perl5\bin/perlcc.bat <file_list>
Flags with arguments
-L < extra library dirs for installation (form of 'dir1:dir2') >
-I < extra include dirs for installation (form of 'dir1:dir2') >
-C < explicit name of resulting C code >
-o < explicit name of resulting executable >
-e < to compile 'one liners'. Need executable name (-o) or '-run'>
-regex < rename regex, -regex 's/.p/.exe/' compiles a.p to a.exe >
-verbose < verbose level (1-63, or following letters 'gatfcd' >
-argv < arguments for the executables to be run via '-run' or '-e' >
Boolean flags
-gen ( to just generate the c code. Implies '-sav' )
-sav ( to save intermediate c code, (and executables with '-run'))
-run ( to run the compiled program on the fly, as were interpreted.)
-prog ( to indicate that the files on command line are programs )
-mod ( to indicate that the files on command line are modules )
****************** end of sorta snippet section *****************************
HTH and good luck.
------------------------------
Date: Fri, 16 Apr 1999 14:04:52 GMT
From: "Ray A. Lopez" <rdsys@inficad.com>
Subject: Reading File to a Scalar?
Message-Id: <37174383.4E4A5468@inficad.com>
I wanted to know if there were any other (or better) ways of reading
file data into a scalar? Below is one implementation I came up with.
Any other ways????
#!/usr/bin/perl -w
use strict;
my $slurp;
open (FILE, "< file") or die "Can not open file!\n";
while (<FILE>) {
$slurp = join ('', $slurp, $_);
}
close (FILE);
print "\n$slurp";
------------------------------
Date: Fri, 16 Apr 1999 18:40:44 +0300
From: blade@leela.janton.fi (Sami Rosenblad)
Subject: Re: Reading File to a Scalar?
Message-Id: <blade-1604991840450001@durandal.janton.fi>
In article <37174383.4E4A5468@inficad.com>, "Ray A. Lopez"
<rdsys@inficad.com> wrote:
> I wanted to know if there were any other (or better) ways of reading
> file data into a scalar? Below is one implementation I came up with.
> Any other ways????
>
>
> #!/usr/bin/perl -w
> use strict;
>
> my $slurp;
>
> open (FILE, "< file") or die "Can not open file!\n";
>
> while (<FILE>) {
> $slurp = join ('', $slurp, $_);
> }
>
> close (FILE);
>
> print "\n$slurp";
#!/usr/bin/perl -w
use strict;
my $slurp;
open FILE, "file" or die "can't open file: $!";
$slurp = join '', <FILE>;
close FILE;
print "\n$slurp";
--
Sami Rosenblad | blade@leela.janton.fi | running Linux since 1999
------------------------------
Date: Fri, 16 Apr 1999 08:35:55 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reading File to a Scalar?
Message-Id: <MPG.1180f8ad5741605a9898c6@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37174383.4E4A5468@inficad.com> on Fri, 16 Apr 1999 14:04:52
GMT, Ray A. Lopez <rdsys@inficad.com> says...
> I wanted to know if there were any other (or better) ways of reading
> file data into a scalar? Below is one implementation I came up with.
> Any other ways????
You bet -- a common and efficient way. See below.
> #!/usr/bin/perl -w
> use strict;
Good!
> my $slurp;
>
> open (FILE, "< file") or die "Can not open file!\n";
Include $! in the error message, to tell why.
> while (<FILE>) {
> $slurp = join ('', $slurp, $_);
> }
my $slurp = do { local $/; <FILE> };
> close (FILE);
>
> print "\n$slurp";
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Apr 1999 16:36:00 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Reading File to a Scalar?
Message-Id: <371758e0@newsread3.dircon.co.uk>
Ray A. Lopez <rdsys@inficad.com> wrote:
> I wanted to know if there were any other (or better) ways of reading
> file data into a scalar? Below is one implementation I came up with.
> Any other ways????
>
>
local $/ = undef; # $/ is the input record separator
open(FILE,$ARGV[0]) or die "$!\n";
$slurp = <FILE>;
close(FILE);
print $slurp;
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Fri, 16 Apr 1999 11:24:23 -0400
From: Slav Inger <vinger@ford.com>
Subject: Re: Reading File to a Scalar?
Message-Id: <37175627.B470B2E2@ford.com>
"Ray A. Lopez" wrote:
> I wanted to know if there were any other (or better) ways of reading
> file data into a scalar? Below is one implementation I came up with.
> Any other ways????
>
> #!/usr/bin/perl -w
> use strict;
>
> my $slurp;
>
> open (FILE, "< file") or die "Can not open file!\n";
>
> while (<FILE>) {
> $slurp = join ('', $slurp, $_);
> }
>
> close (FILE);
>
> print "\n$slurp";
How about this: $slurp .= $_;
- Slav Inger.
--
Ford Motor Co., FSIC
UNIX Server Group
Phone: 1-313-594-0216
E-mail: vinger@ford.com
------------------------------
Date: Fri, 16 Apr 1999 11:42:28 -0500
From: danbeck@scott.net (Daniel Beckham)
Subject: Re: Reading File to a Scalar?
Message-Id: <MPG.1181246d8fe4946198969c@news.idt.net>
Not better, just less wordy...
while(<FILE>){
$slurp .= $_;
}
Daniel
In article <37174383.4E4A5468@inficad.com>, rdsys@inficad.com says...
> I wanted to know if there were any other (or better) ways of reading
> file data into a scalar? Below is one implementation I came up with.
> Any other ways????
>
>
> #!/usr/bin/perl -w
> use strict;
>
> my $slurp;
>
> open (FILE, "< file") or die "Can not open file!\n";
>
> while (<FILE>) {
> $slurp = join ('', $slurp, $_);
> }
>
> close (FILE);
>
> print "\n$slurp";
>
>
>
------------------------------
Date: Fri, 16 Apr 1999 10:08:11 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Recursion not working properly
Message-Id: <x3yyajsacac.fsf@tigre.matrox.com>
"Mike Rizzo" <mrizzo@ismd.ups.com> writes:
> I have a perl script in wihch a recursive call that I am attempting is not
> executing properly. The sub is called coparedirs(), when I call comparedirs
> from inside
> comparedirs, it does start exectuing compare dirs, but it seems as if the
> original
> call to comparedirs never completes running. Is there something I am missing
> about recursion in Perl that I should know about before attempting this
> execution.
Let me guess ...
your comparedirs() subroutine contains an:
exit;
statement on line 5. Am I correct?
------------------------------
Date: 16 Apr 1999 16:39:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Uploading script.
Message-Id: <371759a8@newsread3.dircon.co.uk>
Ours <ours@casema.net> wrote:
> Hi All,
>
> I would like to have a script (write) that would upload an attachement to my
> server.
> Idea is to be able to browse my local drives and find the source-file and
> then press UPLOAD to upload to a remote server.
>
l
I would recommend checking out:
<http://webreview.com/wr/pub/98/08/14/perl/index.html>
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Fri, 16 Apr 1999 09:41:51 -0400
From: George <dscapin@harris.com>
Subject: why won't this statement work @array=<*.*>
Message-Id: <37173E1F.6379FD2B@harris.com>
I am trying to put files in the current directory into an array. When I
use the following statement on my machine running xwin32 server, it
works:
@array = <*.*>
Now, when I put the perlscript on the server this statement doesn't
work. The server is an NT server. It doesn't work because the number
of elements is 0. I am looking for a code snipplet that will load the
filenames into the array. Can someone help me?
dscapin@maelstrom.cs.fit.edu
------------------------------
Date: 16 Apr 1999 16:30:03 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: why won't this statement work @array=<*.*>
Message-Id: <3717577b@newsread3.dircon.co.uk>
George <dscapin@harris.com> wrote:
> I am trying to put files in the current directory into an array. When I
> use the following statement on my machine running xwin32 server, it
> works:
>
> @array = <*.*>
>
> Now, when I put the perlscript on the server this statement doesn't
> work. The server is an NT server. It doesn't work because the number
> of elements is 0. I am looking for a code snipplet that will load the
> filenames into the array. Can someone help me?
>
If all else fails :
opendir(DIR,'.') || die "aieee - $!\n";
@array = readdir(DIR);
closedir(DIR);
You might want to use grep in the assignement to the array in order to
get rid of unwanted directory entries.
However:
P:\test>cat ddir.pl
@array = <*.*>;
print @array;
P:\test>perl ddir.pl
ddir.plh2p.pltt.pl
P:\test>ver
Windows 98 [Version 4.10.1998]
P:\test>perl -v
This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-1999, Larry Wall
Binary build 515 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 19:53:14 Apr 9 1999
- so perhaps there is something wrong with your installation.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Fri, 16 Apr 1999 11:18:33 -0400
From: Slav Inger <vinger@ford.com>
Subject: Re: why won't this statement work @array=<*.*>
Message-Id: <371754C9.C3570D82@ford.com>
George wrote:
> I am trying to put files in the current directory into an array. When I
> use the following statement on my machine running xwin32 server, it
> works:
>
> @array = <*.*>
>
> Now, when I put the perlscript on the server this statement doesn't
> work. The server is an NT server. It doesn't work because the number
> of elements is 0. I am looking for a code snipplet that will load the
> filenames into the array. Can someone help me?
>
> dscapin@maelstrom.cs.fit.edu
Try this: @array = <*>;
This should work on all platforms.
- Slav Inger.
--
Ford Motor Co., FSIC
UNIX Server Group
Phone: 1-313-594-0216
E-mail: vinger@ford.com
------------------------------
Date: Fri, 16 Apr 1999 11:38:12 -0500
From: danbeck@scott.net (Daniel Beckham)
Subject: Re: Would anyone care to teach me perl?
Message-Id: <MPG.118111e975d3a28098969a@news.idt.net>
Along the same lines... I would recommend "Learning Perl" published by
O'Reilly & Assoc. www.ora.com It's 29.95 well worth spent.
In article <x3yzp49a7iy.fsf@tigre.matrox.com>, aqumsieh@matrox.com
says...
>
> Raymond Yu <WizeGuy@nettaxi.com> writes:
>
> > Would anyone care to teach me perl? Just with email though.
>
> Why? Don't you know how to read books? It's very simple. In English,
> words go from left to write, but you knew that already.
> Pages can be flipped. A book is made up of one or more pages. Words in
> books look almost exactly like words in email messages. They can be
> read too.
>
>
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5399
**************************************