[15837] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3250 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 5 00:05:49 2000

Date: Sun, 4 Jun 2000 21:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960177913-v9-i3250@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 4 Jun 2000     Volume: 9 Number: 3250

Today's topics:
    Re: 如何在pc下安裝perl?? <tshinnic@io.com>
    Re: @INC (Tad McClellan)
    Re: @INC <scott@industrial-linux.org>
    Re: Free programming offerred by student (twma)
        Getting time & date from DOS <mikula@students.uiuc.edu>
    Re: Getting time & date from DOS <tina@streetmail.com>
    Re: Getting time & date from DOS (Joe Smith)
    Re: Getting time & date from DOS (Craig Berry)
    Re: How do I make perl flush? <philip@my-deja.com>
    Re: How do I make perl flush? (Joe Smith)
    Re: How do I make perl flush? (Craig Berry)
    Re: How do I update records in a file?  (cgi & perl) (Peter McMorran)
    Re: How do I update records in a file?  (cgi & perl) (Joe Smith)
    Re: How do you pass a hash reference in Perl 4? <sfighter@cs.utexas.edu>
    Re: How do you pass a hash reference in Perl 4? <makarand_kulkarni@My-Deja.com>
    Re: Module Loading <scott@industrial-linux.org>
        Newbie~~Please Help !!!!!!!!! <agi@feib.com.tw>
        Newbie~~Please Help !!!!!!!!! <agi@feib.com.tw>
    Re: Newbie~~Please Help !!!!!!!!! <tina@streetmail.com>
    Re: Not able to run PERL script as CGI by Apache <scott@industrial-linux.org>
    Re: open http file <scott@industrial-linux.org>
        passing arrays to a subroutine brondsem@my-deja.com
    Re: passing arrays to a subroutine <tina@streetmail.com>
    Re: passing arrays to a subroutine <tina@streetmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 04 Jun 2000 18:01:23 -0500
From: Thomas L. Shinnick <tshinnic@io.com>
Subject: Re: 如何在pc下安裝perl??
Message-Id: <himljs4ii9eou403cnvdlr95mgrbqhn8dq@4ax.com>

On 4 Jun 2000 07:34:26 GMT, "sheu" <dyu_web@pchome.com.tw> wrote:
>hi~
>請問一下perl最新版要去哪下載?而如何在pc下安裝perl?
>Thank you ^^
>
The easiest way to install (安裝?) Perl for PC is to go to the
site at www.activestate.com   The newest versions (最新版?) of Perl 
are also found here.  Try going to
    http://www.activestate.com/Products/ActivePerl/Download.html
Look for "ActivePerl download by platform:" and then "Windows" (they also
have Linux!)  Download the EXE file and just run it.

If you have problems and you are running Win98, you may need
    http://www.activestate.com/download/contrib/Microsoft/9x/InstMsi.exe
If you have problems and you are running Win95, you may also need
    ftp://ftp.microsoft.com/softlib/mslfiles/msvcrt.exe

Do you know about the newsgroup tw.bbs.comp.lang.perl ?  It has too
much spam, but you could ask questions more easily there?


-- 
When time permits, your personal life will be exciting.
  -- Restaurant Fortune Cookie       (They know me there ...)


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

Date: Sun, 4 Jun 2000 18:49:46 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: @INC
Message-Id: <slrn8jlqoq.s8.tadmc@maxim.metronet.com>

On Sun, 04 Jun 2000 16:02:00 -0500, John A. Dutton <jad9@po.cwru.edu> wrote:

>Does anyone know how I specify the contents of the @INC array?


If you have a question about the @INC variable, you should see
what the people who wrote the perl interpreter say about it.

Perl's variables are described in the aptly named perlvar.pod
standard Perl doc:

   perldoc perlvar


The description for @INC there tells how to do what you want.

