[11344] in Perl-Users-Digest
Perl-Users Digest, Issue: 4944 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 19 19:07:20 1999
Date: Fri, 19 Feb 99 16:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 19 Feb 1999 Volume: 8 Number: 4944
Today's topics:
Re: ${%x}{"a"} = "b"; # Why does this work !!!! <aqumsieh@matrox.com>
[Q] CGI.pm for CGI script? (green)
Re: [Q] CGI.pm for CGI script? (Alastair)
Re: Executing a Program <jabbott@dingo.smig.net>
Re: Executing a Program <emschwar@mail.uccs.edu>
Re: FAQ 5.17: How can I lock a file? <tchrist@mox.perl.com>
Re: FAQ 5.25: How can I read a single character from a (Ilya Zakharevich)
FAQ 8.24: Why can't I get the output of a command with <perlfaq-suggestions@perl.com>
getpwent problem on IRIX 6.5 <akalnins@ford.com>
Handling files greater than 2.1 GB <amod.kale@vlsi.com>
Re: Help a new Perl student Please <kenhirsch@myself.com>
Help with Piping <nullspace@hotmail.com>
Re: Help with Piping (Larry Rosler)
how do you find if a string contains something?? (blag)
Re: how do you find if a string contains something?? <terjekv@ifi.uio.no>
Re: Installation Errors <jglascoe@giss.nasa.gov>
perl 5.005_02 compilation fails on IRIX 6.2 <*#^&$@ennui.org>
Re: Perl flock question <smiles@wfubmc.edu>
Re: Perl flock question <terjekv@ifi.uio.no>
Re: Perl flock question (I R A Aggie)
Perl script and Access 95 <sing.loon@uq.net.au>
Re: Perl, PHP, Python, ColdFusion, MS Frontpage, which <aqumsieh@matrox.com>
Problem w/ Recursive functions <jalil@corp.home.net>
Re: Problem w/ Recursive functions <jalil@corp.home.net>
Re: reading a whole file into a string <aqumsieh@matrox.com>
Re: REGEX $1, $2 ... array? (Charles DeRykus)
Re: regex poll <scribble@pobox.com>
Re: Returning file tests under Win95 and WinNT <kenhirsch@myself.com>
Re: unpack scraig@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 Feb 1999 13:58:26 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: ${%x}{"a"} = "b"; # Why does this work !!!!
Message-Id: <x3ysoc2kypa.fsf@tigre.matrox.com>
Tony Edwardson <tony.edwardson@usa.net> writes:
> Can anyone explain why the following snippet works
> #!/apps/exe/perl5.004.04 -w
>
> my %x;
>
> ${%x}{"a"} = "b"; # Why does this work !!!!
>
> foreach $key (keys %x) {
> print "$key=$x{$key}\n";
> }
>
> The output is
> a=b
>
> What is happening in the ${%x}{"a"} construct ?
>
> Any ideas anyone ?
I am not sure, but look at this:
% perl -w
my %x;
print ${%x}, "<<\n";
__END__
this prints:
-<<
But,
% perl -w
my %x;
$x{'a'} = 'b';
print ${%x}, "<<\n";
__END__
prints:
Use of uninitialized value at - line 3.
<<
I have no idea what is happening here. Anybody shed some more light?
Looks like a bug to me.
Ala
------------------------------
Date: 19 Feb 1999 23:03:09 GMT
From: research@proton.vlsi.uiuc.edu (green)
Subject: [Q] CGI.pm for CGI script?
Message-Id: <7akqjd$j1t$1@vixen.cso.uiuc.edu>
Keywords: [Q] CGI.pm for CGI script?
Hello!
I would like to ask a simple question about
how to run a Perl CGI script.
I just installed Perl 5.005_01 to use CGI.pm.
Now I'm trying to run a simple test CGI script,
but all I can see on the Web is just a simple text file,
not the result.
This is the source code I'm testing which I got from
the internet where Perl5 is explained,
but I can't find a document how to run it.
---------------------------------------
#!/usr/local/bin/perl
use lib '/usr/local/lib/perl5';
use CGI qw(:standard);
print header('text/plain'), "Nothing to it!";
---------------------------------------
How can I run it on the Web?
Any replies would be appreciated.
Newbie in Perl.
------------------------------
Date: Fri, 19 Feb 1999 23:11:39 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: [Q] CGI.pm for CGI script?
Message-Id: <slrn7crs00.56.alastair@calliope.demon.co.uk>
green <research@proton.vlsi.uiuc.edu> wrote:
>
>
>Hello!
>
>I would like to ask a simple question about
>how to run a Perl CGI script.
>
>I just installed Perl 5.005_01 to use CGI.pm.
>Now I'm trying to run a simple test CGI script,
>but all I can see on the Web is just a simple text file,
>not the result.
Your web server us misconfigured. Check that you have it configured for CGI. A
web server newsgroup is the place to ask about this.
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Fri, 19 Feb 1999 22:48:16 +0000
From: abbott in Northfield <jabbott@dingo.smig.net>
Subject: Re: Executing a Program
Message-Id: <36CDEA30.FE04A5CC@dingo.smig.net>
nullspace wrote:
>
> running the compiled program from my script. I thought it was the exec("
> /test/a.out & ") command. It works to a point. The program runs but anything
> after that call in my perl script doesn't get reached. I thought that there
> must be a way to find out if a.out has finished but I just don't know the
> proper code. Any help would definitely be appreciated. Thanks!!
>
To quote Tom Christiansen who wrote this to me this very day..... :-)
--ja
TC->
Somehow you appear to have missed the proper answer when you studiously
searched the standard Perl documentation on your very own system.
It was there waiting for you.
% man perlfaq8
...
Why can't I get the output of a command with system()?
You're confusing the purpose of system() and backticks (``).
system() runs a command and returns exit status information (as
a 16 bit value: the low 7 bits are the signal the process died
from, if any, and the high 8 bits are the actual exit value).
Backticks (``) run a command and return what it sent to STDOUT.
$exit_status = system("mail-users");
$output_string = `ls`;
:Any suggestions? Is a system call not the best way to do this?
You haven't made a system call. A system call is a transition from user
space to kernel space, such as you find in section two of the standard
manual, or in Perl when you run something like this:
syscall(&SYS_gettimeofday, $start, 0)
You are talking about running external commands through the shell and
ignoring their output. This is not a system call. (Well, actually,
it's many, but you know what I mean -- I hope.)
--tom
------------------------------
Date: 19 Feb 1999 16:56:26 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: Executing a Program
Message-Id: <xkfhfsikkwl.fsf@valdemar.col.hp.com>
"nullspace" <nullspace@hotmail.com> writes:
> So far, I can do (1) and (3) but I'm having trouble with the code for
> running the compiled program from my script. I thought it was the exec("
> /test/a.out & ") command. It works to a point. The program runs but anything
> after that call in my perl script doesn't get reached. I thought that there
> must be a way to find out if a.out has finished but I just don't know the
> proper code.
It took me about 30 seconds (I had to check the main index for perlfaq,
and try two different pages to get the right one) to find:
perldoc perlfaq8, "How come exec() doesn't return?"
If you check the FAQs before you post to the newsgroup, you'll get the
answer a lot faster than however long it takes you to get this response,
plus you'll come across as a lot less annoying.
-=Eric
------------------------------
Date: 19 Feb 1999 15:58:51 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 5.17: How can I lock a file?
Message-Id: <36cdecab@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:This is a blatant lie.
You just outlived your usefulness.
--tom
--
Fungus doesn't take a vacation. --Rob Pike
------------------------------
Date: 19 Feb 1999 21:41:24 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 5.25: How can I read a single character from a file? From the keyboard?
Message-Id: <7aklq4$9du$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Dan Carson
<dbc@dbc-pc.tc.fluke.com>],
who wrote in article <Pine.LNX.4.00.9902181527180.22635-100000@dbc-pc.tc.fluke.com>:
> > For legacy DOS systems, Dan Carson <dbc@tc.fluke.COM> reports the
> > following:
>
> Since my name is attached to what follows, I should point out that this
> is very old data. This is something that worked with a particular DOS
> port of perl4 circa 1991, if I remember right. I don't think ioctl() is
> supported in the currently popular builds.
EMX build has it. I would guess that so does DJGCC.
Ilya
------------------------------
Date: 19 Feb 1999 15:34:29 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 8.24: Why can't I get the output of a command with system()?
Message-Id: <36cde6f5@csnews>
(This excerpt from perlfaq8 - System Interaction
($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
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/perlfaq8.html
if your negligent system adminstrator has been remiss in his duties.)
Why can't I get the output of a command with system()?
You're confusing the purpose of system() and backticks (``). system()
runs a command and returns exit status information (as a 16 bit value:
the low 7 bits are the signal the process died from, if any, and the
high 8 bits are the actual exit value). Backticks (``) run a command and
return what it sent to STDOUT.
$exit_status = system("mail-users");
$output_string = `ls`;
--
Chip Salzenberg sent me a complete patch to add System V IPC (msg, sem and
shm calls), so I added them. If that bothers you, you can always undefine
them in config.sh. :-) --Larry Wall in <9384@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Fri, 19 Feb 1999 16:16:32 -0500
From: Atis Kalnins <akalnins@ford.com>
Subject: getpwent problem on IRIX 6.5
Message-Id: <36CDD4B0.F82C4405@ford.com>
The code in the snipet below does not work.
It only prints out the NIS entries and yes the nsswitch.conf file looks
correct
listing files nis in order on the nis line.
the getpwent is suppose to print out all the users. Does anyone think
it is a 6.5 bug?
perl -v
This is perl, version 5.004_04 built for irix-n32
Copyright 1987-1997, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.
OK, my problem.
-----snip snip snip-----
#!/ford/thishost/unix/bin/perl
while(($name,$passwd,$uid) = getpwent){
print STDOUT "$name $uid\n";
}
-----snip snip snip-----
IRIX64 SCRAMBLEDFORSECURITY 6.5 01221553 IP28
uname -R
6.5 6.5.3m
------------------------------
Date: Fri, 19 Feb 1999 13:36:37 -0800
From: Amod Kale <amod.kale@vlsi.com>
Subject: Handling files greater than 2.1 GB
Message-Id: <36CDD965.D7E648D3@vlsi.com>
I have a perl script which I use to do some processing on
some large files.
Till now I have never encountered problems with the script
because my file size was always less than 2.1 GB.
Now my file size has grown to 2.2 GB and the perl script
refuses to recognize it.
Is there any switch / workaround for this other than
splitting my file into smaller files and modifying
my perl script?
An email directly to me will be appreciated.
Thanks
Amod
--
===============================================================
Amod Kale Amod.Kale@vlsi.com
Design Center Manager Voice: (408)474-7394
VLSI Technology Inc. Fax: (408)922.5252
1240 McKay Drive, M/S 41
San Jose, CA 95132
===============================================================
------------------------------
Date: Fri, 19 Feb 1999 16:43:49 -0500
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: Help a new Perl student Please
Message-Id: <7akluk$1qc$1@fir.prod.itd.earthlink.net>
Mickey Todd wrote in message <36CC4EED.70282FC6@hcranches.com>...
>Sounds like you have a similar problem as I did. Mine deals with using
Win95
>and associated applications. The Win95 registry "understands" certain file
>types and associates file extensions to those file types and saves a "new"
file
>with a particular file extension. I use WordPad to create my text files.
After
>I save it the first time I have to go out to a DOS window and rename the
file
>correctly and then re-load it into WordPad. Then everytime I save the file
as a
>Text Document it is saved with the correct file name. I know this isn't
the
>"right" solution, but I haven't found out how to correct the initial
problem.
>
>"William M. Toohey" wrote:
It would be better to use a programmers editor. Anyway, the easy solution
is to use double quotes around the name of the file in the File Name box of
the Save As ... dialog box.
Also, you can in windows change the associations for file types. On my
system the default "Open" action for text files and perl programs is to run
Gvim. You might want the default action for perl programs be to run the
program although that rarely makes sense for me since I usually use
arguments and/or input-output redirection when I run perl programs. You can
also add other actions (e. g. "edit") which are available when you
right-click on a file icon.
See http://www.vim.org for downloading Vim
Ken Hirsch
Carrboro, NC
------------------------------
Date: Fri, 19 Feb 1999 18:31:56 -0400
From: "nullspace" <nullspace@hotmail.com>
Subject: Help with Piping
Message-Id: <7akoni$jot$1@News.Dal.Ca>
Hi,
I'm trying to write a script that looks something like this (in chuncks):
1)Writes two values to a file
2)Runs a complied program from inside the script by calling it( an a.out
file)
3)Reads an outfile that the a.out program creates back into the script for
manipulation.
So far, I can do (1) and (3) but I'm having trouble with the code for
running the compiled program from my script.
I thought it was the exec(" /test/a.out & ") command. It works to a point.
The program runs but anything after that call in my perl script doesn't get
reached. I thought that there
must be a way to find out if a.out has finished but I just don't know the
proper code.
I assume this is called piping so I thought I would post it as such.
Any help would definitely be appreciated. Thanks!!
Chris
------------------------------
Date: Fri, 19 Feb 1999 15:31:42 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help with Piping
Message-Id: <MPG.1137943d96a0d288989a61@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7akoni$jot$1@News.Dal.Ca> on Fri, 19 Feb 1999 18:31:56 -
0400, nullspace <nullspace@hotmail.com> says...
...
> I thought it was the exec(" /test/a.out & ") command. It works to a point.
> The program runs but anything after that call in my perl script doesn't get
> reached.
You would understand this immediately if you read the documentation of
the 'exec' function (it's in the first paragraph!). It would also point
you in the right direction.
`perldoc-f exec`
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 19 Feb 1999 22:08:17 GMT
From: sads (blag)
Subject: how do you find if a string contains something??
Message-Id: <36cde090.2022177@news.mindspring.com>
im new to perl and i wanna know how i could figure out if a host
address (bou-058.dorm.uml.edu) contains "uml.edu" ??
------------------------------
Date: 19 Feb 1999 23:11:17 +0100
From: Terje Kvernes <terjekv@ifi.uio.no>
Subject: Re: how do you find if a string contains something??
Message-Id: <wxxg182jb7e.fsf@gjallarhorn.ifi.uio.no>
sads (blag) writes:
> im new to perl and i wanna know how i could figure out if a host
> address (bou-058.dorm.uml.edu) contains "uml.edu" ??
Long;
perldoc perlre
Short;
if ($host =~ /uml\.edu$/) {
print "$host is under the domain uml.edu!\n";
}
--
Terje
------------------------------
Date: Fri, 19 Feb 1999 18:01:49 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Scott Ranzal <scott.ranzal@mci.com>
Subject: Re: Installation Errors
Message-Id: <36CDED5D.2DD461E@giss.nasa.gov>
[courtesy copy of post sent to Scott]
hi Scott,
Scott Ranzal wrote:
>
> cc my way through things and then I get to:
>
> undefined first referenced
> symbols in file
>
> atan2 libperl.a
> cos libperl.a
> exp libperl.a
> log libperl.a
> sqrt libperl.a
> ... libperl.a
all of these symbols are defined in the math C library.
So, I think you need to add a "-lm" argument to cc when
building your perl library.
--
"Try not! there is no *try*, only *do*."
-- Yoda
------------------------------
Date: 19 Feb 1999 15:36:14 -0800
From: onomatopoetic justice <*#^&$@ennui.org>
Subject: perl 5.005_02 compilation fails on IRIX 6.2
Message-Id: <rone.7akshe$91o$1@ennui.org>
% make
./miniperl configpm tmp
Use of uninitialized value at configpm line 339, <GLOS> chunk 2.
Use of uninitialized value at configpm line 339, <GLOS> chunk 3.
[etc.]
Use of uninitialized value at configpm line 339, <GLOS> chunk 541.
Use of uninitialized value at configpm line 339, <GLOS> chunk 542.
Use of uninitialized value at configpm line 403.
configpm: tmp not valid at configpm line 403.
*** Error code 2 (bu21)
This wasn't a problem on my 6.[345] boxes. I configured it to use gcc
because IRIX cc would barf on certain function calls.
thanks
rone
--
In the truest spirit of usenet I actually have zero idea what I'm talking
about and am making all this up, but it does seem reasonable and has the
added benefint of possibly even beng true.
- Richard Sexton <richard@vrx.net>
------------------------------
Date: Thu, 18 Feb 1999 17:04:38 -0500
From: Steve Miles <smiles@wfubmc.edu>
Subject: Re: Perl flock question
Message-Id: <36CC8E76.39848302@wfubmc.edu>
My thinking is that if you run script one that "requires" a script two, the
system will wait until script one's
processes are over before it lets anyone run script two - thus prevent any
simultaneous usage of both scripts.
Am I right or pure hogwash?
Steve
I R A Aggie wrote:
> On Thu, 18 Feb 1999 13:05:20 -0500, Steve Miles <smiles@wfubmc.edu> wrote:
>
> + My question is: What if in each script you 'require "otherscript.cgi";'
> + so that when one script is called it requires the other - in that case
> + would that solve the database locking problem?
>
> Why do you think this will work?
>
> James
=============================================
Steve Miles (smiles@wfubmc.edu)
----> http://www.groundbreak.com <----
Wake Forest University School of Medicine
5019 Hanes, Medical Center Blvd.
Winston-Salem, NC 27157
Phone: 336.716.0454 FAX: 336.716.7200
=============================================
------------------------------
Date: 19 Feb 1999 23:30:10 +0100
From: Terje Kvernes <terjekv@ifi.uio.no>
Subject: Re: Perl flock question
Message-Id: <wxx90dujabx.fsf@gjallarhorn.ifi.uio.no>
Steve Miles <smiles@wfubmc.edu> writes:
> My thinking is that if you run script one that "requires" a script two, the
> system will wait until script one's
> processes are over before it lets anyone run script two - thus prevent any
> simultaneous usage of both scripts.
It works fine for me... =)
On a multiuser-system like unix here at the unix anything not working
like this would be disaster.
(FYI: perl, version 5.005_02 built for sun4-solaris, sparc)
> Am I right or pure hogwash?
*erhm* =)
--
Terje - =)
------------------------------
Date: 19 Feb 1999 23:06:30 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl flock question
Message-Id: <slrn7crrof.t2f.fl_aggie@enso.coaps.fsu.edu>
On Thu, 18 Feb 1999 17:04:38 -0500, Steve Miles <smiles@wfubmc.edu> wrote:
+ My thinking is that if you run script one that "requires" a script two, the
+ system will wait until script one's
+ processes are over before it lets anyone run script two - thus prevent any
+ simultaneous usage of both scripts.
+
+ Am I right or pure hogwash?
It depends...is the only way to access script2 thru script1? in that
case, they wouldn't get in each others way. script1 would complete,
and close the file before script2 started and opened that file, depending
on the placement of the 'require'.
What about the possibility of two or more instances of script1 running?
You did make a vague reference to a "cgi" -- if your program is hooked
to the CGI interface, you may have many instances of this script1/script2
train running, at various stages of completion.
I can envision something like this occuring:
a script1/script2
b script1/script2
c script1.........../script2
a+b+c=who gets to write what when and where? looks disasterous to me.
I have thus far avoided flock() because I have not needed it.
Therefore, I do not have detailed information about it, and would
recommend looking at perldoc -f flock, doing a dejanews search on this
newsgroup for 'flock', Tom C's recently posted samples, the FAQ, and
Randall's (Web|Unix)Techniques column.
You may want to wander over to your neighborhood bookstore and look
thru the examples in the Perl Cookbook.
James
------------------------------
Date: Sat, 20 Feb 1999 08:53:21 +1100
From: "liu singloon" <sing.loon@uq.net.au>
Subject: Perl script and Access 95
Message-Id: <7akqag$lu$1@bunyip.cc.uq.edu.au>
Hi
I have just created an entertainment web site that mainly lists movie
release dates for Australia and the United States at the moment.
I have Microsoft Access 95 and use Dreamweaver 2.0 and Fireworks/Photoshop
4.01 for my web sites. What I want is to be able to use a MS Access
database to update new entries and delete old entries of movies and there
release dates and then be able to generate a htm/html file etc to display
the listings on specific pages.
Currently, my release dates are set out on 24 html pages - 12 html pages
each for Australia and 12 for US - sorted by months - Jan through to Dec
1999. It doesn't have to be on the fly as such, but can be done or
generated on my computer and then I can upload the htm/html files myself.
I did a search of the web for perl scripts - since my webjump server has a
cgi-bin for them and I can implement this once I learn how to (working on
that at the moment).
An example of intended use in adding a new movie release date for February
1999 in the US - which is the file feb.htm
I would like to be able to add it to a database created in Access 95 and
then for the perl script or program etc to be able to generate a page -
feb.htm
Also I will need to have control over the layout and design of the generated
page to look something like http://georges-place.webjump.com/feb.htm
Is there anything freeware/free on the web that I can go to for such a
script or program, anything that costs a little - no more than AUS$1-30?
Thanks
--
George
-------------------- VISIT ---------------------
http://georges-place.webjump.com/
- 1999 OSCARS - 71st Academy Awards
- Australian/US/HK movie release dates
- Movies, Trailers & Info for 1999 , 2000 , 2001
- i.e. Star Wars Ep 1; The Corruptor & Trailers; 13th Floor; Baby Geniuses;
8 MM; The Deep End of the Ocean; The Matrix; Joan of Arc and
more....
http://www.uq.net.au/~zzgliu/index.htm
- George's Place version 3
- Resume - recent graduate - Bachelor of Commerce
http://www.uq.net.au/~zzgliu/computing.htm
- Ultra-portables
-----------------------------------------
------------------------------
Date: Fri, 19 Feb 1999 13:46:31 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Perl, PHP, Python, ColdFusion, MS Frontpage, which one for beginner
Message-Id: <x3yu2wikz94.fsf@tigre.matrox.com>
Shane Nay <snay@no-junkformeprimenet.com> writes:
> Essentially perl is the most versatile... the other options you
> mentioned are not versatile in the least,
You mention later on that the languages you know are Pascal, C, C++,
Basic and Java. None of these were mentioned by the original poster.
How could you then determine that Perl is the most
versatile of the tools the original poster mentioned? You don't seem
to know all of them.
> As far as how well you need to know perl, or what the learning curve
> is like... well to be honest it's a "scripting" language, so it has
> a much softer curve than real "programming" languages.
Woo .. hold on a minute. What is your notion of a scripting language
and a programming language? Could you please point out the
similarities/differences? Do you have a clear definition of each?
Perl is a scripting language. Perl is a programming language.
Ala -- an avid Perler
------------------------------
Date: Fri, 19 Feb 1999 22:04:59 GMT
From: "Jalil Feghhi" <jalil@corp.home.net>
Subject: Problem w/ Recursive functions
Message-Id: <919461899.880845@zeppelin.svr.home.net>
I am calling my function recursively and it seems to me that the arguments I
pass to my function get changed or something. Could somebody tell me how
should we exactly call a function recursively. Here is part of my code (I
have deleted some lines but the calling convention is unchanged).
Thanks;
-Jalil
sub MoveFilesFromTo {
my ($from, $to, $recursive) = @_;
use File::Copy;
use Cwd;
my $file;
while($file = <${from}>){
if (-d $file){
# we got a dir.
if ($recursive){
MoveFilesFromTo ($file, $to);
}
}
else {
copy ($file, $to) or LogError "Cannot copy $file: $!";
}
}
}
------------------------------
Date: Fri, 19 Feb 1999 22:34:30 GMT
From: "Jalil Feghhi" <jalil@corp.home.net>
Subject: Re: Problem w/ Recursive functions
Message-Id: <919463669.952727@zeppelin.svr.home.net>
It seems that $file in
while($file = <${from}>)
iterates through the old list when called again. I check the value of $from
before the while loop and it
is fine but the globing does not return a value based on the current value
of $from.
Any help would be great.
-Jalil
Jalil Feghhi wrote in message <919461899.880845@zeppelin.svr.home.net>...
>I am calling my function recursively and it seems to me that the arguments
I
>pass to my function get changed or something. Could somebody tell me how
>should we exactly call a function recursively. Here is part of my code (I
>have deleted some lines but the calling convention is unchanged).
>
>Thanks;
>
>-Jalil
>
>sub MoveFilesFromTo {
> my ($from, $to, $recursive) = @_;
>
> use File::Copy;
> use Cwd;
>
> my $file;
>
> while($file = <${from}>){
> if (-d $file){
> # we got a dir.
> if ($recursive){
>
> MoveFilesFromTo ($file, $to);
> }
> }
> else {
> copy ($file, $to) or LogError "Cannot copy $file: $!";
> }
> }
>}
>
>
------------------------------
Date: Fri, 19 Feb 1999 12:16:09 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: reading a whole file into a string
Message-Id: <x3yvhgyl3fw.fsf@tigre.matrox.com>
dhosek@webley.com writes:
>
> Or, rather than mucking about with $/, one could do something like:
Ugh! What a waste! Built-in variables were made for a purpose. Use
them. (this is a weakpoint in Python IMHO).
> $s = join "\n", <IN>;
Adding an empty line between each line in your file isn't very useful.
> because there's always more than one way to solve a problem.
>
> This is probably slower than the $/ solution, but will be a bit less opaque to
> the casual perl reader.
I encourage the casual Perl user to muck about with $/ for the
following reasons:
1) My benchmarks suggest that using join() is ~4 times slower than
modifying $/.
2) Most readers (I hope) will go and read some more about $/, if they
haven't seen|used it before.
3) If someone decides to venture into perlop to read about $/, they
will surely learn much more than what they were hoping for. This is a
Good Thing.
4) using join() will not be very useful if the readers want to read
from a file up to a certain point. For example, reading paragraph by
paragraph, or reading statements that can span multiple physical lines
but are terminated by a defined character (like ';' in Perl and C
code).
Ala - Unleash the power of Perl.
------------------------------
Date: Fri, 19 Feb 1999 22:13:13 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <F7F9q1.FEo@news.boeing.com>
In article <7a9mkp$12c@enews2.newsguy.com>,
William H. Asquith <asquith@macconnect.com> wrote:
>Why isn't there a special array that contains
>$1, $2, $3, etc . . . from application of a regex.
>This would really make things easier.
If you don't have access to the new @+ and @-,
you can always push 'em:
push(@pos, $1, $2) while $tst =~ s/(Hel.*?)(he)//;
or, if a loop isn't needed:
push(@pos, $1, $2) if $tst =~ s/(Hel.*?)(he)//;
or, directly assign if your're just matching as
pointed out earlier.
hth,
--
Charles DeRykus
------------------------------
Date: 19 Feb 1999 14:57:52 -0600
From: Tushar Samant <scribble@pobox.com>
Subject: Re: regex poll
Message-Id: <7akj8g$1sc@masu.wwa.com>
rra@stanford.edu writes:
>The reason for not posting the survey answers is that Uri is taking the
>survey and presumably will collect responses and summarize; that's the
>standard way on Usenet that such things have always been done for decades.
Sorry, I didn't think of that angle.
------------------------------
Date: Fri, 19 Feb 1999 17:25:40 -0500
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: Returning file tests under Win95 and WinNT
Message-Id: <7akocu$53v$1@fir.prod.itd.earthlink.net>
david.willingham@fernhart.com wrote
>The code is as follows:
>
>my $news_dir = "C:/temp";
>my $news="", $created="", $modified="", $accessed="";
>my $cnt=0;
>opendir (NEWS, $news_dir) || die "Cannot open $!";
>while($news[$cnt] = readdir(NEWS)) {
> open(NEWS);
> $created = (-C $news[$cnt]);
> $modified = (-M $news[$cnt]);
> $accessed = (-A $news[$cnt]);
> print("Filename:$news[$cnt], Created:$created, Modified:$modified,
>Accessed:$accessed\n");
> close(NEWS);
> $cnt++;
>}
>closedir(NEWS);
>
>Is the problem with my coding or is it environment specific? Can anyone
>suggest a way forward?
The problem is with your code.
1. take out "open(NEWS)" and "close(NEWS)".
2. read the manual entry on readdir again, specifically,
"If you're planning to filetest the return values out of a readdir(), you'd
better prepend the directory in question"
or chdir()
Ken Hirsch
Carrboro, NC
------------------------------
Date: Fri, 19 Feb 1999 22:17:32 GMT
From: scraig@my-dejanews.com
Subject: Re: unpack
Message-Id: <7aknto$e36$1@nnrp1.dejanews.com>
In article <NEWTNews.919435132.1622.henry@procrusteus.solcom.co.uk>,
henry@solcom.co.uk wrote:
>
> Is it possible to use unpack to unpack different bits of
> a byte into different variables?
> Or does each new element of the format imply moving on to new byte?
New whatever, not just bytes. That is character strings are sequences of
bytes, but numbers, for example, are 8 bytes long.
>
> I thought that for instancewould
> ($upper6bits, $lower2bits) = unpack('B6B2', $somedata)
>
> would extract the upper six bits of the first byte of somedata
> into upper6bits, and the lower two bits of the first byte of
> somedata into lower2bits.
Instead try
($upper6bits, $lower2bits) = unpack('A6A2', unpack( 'B8',$somedata))
The first unpack creates a sequence of character values ( 0's and 1's ). The
second unpack splits it into two characters strings. This may be what you
want.
You may want to check out vec(), with BITS set to 1. This allows looking
at, or setting, individual bits in the input byte.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
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 4944
**************************************