[10284] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3876 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 2 16:07:30 1998

Date: Fri, 2 Oct 98 13:00:35 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 2 Oct 1998     Volume: 8 Number: 3876

Today's topics:
        (&foo())[0] in list context <earl@rchland.ibm.com>
        A bug in Perl 5.003??? <jvaught@ichips.intel.com>
    Re: Alternate colors in tables with perl command? <evonzee@tritechnet.com>
    Re: Alternate colors in tables with perl command? <evonzee@tritechnet.com>
    Re: Bug or Proprietary Internet Take-Over? <keithmur@mindspring.com>
    Re: CGI to CGI (Shambo Pfaff)
    Re: CGI to mod_perl: language issue (Jon Drukman)
    Re: FAQ: Daylightsavings problem droby@copyright.com
    Re: How do I remove a carriage return or space from a s (Sean McAfee)
    Re: How do I remove a carriage return or space from a s (Glenn West)
    Re: How do I remove a carriage return or space from a s <sergio@mail.pt>
    Re: How do I remove a carriage return or space from a s (John Moreno)
    Re: How do I remove a carriage return or space from a s (Larry Rosler)
    Re: How do I remove a carriage return or space from a s (John Moreno)
    Re: How do I remove a carriage return or space from a s <r28629@email.sps.mot.com>
    Re: I have installed Linux. Now what? (Bill Unruh)
    Re: I have installed Linux. Now what? ()
        Inconsistency in -w for substr outside of string (Larry Rosler)
    Re: make script for NT? <abacchi@together.net>
    Re: Messages I never read (I R A Aggie)
    Re: Messages I never read (Larry Rosler)
    Re: new term for illogical <keithmur@mindspring.com>
    Re: Omaha Perl Mongers - First Meeting ! (Patrick Timmins)
    Re: Omaha Perl Mongers - First Meeting ! <eashton@bbnplanet.com>
    Re: Passing variable from form to form (Shambo Pfaff)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 02 Oct 1998 14:23:44 -0500
From: Joel Earl <earl@rchland.ibm.com>
Subject: (&foo())[0] in list context
Message-Id: <5ueaf3en4xr.fsf@shadowfax.rchland.ibm.com>


I thought that (&foo())[0] would provide a list context to the return
expression of &foo(), and return the first element of the list as a
scalar. I read the "list context: || vs or" thread from last May, but
I still can't explain the behavior of the attached script.

I get this output:

(Perl4)      (Perl5)
                    
B  / /3      B  / /3
C  / /3      C 3/ /     <- !!
                    
B  /2/3      B  /2/3
C  /2/3      C 2/3/     <- !!
                    
B 1/ /3      B 1/ /3
C 1/ /3      C 1/3/     <- !!
                    
B 1/2/3      B 1/2/3
C 1/2/3      C 1/2/3

I expected (&current())[0] to call "current" in a list context, index
to the first element of the list, and return that. This works if that
element is defined. If the element is undefined, though, I get
different results depending on list or scalar context. It appears that
in list context, I get a null list instead of a list containing undef.

Camel II says in the "return" writeup on page 207:

   A return with no argument returns the undefined value in scalar
   context, and a null list in list context.

This descibes the behavior that I'm seeing, but I am providing an
argument to the return function in &current! The indexing of
&current's returned list is the last expression evaluated in &first,
&second, and &third, which to my eyes ought to always produce a single
scalar. I not certain of the significance of the fact that Perl4
behaves as I expected, but I thought it was interesting.

Can someone help me see what I'm missing here?

----- cut here ------
#!/bin/perl

$third = 3;
foreach $first (undef, 1) {
  foreach $second (undef, 2) {
    # this looks right (forced scalar context)
    printf "B %1s/%1s/%1s\n", scalar &first(), 
        scalar &second(), scalar &third(); 
    # this looks wrong! (list context)
    printf "C %1s/%1s/%1s\n", &first(), &second(), &third(); 
    print "\n";
  }
}

sub first {
  # this doesn't change the result: return ((&current())[0]);
  # this doesn't change the result: return (&current())[0];
  (&current())[0];
}

sub second {
  (&current())[1];
}

sub third {
  (&current())[2];
}

sub current {
  return ($first, $second, $third);
}
----- cut here ------



