[13289] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 699 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 1 23:07:32 1999

Date: Wed, 1 Sep 1999 20:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 1 Sep 1999     Volume: 9 Number: 699

Today's topics:
        $x=(($m,$n)=('a'..'d')) why 4? not 2? <johnlin@chttl.com.tw>
    Re: $x=(($m,$n)=('a'..'d')) why 4? not 2? <tchrist@mox.perl.com>
    Re: Appending and Writing (Eric Bohlman)
        beginner in for loop <bzhaainc@erols.com>
    Re: beginner in for loop (Martien Verbruggen)
    Re: Blat on NT <wyzelli@yahoo.com>
    Re: Can I have a subroutine return a hash? <gremlin_NO_SPAM_@ix.netcom.com>
    Re: Compiling 5.005_03 source on Solaris 7 (Paul Eggert)
    Re: Convert dbf files to ASCII text (Eric Bohlman)
        CPAN.pm (Bill Moseley)
    Re: Date / time problem (resolution) (Martien Verbruggen)
        effective means of simultaneous processing shaun.coon@ayer.mec.edu
    Re: effective means of simultaneous processing (Alan Curry)
        How do I pass a variable to the "use" statement? samingins@my-deja.com
    Re: Maybe too academic: How to build a (binary) tree (s <rick.delaney@home.com>
    Re: Need "Universal" exporter.pm File (Martien Verbruggen)
    Re: Perl5 sendmail <ytliu@cgi-factory.com>
    Re: Perl5 sendmail <ron_savage@non-hp-australia-om5.om.hp.com>
        Problem in CGI.pm module <rctwo@erols.com>
        reference to a partial array <johnlin@chttl.com.tw>
        SEARCH and REPLACE tvn007@my-deja.com
    Re: shebang question for Win32 Perl/Apache <Allan@due.net>
    Re: using the exec command. (Charles DeRykus)
    Re: using the exec command. (Martien Verbruggen)
        Where a subroutine gets called from? <kdl@softhome.net>
    Re: Where a subroutine gets called from? (Bill Moseley)
        Y2K <ytliu@cgi-factory.com>
    Re: Y2K <rra@stanford.edu>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 2 Sep 1999 08:55:12 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: $x=(($m,$n)=('a'..'d')) why 4? not 2?
Message-Id: <7qkhpo$ne4@netnews.hinet.net>

I am sorry to have got my question out of focus.
Originally I ONLY wanted to ask this question:

Why in
$x=(($m,$n)=('a'..'d'));
we get $x=4? not 2?  Since in
@a=(($m,$n)=('a'..'d'));  # we get @a=('a','b');

In perldata I see the explanation:
"This is very handy when you want to do a list assignment
in a Boolean context."

But I think $x=2 is good enough to fit this need.

Could anyone please give me some examples to explain that
$x=4 is more useful than $x=2 here?

Thank you very much.

John Lin





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

Date: 1 Sep 1999 19:03:47 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: $x=(($m,$n)=('a'..'d')) why 4? not 2?
Message-Id: <37cdccf3@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    "John Lin" <johnlin@chttl.com.tw> writes:
:Why in
:$x=(($m,$n)=('a'..'d'));
:we get $x=4? not 2?  Since in
:@a=(($m,$n)=('a'..'d'));  # we get @a=('a','b');
:
:In perldata I see the explanation:
:"This is very handy when you want to do a list assignment
:in a Boolean context."
:
:But I think $x=2 is good enough to fit this need.
:
:Could anyone please give me some examples to explain that
:$x=4 is more useful than $x=2 here?

Because when you write:

    $count = ( ($x, $y) = fn() )

You *know* the number of items in the LHS list.  So 
why bother with it?  It's the RHS you don't otherwise know.

e.g

    if (( ($x, $y) = split /:/, $data ) > 2) {
	warn "excess fields discarded";
    } 

--tom
-- 
    [End of diatribe.  We now return you to your regularly scheduled
    programming...]
        --Larry Wall in Configure from the perl distribution


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

Date: 2 Sep 1999 00:27:44 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Appending and Writing
Message-Id: <7qkga0$4kk@dfw-ixnews7.ix.netcom.com>

RICHARDS  AMANDA DAWN (richara@ecf.toronto.edu) wrote:
: I was wondering if there would be any way besides copying the contents of
: a file, changing them and then writing a totally new file to change some
: (well...one) bit of information in a file (ie get rid of the old bit in
: the file and replace it with a new bit) and also append at the same time.

It's possible only if the new "bit" is *exactly* the same size as the old
"bit."  In that case, open the file for read/write, seek() to the spot
where you want to make the change, print() the change, and then seek() to
the end of the file. 



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

Date: Wed, 1 Sep 1999 20:27:29 -0400
From: "Ben Horowitz" <bzhaainc@erols.com>
Subject: beginner in for loop
Message-Id: <7qkgeq$679$1@autumn.news.rcn.net>

i don't understand how it works?
print "\n how many in your party?";
chomp ($num = <>);
for ($i = 1;$i<= $num;$i==){
print "like the movie,person #$i? ":
chomp ($choice =<>);
push (@choices,$choice);
}

it comes up, unterminated <> operater at line 9,why dosn't it work.

this is the middle of the example of tickets 4,.the first part works,.
i don't understand,when you the  <>,operater and you don't?am a
newbie,learning from a book ,perl 5 interactive, and it's getting very
frustrating,could any one explain it to me,in simple terms how the for loop
works ,and arrays?











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

Date: Thu, 02 Sep 1999 02:42:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: beginner in for loop
Message-Id: <Mulz3.124$D16.7485@nsw.nnrp.telstra.net>

In article <7qkgeq$679$1@autumn.news.rcn.net>,
	"Ben Horowitz" <bzhaainc@erols.com> writes:
> i don't understand how it works?
> print "\n how many in your party?";
> chomp ($num = <>);
> for ($i = 1;$i<= $num;$i==){
> print "like the movie,person #$i? ":
> chomp ($choice =<>);
> push (@choices,$choice);
> }
> 
> it comes up, unterminated <> operater at line 9,why dosn't it work.

No, it comes up with:
syntax error at - line 3, near "==)"
syntax error at - line 4, near ""like the movie,person #$i? ":"

If that is your real code (which I doubt), you will need to fix those
first. Then, unless you use an array @i somewhere, you will need to
fix that $#i.

I don't know the book you are talking about, but if this is the code
that is in it, I'd chuck it. Even if it actually displays the code
without the syntax errors, I'd still consider the above unnecessarily
inelegant.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | 
Commercial Dynamics Pty. Ltd.       | Can't say that it is, 'cause it ain't.
NSW, Australia                      | 


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

Date: Thu, 2 Sep 1999 10:56:29 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Blat on NT
Message-Id: <3okz3.1$1j5.422@vic.nntp.telstra.net>

Caper <stevencNOSPAM@nbnet.nb.ca> wrote in message
news:7qjhpl$6km$1@garnet.nbnet.nb.ca...
> I'm having trouble using the blat command to send an email with WinNT.
The
> whole script works but never sends out the email.  When I did the
> installation, I simply put Blat -install <smtp server> <my email>  Is this
> the problem or something else?  In the option line [retry[port[profile]]],
> what is the profile for??  Thanks
>
This is not really a Perl question, but I will assume you are attempting to
send mail using blat from a Perl script.

Are you able to send files using blat from the command line?  If you are,
then the problem is in your script.  If not, the problem is with Blat.  It
should report the error to you.

I use blat successfully to e-mail 160 odd (no.. not even.. LOL) files to
clients and it works fine.

Here are the lines I use to attach a file and e-mail it (same file to two
different users)...

 system ("blat c:\\logs\\$user.txt -t $recip -s NetStats -q");
 system ("blat c:\\logs\\$user.txt -t username\@domain.com.au -s $user -q");

Wyzelli




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

Date: Wed, 01 Sep 1999 21:39:46 -0400
From: gremlin <gremlin_NO_SPAM_@ix.netcom.com>
Subject: Re: Can I have a subroutine return a hash?
Message-Id: <37CDD562.5B73D881@ix.netcom.com>

Thanks to all of you.  I ended up implementing some routines earlier
today that was like choices #2 and #3.  

Mike


Ala Qumsieh wrote:
> 
> gremlin <gremlin_NO_SPAM_@ix.netcom.com> writes:
> 
> > I would like to call a subroutine and have that routine open up a file,
> > add data to a hash, and return the new hash to the calling routine.  I
> > have everything working except getting the data back to the caller!  Can
> > anyone show me the declaration; call; sub. return statement that will
> > make all this work?
> 
> In the future, consider showing us some code so that we would exactly
> know how to help you. But, from what you told us, I can give you a
> couple of examples. These example assume that you pass in a hash to
> the subroutine, but can be easily modified.
> 
> 1) A subroutine that takes a hash and returns a hash:
> 
>         sub sub1 {
>                 my %hash_in = @_;
>                 my %hash_out;
> 
>                 # do something to fill up %hash_out
>                 return %hash_out;
>         }
> 
> This would be called as so:
> 
>         my %hash_out = sub1(%hash);
> 
> This approach can be potentially very slow if the hashes are big,
> since they have to be placed on/retrieved from the stack everytime the
> function is called.
> 
> 2) A subroutine that takes a reference to a hash, and returns a
> reference to a hash:
> 
>         sub sub2 {
>                 my $h_in_ref = shift;
>                 my %hash_out;
> 
>                 # do something to fill up %hash_out
>                 return \%hash_out;
>         }
> 
> This would be called as so:
> 
>         my $new_hash_ref = sub2(\%hash);
> 
> Elements can be accessed as $new_hash_ref->{'key'}. See 'perldsc' for
> more details.
> 
> 3) This is what I would actually do (assuming your function just adds
> new (key, value) pairs, or modifies existing ones in that hash).
> A subroutine that takes in a reference to a hash, and modifies that
> hash directly:
> 
>         sub sub3 {
>                 my $h_in_ref = shift;
> 
>                 # modify $h_in_ref as you wish:
>                 $h_in_ref->{'key1'} = 'val1';
>                 $h_in_ref->{'key2'} = 'val2';
>                 # no need to return anything
>         }
> 
> This would be called as so:
> 
>         sub3(\%hash);
> 
> This last approach would be the fastest, and least
> memory-consuming. These might or might not be issues, depending on
> your application.
> 
> HTH,
> --Ala