You are expected to check the Perl docs *before* posting
to the Perl newsgroup.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 04 Jun 2000 22:11:29 -0600
From: "scott thomason" <scott@industrial-linux.org>
Subject: Re: @INC
Message-Id: <BTE_4.1696$gZ4.636223@feed.centuryinter.net>

 ..You can check the contents like this:

print "INC contents:\n", join("\n", @INC), "\n";

If you need to modify it to include a path to your_module.pm, you can either do:

#!/usr/bin/perl -Imy_module_dir

 ...or if you need to be fancier you can try:

BEGIN {
  push(@INC, "my_module_dir");
}




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

Date: 5 Jun 2000 01:18:31 GMT
From: twma@maths.uwa.edu.au (twma)
Subject: Re: Free programming offerred by student
Message-Id: <twma-0506000919420001@mac89.maths.uwa.edu.au>

In article <3922DF46.4740E73A@zipmail.com>, Carl Gibbs <cgi2@zipmail.com> wrote:

> I'm a grad student and know C++, Java, Javascript, Perl, CGI, HTML, the
> Win32API , MFC, Winsock and some 80x86 assembly. I'd like to get some

> Allow me to work for free for you in any of the above areas. I do
> request that credit be given for the work ( a comment line in the code
> will suffice). Projects taking about 10 days of work or therabouts would
> be nice. I'm currently familiar with the windows development platform,
> but could learn others if needed.
> Thanks
> -M
===============


I am looking for source codes of a standard password-system and BBS in
order to carry out experiment on distance education. I did several
web-searches for free software but could not get any. I would be grateful
if somebody could help. 
Your code will also serve the educational purpose for many beginners,
especially me.

As a pure mathematician, 
***" http://maths.uwa.edu.au/~twma/free/norm/norm.htm "
I do not know anything about scripts although I managed to put my lecture notes 
***" http://maths.uwa.edu.au/~twma/free/linear_algebra_maple/readme.htm "
on the web for my own students. 

Somebody installed a simple password device for me in order to protect the
copyright of the textbook which I am using. I do not have research grant
to employ programmer for software development.

Now, you can understand how happy I am when I read your article of
providing free scripts. I hope that other people will also join in to
develop a standard free package for distant education. Please send me the
related URL if it exists.

Thank you for your contribution to advance our GLOBAL affair of 21 century. 
==============================================

Assumptions:

Operating system: UNIX, Tshell
           allowing cgi-scripts written in shell, peal and C++ only
           but does NOT allow server-side-includes

Name of staff: Newton
Name of course: calculus

The following directories have chmod = 755
Private directory: \usr\Newton\calculus\
Private directory for cgi-scripts : \usr\Newton\cgi_bin\
Public directory:  http://www.university.edu.country/~Newton/calculus/

There are three empty text dot-files: chmod (644 ???) the following files??
\usr\Newton\calculus\.htgroup_calculus
\usr\Newton\calculus\.htpassword_calculus
www.university.edu.country\~Newton\calculus\.htaccess

================
Suppose that the following page has been sent to the client. I wish to
know how to activate a cgi-script without any button.
---------------------------------------
<html><head><title>welcome</title></head><body>
Welcome. Please click anywhere to activate the password system.
</body></html>
---------------------------------------
SCRIPT-requested#1--  script:  \usr\Newton\cgi_bin\one.cgi
We know the TCP/IP of the client and the time to login whenever he clicks.
I do not know where to store this information (in a temporary file, or as
part of the following page). However, I can write a script (in C only)
myself to send out the following page. I do not know shell or peal.

I also have an audio file : 
\usr\Newton\background.wav (??) or music.mp3(??), or nice.midi. 
How do I attach it to the following page. The background music should be
played repeatedly, recursively until the user clicks the submit button or
closes the window.
================
<html><head><title>who are you</title></head><body>
<form method=post  action="\usr\Newton\cgi_bin\two.cgi">