-- 

   Joel Earl, jrearl@vnet.ibm.com
   Logic Analysis and Optimization
   IBM Rochester, Minnesota


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

Date: Fri, 02 Oct 1998 12:08:57 -0700
From: Jim Vaught <jvaught@ichips.intel.com>
Subject: A bug in Perl 5.003???
Message-Id: <361524C8.2D911E63@ichips.intel.com>


--------------54F25BC19AE97ED1F60A813F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Am I doing something wrong or is this a bug in Perl?  This is the
strangest thing I've ever seen in all my days of programming.  Here is
my entire program

sub jim   {die;}

if (defined $a)
   {&jim(1);}

(since netscape does wierd things with whitespace I should mention that
the {&jim is indented by 3 spaces to make this bug appear).

This gives me the error:

Number found where operator expected at try line 6, near "&jim(1"
        (Missing operator before 1?)

It seems that this error occurs when all of the following are true:

1) first term in the conditional expression is a "defined" check
2) first instruction in the execution block is a subroutine call which
takes an argument
3) the innermost open parentheses is the same number of characters into
a line
    as the open curly brace of the conditional block

Here are some examples of other code which gives the me error:

if     (defined $a)
       {&jim(1);}

(extra spaces on both lines but still aligned... even works if you tab
after the if and
indent the {& by 3 spaces (i + f + tab))

if ((defined $a))
    {&jim(1);}

({& under the inner open paren)

if (defined $a)

#comment

   {&jim(1);}

(extra lines in between... even with comments)

if (defined $a)
   {    &jim(1);}

(spaces between the { and the &)

Here are some examples of code which don't give me the error:

if (0 || defined $a)
   {&jim(1);}

( first term of conditional isn't "defined" check, even though it is
meaningless)

if (defined $a)
   {;&jim(1);}

(first instruction in conditional block isn't function call, even though
it is null)

if (defined $a)
   {&jim;}

(first instruction is function call but takes no args)

if ((defined $a))
   {&jim(1);}

(open curly is under outermost paren)


I tried all of these test cases with and without the "jim" subroutine
using $_[0] and
it behaved the same for all of the cases either way.  I am completely
baffled.  Am I actually breaking some gramatical rule of Perl, or is
there a bug in Perl 5.003?  If anyone can shed any light on this I'd be
grateful.  Getting an error  which I don't understand from a compiler
makes me uncomfortable...

Thanks,
Jim


--------------54F25BC19AE97ED1F60A813F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
<TT>Am I doing something wrong or is this a bug in Perl?&nbsp; This is
the strangest thing I've ever seen in all my days of programming.&nbsp;
Here is my entire program</TT><TT></TT>

<P><TT>sub jim&nbsp;&nbsp; {die;}</TT><TT></TT>

<P><TT>if (defined $a)</TT>
<BR><TT>&nbsp;&nbsp; {&amp;jim(1);}</TT><TT></TT>

<P><TT>(since netscape does wierd things with whitespace I should mention
that the {&amp;jim is indented by 3 spaces to make this bug appear).</TT><TT></TT>

<P><TT>This gives me the error:</TT><TT></TT>

<P><TT>Number found where operator expected at try line 6, near "&amp;jim(1"</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Missing operator before
1?)</TT><TT></TT>

<P><TT>It seems that this error occurs when all of the following are true:</TT><TT></TT>

<P><TT>1) first term in the conditional expression is a "defined" check</TT>
<BR><TT>2) first instruction in the execution block is a subroutine call
which takes an argument</TT>
<BR><TT>3) the innermost open parentheses is the same number of characters
into a line</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; as the open curly brace of the conditional block</TT><TT></TT>

<P><TT>Here are some examples of other code which gives the me error:</TT><TT></TT>

<P><TT>if&nbsp;&nbsp;&nbsp;&nbsp; (defined $a)</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&amp;jim(1);}</TT><TT></TT>