-- 
-----------------------------------------------------
To reply to me via email, remove the "__NO_SPAM__" in 
the header email address.  
-----------------------------------------------------


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

Date: 1 Sep 1999 18:45:02 -0700
From: eggert@twinsun.com (Paul Eggert)
Subject: Re: Compiling 5.005_03 source on Solaris 7
Message-Id: <7qkkqu$hun$1@shade.twinsun.com>

Dominic Coombe <dominic_coombe@lotus.com> writes:

>has anyone else experiences problems getting a 100%
>make test [of perl] on Solaris 7 on a Sparc?

Yes, we had the same symptoms that you did when building perl 5.005_03.
We fixed the problem by upgrading from the following set of Solaris patches:

106148-02 106327-04 106541-01 106725-01 106793-01 106812-04 106938-01
106952-01 106960-01 106980-04 107001-01 107011-01 107018-01 107022-02
107038-01 107059-01 107078-03 107081-03 107094-02 107171-01 107200-02

to the following set of Solaris patches:

106145-08 106147-04 106148-06 106300-06 106327-05 106541-07 106725-01
106748-02 106793-03 106812-04 106934-03 106938-02 106944-02 106950-03
106952-01 106960-01 106978-06 106980-05 106987-02 107001-01 107011-01
107018-01 107022-04 107038-01 107058-01 107059-01 107076-01 107078-14
107081-07 107094-04 107115-02 107117-04 107171-03 107180-09 107200-08
107219-02 107233-01 107259-01 107261-01 107306-01 107318-04 107337-01
107359-01 107374-01 107441-01 107451-01 107456-01 107544-02 107551-01
107587-01 107684-01 107813-01 107972-01 108131-01 108132-01

