[9551] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3145 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 13 19:08:13 1998

Date: Mon, 13 Jul 98 16:00:43 -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           Mon, 13 Jul 1998     Volume: 8 Number: 3145

Today's topics:
    Re: "@foo=<*>" missing files on FAT32 partitions? (Jamie O'Shaughnessy)
    Re: compare arrays (Craig Berry)
    Re: compare arrays <bytealite@yahoo.com>
    Re: compare arrays <bytealite@yahoo.com>
        Dynamic HTML document in new browser window? <sabine@ikt.de>
    Re: forking on win32 kolovos_ted@prc.com
        Help - search table across network (Joseph M Carlton)
    Re: I am an "antispam spammer"? (Ken Irving)
    Re: My script stops searching... <westxga@ptsc.slg.eds.com>
        NEWBIE: File Age? <nheagy@cintek.com>
    Re: NEWBIE: File Age? <khaines@oshconsulting.com>
    Re: NEWBIE: File Age? (Larry Rosler)
    Re: Parsing Perl (Ilya Zakharevich)
    Re: Password script <bytealite@yahoo.com>
    Re: Perl 4 compilation on Solaris 2.6 <bytealite@yahoo.com>
    Re: Perl 4 compilation on Solaris 2.6 <bytealite@yahoo.com>
    Re: Perl installation (Version Perl 5.004_04) <bytealite@yahoo.com>
    Re: Putting CPAN on a CD: good or not good? birgitt@my-dejanews.com
    Re: Quickie: the number of occurences of a character in (Gabor)
    Re: Quickie: the number of occurences of a character in (Craig Berry)
        Reading Directories w/ Perl marius77@my-dejanews.com
    Re: Reading Directories w/ Perl (Bob Trieger)
    Re: Reading Directories w/ Perl (Kelly Hirano)
    Re: Recommend me Perl! (brian d foy)
    Re: Recommend me Perl! (Craig Berry)
    Re: Recommend me Perl! <tchrist@mox.perl.com>
    Re: Recommend me Perl! (Craig Berry)
    Re: RegExps: Check if string consists of EXACTLY 3 digi (Larry Rosler)
    Re: RegExps: Check if string consists of EXACTLY 3 digi (Craig Berry)
        script opening another script faganb@my-dejanews.com
    Re: Urgent!! Need Programmer for perm in Malibu, Ca <rkoehler@osmre.gov>
    Re: Using Perl to generate HTML Pages. <bytealite@yahoo.com>
    Re: Using Perl to generate HTML Pages. <bytealite@yahoo.com>
    Re: Using Perl to generate HTML Pages. <bytealite@yahoo.com>
    Re: Using Perl to generate HTML Pages. <bytealite@yahoo.com>
    Re: Using Perl to generate HTML Pages. <bytealite@yahoo.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 13 Jul 1998 21:25:58 GMT
From: jamie@thanatar.demon.co.uk (Jamie O'Shaughnessy)
Subject: Re: "@foo=<*>" missing files on FAT32 partitions?
Message-Id: <35aa7ad8.3543525@news.demon.co.uk>

On Mon, 13 Jul 1998 12:17:52 +0200, "The Beals"
<yoshiko.beal@munich.netsurf.de> wrote:

>aka: Bug in Perl for Win32?
>
>I'm seeing that the following code snippet........
>
>@files = <*>;
>foreach $file (@files) {
> print $file."\n";
>}

I don't think it's recommended using <*> syntax for globs any more, use the
explicit glob('*') function (which you're at it, if you're using win32 you
should be using DosGlob, do a "perldoc DosGlob").

>..........misses the first file in the list when run on a FAT32 drive under
>Win98. When run on an NTFS drive over a network using Win98, or on a FAT16
>drive, it gets all file names correctly.
? Dunno about this bit though

>I've also tries while/for loops to iterate through the array, but no luck.
>Is anybody else having the same problem? Does anyone have a solution?
Don't use win98/fat32 :)

Jamie
---
Jamie O'Shaughnessy >>> jamie@thanatar.demon.co.uk
                        joshaugh@uk.oracle.com


------------------------------

Date: 13 Jul 1998 21:38:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: compare arrays
Message-Id: <6oduns$5ov$1@marina.cinenet.net>

Alberto Brosich (brosich@univ.trieste.it) wrote:
: A stupid question.

Not stupid at all.

: How can i compare two arrays other then with a loop?

Short answer: You can't do it without looping.

You may want to look at the FAQ item "How do I compute the difference of
two arrays? How do I compute the intersection of two arrays?", which
covers this in the very general case.  For your specific purpose you can
use a simpler solution, provided you're willing to stipulate wuat kind of
equality you want, string or numeric.  Presuming string equality:

#!/usr/bin/perl -w

sub array_eq
{                                      
  my ($ar, $br) = @_;                  
                                       
  return 0 unless @$ar == @$br;        
                                       
  for (my $i = 0; $i < @$ar; $i++) {   
    return 0 unless $$ar[$i] eq $$br[$i];
  }                                    
                                       
  return 1;                      
}


@a = qw( 1 2 3 4 );
@b = qw( 1 2 3 );
@c = qw( 1 2 4 );
@d = qw( 1 2 4 );

print 'a=b:', array_eq(\@a, \@b), "\n";
print 'b=c:', array_eq(\@b, \@c), "\n";
print 'c=d:', array_eq(\@c, \@d), "\n";


---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: Mon, 13 Jul 1998 21:10:05 +0100
From: Andy Bold <bytealite@yahoo.com>
Subject: Re: compare arrays
Message-Id: <35AA699D.2C314190@yahoo.com>

Alberto Brosich wrote:
> 
> A stupid question.
> 
> How can i compare two arrays other then with a loop?

Straight out of the original Camel Book:-

Computing the difference of two arrays:

local(%MARK);
grep($MARK{$_}++, @ARRAY1);
@RESULT = grep(!$MARK{S_}, @ARRAY2);

@RESULT contains the differences.


Computing the intersection of two arrays:

local(%MARK);
grep($MARK{$_}++,@ARRAY1);
@RESULT = grep($MARK{$_}, @ARRAY2);

With thanks to Larry Wall, Tom Christiansen & Randal L. Schwartz for
being great teachers.




------------------------------

Date: Mon, 13 Jul 1998 23:54:39 +0100
From: Andy Bold <bytealite@yahoo.com>
Subject: Re: compare arrays
Message-Id: <35AA902F.D3FA1D66@yahoo.com>

Alberto Brosich wrote:
> 
> A stupid question.
> 
> How can i compare two arrays other then with a loop?

Straight out of the original Camel Book:-

Computing the difference of two arrays:

local(%MARK);
grep($MARK{$_}++, @ARRAY1);
@RESULT = grep(!$MARK{S_}, @ARRAY2);

@RESULT contains the differences.


Computing the intersection of two arrays:

local(%MARK);
grep($MARK{$_}++,@ARRAY1);
@RESULT = grep($MARK{$_}, @ARRAY2);

With thanks to Larry Wall, Tom Christiansen & Randal L. Schwartz for
being great teachers.


------------------------------

Date: Mon, 13 Jul 1998 23:07:46 +0200
From: Sabine Cremer <sabine@ikt.de>
Subject: Dynamic HTML document in new browser window?
Message-Id: <35AA7721.D0583168@ikt.de>

I wrote a simple perl application to get an answer from a database.
Because it is called from a frame too small for the output, I want to
put the dynamically generated data into a new browser window. How to do
it??

Sabine




------------------------------

Date: Mon, 13 Jul 1998 22:18:06 GMT
From: kolovos_ted@prc.com
Subject: Re: forking on win32
Message-Id: <6oe12u$2kc$1@nnrp1.dejanews.com>

In article <35A63325.DB38149D@prc.com>,
  Ted <kolovos_ted@prc.com> wrote:
> I noticed that fork is unimplemented on win32, is there
> a way around this, perhaps through a call to the windows createthread
> api
> in kernerl32.dll??
>
> also is there a way to setup a signal so that whenever a socket is
> closed on the
> other end my perl script can be notified so that it can terminate?
>
> please send any help to kolovos_ted@prc.com,
> thanks for your time,
> Ted
>
>
I found some software called gnu-win32 which provides a unix-like
shell environment which has a perl port that will allow forking on
windows nt.  If you are interested in checking this out go to the link:
http://www.cygnus.com/misc/gnu-win32

Ted

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: 13 Jul 1998 22:18:12 GMT
From: carltjm@mail.auburn.edu (Joseph M Carlton)
Subject: Help - search table across network
Message-Id: <6oe134$o64$1@ultranews.duc.auburn.edu>

Hello, I'm fairly new to perl.  I need to search a table that exists on a 
different computer on the network.  Then I need to create a graph with 
the returned data.  This script will be called from a web page with the 
user inputing the search value.  Can anyone give me any advice/tell me a 
document that I need to read?

I need the table search question answered first (before the creating a 
graph image question).  Thanks in advance for your help.

--

Joey Carlton
Senior, Computer Engineering
Auburn University
carltjm@mail.auburn.edu


------------------------------

Date: Mon, 13 Jul 1998 23:55:37 GMT
From: jkirving@mosquitonet.com (Ken Irving)
Subject: Re: I am an "antispam spammer"?
Message-Id: <35aa6dd6.14511826@news.mosquitonet.com>

(news.admin.net-abuse.email removed from ng list)

On Mon, 13 Jul 1998 17:41:31 GMT, dont.reply@this.address (John
Oliver) wrote:

>On 11 Jul 1998 01:08:28 GMT, dmacks@sas.upenn.edu (Daniel E. Macks)
>wrote:
>
>>CLPM has a large contingent of "if you want a reply by email, I'd damn
>>well better be able to just hit reply." That's one of the
>>characteristics that's developed in the froup. An even stronger
>>contingent is "you asked by posting, so I'm gonna reply by posting"
>>(at one point the FAQ made this very clear). One of the premises there
>>is that one is coming for help, so one must do everything possible to
>>help folks help that person. Each additional hoop is that many more
>>YAPHer (possibly the only one with the answer to a tricky question)
>>who will say "too much trouble...I'll skip this one."
>
>What I don't understand, though, are the people who evidentially want
>to reply (most likely too the newsgroup), but as soon as they detect a
>munged address, *that* becomes the basis of their reply.  Never mind
>that the person never asked for an email reply, and may have even
>stated that they expect replies to the NG... nope, damn it, they have
>a munged address, so by God they're an inconsiderate bastard and I'm
>going to tell them so!  And screw them... I'm not going to help them!
>
>Very strange...
>

As the instigator of this thread (though via a private email), the
situation was that the original post was a trivial question--"why
doesn't this work..."--well, it did work, so the problem was one of
the author's perception, or was hidden in code not posted with 
the question. I ran the code, composed a reply, and then deleted it
after seeing that my reply would be _handled_ as spam. I admit to then
(privately) flaming the person after finding an address in the sig
lines. My bad. I don't go around flaming every antispammer, but it
does annoy me (i.e., I'm of the former camp referenced above) that
simple replies are not possible or guaranteed. I'm not (that) naive
that I don't know this is the case, that spam is a problem, and that
usenet is no longer what it was.

I've only been on usenet a few years, but my perception is that for
all the public replies and posts, there are, or at least used to be,
an invisible host of private messaging going on.  Some things just
clutter the ng, IMO, and trivial questions, simple incorrect
assumptions, FAQs, and the like are appropriately handled by private
response, IMO of course.  I have on numerous occasions answered a
post, after running code, looking up references, etc., then deleted it
after finding a bad reply address. Just time wasted; my bad. The
alternative view that all posts should be public would surely result
in numerous repetitive replies--more noise & clutter. I'll reply to
the group when I feel sufficiently expert in the subject area, or
figure others might not reply.

In this instance, I was annoyed that, had I sent my original (helpful)
reply I would then be handled as a spammer (whatever that means). To
me that seems to be proactively aggresive, directed at someone who is
(naively) trying to help out. As it stands, the thread was redirected
to a spam-dangerous list, as I understand it, thankfully without my
address (which is why I've removed that ng from this post).

My lessons from all this include:
  * usenet ain't what it used to be (news flash)
  * don't private reply to them that don't care
  * just keep lurking, it's a dangerous world out there
  * when in doubt, sit on it
  * don't flame spam fighters, they don't like it
  * keep wishing CLPM was for Perl topics

 -- Ken
jkirving@mosquitonet.com
>-- 
>**********************************************************
>IMPORTANT! >>>>>>>>>>>>>>>>>>>>>>>>>>>
>**********************************************************
>If you wish to reply to me via email, watch out for
>my spam-trap.  I can be reached at joliver at oliver
>dot escondido dot ca dot us.  Sorry for the 
>inconvenience, but I hate spam...
>
>On that note, if you hate spam too, join CAUCE!
>www.cauce.org
>**********************************************************



------------------------------

Date: Mon, 13 Jul 1998 17:04:52 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: My script stops searching...
Message-Id: <35AA3E34.2C10@ptsc.slg.eds.com>

Geoff Wild wrote:
> 
> I am trying to search every text file on our system for a particular string.
> 
> The command line is: test.pl <STRING>
> 
> I'm using a script from Larry Wall's Programming Perl book.
> 
> The difference is I want the output to a file, I have tried the script with
> the log file as well as to STDOUT - and once I have hit 94 files, the script
> slowly loses cpu, until it uses nothing.
> 
> I thought maybe it was dying on a large file - but nope - I moved that file
> to another directory - and the script still stops searching after 94 files.
> 
> I get no error messages.....
> 
> Anyone have any ideas I can try?
[snipped script]

Three suggestions:

Don't open the log file in the middle of your while loop, open it before
the FILE: label.

Close the file descriptor TEXTFILE before performing the next while
loop.

Replace "next FILE" with "next" and drop the FILE: label.


------------------------------

Date: Mon, 13 Jul 1998 14:01:41 -0700
From: "Nathan R Heagy" <nheagy@cintek.com>
Subject: NEWBIE: File Age?
Message-Id: <6odlsp$19p$1@news.junction.net>

I am trying to write a simple script that lists files in a directory and
their modification/creation/age dates. I have looked through all the man
pages and perl.com stuff I can, without finding anything: how do I find out
how old a file is, or when it was last modified? I would like it to run on
my win95 machine, which I use for testing, but it will eventually end up on
Apache/Unix, so any platform-specific solutions can be used as well.

Thanks for all answers,
--
Nathan Heagy





------------------------------

Date: Mon, 13 Jul 1998 16:27:08 -0600
From: "Kirk D. Haines" <khaines@oshconsulting.com>
To: Nathan R Heagy <nheagy@cintek.com>
Subject: Re: NEWBIE: File Age?
Message-Id: <6oe1dm$mmb$1@news-2.news.gte.net>

Nathan R Heagy wrote:
> 
> I am trying to write a simple script that lists files in a directory and
> their modification/creation/age dates. I have looked through all the man
> pages and perl.com stuff I can, without finding anything: how do I find out
> how old a file is, or when it was last modified? I would like it to run on
> my win95 machine, which I use for testing, but it will eventually end up on
> Apache/Unix, so any platform-specific solutions can be used as well.

perldoc -f stat


Kirk Haines


------------------------------

Date: Mon, 13 Jul 1998 15:31:15 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: NEWBIE: File Age?
Message-Id: <MPG.10142a8ebee18665989709@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6odlsp$19p$1@news.junction.net> on Mon, 13 Jul 1998 14:01:41 
-0700, Nathan R Heagy <nheagy@cintek.com> says...
> I am trying to write a simple script that lists files in a directory and
> their modification/creation/age dates. I have looked through all the man
> pages and perl.com stuff I can, without finding anything: how do I find out
> how old a file is, or when it was last modified? I would like it to run on
> my win95 machine, which I use for testing, but it will eventually end up on
> Apache/Unix, so any platform-specific solutions can be used as well.

Look again, for -M and -C file tests, under -X in perlfunc.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 13 Jul 1998 22:04:18 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Parsing Perl
Message-Id: <6oe092$e5$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <6odqld$3vu$1@csnews.cs.colorado.edu>:
> In comp.lang.perl.misc, alias@mcs.com writes:
> :Yes. Specifically, see the B::Deparse module in recent development versions
> :(originally by Malcolm, significantly enhanced by me). It generates perl
> :code, marks up the beginnings and ends of blocks, and uses this to do
> :rudimentary indentation. Its current idea of `beauty' is pretty simplistic,
> :but it could be extended to handle lining up parts of expressions, syntax
> :highlighting, etc.
> 
> Does it lose the comments and pods?

It loses almost everything.  It is done after constant folding, so
some functions may have been already called.

Imagine that it is working on the result of -Dx.

Ilya


------------------------------

Date: Mon, 13 Jul 1998 23:54:56 +0100
From: Andy Bold <bytealite@yahoo.com>
Subject: Re: Password script
Message-Id: <35AA9040.56391FB8@yahoo.com>

brian d foy wrote:
> 
> In article <6o2p42$8k1$1@nnrp1.dejanews.com>, rpearce@my-dejanews.com posted:
> 
> >In article <35a18936.1650343@dub-news.tpgi.com.au>,
> >  mail@moggy.com (Bee Pee) wrote:
> >>
> >> I'm lookin for a password script (free one preferrably) which will
> >> protect a bunch of directories (not necessarily in the same root dir).
> >>
> >Use .htaccess built in to unix.
> 
> my unix doesn't have that feature.

Nor mine... Apache WWW server can use .htaccess files to control access
to directories.  Rather than go looking for a passwd script, why not do
a man "chmod" and get down to some homework on file permissions ;-)


------------------------------

Date: Mon, 13 Jul 1998 20:48:11 +0100
From: Andy Bold <bytealite@yahoo.com>
Subject: Re: Perl 4 compilation on Solaris 2.6
Message-Id: <35AA647B.1D95891E@yahoo.com>

Brad Skrbec wrote:
> 
> Has anyone successfully compiled version 4.036 on Solaris 2.6?
> Thanks in advance for your help!
> 
> Brad Skrbec
> Lead Engineer
> Motorola Inc

I came across very similar problems under ICL DRS/NX on SPARC, which as
far as I can tell, is a rebadged Solaris.  (ICL have stated binary
compatibility with Solaris 2.1 ...), although my problems were with Perl
5.004.04

Anyway, I eventually traced all my problems to the version of the C
compiler I was using.  The default cc is a SVR4 version compiler (?),
but there's also a UCB compiler in somewhere like /usr/ucb/cc or
/usr/ucb/bin/cc.  (Sorry that I can't be more specific, but I'm at home
and I've not got access to the office server.)

Hope this helps.




------------------------------

Date: Mon, 13 Jul 1998 23:54:06 +0100
From: Andy Bold <bytealite@yahoo.com>
Subject: Re: Perl 4 compilation on Solaris 2.6
Message-Id: <35AA900E.45DFB2C4@yahoo.com>

Brad Skrbec wrote:
> 
> Has anyone successfully compiled version 4.036 on Solaris 2.6?
> Thanks in advance for your help!
> 
> Brad Skrbec
> Lead Engineer
> Motorola Inc

I came across very similar problems under ICL DRS/NX on SPARC, which as
far as I can tell, is a rebadged Solaris.  (ICL have stated binary
compatibility with Solaris 2.1 ...), although my problems were with Perl
5.004.04

Anyway, I eventually traced all my problems to the version of the C
compiler I was using.  The default cc is a SVR4 version compiler (?),
but there's also a UCB compiler in somewhere like /usr/ucb/cc or
/usr/ucb/bin/cc.  (Sorry that I can't be more specific, but I'm at home
and I've not got access to the office server.)

Hope this helps.


------------------------------

Date: Mon, 13 Jul 1998 23:54:48 +0100
From: Andy Bold <bytealite@yahoo.com>
Subject: Re: Perl installation (Version Perl 5.004_04)
Message-Id: <35AA9038.E453BEA9@yahoo.com>

> Could anybody help me?
> After compilation and configuration of Perl5.004_004 I wrote: make and I
> got the following message:
> 
> rm -f libperl.a
> ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o regcomp.o
> dump.o util.o mg.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o
> pp_sys.o doop.o doio.o regexec.o taint.o deb.o universal.o globals.o
> perlio.o
> make: ar: Command not found

Make sure that ar is in your $PATH before typing make.  If you don't
know where "ar" lives on your system, try "find / -name ar -print".


------------------------------

Date: Mon, 13 Jul 1998 21:08:45 GMT
From: birgitt@my-dejanews.com
Subject: Re: Putting CPAN on a CD: good or not good?
Message-Id: <6odt0t$st6$1@nnrp1.dejanews.com>

In article <fl_aggie-1207981425490001@aggie.coaps.fsu.edu>,
  fl_aggie@thepentagon.com (I R A Aggie) wrote:
> In article <6oa77g$p1a$1@nnrp1.dejanews.com>, birgitt@my-dejanews.com wrote:
>
> + The attached CD-ROM to the magazin is something done often in Germany,
> + apparently because online time to download things directly is
> + expensive. That is my assumption and I like to be corrected if
> + I am wrong.
>
> My understanding of the telecom system in Germany is this: you pay for
> every call you make. There's no such thing as "free local calling".
>
> James
>

Right, you pay around 8 cents for every 48 seconds of a local call during
business hours, for every 65 seconds morning and evening hours, for
every 96 seconds during nightime hours.

Birgitt Funk

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: 13 Jul 1998 21:19:03 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Quickie: the number of occurences of a character in a string
Message-Id: <slrn6qkui3.ij.gabor@guava.vmunix.com>

In comp.lang.perl.misc, Andre L. <alecler@cam.org> wrote :
# In article <6odh9t$s2g$1@nnrp1.dejanews.com>, shapiroj@logica.com wrote:
# 
# > I want to find the number of occurences of a given character ($char) in a
# > particular string, ($text). I thought there would be some cool, quick method
# > to do this using m//, but all I've been able to come up with is:
# > 
# > $number_of_occur = scalar ( @temp = ($text =~ /$char/g));
# > 
# > which is nice because it's one-line, but the @temp array is ick. (And -w
# > doesn't like it either.) Any suggestions?
# 
# 
# $num = () = $text =~ /$char/g;
# 
# HTH,
# A.L.

$cnt = tr/a//;
replace 'a' with whatever character you want to count


------------------------------

Date: 13 Jul 1998 22:21:32 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Quickie: the number of occurences of a character in a string
Message-Id: <6oe19c$5ov$2@marina.cinenet.net>

Larry Rosler (lr@hpl.hp.com) wrote:
: In article <6odmf9$26f$1@earth.superlink.net> on Mon, 13 Jul 1998 
: 15:16:57 EDT, David A. Black <dblack@saturn.superlink.net> says...
: > You could do:
: > 
: > $num = $text =~ s/$char/$char/g;
: > 
: > or
: > 
: > $num = $text =~ s/($char)/$1/g;  # which would be more /i friendly, if
: >                                  # that mattered
: 
: What makes you think that?  These two statements have identical 
: functions.

They do for the simple requirement given.  His point is that, if you add
an /i modifier, the latter one preserves case, which the former does not. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: Mon, 13 Jul 1998 20:54:21 GMT
From: marius77@my-dejanews.com
Subject: Reading Directories w/ Perl
Message-Id: <6ods5t$rc6$1@nnrp1.dejanews.com>

I'm stumped on this and I'm sure there is a very easy solution so hopefully
someone can help me out.  All I need to do is be able to look at a specific
directory with my script and get all of the filenames within that directory. 
It doesn't even need to recursively go through the whole directory tree.

I just want to be able to feed it a directory name and get the names of the
files it contains...that's all.  Any help would be appreciated.  Thanks!!

Marius

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: Mon, 13 Jul 1998 21:04:09 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Reading Directories w/ Perl
Message-Id: <6odssl$bp$3@strato.ultra.net>

[ posted and mailed ]

marius77@my-dejanews.com wrote:
-> I'm stumped on this and I'm sure there is a very easy solution so hopefully
-> someone can help me out.  All I need to do is be able to look at a specific
-> directory with my script and get all of the filenames within that directory. 
-> It doesn't even need to recursively go through the whole directory tree.
-> 
-> I just want to be able to feed it a directory name and get the names of the
-> files it contains...that's all.  Any help would be appreciated.  Thanks!!

perldoc -f opendir
perldoc -f readdir


HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972 
  Ext: 1949 and let the jerk that answers know 
  that his toll free number was sent as spam. "


------------------------------

Date: 13 Jul 1998 14:10:54 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: Reading Directories w/ Perl
Message-Id: <6odt4u$kkg@Xenon.Stanford.EDU>

In article <6ods5t$rc6$1@nnrp1.dejanews.com>,
 <marius77@my-dejanews.com> wrote:
>I'm stumped on this and I'm sure there is a very easy solution so hopefully
>someone can help me out.  All I need to do is be able to look at a specific
>directory with my script and get all of the filenames within that directory. 
>It doesn't even need to recursively go through the whole directory tree.
>
>I just want to be able to feed it a directory name and get the names of the
>files it contains...that's all.  Any help would be appreciated.  Thanks!!

$ perldoc -f readdir
=item readdir DIRHANDLE

Returns the next directory entry for a directory opened by opendir().
If used in a list context, returns all the rest of the entries in the
directory.  If there are no more entries, returns an undefined value in
a scalar context or a null list in a list context.

If you're planning to filetest the return values out of a readdir(), you'd
better prepend the directory in question.  Otherwise, because we didn't
chdir() there, it would have been testing the wrong file.

    opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
    @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
    closedir DIR;

-- 
Kelly William Hirano	                    Stanford Athletics:
hirano@cs.stanford.edu	                 http://www.gostanford.com/
hirano@alumni.stanford.org      (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20


------------------------------

Date: Mon, 13 Jul 1998 18:24:36 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Recommend me Perl!
Message-Id: <comdog-ya02408000R1307981824360001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6odnon$cul$1@nnrp1.dejanews.com>, c960901@student.dtu.dk posted:

>I've never written a line of Perl, but I'm going to in the very near future.
>I need someone to recommend me -the best- Perl book available. 
Absolutely postively:

Learning Perl (Llama on cover)
Randal L. Schwartz & Tom Christiansen
ISBN 1-56592-284-0 
<URL:http://www.oreilly.com>

Programming Perl (Camel on cover)
Larry Wall, Tom Christiansen & Randal L. Schwartz
ISBN 1-56592-149-6
<URL:http://www.oreilly.com>

and, if you are on a Windoze machine (so says your newsreader), there
is a "Learning Perl on Win32" or somesuch.  it has a gecko on the
cover.


>What can Perl
>do? I've seen only little Perl code. Can it scan a directory for subdirs and
>files and return the names in a string array? Cause that's what I really
>need.

come on - challenge Perl!  scanning a directory and getting the file
names needs one line for each:

   opendir(DIRECTORY, $directory_path) or die "Error: $!";
   @files = readdir(DIRECTORY);

Perl can even do things that take *more* than two lines. :)

good luck and welcome to the oasis ;)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
llamas are furry and warm.  geckos are cold-blooded.  the choice is yours.


------------------------------

Date: 13 Jul 1998 22:30:40 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Recommend me Perl!
Message-Id: <6oe1qg$5ov$3@marina.cinenet.net>

c960901@student.dtu.dk wrote:
: I've never written a line of Perl, but I'm going to in the very near future.

Congratulations!

: I need someone to recommend me -the best- Perl book available.

I'm going to cheat and recommend two:

_Learning Perl_  (Schwartz and Wall)
_Programming Perl_ (Schwartz, Wall, and Christiansen)

The former will bring you up to speed on the basics of the language; the
latter is an invaluable reference and learning tool for when you get past
what _Learning Perl_ covers.  Both books are published by O'Reilly.
You'll frequently see them called the "Llama" and "Camel" books
respectively, because that's what is on their covers.

: What can Perl do?

Damn near anything short of miracle weight loss in days, near as I can
tell.  It's ideal as a platform-independent scripting language, and also
as a text-processing language.  These two attributes in turn make Perl
very popular as a CGI implementation language, though Perl is a lot more
than that.

: I've seen only little Perl code. Can it scan a directory for subdirs and
: files and return the names in a string array? Cause that's what I really
: need.

Yes, three different ways I can think of offhand, and there are probably
others out there.

Best of luck, and happy Perling!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: 13 Jul 1998 22:41:22 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Recommend me Perl!
Message-Id: <6oe2ei$akh$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    cberry@cinenet.net (Craig Berry) writes:
:_Learning Perl_  (Schwartz and Wall)
:_Programming Perl_ (Schwartz, Wall, and Christiansen)

Man, it gets worse every day. :-(

_Programming Perl_ (Wall, Christiansen, and Schwartz)
_Learning Perl_    (Schwartz and Christiansen; foreword by Wall)

--tom
-- 
Why would you WANT to port C news to your PC?  Wouldn't it be smarter
and about as cost-effective to port your PC over to the trashcan and buy
a real computer that runs a real operating system like Unix? --Brian Kantor (brian@ucsd.edu)


------------------------------

Date: 13 Jul 1998 22:46:30 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Recommend me Perl!
Message-Id: <6oe2o6$5ov$5@marina.cinenet.net>

Craig Berry (cberry@cinenet.net) wrote:
: _Learning Perl_  (Schwartz and Wall)

<preempt flame_from=tomc>
Make that "Schwartz and Christiansen" -- with a *foreward* by Wall.
</preempt>

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: Mon, 13 Jul 1998 15:13:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <MPG.101426773897f36989708@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <comdog-ya02408000R1307981607480001@news.panix.com> on Mon, 13 
Jul 1998 16:07:48 -0400, brian d foy <comdog@computerdog.com> says...
> In article <35AACA77.D9C@alpha.futurenet.co.za>, karsten.no.123.spam@alpha.futurenet.co.za posted:
> 
> >I am writing a CGI script which accepts input via QUERY_STRING. 
> >However, the input is only valid if it consists of EXACTLY 3 DIGITS!  No
> >more , no less, no other characters in front, after or in between the
> >digits.  Ive tried things such as:
> >
> >if ($ENV{'QUERY_STRING'} =~ /[0-9]\{3\}/)
> 
> why are you escaping the curlies? :)
> 
> try
> 
>    $string =~ m/^\d{3}(?!\n)$/

Tes.  The *four* others of us who responded so far are wrong, wrong, 
wrong, wrong!  The key is here, from perlre:

$   Match the end of the line (or before newline at the end)

It's harder to find in the Blue Camel (in the text at p. 67, second 
line).  The corresponding table entry says only:

$   Matches at the end of the string (or line, if /m is used)

Thanks for the enlightenment, brian.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 13 Jul 1998 22:34:26 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <6oe21i$5ov$4@marina.cinenet.net>

Karsten (karsten.no.123.spam@alpha.futurenet.co.za) wrote:
: I am writing a CGI script which accepts input via QUERY_STRING. 
: However, the input is only valid if it consists of EXACTLY 3 DIGITS!  No
: more , no less, no other characters in front, after or in between the
: digits.  Ive tried things such as:
: 
: if ($ENV{'QUERY_STRING'} =~ /[0-9]\{3\}/)

Why are you backwhacking those curly braces, thereby removing the very
behavior you want to get?  As written, this matches a single digit
followed by the string '{3}'.  Ditch the \ before each curly and this
would match exactly three digits -- though /\d{3}/ is easier to type and
means the same thing.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: Mon, 13 Jul 1998 20:49:37 GMT
From: faganb@my-dejanews.com
Subject: script opening another script
Message-Id: <6odrt1$r88$1@nnrp1.dejanews.com>

I have the following two scripts. The first prints, but the second never
outputs anything. No error message is printed. What am I doing wrong?  Thanks
for the help.

-Brant

Script 1:

#!bin/perl
print "This is a test\n";
open (SUBPROC, "/u/tct/SuperScripts/hi.pl |") || die "Can't open subproc";
print $_;


Script 2:
#!bin/perl
print "hi world\n";


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: Mon, 13 Jul 1998 21:29:56 GMT
From: "Rick Koehler" <rkoehler@osmre.gov>
Subject: Re: Urgent!! Need Programmer for perm in Malibu, Ca
Message-Id: <Ew1yDI.Fo8@igsrsparc2.er.usgs.gov>

>We need a programmer learned in C, C++, Java, Active X, and ASP
>for a perm position in Malibu, Ca.  Good Salary.
[snip snap snip]

Methinks we're off-track here; they're not looking for someone to
fill a perm position in the exciting Hair Styles field.  Instead,
I believe there's a secret government project to create
"permafrost" near Malibu ... a vast expanse of frozen tundra,
complete with musk oxen, arctic hares, and stunted plants.

Apparently, the concept is a ambitious one, in that they'll be
attempting to replicate same using C, C++, Java, etc.
If they had any sense, they'd be using perl, to take advantage
of the Critters::Arctic and Climate::Control::Frosty modules.
(doesn't *anyone* use CPAN?)

It's nice to be helpful, isn't it? =8^)




------------------------------

Date: Mon, 13 Jul 1998 23:55:09 +0100
From: Andy Bold <bytealite@yahoo.com>
To: richard@carval.co.uk
Subject: Re: Using Perl to generate HTML Pages.
Message-Id: <35AA904D.1F1DDD8C@yahoo.com>

> 
> What I would like to know is how to call a perl function which produces
> plain text output which can be imbedded into a HTML page!

If your hosting on a Unix box, take a look at the Apache WWW server with
mod_perl and Perl::Embed.

-- 
Andy Bold
bytealite@yahoo.com
"There is no Try or Try Not, only Do, or Do Not..." - Yoda.


------------------------------

Date: Mon, 13 Jul 1998 23:55:35 +0100
From: Andy Bold <bytealite@yahoo.com>
To: richard@carval.co.uk
Subject: Re: Using Perl to generate HTML Pages.
Message-Id: <35AA9067.4C35EDBC@yahoo.com>

> 
> What I would like to know is how to call a perl function which produces
> plain text output which can be imbedded into a HTML page!

If your hosting on a Unix box, take a look at the Apache WWW server with
mod_perl and Perl::Embed.

-- 
Andy Bold
bytealite@yahoo.com
"There is no Try or Try Not, only Do, or Do Not..." - Yoda.


------------------------------

Date: Mon, 13 Jul 1998 23:55:54 +0100
From: Andy Bold <bytealite@yahoo.com>
To: richard@carval.co.uk
Subject: Re: Using Perl to generate HTML Pages.
Message-Id: <35AA907A.A9563477@yahoo.com>

> 
> What I would like to know is how to call a perl function which produces
> plain text output which can be imbedded into a HTML page!

If your hosting on a Unix box, take a look at the Apache WWW server with
mod_perl and Perl::Embed.

-- 
Andy Bold
bytealite@yahoo.com
"There is no Try or Try Not, only Do, or Do Not..." - Yoda.


------------------------------

Date: Mon, 13 Jul 1998 23:59:08 +0100
From: Andy Bold <bytealite@yahoo.com>
To: richard@carval.co.uk
Subject: Re: Using Perl to generate HTML Pages.
Message-Id: <35AA913C.24D33715@yahoo.com>

> 
> What I would like to know is how to call a perl function which produces
> plain text output which can be imbedded into a HTML page!

If your hosting on a Unix box, take a look at the Apache WWW server with
mod_perl and Perl::Embed.

-- 
Andy Bold
bytealite@yahoo.com
"There is no Try or Try Not, only Do, or Do Not..." - Yoda.


------------------------------

Date: Tue, 14 Jul 1998 00:00:31 +0100
From: Andy Bold <bytealite@yahoo.com>
Subject: Re: Using Perl to generate HTML Pages.
Message-Id: <35AA918F.4EA63A29@yahoo.com>

> 
> What I would like to know is how to call a perl function which produces
> plain text output which can be imbedded into a HTML page!

If your hosting on a Unix box, take a look at the Apache WWW server with
mod_perl and Perl::Embed.

-- 
Andy Bold
bytealite@yahoo.com
"There is no Try or Try Not, only Do, or Do Not..." - Yoda.


------------------------------

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 3145
**************************************

home help back first fref pref prev next nref lref last post