[15560] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2973 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 7 18:08:56 2000

Date: Sun, 7 May 2000 15:05:07 -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: <957737107-v9-i2973@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 7 May 2000     Volume: 9 Number: 2973

Today's topics:
        [Array] Minimum and Maximum of a List <charles.henry@engineer2k.com>
    Re: [Array] Minimum and Maximum of a List <tony_curtis32@yahoo.com>
    Re: [Array] Minimum and Maximum of a List <rootbeer@redcat.com>
    Re: a cgi.pm question - carrying variable state across  <jeff@vpservices.com>
        a cgi.pm question - carrying variable state across mult <ejwhite1@facstaff.wisc.edu>
        AIX && perl will not play nice... (Phil C)
    Re: CHECKING FORM DATA FOR NUMERIC DATA <iltzu@sci.invalid>
        Checking if Child Process is still Alive abeall@ipcell.com
    Re: Checking if Child Process is still Alive <Peter.Wirdemo@Ericsson.COM>
    Re: converting input to <p></p> pairs via perl <iltzu@sci.invalid>
        Getting variables from html <jamalone@earthlink.net>
    Re: Getting variables from html <jeff@vpservices.com>
    Re: global variable with perl-cgi scripts ? <e.bras@hccnet.nl>
        Grokking the parser <wayne.izatt@myself.com>
    Re: How do I get the subroutine name of a coderef? (Steve Leibel)
    Re: How do I get the subroutine name of a coderef? (Bart Lateur)
    Re: How do I get the subroutine name of a coderef? <Office@AmethystInf.com>
    Re: How to tell if <> operator will work on a given sca <iltzu@sci.invalid>
    Re: problem with "system" and file copy <pautler@hawaii.edu>
    Re: Quality of perl implementations (Was: Re: if file a (Ilya Zakharevich)
        reading char by char in a string <jetlund@tele.ntnu.no>
    Re: reading char by char in a string <jamalone@earthlink.net>
        Thank you! <david@celtic1888.fsbusiness.co.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 7 May 2000 20:00:35 +0200
From: "Charles Henry" <charles.henry@engineer2k.com>
Subject: [Array] Minimum and Maximum of a List
Message-Id: <8f4bae$1ejs$1@news5.isdnet.net>

Is there a function in perl to retrieve the Maximum, Minimum, or Average of
@array which contains only numbers or do I have to build up those functions?

Thanks in advance!




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

Date: 07 May 2000 13:16:40 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: [Array] Minimum and Maximum of a List
Message-Id: <87bt2i8buf.fsf@shleppie.uh.edu>

>> On Sun, 7 May 2000 20:00:35 +0200,
>> "Charles Henry" <charles.henry@engineer2k.com> said:

> Is there a function in perl to retrieve the Maximum,
> Minimum, or Average of @array which contains only
> numbers or do I have to build up those functions?

The module Statistics::Descriptive will do what you want.
It provides min(), max() and various types of mean().

hth
t


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

Date: Sun, 7 May 2000 11:18:57 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: [Array] Minimum and Maximum of a List
Message-Id: <Pine.GSO.4.10.10005071118280.3921-100000@user2.teleport.com>

On Sun, 7 May 2000, Charles Henry wrote:

> Is there a function in perl to retrieve the Maximum, Minimum, or
> Average of @array which contains only numbers or do I have to build up
> those functions?

Neither. :-)

    http://search.cpan.org/search?module=List::Util

Does that get you started? Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 07 May 2000 12:53:38 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: a cgi.pm question - carrying variable state across multiple  invocations of the same script
Message-Id: <3915C9C2.1EBDE408@vpservices.com>

"Eric J. White" wrote:
> 
> I'm trying write a script that will allow me to present a series of web
> pages that will change based on the values of responses given to earlier
> pages.

> ... I want to refer to variables defined in the
> page 1 subroutine during the creation of page 3.  Is there a way that I
> can carry the state of the page 1 variables through each time the script

You've got the basic idea.  The only thing you are missing is the
conecpt of hidden fields.  When you get the parameter for "sex" from
page 1, stick it in a hidden field on all succeeding forms that need the
info and it will be passed along.  Since forms are by default "sticky"
the value for sex will be added to each hidden field automatically
without you even having to supply a value (assuming, of course, that you
keep the name of the field the same).