Sorry, I don't know which patch in the above list actually fixed things,
but I'd guess that it was either 106541-07 (the kernel patch) or
106950-03 (the linker patch).  You might try installing the
Sun-recommended patches for Solaris 7, which are freely available from:

ftp://sunsolve.sun.com/pub/patches/7_Recommended.zip

This includes 106541-07.  If that doesn't work, I think you'll need a
Sun maintenance contract to get 106950-03.

Please also note that Sun patch 107058-01 breaks GCC.
107058-01 used to be recommended by Sun for all Solaris 7 sparc installations,
but currently it's recommended only if you use Sun's compilers.
We worked around this problem by copying /usr/ccs/bin/as to
/opt/reb/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/as
(obviously you must substitute your own installation's pathname here)
_before_ installing patch 107058-01.  See the file install/SPECIFIC in
the GCC distribution for more details about this Solaris bug.


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

Date: 2 Sep 1999 00:28:31 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Convert dbf files to ASCII text
Message-Id: <7qkgbf$4kk@dfw-ixnews7.ix.netcom.com>

Mani Upadhyaya (msupadhyaya@mmm.com) wrote:
: I need to read a *.dbf file and extract a column out. Today, we are
: loading the dbf file into Microsoft Excel and cutting out the column we
: need. I want to automate this process hence the need for a perl module.
: Is there a perl module out there that can help me?

XBase.pm

DBI with DBD::XBase



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

Date: Wed, 1 Sep 1999 17:30:03 -0700
From: moseley@best.com (Bill Moseley)
Subject: CPAN.pm
Message-Id: <MPG.123764ebc61f0e279896f0@nntp1.ba.best.com>

ActiveState on Win98

Running perl -MCPAN -e shell and doing an install or r or anything, 
really spits out a bunch redefined errors (below).  Any ideas what's 
needed to fix it?

I also tried to update CPAN by 'install Bundle::CPAN' but ended up 
(along with all the redefined errors) with:

CPAN: Archive::Tar loaded ok
Removing previously used \.cpan\build\CPAN-1.50\.
Couldn't find a Bundle file in \.cpan\build\CPAN-1.50\. at 
C:/perl5/lib/CPAN.pm line 1717

One last question -- what do people recommend for gcc on the PC?  The 
MingW32 setup?

I wish my PC was setup better.

Thanks,


---

Subroutine new redefined at C:/perl5/site/lib/LWP\UserAgent.pm line 116.
Subroutine simple_request redefined at 
C:/perl5/site/lib/LWP\UserAgent.pm line 159.
Subroutine request redefined at C:/perl5/site/lib/LWP\UserAgent.pm line 
244.
Subroutine redirect_ok redefined at C:/perl5/site/lib/LWP\UserAgent.pm 
line 357.

Subroutine credentials redefined at C:/perl5/site/lib/LWP\UserAgent.pm 
line 379.

Subroutine get_basic_credentials redefined at 
C:/perl5/site/lib/LWP\UserAgent.pm line 401.
Subroutine timeout redefined at C:/perl5/site/lib/LWP\UserAgent.pm line 
463.



-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Thu, 02 Sep 1999 02:39:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Date / time problem (resolution)
Message-Id: <krlz3.120$D16.7485@nsw.nnrp.telstra.net>

[removed nonsensical group alt.perl from newsgroups]

In article <37CDB0A3.C09F6B87@news.news>,
	news <news@news.news> writes:

> I checked the version and it was 5. Everything else works ok, so I tried
> this and this works. How is this misinformation if it works? How am I
> supposed to know that this is a workaround and not the proper method if I am
> new to perl?

In perl 5 your code should have worked. Besides that, the '5' is not
enough information. You need to provide the _full_ verison number.

If your code does not work on your version of perl 5, and you are
absolutely certain that it _is_ perl 5, then your installation of perl
has a serious problem, which you need to fix by installing it again,
or even better, installing the latest perl,

How can you trust what that perl does, if it can't even get this
right?

_That_ was the point. There was no personal attack intended, and you
shouldn't have taken it that way.

A broken perl is worse than no perl.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | You can't have everything, where would
Commercial Dynamics Pty. Ltd.       | you put it?
NSW, Australia                      | 


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

Date: Wed, 1 Sep 1999 20:45:18 -0400
From: shaun.coon@ayer.mec.edu
Subject: effective means of simultaneous processing
Message-Id: <MPG.123791818b16f060989684@news.earthlink.net>

Hello,

I'm looking for a good means of setting up a for loop which will 
basically take an array and send each element off to a separate instance 
of a different perl script for processing. The aim of this is get the 
process done on the whole array "at once", rather than chug through each 
individual item sequentially.
	Here's my dilemma: I can't find a good way of doing this. One bad 
option seems to be to fork and exec or system, which, once the exec'ing 
has occurred, has no further communication with the Perl script from 
which it was called. The other option is backticks or qx(), which does 
what I want it to insofar as it accepts arguments from the main program, 
and then passes the results back to the main program and places in 
whatever variable you set to grab them. Sounds great, but it takes place 
on a single line - so every chunk of data has to be processed 
sequentially, which defeats the purpose of sending to a separate program. 
The only way I can come up with to get around this is to have each 
instance of the subordinate program retrieve its data from a file, and 
then write its results to another file. This, however, sounds like a 
recipe for disk thrashing. Any suggestions?

Shaun 



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

Date: Thu, 02 Sep 1999 02:13:35 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: effective means of simultaneous processing
Message-Id: <j3lz3.93$9D2.13160@typ11.nn.bcandid.com>

In article <MPG.123791818b16f060989684@news.earthlink.net>,
 <shaun.coon@ayer.mec.edu> wrote:
>Hello,
>	Here's my dilemma: I can't find a good way of doing this. One bad 
>option seems to be to fork and exec or system, which, once the exec'ing 
>has occurred, has no further communication with the Perl script from 
>which it was called. The other option is backticks or qx(), which does 

It has further communication if you set it up beforehand. After all, the
other options are all implemented with fork.

Here's some psuedocode:

foreach job
  create a pipe
  fork
  if iamthechild
    close the reading end of the pipe
    dup the writing end of the pipe to stdout
    exec the other program with the input for this job
  /* iamtheparent */
  close the writing end of the pipe
  push the reading end of the pipe onto an array

create a bunch of empty result strings
while there are pipes remaining in the array
  select over the pipes for reading
  foreach pipe that select said is readable
    read from the pipe and append to the result of the corresponding job
    if you got an EOF, close the pipe and remove it from the array

That strategy will allow all your jobs to run in parallel. Hope you have lots
of processors :)