<P><TT>(extra spaces on both lines but still aligned... even works if you
tab after the if and</TT>
<BR><TT>indent the {&amp; by 3 spaces (i + f + tab))</TT><TT></TT>

<P><TT>if ((defined $a))</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; {&amp;jim(1);}</TT><TT></TT>

<P><TT>({&amp; under the inner open paren)</TT><TT></TT>

<P><TT>if (defined $a)</TT><TT></TT>

<P><TT>#comment</TT><TT></TT>

<P><TT>&nbsp;&nbsp; {&amp;jim(1);}</TT><TT></TT>

<P><TT>(extra lines in between... even with comments)</TT><TT></TT>

<P><TT>if (defined $a)</TT>
<BR><TT>&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp; &amp;jim(1);}</TT><TT></TT>

<P><TT>(spaces between the { and the &amp;)</TT><TT></TT>

<P><TT>Here are some examples of code which don't give me the error:</TT><TT></TT>

<P><TT>if (0 || defined $a)</TT>
<BR><TT>&nbsp;&nbsp; {&amp;jim(1);}</TT><TT></TT>

<P><TT>( first term of conditional isn't "defined" check, even though it
is meaningless)</TT><TT></TT>

<P><TT>if (defined $a)</TT>
<BR><TT>&nbsp;&nbsp; {;&amp;jim(1);}</TT><TT></TT>

<P><TT>(first instruction in conditional block isn't function call, even
though it is null)</TT><TT></TT>

<P><TT>if (defined $a)</TT>
<BR><TT>&nbsp;&nbsp; {&amp;jim;}</TT><TT></TT>

<P><TT>(first instruction is function call but takes no args)</TT><TT></TT>

<P><TT>if ((defined $a))</TT>
<BR><TT>&nbsp;&nbsp; {&amp;jim(1);}</TT><TT></TT>

<P><TT>(open curly is under outermost paren)</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>I tried all of these test cases with and without the "jim" subroutine
using $_[0] and</TT>
<BR><TT>it behaved the same for all of the cases either way.&nbsp; I am
completely baffled.&nbsp; Am I actually breaking some gramatical rule of
Perl, or is there a bug in Perl 5.003?&nbsp; If anyone can shed any light
on this I'd be grateful.&nbsp; Getting an error&nbsp; which I don't understand
from a compiler makes me uncomfortable...</TT><TT></TT>

<P><TT>Thanks,</TT>
<BR><TT>Jim</TT>
<BR><TT></TT>&nbsp;</HTML>

--------------54F25BC19AE97ED1F60A813F--



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

Date: Fri, 02 Oct 1998 13:02:04 -0500
From: Eric Von Zee <evonzee@tritechnet.com>
Subject: Re: Alternate colors in tables with perl command?
Message-Id: <3615151C.AFC7F469@tritechnet.com>

Just adding my results to the soup...
Had to go 2M, 1M was deemed as not enough for reliable..

System: W95 P266 64MB
Perl : This is perl, version 5.004_02

Benchmark: timing 2000000 iterations of control, using_bang, using_not,
using_xor...
control:  0 secs ( 0.57 usr  0.00 sys =  0.57 cpu) #once again, $toggle
= $toggle
using_bang:  2 secs ( 3.10 usr  0.00 sys =  3.10 cpu)
using_not:  2 secs ( 3.06 usr  0.00 sys =  3.06 cpu)
using_xor:  1 secs ( 1.57 usr  0.00 sys =  1.57 cpu)

--
Best Regards,
Tritech Marketing Inc.

Eric Von Zee
Webmaster



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

Date: Fri, 02 Oct 1998 13:10:32 -0500
From: Eric Von Zee <evonzee@tritechnet.com>
Subject: Re: Alternate colors in tables with perl command?
Message-Id: <36151718.3AE96D7B@tritechnet.com>

oops, make that P366



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

Date: Fri, 02 Oct 1998 13:31:28 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Bug or Proprietary Internet Take-Over?
Message-Id: <36151C00.CC777322@mindspring.com>

Perhaps it would help to post some URLs and (short) script examples?

Anthony Sadera wrote:
> 
> I need to know why MSIE4 chokes on certain CGI-based
> form submissions. (Can't access errors, etc.)
> I need to know what to do about it (aside from recommending
> Netscape to everyone that uses our CGI forms).
> It may be an SSL problem, it may be a STDIN problem,
> it may be MSIE's stupid file associations (why does MS hide
> the damn things by default if they're so friggin' important?).
> 
> I guess what I'm asking is there some depository of information
> about things I need to know to update about 40-50 Perl
> Scripts running under an Apache server on four linux boxes.
> 
> --
> 
>                                      Anthony Sadera
>                               mailto:afs@sadera.com


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

Date: Fri, 02 Oct 1998 14:48:25 -0400
From: shambop@bacon-and-spam.timeoutny.com (Shambo Pfaff)
Subject: Re: CGI to CGI
Message-Id: <shambop-0210981448250001@www.timeoutny.com>

What if there are two variables, and one of the variables in the
QUERY_STRING is the name of the cecond CGI to run, and the second variable
is to be passed to that second CGI?

In article <36137A0E.3D68C4E8@uic.nnov.ru>, "Aleksey A. Pavlov"
<paaa@uic.nnov.ru> wrote:

> Swetal Jariwala wrote:
> > 
> > I have a web form that has only one parameter, a user ID.  Once the
> > user clicks on the Submit button my Perl CGI script is called.  The
> > problem now is that my script needs to send that user ID to another
> > CGI script to do a lookup in a database.  Get the record associated
> > with user ID and inject that into a Notes database.  Anyone have any
> > idea how to go about doing this?  The perl script is on a Win32
> > platform.  Thanks for all help.
> > 
> > Swetal Jariwala
> > swet@clk.net
> try this:
>  sub toanatherscript{
>   local %ENV;
>   $ENV{'QUERY_STRING'}=urlencode(@_);
>   system("perl anothersdcript.cgi");
>  }
>                    Lesha.


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

Date: 2 Oct 1998 19:02:28 GMT
From: jsd@hudsucker.gamespot.com (Jon Drukman)
Subject: Re: CGI to mod_perl: language issue
Message-Id: <slrn71a8t5.so8.jsd@hudsucker.gamespot.com>

In article <3614EFBE.4ADD2718@mcguckin.com>, Jeff Beard wrote:
>My situation is that I've got CGI scripts written in Perl that I need to
>get running under mod_perl wich basically do the same thing.

You will probably have better luck asking on the mod_perl mailing
list.

>I get varying degrees of success but when it does "work" I get the
>"Variables retain their value from one request to the next" problem
>mentioned in the cgi_to_mod_perl FAQ. However, I don't understand
>really what the docs are telling me.

Your program relies on a global hash called %field, which you are not
clearing between requests.  If someone specifies $field{mfg} on one
pass through but not on the next, that caller will get the old value.

You should really use CGI.pm - for a million reasons, not the least of 
which is that it would have eliminated this error.

>my $mfg = $field{'mfg'} ;	 
>my $model = $field{'model'} ;	 
>my $desc = $field{'desc'} ;	 
>my $retail = $field{'retail'} ;	 

why do you copy all the hash elements to these variables?  it's a
waste of time and memory.

>open (DATAFILE, ">>/tmp/inv_update.dat") ||
>	die "Error: problem opening datafile" ;

checking return value of open is good.  thumbs up!

>print DATAFILE "Manufacturor= $mfg\n" ;
>print DATAFILE "Model number= $model\n" ;
>print DATAFILE "Description= $desc\n" ;
>print DATAFILE "Retail= $retail\n" ;

look up 'here-doc' in perldata.  you can collapse all these prints
into one mega-print which is much easier to deal with.

>sub GetFormInput {

this subroutine is a disaster.  use CGI.pm instead.

>Global symbol "field" requires explicit package name at
>/home/httpd/exec/inv_update.pl line 9.

you're using strict (good) but then using undeclared global variables
(bad).

>[Fri Oct  2 09:03:19 1998] [error] Undefined subroutine
>&Apache::ROOT::exec::inv_5fupdate_2epl::handler called at
>/usr/lib/perl5/site_perl/Apache/Registry.pm line 141.
>
>Subroutine GetFormInput redefined at /home/httpd/exec/inv_update.pl line
>104.

i've noticed that modperl can only take so much reloading of a script
before it starts to "wig out".  killing and restarting the modperl
server usually fixes it.

>I know that some of this stuff can be done with CGI.pm but I'm trying to
>understand at a little bit of why things do what they do.

fair enough.

-- 
Jon Drukman                                            jsd@gamespot.com
-----------------------------------------------------------------------
Fear the government that fears your computer.


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

Date: Fri, 02 Oct 1998 19:29:23 GMT
From: droby@copyright.com
Subject: Re: FAQ: Daylightsavings problem
Message-Id: <6v39ii$4sd$1@nnrp1.dejanews.com>

In article <3614FE20.41C6@arch.ethz.ch>,
  Patrick Sibenaler <patrick@arch.ethz.ch> wrote:
> Hi,
>
> I'm looking for information about the conversion of seconds to
> date and the implementation of daylight saving time. I know
> Perl uses the system routines to convert localtime(time).
> I happen to have this script that uses seconds as a pointer
> to dates:
>
>     localtime (909352800) = [1998_10_26_00_00_00]
>
> ... very handy, but adding 1 day (84600secs):
>
>     localtime (909439200) = [1998_10_26_23_00_00]
>
> instead of the expected [1998_10_27_00_00_00]
> ... daylight savings switch.
>

Two possibilities spring to mind as you seem to be interested in the date
portion.

Use gmtime instead of localtime or point at noon instead of midnight.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 02 Oct 1998 17:57:50 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <yu8R1.5856$F7.21473510@news.itd.umich.edu>

>brettr wrote in message <6v31b4$ckg$1@newsread1-mx.centuryinter.net>...
>>Suppose the var $hello contains the string "hi " and has a space or
>carriage
>>return at the end of it. How would I remove the space or carriage return so
>>that only the word "hi" exist?

In article <6v32le$qnr@news-central.tiac.net>,
Craig Bandon <cbandon_nospam@tiac.net> wrote:
>$hello = chop($hello);

Uhhhhh... No!  Huh huh, huh huh.

chop($hello);

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Fri, 02 Oct 1998 17:27:09 GMT
From: glenn.west@ptsc.slg.eds.com (Glenn West)
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <36150c3e.162573892@news.ses.cio.eds.com>

On Fri, 2 Oct 1998 12:05:30 -0500, "brettr" <brettr@centuryinter.net>
wrote:

>Suppose the var $hello contains the string "hi " and has a space or carriage
>return at the end of it. How would I remove the space or carriage return so
>that only the word "hi" exist?

$hello=~s/[ \n]+$//g;


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

Date: Fri, 02 Oct 1998 19:25:43 -0300
From: Sergio Bernardo <sergio@mail.pt>
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <361552E7.28D96A06@mail.pt>

brettr wrote:
> 
> Suppose the var $hello contains the string "hi " and has a space or carriage
> return at the end of it. How would I remove the space or carriage return so
> that only the word "hi" exist?
> 
> brettr

If there is always someting (' ' or '\n' or other char), you
simply have to use chop:

chop($hello);

--> removes last character from string!

if you are not shore there is always an extra char, it's better
to use someting like this:

$hello =~ s/^(\w+).*/$1/s || warn "Invalir Hello!\n";

--> Takes the first word in the string, admiting the word starts
at the 1st position of string. 
--> If there is a possibility of existing a white space
or other strange chars at the beginning, replace 
the ^ by \W*:

$hello =~ s/\W*(\w+).*/$1/s || warn "Invalir Hello!\n";


Sergio Bernardo
sergio@navegante.pt


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

Date: Fri, 2 Oct 1998 14:38:46 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <1dga0bd.xodtznltvezaN@roxboro0-008.dyn.interpath.net>

Yogish Baliga <baliga@synopsys.com> wrote:

> use
>   $hello =~ s/\s*$//g;
> 
>  This means remove all the whitespaces at end of string with null.

And has either a superfluous * or g.

-- 
John Moreno 


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

Date: Fri, 2 Oct 1998 12:12:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <MPG.107ec5992a776f099897d9@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <1dga0bd.xodtznltvezaN@roxboro0-008.dyn.interpath.net> on Fri, 
2 Oct 1998 14:38:46 -0500, John Moreno <phenix@interpath.com> says...
> Yogish Baliga <baliga@synopsys.com> wrote:
> >   $hello =~ s/\s*$//g;
> > 
> >  This means remove all the whitespaces at end of string with null.
> 
> And has either a superfluous * or g.

Not 'either .. or'.  The '*' should be '+' and the 'g' should be omitted.  
But the effect is the same in any case.

That ' with null' at the end of Yogish's description of the statement is 
superfluous for sure, though.  What can it mean?

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


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

Date: Fri, 2 Oct 1998 15:36:06 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <1dga2ya.1ab5fu3j2qweeN@roxboro0-008.dyn.interpath.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> [Posted to comp.lang.perl.misc and a copy mailed.]
> 
> John Moreno <phenix@interpath.com> says...
> > Yogish Baliga <baliga@synopsys.com> wrote:
> > >   $hello =~ s/\s*$//g;
> > > 
> > >  This means remove all the whitespaces at end of string with null.
> > 
> > And has either a superfluous * or g.
> 
> Not 'either .. or'.  The '*' should be '+' and the 'g' should be omitted.
> But the effect is the same in any case.

Right, TMTIWTDI - but using both is a waste.
 
> That ' with null' at the end of Yogish's description of the statement is
> superfluous for sure, though.  What can it mean?

That English isn't his native language?  I thought it was close enough
to 'finds all of the whitespaces at the end of the string and replaces
them with nothing/a null string' (which is what I'm believe he meant)
that it didn't need correcting (English not being as precise as perl in
any case).

-- 
John Moreno


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

Date: Fri, 02 Oct 1998 13:54:53 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: How do I remove a carriage return or space from a string?
Message-Id: <3615217D.F07DBA25@email.sps.mot.com>

brettr wrote:
> 
> Suppose the var $hello contains the string "hi " and has a space or carriage
> return at the end of it. How would I remove the space or carriage return so
> that only the word "hi" exist?
> 
> brettr

Pardon me, but I coundn't help myself after reading Andy Lester's post a
moment ago. This post fits so perfectly on Andy's list.

I know we all like to get things done quickly, but we should at least do
a little homework - this is such a basic must-know question. If you
haven't, stop writing Perl script, go get a copy 'Learning Perl' and
read it. 

Please...

-JAPU (Just Another Perl User)


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

Date: 2 Oct 1998 18:25:34 GMT
From: unruh@physics.ubc.ca (Bill Unruh)
Subject: Re: I have installed Linux. Now what?
Message-Id: <6v35qu$kqu$1@nntp.ucs.ubc.ca>

In <3614EA91.40E9@spacely.com> George Jetson <gjetson@spacely.com> writes:

>At the risk of starting an editor war, I would suggest that you look
>around for an editor called nedit.  If you can find a binary package of
>it, instead of compiling it yourself, I think you would like it much
>better.

>(To those who might respond "Wrong! nedit uses Motif, and Motif is
>commercial." I will respond, "True, but you can use LessTif 0.85 or
>greater.  Works fine for me.")

Well, I had problems with nedit under lesstif- crashes, etc. I got the
version from fnal with Motif comiled in but then had to put a script so
that the libc5 libraries were used instead of the glibc ones on REdhat
5.1


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

Date: Fri, 2 Oct 1998 12:24:19 -0700
From: jedi@dementia.mishnet ()
Subject: Re: I have installed Linux. Now what?
Message-Id: <slrn71aa33.ud.jedi@dementia.mishnet>

On Fri, 02 Oct 1998 01:31:23 -0700, Dan Bialek <dan.bialek@mindspring.com> wrote:
>Dear Clever Linux People,
>
>I have installed Red Hat onto my PC, and now I am unable to get it do
>anything useful. How do I use
>the various editors, so that I can write basic Perl programs from my new
>example book and run them?
>I am at complete loss. I fired up the emacs in X windows, but I really

	Try nedit. You should have an xterm available to run it in.
	If not, then start looking through your root menu and running
	things to see what they do. 

>have no idea what I am doing. I apologize for my ignorance, but if
>anyone can shine flashlight of help this way, I would be ever thankful.
>Please respond via email.
>
>Thanks again,
>Dan
>
>--
>** Insert clever signature here **
>
>


-- 
Hardly. Microsoft has brought the microcomputer OS to
the point where it is more bloated than even OSes from          |||
what was previously larger classes of machines altogether.     / | \
This is perhaps Bill's single greatest accomplishment.    

	In search of sane PPP docs? Try http://penguin.lvcm.com


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

Date: Thu, 1 Oct 1998 18:15:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Inconsistency in -w for substr outside of string
Message-Id: <MPG.107dc91feba4c8de989891@nntp.hpl.hp.com>

perl -we '$x = "x"; print substr $x, 2'

produces two warnings:

substr outside of string at -e line 1.
Use of uninitialized value at -e line 1.

But the following produces no warnings:

perl -we '$x = "x"; print substr $x, 1'

Is this a bug?  Perl -v:  5.005_02
and all the previous versions I have checked.
                                      
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 02 Oct 1998 14:17:33 -0400
From: "Andrew G. Bacchi" <abacchi@together.net>
Subject: Re: make script for NT?
Message-Id: <361518BD.D63E024A@together.net>

In the perl directory there is a file called "pl2bat.bat"  this is used to
place a wrapper around .pl script so that dumb DOS can understand it as a
perl script.  The command line use is as follows:

pl2bat myscrpt.pl myscript.bat

You can do this in the directory that myscript lives in, from either the
Start > Run line or from the DOS prompt.  It works on my NT4.0 and my W98
machine.  Good luck.

Krzysztof Kunowski wrote:

> I've got program in perl and I don't know haw compile it for Windows NT?





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

Date: Fri, 02 Oct 1998 13:56:17 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Messages I never read
Message-Id: <fl_aggie-0210981356170001@aggie.coaps.fsu.edu>

In article <6v311b$poe@news-central.tiac.net>, "Craig Bandon"
<cbandon_nospam@tiac.net> wrote:

+ Well for anyone that would be so kind as to take a moment to look at my code
+ I am having problems getting the CGI environment variables out of the %ENV.
+ I do a foreach on the keys of %ENV and only get back one environment
+ variable.

Then there's something mucked up with your system/server. This is
the code that I use to poke and prod various and sundry browsers, to
see what sort of secrets they routinely give up:

print qq(Content-Type: text/html\n\n<HTML>
<HEAD>
<TITLE>Environmental Variables in CGI</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFF0">
);
foreach $key (sort keys %ENV){
    print qq(<strong>$key</strong>: <pre>$ENV{$key}</pre><br>);
}
print "</body>\n";

Looks familiar, eh?

James


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

Date: Fri, 2 Oct 1998 11:20:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Messages I never read
Message-Id: <MPG.107eb95466d57d469897d8@nntp.hpl.hp.com>

In article <6v311b$poe@news-central.tiac.net> on Fri, 2 Oct 1998 13:02:52 
-0400, Craig Bandon <cbandon_nospam@tiac.net> says...
 ... 
!> Thanks for the kind words and advice. I am sorry if my post original 
post
!> (even this one) is lame but I am really stumped. I am not looking for
!> someone to solve my problem but if someone has seen something like 
this
!> before or has an idea to try I would greatly appreciate it.

I didn't ignore your original post.  I just had little to say other than 
this behavior is incomprehensible and (for me) not reproducible.

Some suggestions:

Try the code from the command line and see what happens.

Add direct calls to commands such as `env` or `set` (depending on the 
operating system) and see what they report.

Simplify your code by interpolating variables directly into double-quoted 
strings instead of using all those concatenations.

!> Here is the output/code from my original post.
!> 
!> OUTPUT
!> Perl Version 5.00307
!> 
!> PERLXS='PerlIS'
!> 
!> ENV{"REQUEST_METHOD"}='GET'
!> 
!> REQUEST_METHOD='GET'
!> PERLXS='PerlIS'
!> 
!> 
!> 
!> CODE
!> #!/usr/local/bin/perl5
!> 
!> $| = 1;
!> 
!> print "Content-Type: text/html\n\n";
!> 
!> print "Perl Version " . $] . "<br><br>\n";
!> 
!> foreach $var ( keys %ENV )
!> {
!>    print $var . "='" . $ENV{$var} . "'<br>\n";
!> }
!> 
!> print "<br>\n";
!> print "ENV{\"REQUEST_METHOD\"}='". $ENV{"REQUEST_METHOD"} . "'<br>\n";
!> print "<br>\n";
!> 
!> foreach $var ( keys %ENV )
!> {
!>    print $var . "='" . $ENV{$var} . "'<br>\n";
!> }
!> 
!> --
!> Craig
!> to reply remove _nospam

I have no objection to emailing responses, provided I don't have to edit 
your address to make it work.  (My newsreader has a simple checkbox to 
turn it on, and I am too lazy to do more than that.)

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


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

Date: Fri, 02 Oct 1998 13:24:58 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: new term for illogical
Message-Id: <36151A7A.15172A76@mindspring.com>

Elaine -HappyFunBall- Ashton wrote:
> 
> Scratchie wrote:
> 
> > : poor abby couldn't handle some acerbic comments back at he/r!
> >
> > She's the sensitive type, you know.
> 
> The more abrasive you are the more insecure and sensitive you are...as a
> general rule of thumb.
> 
I suspect the causation goes in the opposite direction, though...


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

Date: Fri, 02 Oct 1998 18:02:02 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Omaha Perl Mongers - First Meeting !
Message-Id: <6v34eq$snb$1@nnrp1.dejanews.com>

In article <3614EA0D.F8216D69@bbnplanet.com>,
  Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:

> Patrick Timmins wrote:
>
> > the Gateway to the West, beautiful Omaha, Nebraska
>
> Um, Darlin', since I'm from St. Louis, and we got that arch thingie, I
> think you may be a little confused. :) Omaha is sorta north and west of
> there...prarie dog country. No gateways.