> sub print_form2 {
>   ...
>   "SEX = $SEX",

Add:  hidden(-name=>'sex),

Then in form three param('sex') will contain the value the user put in
form one.  And keep adding the same hidden field in all the forms that
you want to keep passing that value on.

-- 
Jeff


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

Date: Sun, 07 May 2000 13:26:25 -0500
From: "Eric J. White" <ejwhite1@facstaff.wisc.edu>
Subject: a cgi.pm question - carrying variable state across multiple invocations  of the same script
Message-Id: <3915B551.8C8110D8@facstaff.wisc.edu>

Hello,

I'm trying write a script that will allow me to present a series of web
pages
that will change based on the values of responses given to earlier
pages.
For example, at page 1 someone might indicate he's male. On page 2 and
following pages I'd like to ask questions that only men get.  Ultimately
I'd
like to be able to write a reasonably customized online survey, with the

questions being determined by the user's responses.

The code below shows what I've been trying to do.  I present page 1,
then go to the subroutine for page 1 to look at the responses, then
deliver page 2 based on the responses at page 1.  This seems to work,
but things break down when I want to refer to variables defined in the
page 1 subroutine during the creation of page 3.  Is there a way that I
can carry the state of the page 1 variables through each time the script

is invoked?

You'll no doubt note that the programming is rudimentary, but that's
where
my skills are right now.  I'd like to find a way to make this work and
then
go on to refine it.  I'm not a perl wiz, but I'd like to continue
traveling down
that road.

Thanks a lot,

Eric

Here's what I've been trying under perl 5.6.0:


#!c:\perl\bin\perl.exe
# Script: p9258.pl
use CGI ':all';
use warnings;
#use strict;


$action=param('Action');





#testing doing evals in subroutines after each page is filled out

if ($action eq "Onto page 2") {
 sub_2();
} elsif  ($action eq "Onto page 3") {
 sub_3();
}else {
 sub_1();
}




if ($action eq "Onto page 2") {
 print_form2();
} elsif ($action eq "Onto page 3") {
 print_form3();
} else {
 print_form();
}


print "action value is $action";
print end_html;

sub print_form {
 print header,
   start_html('Page 1'),
   h1('THIS IS PAGE 1');

 print start_form,

  "This is page 1: ",
  radio_group(-name=>'sex', -values=>['male', 'female']),
  p(),
  submit(-name=>'Action', -value=>'Onto page 2'),
  end_form;

}

sub print_form2 {
 print header,
   start_html('Page 2'),
   h1('THIS IS PAGE 2');

 print start_form,
  "This is page 2: ",
  p(),

    "Do you wear $clothing to work? ",
  p(),

  "SEX = $SEX",
  p(),

    p(),
    radio_group(-name=>'formal', -values=>['yes', 'no']),
  p(),
  submit(-name=>'Action', -value=>'Onto page 3'),
  end_form;

}


sub print_form3 {
 print header,
   start_html('Page 3'),
   h1('THIS IS PAGE 3');

 print start_form,
  "This is page 3: ",
  p(),

    "Are you a $parent? ",
  p(),

    "Clothing var = $clothing",
    p(),


    radio_group(-name=>'momordad', -values=>['yes', 'no']),
  p(),
  submit(-name=>'Action', -value=>'Submit completed form'),
  end_form;
}


#these are the subroutines that do some work after each page
#is filled out

sub sub_1 {
    ($testvar);
    $testvar = 'this is a dummy var'

}

sub sub_2 {
 ($clothing);
 ($SEX);

 if (param ('sex') eq 'male') {
  $clothing = 'suits',
  $SEX=1
 } else {
  $clothing = 'dresses',
  $SEX=2
 }

}


sub sub_3 {
 ($parent);

 if ($gSEX == 1) {
  $parent = 'father'
 } else {
  $parent = 'mother'
 }

 if (param ('sex') eq 'male') {
  $parent = 'father'
 } else {
  $parent = 'mother'
 }

}







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

Date: 7 May 2000 20:07:59 GMT
From: pchampon@valueweb.net (Phil C)
Subject: AIX && perl will not play nice...
Message-Id: <8f4iev$2dkk$1@news.gate.net>
Keywords: aix perl berkeley db help

It is not apparent right now why I am having problems with this script of mine,
but non the less running it on an AIX v4.3.3 box with perl 5.00503 and
Bekeley DB 2.7.7.0 using 'use strict;' I can not use my db? The only thing that
I can offer as insight is that $db_obj->put() (being called through MLDBM)
returns a -7 when I try to 'put' something into the database. I have not been
able to find out what -7 is, and I find it particularly odd since it is supposed
to return 0 or -1 according to the man page. Also $! is not being set to
anything when it errors out so I have no idea what is really going on. The only
other peice of info that I have is that this script (db wise) runs perfecly on
my FreeBSD 3.4 box with the same versions of perl and Bdb. The only difference
between the perl's is that my BSD perl  is the stock version that came with
the OS, while the AIX perl is something that I picked up from www.bull.de/pub.

Any help/insight would be greatly appreciated.

Thanks, Phil

PS - I can send anyone the code who would like to look it over, it is soo big
     tho and that is why I did not send it.


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

Date: 7 May 2000 18:27:14 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: CHECKING FORM DATA FOR NUMERIC DATA
Message-Id: <957723706.27411@itz.pp.sci.fi>

In article <8evbso$ob6$1@nnrp1.deja.com>, linux4all@yahoo.com wrote:
>With Perl, how can I check a string from a form submission to make sure
>that the string contains *only* digits and zero or one period (decimal
>point).  I tried using the following, but it doesn't seem to work quite
>right:
>
>if ($present_value !~ /\d*\.?\d*/)

Others have already pointed you to a FAQ entry about what you _want_
to do, so I'll just mention how to do what you're _trying_ to do.

  unless ($present_value =~ /^\d*\.?\d*$/)

The ^ and $ anchor the match.  Type "perldoc perlre" at your shell
prompt for more information.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: 07 May 2000 16:38:44 EDT
From: abeall@ipcell.com
Subject: Checking if Child Process is still Alive
Message-Id: <3915d46d.288354902@news.ipcell.com>

Does anyone know how the main process can check if a particular child
process has died without making the main process wait.

Caveat: this must work with Activeperl on a NT box but if you know how
to do this in unix I would still like to know :).

Below is an example of what I would like to do:
    $pid = fork();
    if ($pid == 0) { #Child process
            system("sdf -2mif stuff.txt");
            exit(0);
   }

if ($pid != 0) { #Parent Process
      while (1) {
        sleep 5;
         if (child has not died yet) {
             print "The child is still doing something. Please be
patient\n";
         }
      }
}

Thanks in Advance,
Art Beall


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

Date: Sun, 07 May 2000 21:25:03 GMT
From: Peter Wirdemo <Peter.Wirdemo@Ericsson.COM>
Subject: Re: Checking if Child Process is still Alive
Message-Id: <3915DF4B.6C3984D4@Ericsson.COM>

perldoc -f kill
     kill SIGNAL, LIST
             Sends a signal to a list of processes.  Returns the
             number of processes successfully signaled (which is
             not necessarily the same as the number actually
             killed).

                 $cnt = kill 1, $child1, $child2;
                 kill 9, @goners;

         ->  If SIGNAL is zero, no signal is sent to the process.
         ->  This is a useful way to check that the process is
         ->  alive and hasn't changed its UID.  See the perlport
         ->  manpage for notes on the portability of this
         ->  construct.

/Peter
             

abeall@ipcell.com wrote:
> 
> Does anyone know how the main process can check if a particular child
> process has died without making the main process wait.
> 
> Caveat: this must work with Activeperl on a NT box but if you know how
> to do this in unix I would still like to know :).
> 
> Below is an example of what I would like to do:
>     $pid = fork();
>     if ($pid == 0) { #Child process
>             system("sdf -2mif stuff.txt");
>             exit(0);
>    }
> 
> if ($pid != 0) { #Parent Process
>       while (1) {
>         sleep 5;
>          if (child has not died yet) {
>              print "The child is still doing something. Please be
> patient\n";
>          }
>       }
> }
> 
> Thanks in Advance,
> Art Beall


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