A generic module implementing the above might be a good thing to have. You
could call it like

  ($passwd,$last,$ftplog) =
    parallel_qx("cat /etc/passwd", "last ttyp0", "fgrep ftp /var/log/messages");

With error checking included, the code implementing parallel_qx is gonna get
long and ugly. Good luck :)
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Thu, 02 Sep 1999 02:30:56 GMT
From: samingins@my-deja.com
Subject: How do I pass a variable to the "use" statement?
Message-Id: <7qknh1$kh3$1@nnrp1.deja.com>

I wish to achieve something like the following:

$module = 'my_module';

use $module;

As the above does not work, how can this be done?  Can this be done?

Thank you in advance

Shane.

------------------------------------------------------------------------
Remember, the tortise only got there first by sticking his neck out.
------------------------------------------------------------------------


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 02 Sep 1999 03:04:59 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Maybe too academic: How to build a (binary) tree (structure)
Message-Id: <37CDE949.FE64917F@home.com>

[posted & mailed]

Ulf Rimkus wrote:
> 
> When I was just looking through my computer language books like them for C
> and PASCAL everyone takes a huge amount of paper to explain all about trees,
> pre-order, in-order search and stuff like that. Now I was trying to find out
> how to do that in Perl, but donīt have even an idea how to implement such a
> data structure in Perl.