St. Louis?  St. Louis!!?

That's like, Baltimore,  or something! I think Lewis and Clark stayed
at the Ritz in St. Louis, then took a limo to Omaha to begin their
journey west!

I always thought the arch thing was sort of a permanent McDonald's
billboard. It's not?

Patrick Timmins
$monger{Omaha}[0]
Omaha, NE - "The City by the Bay"

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 02 Oct 1998 19:57:45 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Omaha Perl Mongers - First Meeting !
Message-Id: <36152DC5.FA978B87@bbnplanet.com>

Patrick Timmins wrote:

> That's like, Baltimore,  or something! I think Lewis and Clark stayed
> at the Ritz in St. Louis, then took a limo to Omaha to begin their
> journey west!

Bawlmer is in Merlin (for the MD set :) not Misery. Did Omaha even exist
at the time of L&C? Probably not :)

> I always thought the arch thing was sort of a permanent McDonald's
> billboard. It's not?

Saarinen was wacky. Its a croquet wicket, of course. 

e.

Would I live my life over again? 
Make the same unforgivable mistakes? 
Yes, given half a chance. Yes  -R. Carver-


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

Date: Fri, 02 Oct 1998 15:07:40 -0400
From: shambop@bacon-and-spam.timeoutny.com (Shambo Pfaff)
Subject: Re: Passing variable from form to form
Message-Id: <shambop-0210981507400001@www.timeoutny.com>