Date: 7 May 2000 19:00:36 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: converting input to <p></p> pairs via perl
Message-Id: <957725299.28467@itz.pp.sci.fi>

In article <slrn8hakcj.ph.efflandt@efflandt.xnet.com>, David Efflandt wrote:
>How do you know what lines end with?  Even from a Linux Netscape textarea
>they end with \r\n.  Not sure about Mac.  It is wise to not assume.
 [snip]
># These work with any line ending
>s/(\r\n\r\n|\n\n|\r\r)/<\/p><p>/g;
>s/(\r\n|\n|\r)/<br>/g;

Yuck.  What's wrong with:

  s!\r\n?!\n!g;
  s!\n\n+!</p><p>!g;
  s!\n!<br>!g;

 ..or an alternative approach that preserves the newlines as well:

  s!\r\n?!\n!g;
  s!\n!<br>\n!g;
  s!(<br>\n){2,}!</p>\n<p>!g;

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.




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

Date: Sun, 07 May 2000 19:31:32 GMT
From: "Jason Malone" <jamalone@earthlink.net>
Subject: Getting variables from html
Message-Id: <owjR4.37791$g4.1008069@newsread2.prod.itd.earthlink.net>

I have done this before but I can't find my code anywhere.  I can't remember
how I get the variables from an http request i.e. when a user clicks on a
link (www.whatever.com/cgi-bin/test.pl?var1=value&var2=value2....) Is this a
get or a post or neither.