Here's a good article:

http://www.plover.com/~mjd/perl/BTree/article.html

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Thu, 02 Sep 1999 02:48:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Need "Universal" exporter.pm File
Message-Id: <eAlz3.129$D16.7485@nsw.nnrp.telstra.net>

In article <x3y3dwywcc4.fsf@tigre.matrox.com>,
	Ala Qumsieh <aqumsieh@matrox.com> writes:
> ebohlman@netcom.com (Eric Bohlman) writes:
>> John R. Maiocchi (jrmaiocchi@home.com) wrote:
>> : Looking for exporter.pm file. For a friend and I don't know what
>> : version. Needs to have security that will enable IP banning?
>> 
>> Huh?  exporter.pm is part of the standard Perl distribution;
> 
> I am tempted to add that the correct name for that module is:
> 
> 	Explorer.pm

And I am tempted to add that 'Explorer.pm' and 'exporter.pm' differ in
more than just case :)

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

Date: Wed, 1 Sep 1999 21:29:58 -0700
From: "Yutung Liu" <ytliu@cgi-factory.com>
Subject: Re: Perl5 sendmail
Message-Id: <7qkndo$8ec$1@flotsam.uits.indiana.edu>

Go to my source codes here
http://www.cgi-factory.com/rankingsystem/signup.pl.txt
then scroll down to the part starts with
open(MAIL,"|$mail_prog -t") or &error("Unable to open the mail program.");