Your Name: <input type="text" name="Student"size=40 ><br>
Family name first, blank and punctuation will be skipped, all converted to
lower cases in order to form one single string as the unique id.

<p> Your Email Address: <input type="text" name="Address" size=40 ><br>
Password will be sent to you by email within a few seconds after your
submission.

<p> <input type="radio" name="purpose" value="new" checked> New password, 
<input type="radio" name="purpose" value="change"> change old password.

<p>Your password: <input type="text" name="passwordA" size=40 >

<p>Type in again to confirm: <input type="text" name="passwordB" size=40 >

<p><input type="reset" value="Clear">
<input type="submit" name="submit" value="submit">
</form></body></html>
================
SCRIPT-requested#2
================
If the user does not reply within 10 minutes, send him the following
reminder ON TOP OF the above page, in addition to the above page.
---------------------------------------
<html><head><title>Attention</title></head><body>
You have not filled in the form. This is the first and final reminder.
</body></html>
================
If the user replies, what is the script to process the password?
If he asks for new password, check the current date. If it is before 1
January 2001, set up a new password for him, else send our a page that no
more new users can be authorized. I suppose that it would involve a lot of
UNIX-system calls. We are allowed to open, close, create and delete files
in the above directories.
---------------------------------------

================
SCRIPT-requested#3
================
I need a BBS-script so that the students can discuss the examples,
exercises, etc openly. Students can initial a thread or follow a thread.
Number of visitors of an article must be visible as a measure of
importance.
---------------------------------------

================
SCRIPT-requested#4
================
I need a script to reply the students automatically.
If the subject of an incoming email is "xxx", a message 
" Please visit http://www.university.edu.country\~Newton\calculus\xxx.htm "
is sent back to the sender by email where xxx is a string obtained in the file
\usr\Newton\admissible_strings
where the strings are separated by \n contains alphanumerical only.
If xxx cannot be found, do nothing of course.
---------------------------------------
I believe that all these scripts are used by practically every manager of
info-tech. I am NOT in the trade. So, I need help.

After this is tested, I am sure that you can sell this package for money.
Please let me know how do you want me to acknowledge your help.

Thank you in advance.

-- 
==================
This article reflects my personal view only.
twma@maths.uwa.edu.au


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

Date: Sun, 4 Jun 2000 19:34:25 -0500
From: Scott Mikula <mikula@students.uiuc.edu>
Subject: Getting time & date from DOS
Message-Id: <Pine.GSO.4.10.10006041931380.8391-100000@ux12.cso.uiuc.edu>

I am trying to get the time and date within a perl script, on my Windows
machine.  I can use the "time" and "date" commands, which display the
information, but these commands also expect an input so the script freezes
until I hit enter.  Is there any way to access the time and date without
going through those DOS commands?

Thanks for any help!



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

Date: 5 Jun 2000 01:12:10 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Getting time & date from DOS
Message-Id: <8heupa$2qbcs$1@fu-berlin.de>

hi,

Scott Mikula <mikula@students.uiuc.edu> wrote:
> I am trying to get the time and date within a perl script, on my Windows
> machine.  I can use the "time" and "date" commands, which display the
> information, but these commands also expect an input so the script freezes
> until I hit enter.  Is there any way to access the time and date without
> going through those DOS commands?

have you tried out the perl functions "time" and "localtime"?
perldoc -f localtime

tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: 05 Jun 2000 01:33:51 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Getting time & date from DOS
Message-Id: <393b037f$0$2979@nntp1.ba.best.com>

In article <Pine.GSO.4.10.10006041931380.8391-100000@ux12.cso.uiuc.edu>,
Scott Mikula  <mikula@students.uiuc.edu> wrote:
>I am trying to get the time and date within a perl script, on my Windows
>machine.  I can use the "time" and "date" commands, which display the
>information, but these commands also expect an input so the script freezes
>until I hit enter.  Is there any way to access the time and date without
>going through those DOS commands?