Can someone give me a snippet of code that will grap these variables into
the script?

Thanks in advance.
Jason Malone




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

Date: Sun, 07 May 2000 12:42:09 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Getting variables from html
Message-Id: <3915C711.2ABF8137@vpservices.com>


Jason Malone wrote:
> 
> I have done this before but I can't find my code anywhere.  I can't remember
> how I get the variables from an http request i.e. when a user clicks on a
> link (www.whatever.com/cgi-bin/test.pl?var1=value&var2=value2....) Is this a
> get or a post or neither.

That is a GET.
 
> Can someone give me a snippet of code that will grap these variables into
> the script?

# ...
use CGI qw(:standard);
my $var1 = param('var1') || '';
if( param('var2') eq 'foo' ) { ... }
for(param) {...}
# etc.

Which works regardless of whether the parameters are passed in from a
GET in a URL like in your example, or from POST from a form, or from the
command line, or from a file, etc.

Further documentation is in the CGI.pm module which comes standard with
Perl and is your best bet for most CGI related tasks.

-- 
Jeff


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

Date: Sun, 7 May 2000 22:16:51 +0200
From: "Ed Bras" <e.bras@hccnet.nl>
Subject: Re: global variable with perl-cgi scripts ?
Message-Id: <8f4jct$hgc$1@news.hccnet.nl>

Thanks Bart,

But how do I know that a session has been terminated, such that his session
file can be deleted ?
For example when someone, during placing an order, just exit his browser,
and so terminates his session. How do I detect this ?

Regards,
Ed Bras

Bart Lateur <bart.lateur@skynet.be> wrote in message
news:39157fcb.1064666@news.skynet.be...
> Ed Bras wrote:
>
> >what about session depend variables ?
> >That is that one person can change the variable value of another when
they
> >both have web connection with the same page. Do you have  a solution for
> >that ?
>
> If you have a unique session ID, save a data file with the name based on
> it, containing the data for that session. For simple cases, a tab
> delimited text file will do nicely: one column for the keys, and one for
> the values.
>
> --
> Bart.




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

Date: Sun, 07 May 2000 22:03:34 GMT
From: Wayne Izatt <wayne.izatt@myself.com>
Subject: Grokking the parser
Message-Id: <3915E825.866D542F@myself.com>

I'm having trouble wrapping my head around this (based on an altered
chunk from Essential Perl).

#!/usr/bin/perl -w

%spacers = (husband => 'george', wife => 'june', son => 'elroy');
@spacers = ('a', 'b');
delete @spacers{'son', 'wife'}; # line 5

print keys(%spacers);
print "\n";
print "@spacers\n";

When run, the code prints

husband
a b

Which means that line 5 works. Yet it would appear to reference the
spacers array. So I guess what Im not getting is the way the parser
takes this line apart.

Ideas, oh enlightened ones?



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

Date: Sun, 07 May 2000 12:38:35 -0700
From: stevel@coastside.net (Steve Leibel)
Subject: Re: How do I get the subroutine name of a coderef?
Message-Id: <stevel-0705001238350001@192.168.100.2>

In article <Pine.GSO.4.10.10005070727510.3921-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:

> On Sun, 7 May 2000, Steve Leibel wrote:
> 
> > Later in the program for debugging purposes I would like to recover
> > the name of the referenced subroutine from the coderef.  In other
> > words given $fooref, how do I get "foo"?
> 
> As others have pointed out, the sub may not have a name. But maybe you
> want something else. You could make a hash of the named subs when you
> create the references, something like this:
> 

Tom,

In general a coderef may point to an anonymous subroutine.