It should give you some ideas.

--
Your Sincerely,
Yutung L.




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

Date: Thu, 2 Sep 1999 12:55:18 +1000
From: "Ron Savage" <ron_savage@non-hp-australia-om5.om.hp.com>
Subject: Re: Perl5 sendmail
Message-Id: <7qkpn8$i0k$1@ocean.cup.hp.com>

There's a mail tutorial on my web site. Some Perl packages work both under
Win* & Unix.

--
Cheers
Bus: rons@hpaco.aus.hp.com
Home: ron@savage.net.au
http://savage.net.au/





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

Date: Wed, 01 Sep 1999 21:51:06 -0400
From: Ruiming Chen <rctwo@erols.com>
Subject: Problem in CGI.pm module
Message-Id: <37CDD80A.9BCBA897@erols.com>

This is a multi-part message in MIME format.
--------------22DE1898789748E165B605EE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


In my html form I have:

<form action=POST method="http://myhost/cgi-bin/mycgi.pl">
<input type=radio name=name1 value=a>
 ....
<input type=radio name=name1 value=d>

<input type=radio name=name2 value=a>
 ....
<input type=radio name=name2 value=d>
 ....
<input type=submit value=Go></form>

In mycgi.pl I have:

use CGI;
$mycgi = new CGI;

print header, start_html('test');

@fields = $mycgi->param;
foreach (@fields) {
    print $_, "=", $mycgi->param($_), "<br>\n";
}
print end_html;

My problem is if I checked an item in name1, but do NOT checked any item
in name2. I got
out put

name1=b

only. But I want the output also shows name2 even it has null value,
like

name1=b
name2=


How can I do that?

Thank you in advance!

--
RC Square Team.


--------------22DE1898789748E165B605EE
Content-Type: text/x-vcard; charset=us-ascii;
 name="rctwo.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Ruiming Chen
Content-Disposition: attachment;
 filename="rctwo.vcf"