RTFM!!!!

	print "The date and time is: ".localtime."\n";

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Mon, 05 Jun 2000 03:07:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Getting time & date from DOS
Message-Id: <sjm6aoro5ri160@corp.supernews.com>

Scott Mikula (mikula@students.uiuc.edu) wrote:
: I am trying to get the time and date within a perl script, on my Windows
: machine.  I can use the "time" and "date" commands, which display the
: information, but these commands also expect an input so the script freezes
: until I hit enter.  Is there any way to access the time and date without
: going through those DOS commands?

perldoc -f localtime
perldoc -f gmtime

See in particular what these do in scalar context, which is quite useful
for a lot of purposes.  Otherwise, you can call them in list context and
hand-format their return values; or, alternatively, you can use the
POSIX:strftime function to do lots of more advanced time and date
formatting tricks.

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "You live in Los Angeles, and you are going to Reseda; we are
   |   all in some way or another going to Reseda someday, to die."
               - Soul Coughing


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

Date: Mon, 05 Jun 2000 00:54:53 GMT
From: Fearless <philip@my-deja.com>
Subject: Re: How do I make perl flush?
Message-Id: <8hetoo$153$1@nnrp1.deja.com>

In article <sjdu9naq5ri125@corp.supernews.com>,
  cberry@cinenet.net (Craig Berry) wrote:
> Fearless (philip@my-deja.com) wrote:
> : anyone else can suggest a better approach for my original problem
> : (retaining the timestamp of unaltered files), I'm all ears.
>
> Your code as written appears to do nothing if $MODIFY is false.  If
it's
> true, then all files are checked for the string 's1'; for each line
> containing it, the result of substituting this with 's2' is sent to
> stdout.  Then a diff is done with a .bak file which seemingly comes
out of
> nowhere...are you running with -i.bak and not telling us?  I'll

Yes and no; my original post did include the invocation :) It also
implied that I had removed the code for the $MODIFY=false case - I
wasn't sufficiently clear about this. At this point, I might as well
mention that this code is more complex than the code for the true case.

assume so.
>
> If I've understood the rest of what you're doing properly, this seems
a
> more direct path:

<snip code>