But my coderef points to a named sub.  If I were to call the sub by name,
Perl would be able to branch to the correct code addr.  So I'm thinking
there must be some secret data structure containing the names of named
subroutines and their addresses.

Thanks to other responders who pointed out that

1) I could call the sub and then have the sub invoke caller() -- a bit of
an overkill, since I just want to get the name, not call the sub;

2) I could save a map of the names/addresses myself -- if all else fails
I'll do that;

3)  A wonderful solution has been posted to deja.com, where I can no
longer find it -- deja moved their site again and many pages are no longer
accessible.

So Perl wizards, can anyone supply either a solution or a definitive
statement that there is no solution.

Given

$fooref = \&foo;

later in the program, given $fooref, can I recover the string "foo"?  

Thanks,

Steve L
stevel@coastide.net


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

Date: Sun, 07 May 2000 19:58:55 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: How do I get the subroutine name of a coderef?
Message-Id: <3915ca1d.30281470@news.skynet.be>

Steve Leibel wrote:

>3)  A wonderful solution has been posted to deja.com, where I can no
>longer find it -- deja moved their site again and many pages are no longer
>accessible.

Is this it?

Subject: Re: subname from subref
Date: 04/21/2000
From: Bart Lateur <bart.lateur@skynet.be>

     #! perl -w
     my %sub;
     {
         my @todo =  [ '', \%:: ];
         while(@todo) {
             my($package, $stash) = @{shift @todo};
             foreach(sort keys %$stash) {
                 if(/::/) {
                     push @todo, [ "$package$_", $stash->{$_} ]
                       unless "$package$_" eq 'main::';
                 } else {
                     my $sub = \&{$stash->{$_}};
                     $sub{$sub} = ($package || 'main::') . $_;
                 }
             }
         }
     }
  
     sub test {
         return "Yes";
     }
  
     sub Foo::Bar::test {
         return "No";
     }
  
     $\ = "\n"; $, = "\t";
     for my $test(\&test, \&Foo::Bar::test) {
         print $test, $sub{$test};
     }
  
-- 
	Bart.


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

Date: Sun, 7 May 2000 23:02:14 +0200
From: "Victor Kroese" <Office@AmethystInf.com>
Subject: Re: How do I get the subroutine name of a coderef?
Message-Id: <xQkR4.2166$bO4.36917@news1.online.no>

Hi Steve,

I have been looking at deja as well and found this in a thread that Bart was
pointing to.
I think it is what you are looking for.

Victor Kroese
Victor.Kroese@AmethystInf.com

Dan Sugalski  <dan@tuatha.sidhe.org> wrote:
>
>This isn't a 100% general solution, FWIW. You'll have problems with
>anonymous sybs, subs that've been redefined after the table's built, and
>globs that get localizes. (Though that's not that common) But, then,
>there's no general way to go from a reference to the name of the thing
>being referred to in perl.

The method used by the debugger (in up-to-date Perl versions) is probably as
general as you'll get and of course enormously more efficient:

sub CvGV_name_or_bust {
  my $in = shift;
  return if $skipCvGV;          # Backdoor to avoid problems if XS broken...
$in = \&$in;                  # Hard reference...
  eval {require Devel::Peek; 1} or return;
  my $gv = Devel::Peek::CvGV($in) or return;
  *$gv{PACKAGE} . '::' . *$gv{NAME};
}

Devel::Peek comes as standard with current Perls.  Pity its
documentation is woefully inadequate.


Mike Guy





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

Date: 7 May 2000 19:31:01 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: How to tell if <> operator will work on a given scalar?
Message-Id: <957726600.29276@itz.pp.sci.fi>

In article <391324C4.E6636F2A@zeegee.com>, Eryq wrote:
>Hmmmm.... I wonder then... it is *always* true that <$foo>
>will work if fileno($foo) is defined?  In this uncertain 
>age of tiehandle, I find myself just a wee bit unsure....

Perhaps not - but you'll still have the value of fileno($foo), which
should be a valid file descriptor number.  If it isn't, you'll find
that out quickly in the next step:

  open FILE, "<&=$fd" or die "Can't open file descriptor $fd: $!\n";

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Sun, 07 May 2000 21:28:02 GMT
From: David Pautler <pautler@hawaii.edu>
Subject: Re: problem with "system" and file copy
Message-Id: <8f4n4k$80q$1@nnrp1.deja.com>

In article <3911a125$1_1@news.iglou.com>,
  tzz@iglou.com (Teodor Zlatanov) wrote:
> I would use glob (perldoc -f glob) as it uses /bin/csh, which will
> understand tilde notation, wildcards, etc.  You can do your own,
> as Paul suggested, but it's easier to use the built-in functions.

Strangely, glob("$path/*") doesn't seem to return filenames that
have extensions.

Also, glob("$path/*.*") doesn't return anything when the directory
contains filenames with extensions, although changing ".*" to
a particular extension does return filenames.

Is using a system call the only option in these cases?

	-dp-


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


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

Date: 7 May 2000 17:31:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Quality of perl implementations (Was: Re: if file already exists then remove...)
Message-Id: <8f498v$751$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler 
<lr@hpl.hp.com>],
who wrote in article <MPG.137e5a5744f6439f98aa17@nntp.hpl.hp.com>:
> I am troubled by your philosophy of abstention from directing the 
> attention of Perl implementors toward reliability as opposed to new 
> features.  