begin:vcard 
n:Chui /Chen;Raymond/Ruiming
x-mozilla-html:TRUE
org:RC Square
adr:;;;;;;U.S.A.
version:2.1
email;internet:rctwo@erols.com
title:CS
tel;fax:301-498-8959
tel;home:URL http://www.erols.com/rctwo/
tel;work:301-498-8959
note:Raymond Chui & Ruiming Chen Company
x-mozilla-cpt:;0
fn:Chui /Chen, Raymond/Ruiming
end:vcard

--------------22DE1898789748E165B605EE--



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

Date: Thu, 2 Sep 1999 10:06:14 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: reference to a partial array
Message-Id: <7qklvf$sm9@netnews.hinet.net>

Dear all,

Can we get a reference to a partial array?

I express my question conceptually in C++

void main() {
    readonly_recursive("abcdefg");
}

void readonly_recursive(char *reference) {
    if(reference && *reference) {
        char head,*tail;
        head= *reference;  tail=reference+1;
        ...
        readonly_recursive(tail);
        ...
    }
}

In Perl the code would look like:

readonly_recursive(['a'..'g']);

sub readonly_recursive {
    my ($reference)=@_;
    return unless $reference and @$reference;
    my ($head,$tail);
    ($head,@$tail)=@$reference;  # question
    ...
    readonly_recursive($tail);
    ...
}

Of course, the code there

($head,@$tail)=@$reference;

is not what I want (reference to a partial array)
because it will do a copy.

It would cause a slow down if I want to process
a very large array just in a read only manner.

Can we do that in Perl (just reference, no copy)?

Thank you very much.

John Lin





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

Date: Thu, 02 Sep 1999 01:45:21 GMT
From: tvn007@my-deja.com
Subject: SEARCH and REPLACE
Message-Id: <7qkkrf$iqt$1@nnrp1.deja.com>

Hi,

Would someone help me with this:
I would like to change the following line from:

sys    "a-b"  "c*a"  "(xyz+b)"
test   "xyxx*2" "abc+2" "fcy*2"

to


$sys = '$a-$b'; '$c*$a'; '($xyz+$b)';
$test = '$xyxx*2'; '$abc+2' ;'$fcy*2';

Thanks for your help,





Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 1 Sep 1999 15:55:05 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: shebang question for Win32 Perl/Apache
Message-Id: <7qk0gt$gr$1@nntp2.atl.mindspring.net>

Daniel Kirkdorffer wrote in message <37CD5DC9.6D57020C@bottom.in.sig>...
:I recently installed Apache 1.3.9 on my Win95 box to put the OS
:to good use ;^) and I've been hunting down solutions to a problem
:with the shebang line that starts all my Perl scripts so that I can
:continue to write #!/usr/bin/perl (which is where Perl is on
:the Linux production box), rather than #!c:\perl\bin\perl .
:The closest I've been able to come is to create a directory
:at c:\usr\bin to house a copy of perl.exe, and use
:#!c:/usr/bin/perl locally (because it at least works with forward
:slashes).
:Has anyone been able to do this so that they can omit the
:"c:" entirely?  Or am I SOL and going to have to always remember
:to modify this when I upload to production?


If perl and your Apache server are installed on the same drive you can
omit the c:, other wise it has to be there.  Since your Linux box uses
#!/usr/bin/perl I would strongly suggest re-installing Perl onto the
same drive as Apache in a directory named (using c: as an example)
c:\usr\bin.  As you note, neither Perl nor Apache care about the
direction of your slashes so you can then just use #!/usr/bin/perl at
the top of your scripts and they will work fine on both machines.  I
have never tried placing perl.exe in a directory by itself but I fear
that you will have problems with such an arrangement.

HTH

--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
Imagination is more important than knowledge.
 - Albert Einstein




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

Date: Thu, 2 Sep 1999 00:11:13 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: using the exec command.
Message-Id: <FHEoIp.GM9@news.boeing.com>