Hmm, food for thought, especially the dirty flag (which is of course
the centrepiece). I understand the gist of '||=' but "my documentation"
   (http://www-cgi.cs.cmu.edu/cgi-bin/perl-man)
doesn't mention it. Can you point me somewhere that does? And please
don't say perldoc, I don't have it.

(>|<)
  |


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 05 Jun 2000 01:52:52 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: How do I make perl flush?
Message-Id: <393b07f4$0$2983@nntp1.ba.best.com>

In article <8hetoo$153$1@nnrp1.deja.com>, Fearless  <philip@my-deja.com> wrote:
>Hmm, food for thought, especially the dirty flag (which is of course
>the centrepiece). I understand the gist of '||=' but "my documentation"
>   (http://www-cgi.cs.cmu.edu/cgi-bin/perl-man)
>doesn't mention it. Can you point me somewhere that does?

> And please don't say perldoc, I don't have it.

Baloney!  If you have perl, then you have perldoc.  It comes with the package.
	C:\>perldoc perlop
	unix% perldoc perlop
	Mac: do the same thing from the one-liner menu, or run shuck
	http://www.perl.com/pub/v/documentation
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Mon, 05 Jun 2000 03:02:33 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How do I make perl flush?
Message-Id: <sjm629kb5ri109@corp.supernews.com>

Fearless (philip@my-deja.com) wrote:
: Yes and no; my original post did include the invocation :)

Sorry, I must have skimmed over it somehow.

: It also
: implied that I had removed the code for the $MODIFY=false case - I
: wasn't sufficiently clear about this. At this point, I might as well
: mention that this code is more complex than the code for the true case.

I'd figured as much, clearly.

: Hmm, food for thought, especially the dirty flag (which is of course
: the centrepiece). I understand the gist of '||=' but "my documentation"
:    (http://www-cgi.cs.cmu.edu/cgi-bin/perl-man)
: doesn't mention it. Can you point me somewhere that does? And please
: don't say perldoc, I don't have it.

If you don't have perldoc, you have a broken, misconfigured perl
installation; lord only knows what else might be wrong with it.  Hasten to
get it reinstalled properly.

The ||= operator (described in perlop) is one of a family of "op="
operators, which combine a binary operator with assignment of the result
to the left operand.  So, for example, "$x *= 2" means "multiply $x by 2,
and store the result back into $x."  It's equivalent to "$x = $x * 2" in
all but esoteric cases, but it's easier to type, easier to read once you
know the convention, and possibly easier to optimize.  So, || being the
logical-or operator, "$x ||= $y" is equivalent to "$x = $x || $y".
"Short-circuit evaluation will occur as usual; if $x is already true, $y
will never even get evaluated in either case.  This is a common idiom for
setting a flag that something has happened; once $y is true once, $x will
be true from then on, regardless if $y is false on other trips through the
loop.

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "You live in Los Angeles, and you are going to Reseda; we are
   |   all in some way or another going to Reseda someday, to die."
               - Soul Coughing


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

Date: Sun, 04 Jun 2000 23:55:48 GMT
From: mcmorran@visi.net (Peter McMorran)
Subject: Re: How do I update records in a file?  (cgi & perl)
Message-Id: <393aec7e$2$zpzbeena$mr2ice@news.visi.net>

In <8hao29$pv4$1@ftp.curtin.edu.au>, on 06/03/00 
   at 06:52 PM, "Thaddeus" <nayler@SPAMOFFses.curtin.edu.au>
said:


>I have some data stored in a file in the following format:

>1|2|person|description
>2|8|person|description
>3|25|person|description
>4|0|person|description
>....etc...

>People need to be able to update the second field via cgi and
>see the results.

>I'm fine with opening, printing, appending, and overwriting
>records, but how do I get to a certain part of a certain record
>and update that in particular? Since this is web-based,
>different people can update the same record at any one time -
>and I want all changes recorded.

>How would I do this?

>Thaddeus

Just a couple of suggestions:

It seems like your file has records of variable lengths, i.e. it
is a stream. Since the underlying file is just a stream of bytes,
it is not possible to surgically update only one field -- unless
the new data is the same length as the old data and you are very
careful. The simple way is to copy the file, making the changes
as you go, then delete the old file and rename the new file to
the old name. 

Obviously this gets messy when multiple clients are running CGI
scripts, all trying to do the same thing. File locking would
help, but the full copy of the file may create a bottleneck. 

If you can restructure the file to have fixed-length fields in
fixed-length records, you could probably work it out with seek
and locking, since it wouldn't take long to update one record.

The other alternative is to use a database server, since your
file is really a database. Then the database server handles
serialization of the requests, and manages a file of fixed-length
records.

I know this isn't a quick solution, but I don't believe it can be
avoided.


Cheers,
Peter

-- 
-----------------------------------------------------------
mcmorran@visi.net (Peter McMorran)
-----------------------------------------------------------



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

Date: 05 Jun 2000 02:11:36 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: How do I update records in a file?  (cgi & perl)
Message-Id: <393b0c58$0$2974@nntp1.ba.best.com>

In article <8hcp69$a69$1@ftp.curtin.edu.au>,
Thaddeus <nayler@ses.curtin.edu.au> wrote:
>There are actually several reason why I couldn't research what I required:
>1. I am remotely logged onto the development server
>2. Which has no perldocs installed (seemingly)

Bad installation.  Complain to the management.  Better yet, install perl
on your local machine so that you can lookup documentation.

>4. I have a telnet window as a development environment (cut/paste difficult
>to impossible).

Time to get a better telnet client.  Running telnet on Unix under an xterm
does copy-and-paste.  Running CRT (http://www.vandyke.com) on Win9x
does copy-and-paste.

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Sun, 4 Jun 2000 18:15:00 -0500
From: Duke Banerjee <sfighter@cs.utexas.edu>
Subject: Re: How do you pass a hash reference in Perl 4?
Message-Id: <Pine.GSO.4.21.0006041813480.11970-100000@cheddar.cs.utexas.edu>

Hey Steve,

Well I tried using *myhash instead of \%myhash, and it worked perfectly in
Perl 4.  Thanks for the suggestion!

Duke Banerjee
sfighter@cs.utexas.edu

On Sun, 4 Jun 2000, Steve Bleazard wrote:

> Duke Banerjee wrote:
> > 
> > I'm trying to pass a hash to a function via a reference.  Here's an
> > example of what I'm trying to do:
> > 
> > $myhash{"bob"} = "here";
> > 
> > &myfunc( \%myhash );
> > 
> > sub myfunc {
> > 
> >         local ( *myhashref ) = @_;
> > 
> >         print $myhashref{"bob"};
> > 
> > }
> Perl4 does not support references in the way Perl5 does.  However, Larry
> included a bit of a hack to do this sort of thing (mostly to support the
> debugger if my memory serves).  Replace
> 
>         &myfunc( \%myhash );
> 
> With
> 
>         &myfunc( *myhash );
> 
> And it will work fine in all versions of perl.  This is known as a
> typeglob - see the camel book for more detail.
> 
> Steve
> 



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

Date: Sun, 04 Jun 2000 20:34:29 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: How do you pass a hash reference in Perl 4?
Message-Id: <393B1FC5.9E2F1742@My-Deja.com>

> But, there's  no output in Perl 4 and perl tells me that I've got a
> spurious backslash at the function call.

Time to upgrade.




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

Date: Sun, 04 Jun 2000 22:17:42 -0600
From: "scott thomason" <scott@industrial-linux.org>
Subject: Re: Module Loading
Message-Id: <sZE_4.1697$gZ4.636588@feed.centuryinter.net>

While I think it's better to not want to do what you're trying to do, here are two topics 
for you to read more on: the "eval" statement, and "autoload" to implement objects.
---scott


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

Date: Mon, 05 Jun 2000 01:35:22 GMT
From: Agi <agi@feib.com.tw>
Subject: Newbie~~Please Help !!!!!!!!!
Message-Id: <8hf04q$2pb$1@nnrp1.deja.com>

Hello, theres,
   I want to split a file to lots of small files.
   I use a while loop and chomp function, how do I keep the privious
   line for further reference to generate a group report ??

   Considering the sample data like follows,
   ( the transactions of two accounts for customer A11111
     and file layout as follows
     id    type  account           date withdraw deposit  balance
    -------------------------------------------------------------  )


    A11111 0300 001-003-0001697-7 2000/05/20 100             1000
    A11111 0300 001-003-0001697-7 2000/05/21         200     1200
    A11111 0300 001-003-0001697-7 2000/05/22 100             1100
    A11111 0300 002-004-0001234-5 2000/05/22         100     5000
    A11111 0300 002-004-0001234-5 2000/05/23 400             4600
    A11111 0300 002-004-0001234-5 2000/05/25 100             4500

    How to got the group report like follows ??


    001-003-0001697-7:
      DATE       Withdraw      Deposit           Balance
    ----------------------------------------------------------------
    2000/05/20        100                          1000
    2000/05/21                     200             1200
    2000/05/22        100                          1100

    002-004-0001234-5:
      DATE       Withdraw      Deposit           Balance
    ----------------------------------------------------------------
    2000/05/22                     100             5000
    2000/05/23        400                          4600
    2000/05/25        100                          4500


    Any hints ??
    I'm quite young in Perl.


Best Regards,
Agi Chen




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 05 Jun 2000 01:35:47 GMT
From: Agi <agi@feib.com.tw>
Subject: Newbie~~Please Help !!!!!!!!!
Message-Id: <8hf05i$2pg$1@nnrp1.deja.com>

Hello, theres,
   I want to split a file to lots of small files.
   I use a while loop and chomp function, how do I keep the privious
   line for further reference to generate a group report ??

   Considering the sample data like follows,
   ( the transactions of two accounts for customer A11111
     and file layout as follows
     id    type  account           date withdraw deposit  balance
    -------------------------------------------------------------  )


    A11111 0300 001-003-0001697-7 2000/05/20 100             1000
    A11111 0300 001-003-0001697-7 2000/05/21         200     1200
    A11111 0300 001-003-0001697-7 2000/05/22 100             1100
    A11111 0300 002-004-0001234-5 2000/05/22         100     5000
    A11111 0300 002-004-0001234-5 2000/05/23 400             4600
    A11111 0300 002-004-0001234-5 2000/05/25 100             4500

    How to got the group report like follows ??


    001-003-0001697-7:
      DATE       Withdraw      Deposit           Balance
    ----------------------------------------------------------------
    2000/05/20        100                          1000
    2000/05/21                     200             1200
    2000/05/22        100                          1100

    002-004-0001234-5:
      DATE       Withdraw      Deposit           Balance
    ----------------------------------------------------------------
    2000/05/22                     100             5000
    2000/05/23        400                          4600
    2000/05/25        100                          4500


    Any hints ??
    I'm quite young in Perl.


Best Regards,
Agi Chen




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 5 Jun 2000 02:31:59 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Newbie~~Please Help !!!!!!!!!
Message-Id: <8hf3eu$2qbcs$4@fu-berlin.de>

hi,
please don't shout.
and think of a better subject next time

Agi <agi@feib.com.tw> wrote:
>    I want to split a file to lots of small files.
>    I use a while loop and chomp function, how do I keep the privious
>    line for further reference to generate a group report ??

store it in a variable?
where's your problem? how do you process
the data in the while loop?


>    Considering the sample data like follows,
>    ( the transactions of two accounts for customer A11111
>      and file layout as follows
>      id    type  account           date withdraw deposit  balance
>     -------------------------------------------------------------  )


>     A11111 0300 001-003-0001697-7 2000/05/20 100             1000
>     A11111 0300 001-003-0001697-7 2000/05/21         200     1200
>     A11111 0300 001-003-0001697-7 2000/05/22 100             1100
>     A11111 0300 002-004-0001234-5 2000/05/22         100     5000
>     A11111 0300 002-004-0001234-5 2000/05/23 400             4600
>     A11111 0300 002-004-0001234-5 2000/05/25 100             4500

>     How to got the group report like follows ??


>     001-003-0001697-7:
>       DATE       Withdraw      Deposit           Balance
>     ----------------------------------------------------------------
>     2000/05/20        100                          1000
>     2000/05/21                     200             1200
>     2000/05/22        100                          1100

>     002-004-0001234-5:
>       DATE       Withdraw      Deposit           Balance
>     ----------------------------------------------------------------
>     2000/05/22                     100             5000
>     2000/05/23        400                          4600
>     2000/05/25        100                          4500


>     Any hints ??
>     I'm quite young in Perl.


> Best Regards,
> Agi Chen




> Sent via Deja.com http://www.deja.com/
> Before you buy.

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Sun, 04 Jun 2000 22:22:17 -0600
From: "scott thomason" <scott@industrial-linux.org>
Subject: Re: Not able to run PERL script as CGI by Apache
Message-Id: <I1F_4.1698$gZ4.636889@feed.centuryinter.net>

You'll need a ScriptAlias directive in your httpd.conf file as documented at: 
http://www.apache.org/docs/mod/mod_alias.html#scriptalias

 ...this tells apache to interpret requests from that directory to be executed as CGI
programs instead of served up as content. Make sure the UID running the webserver
has execute permissions.
---scott


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

Date: Sun, 04 Jun 2000 22:50:41 -0600
From: "scott thomason" <scott@industrial-linux.org>
Subject: Re: open http file
Message-Id: <ksF_4.1703$gZ4.637244@feed.centuryinter.net>

 ..to be more specific, use LWP this way:

#!/usr/bin/perl -w

use LWP::Simple;

my $html = get('http://www.yahoo.com/');


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

Date: Mon, 05 Jun 2000 01:34:45 GMT
From: brondsem@my-deja.com
Subject: passing arrays to a subroutine
Message-Id: <8hf03l$2nt$1@nnrp1.deja.com>

I'm having trouble passing arrays to a subroutine and preserving the
structure.  (I suspect this problem will come up again if I send it a
nested array, which I will need to do.)

Here's the code:

use CGI::Carp qw(fatalsToBrowser);
print "Content-Type: text/html\n\n";
print "starting\n";

@myfields = ("user_id", "username", "pwd", "name");
@myconds = (
	["user_id", "==", "12"],
	["name", ">", "s"],
	);
select("mytable", @myfields, @myconds);
print "done\n";


and here's the subroutine:


sub select()
{
	my $table = @_[0];
	my @fields = @_[1];
	my @conds = @_[2];

	print $table, "<br>";
	foreach (@fields)
	{
		print; print "|";
	}
	print "<br>";
	foreach (@conds)
	{
		print; print "|";
	}
	print "<br>";
	exit(0);
	# more code would follow once I get this to work....
}


And the results are:

starting
mytable<br>user_id|<br>username|<br>

Can anyone show me how do this?  I'm somewhat familiar with perl but
not too experienced.

Thanks,

Dave Brondsema


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 5 Jun 2000 02:40:48 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: passing arrays to a subroutine
Message-Id: <8hf3vf$2qbcs$6@fu-berlin.de>

hi,

brondsem@my-deja.com wrote:
> I'm having trouble passing arrays to a subroutine and preserving the
> structure.  (I suspect this problem will come up again if I send it a
> nested array, which I will need to do.)

arguments for a function will be passed as an array of scalars.
you can't change that. so you will have to use
references.

first:
#!/usr/bin/perl -w
(recognize the -w)

> @myfields = ("user_id", "username", "pwd", "name");
> @myconds = (
>       ["user_id", "==", "12"],
>       ["name", ">", "s"],
>       );
> select("mytable", @myfields, @myconds);

give this function another name; you know there is
a perl select function?
let's call it myselect

using references, you would write:
myselect("mytable", \@myfields, \@myconds);

> sub select()
> {
>       my $table = @_[0];
>       my @fields = @_[1];
>       my @conds = @_[2];

RTFM! ($scalar = $array[$position]) ($scalar = $array[$position])
        my @fields = $_[1];
        my @conds = $_[2];
but that wouldn't work, because you are passing
references. type:
        my $fields = $_[1];
        my $conds = $_[2];

>       foreach (@fields)
$fields is now a reference, so type:

        foreach (@{$fields})
>       {
>               print; print "|";
>       }
>       foreach (@conds)
the same here:
        foreach (@{$conds})
(as @conds is a nested array, you have to
iterate it in another way in the loop)
>       {
>               print; print "|";
>       }
> }

look at the perl documentation
on references: perldoc perlref

tina
-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: 5 Jun 2000 03:37:45 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: passing arrays to a subroutine
Message-Id: <8hf7a9$2qbcs$8@fu-berlin.de>

Tina Mueller <tina@streetmail.com> wrote:
>> select("mytable", @myfields, @myconds);

> give this function another name; you know there is
> a perl select function?
> let's call it myselect

i forgot:
you can call it select and then write:
&select("mytable", @myfields, @myconds);
to make sure that *your* select is called,
not the system function.
so there's no need for another name...

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 3250
**************************************


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