I was puzzled by this attitude of Perl users for a long time.  Until I
lost any faith in that Tom knows what he writes about.

Let me reiterate my current opinion on the topic: the reason for my
puzzlement (and your trouble) is the difference between Perl as a
scripting language and Perl as a programming language.  Perl is
absolutely fine as a scripting language.  Perl is pretty unusable as a
programming language.

Thus people who use Perl "in scripting mode" do not care about bugs,
ambiguities and undoc behaviour: they just experiment with their
scripts until they think the scripts do what they want.  The design of
Perl makes such experiments a kind of fun in itself, and the
understanding that this is not how things are supposed to be
programmed is drowned in all this fun.

And the ubiquitous false advertisements that Perl is a "programming
language" creates a warm fuzzy feeling that all this fun of
experimenting *is* programming.  Hence that

  Programming Perl is fun!

slogan.  Additionally, for a lot of tasks the "scripting mode" is
quite justifiable: the result may be easily controllable/undone, so
that if things go wrong, you just try again.  Or the problem to solve
is so simple, that your experiments (plentiful because it is so hard
to write correct Perl on the first try) have a good chance to cover
most of the cases your script is going to be used in.

Summary: now I'm not so puzzled as before.  ;-)

Ilya


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

Date: Sun, 07 May 2000 20:44:43 +0200
From: Ola Jetlund <jetlund@tele.ntnu.no>
Subject: reading char by char in a string
Message-Id: <3915B99A.1A7DD9CB@tele.ntnu.no>

How can I read special parts from a string? say:

i have string that contains: someinfo_moreinfo_evenmoreinfo_

I would like to store the info between the underscores ("_"). But I'm
still new at this and need help....



rg
J



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

Date: Sun, 07 May 2000 20:02:46 GMT
From: "Jason Malone" <jamalone@earthlink.net>
Subject: Re: reading char by char in a string
Message-Id: <GZjR4.37852$g4.1010214@newsread2.prod.itd.earthlink.net>

Try this...

($var1, $var2, $var3) = split(/_/ $string);

where
$string = someinfo_moreinfo_evenmoreinfo
$var1 will = someinfo
$var2 will = moreinfo
$var3 will = evenmoreinfo

Hope this helps.
Jason Malone

"Ola Jetlund" <jetlund@tele.ntnu.no> wrote in message
news:3915B99A.1A7DD9CB@tele.ntnu.no...
> How can I read special parts from a string? say:
>
> i have string that contains: someinfo_moreinfo_evenmoreinfo_
>
> I would like to store the info between the underscores ("_"). But I'm
> still new at this and need help....
>
>
>
> rg
> J
>




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

Date: Sun, 7 May 2000 17:09:24 +0100
From: "David" <david@celtic1888.fsbusiness.co.uk>
Subject: Thank you!
Message-Id: <8f4oj2$4dv$1@newsg1.svr.pol.co.uk>

A big thank you to everyone that helped me with my earlier question, I have
now finished my first ever perl program :-) It's listed below for anyone
interested. I could have found how to read in in my book eventually, but I
want to devise my own programs as I go along in order that I actually learn
and understand what the book is telling me. Now that i can read in, I can
practise with arrays and array splicing and a few other ideas...

#!/usr/local/bin/perl -w

@array = ("David", "Paul", "Patrick", "Tam", "Bob");
print "@array\n";
print "Type a number between 1 and 5 and then press enter: ";
my $foo = <STDIN>;
chomp $foo;
print "$array[$foo - 1]\n";

--David--




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

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


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