In article <37CBFC5D.67F9B4AE@nacs.net>, kenn  <kenn@nacs.net> wrote:
>mailing list and am having trouble wiht the exec command. here is the
>code.
>...
>exec 'echo "unsubscribe nacs-announce" | /usr/lib/sendmail -f
>  $user\@nacs.net majrdomo\@nacs.net\n';
>
exec 'echo "unsubscribe nacs-announce" | /usr/lib/sendmail -f \
  $user\@nacs.net majrdomo\@nacs.net';
die "exec failed: $!";


hth,
--
Charles DeRykus


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

Date: Thu, 02 Sep 1999 02:44:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: using the exec command.
Message-Id: <5wlz3.127$D16.7485@nsw.nnrp.telstra.net>

In article <FHEoIp.GM9@news.boeing.com>,
	ced@bcstec.ca.boeing.com (Charles DeRykus) writes:

$user = '; rm -rf /;';

> exec 'echo "unsubscribe nacs-announce" | /usr/lib/sendmail -f \
>   $user\@nacs.net majrdomo\@nacs.net';
> die "exec failed: $!";

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.       | cynical. It's perfectly easy to be
NSW, Australia                      | cynical.


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

Date: Wed, 1 Sep 1999 10:57:23 +0900
From: "Denis Kotseba" <kdl@softhome.net>
Subject: Where a subroutine gets called from?
Message-Id: <7qklli$7rs$1@usenet.kreonet.re.kr>

Hi,

In one of my programs there are "nested" subrouties, something like this:

sub a {
    ...
    &c($x,$y);
    ...
}

sub b {
    ...
    &c($x,$y);
    ...
}

sub c {
    ...
}

How can I find out which subrotine (a or b) called c without passing an
extra parameter?

Thanks in advance.

Denis Kotseba.






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

Date: Wed, 1 Sep 1999 19:13:31 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Where a subroutine gets called from?
Message-Id: <MPG.12377d27b57086b29896f1@nntp1.ba.best.com>

Denis Kotseba (kdl@softhome.net) seems to say...
> How can I find out which subrotine (a or b) called c without passing an
> extra parameter?

try perldoc -f caller and see if that returns what you want.

-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Wed, 1 Sep 1999 21:24:26 -0700
From: "Yutung Liu" <ytliu@cgi-factory.com>
Subject: Y2K
Message-Id: <7qkn3c$8de$1@flotsam.uits.indiana.edu>

Hi,
How do I know if my source codes are Y2K safe?

this is how I define the time in the source codes right now... I tried to
plug some numbers like 959888000 into $timenow. It seems to work all right.
But someone emailed me and told me the codes are not Y2K ok.


$timenow=time();
@months =
('January','February','March','April','May','June','July','August','Septembe
r','October','November','December');
@days =
('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
($sec,$min,$hour,$mday,$mon,$year,$wday) =
(localtime($timenow))[0,1,2,3,4,5,6];
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($mday < 10) { $mday = "0$mday"; }
if ($year < 100) { $year = "19$year"; }
else

$year=$year-100;
if ($year <10) {
$year = "200$year";
}
}
$date = "$days[$wday], $months[$mon] $mday, $year";
$time = "$hour:$min:$sec";



--
Your Sincerely,
Yutung L.




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

Date: 01 Sep 1999 19:49:59 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Y2K
Message-Id: <ylu2pe2fjc.fsf@windlord.stanford.edu>

Yutung Liu <ytliu@cgi-factory.com> writes:

> How do I know if my source codes are Y2K safe?

By reading the documentation for localtime and following it.

> (localtime($timenow))[0,1,2,3,4,5,6];
> if ($sec < 10) { $sec = "0$sec"; }
> if ($min < 10) { $min = "0$min"; }
> if ($hour < 10) { $hour = "0$hour"; }
> if ($mday < 10) { $mday = "0$mday"; }
> if ($year < 100) { $year = "19$year"; }

No.

$year += 1900;

That's it.  That's all you have to do and all you *should* do.  The
complex machinations that you're using there are incorrect.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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 699
*************************************


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