That's really cool. One of the variables from the original FORM is the
name of the second cgi to run. So I don't need to return the user input to
the browser. I need to return the user inpout into the cgi script which
the user selected. I'm getting close on this, but any help is greatly
appreciated. I owe you one already with that great explanation.

Thanks,
Shambo



In article <3614F639.B50CB2A0@mindspring.com>, keithmur@mindspring.com wrote:

> If your question is simply how to pass the name, try something like
> this:
> 
> <html>
> <body>
> <form method=POST action="cgi-bin/test.cgi">
> Your name:<br>
> <input type=text name="name" value="" size=50>
> <input type=submit>
> </form>
> <body>
> </html>
> 
> The CGI module makes the target script very simple:
> 
> use CGI;
> $query = new CGI;
> print $query->header;
> print $query->start_html(-title=>'Test Document');
> print "Your name is: " . $query->param('name');
> print $query->startform(-method=>'POST', -action=>'test2.cgi');
> print $query->hidden(-name=>'name'); #a hidden field, like Reiner
> mentioned, automatically POSTed to test2.cgi
> print $query->submit;
> print $query->endform;
> print $query->end_html;
> 
> An example of the 2nd target script, test2.cgi, formless in this case:
> 
> use CGI;
> $query = new CGI;
> print $query->header;
> print $query->start_html(-title=>'Test Document');
> print "Your name is: " . $query->param('name');
> print $query->end_html;
> 
> 
> I hope this isn't too redundant or obvious, just thought you might like
> to see it all done with the CGI module.
> 
> gclimb@my-dejanews.com wrote:
> > 
> > I'm trying to learn CGI programming using perl, and I have a question
> > regarding forms. I want to build a site that requires multiple forms, and
> > wish to have some variables that were defined in one form passed to
the next.
> > One example would be the persons name...by passing the variable I can use
> > their name to address them in each successive form. I've tried my best, but
> > can't seem to get it to work. Any help would be appreciated.
> > 
> > Mark
> > 
> > -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> > http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

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


Administrivia:

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

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


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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