[19339] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1534 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 15 18:11:02 2001

Date: Wed, 15 Aug 2001 15:10:18 -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: <997913418-v10-i1534@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 15 Aug 2001     Volume: 10 Number: 1534

Today's topics:
    Re: Evaluation order of object methods <uri@sysarch.com>
    Re: Evaluation order of object methods <johndporter@yahoo.com>
    Re: Evaluation order of object methods <djberge@uswest.com>
    Re: Evaluation order of object methods <djberge@uswest.com>
        FAQ: How do I print to more than one file at once? <faq@denver.pm.org>
    Re: Function prototype causing type error?? (Tad McClellan)
    Re: Function prototype causing type error?? <miscellaneousemail@yahoo.com>
        How do I get a message back from the server? <bigbanana@mailandnews.com>
    Re: How do I: Count characters between < > in a string? <acacia@online.no>
    Re: How to send output to both a file and stdout <gfu@gscmail.gsfc.nasa.gov>
    Re: How to send output to both a file and stdout <johndporter@yahoo.com>
        Ignoring The First Line <asgar@tkusa.com>
    Re: Ignoring The First Line <ilya@martynov.org>
    Re: Ignoring The First Line (Tad McClellan)
    Re: Ignoring The First Line <krahnj@acm.org>
    Re: Ignoring The First Line (Paul Lew)
        Installing Gd-1.18 problems <porter96@lycos.com>
    Re: Installing Gd-1.18 problems <g-preston1@ti.com>
    Re: Is $! a number or a string? <pne-news-20010815@newton.digitalspace.net>
        Looking for Script (T Mesbah)
        Math::Matica, Perl Modules in general (Adamone11)
    Re: Math::Matica, Perl Modules in general <randy@theoryx5.uwinnipeg.ca>
    Re: multiple striping of leading/trailing chars (Abigail)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 15 Aug 2001 18:46:15 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Evaluation order of object methods
Message-Id: <x7r8udjh55.fsf@home.sysarch.com>

>>>>> "DB" == Daniel Berger <djberg96@hotmail.com> writes:

  DB> It's late.  Couldn't sleep.  Hopefully this makes sense.

well, we shall see.

  DB> I've got question on object methods.  Setting up methods is easy,
  DB> as is calling individual methods.  For this particular object that
  DB> I have created, I would like to return $self if called in void
  DB> context or an array or array ref if called in list or scalar
  DB> context, respectively.  No problem.

hmm, why do you want to return anything when called in a void context?
that means you have nothing to store the returned value. so that doesn't
make any sense. the only proper thing to do in a void context is a plain
return.

  DB> However, where I'm having trouble is when I want to 'stack' methods that
  DB> ultimately are called in list or scalar context.

  DB> First, my very simple object.

  DB> ##############################################
  DB> package Some::Object;
  DB> use strict;

  DB> my @array;  # This is our global array that we manipulate

that is called class data. you don't need objects to manage class data,
just class methods. many times objects are created which manage class
data as well.

  DB> sub new{
  DB>    my $class = shift;
  DB>    @array = @_;
  DB>    my $self = [];
  DB>    bless($self, $class);
  DB> }

	my( $class, @array ) = @_ ;
	return bless [], $class ;

  DB> sub unique{
  DB>    my $self = shift;
  DB>    my %item;
  DB>    foreach(@array){ $item{$_}++ }

	@item{ @array } = () ;

  DB>    unless(defined wantarray){
  DB>       @array = keys %item;
  DB>       return $self;
  DB>    }

like i asked above, what do you think will be using $self? it is tossed
out as it is called in a void context.

  DB>    my @keys = keys %item;
  DB>    return @keys if wantarray;
  DB>    return \@keys;
  DB> }
  DB> ###########################################

it looks like you don't save the unique keys unless it is called in a
void context.

  DB> my $so = Some::Object->new(1,2,3,4,5,2,3,4);
  DB> my $length = $array->unique()->length();           # Want to return '5'
                    ^^^^^

shouldn't that be $so?

unique is called in a scalar context as its return value is used as the
object for length. so it will not return $self, but \@array which is
wrong.

  DB> This would ideally modify the object itself first (with a call to
  DB> 'unique'), then call 'length()', and assign it to $length.
  DB> However, since the 'unique()' method returns a value in list or
  DB> scalar context, it's going to get evaluated first and assigned to
  DB> $length *before* the length() method is called and will die, since
  DB> I'm not operating on the object any longer at that point.

no, it tries to call the method length on a non-object (a ref to
@array). $length won't get assigned because the code will die.

  DB> Is there a non-cheesy way for me to accomplish what I want?  Am I even
  DB> making sense?

you can't have a scalar return and a void return overlap so you are not
making sense.

you can cascade method calls only if each earlier method returns the
invocant (thanx damian!) object. it is a well known api feature. 

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Wed, 15 Aug 2001 19:55:41 GMT
From: John Porter <johndporter@yahoo.com>
Subject: Re: Evaluation order of object methods
Message-Id: <3B7AD2ED.56D1EFF5@yahoo.com>

Daniel Berger wrote:
> 
> where I'm having trouble is when I want to 'stack' methods that
> ultimately are called in list or scalar context.
> 
> my $so = Some::Object->new(1,2,3,4,5,2,3,4);
> my $length = $array->unique()->length();    # Want to return '5'

The thing to understand is that unique() will be called in
scalar context here.

Perl sees that the result of $array->unique() is going to be 
used as an object reference for the call to ->length().
Therefore it *has* to call ->unique() in scalar context.

The context in which ->length() is called is going to be
determined by the left-hand side of the assignment.

-- 
John Porter


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

Date: Wed, 15 Aug 2001 15:05:26 -0500
From: Mr Sunblade <djberge@uswest.com>
Subject: Re: Evaluation order of object methods
Message-Id: <3B7AD606.70926A21@uswest.com>

<snip>

>
> > First, my very simple object.
>
> Do you mean class?

Ok - I've had some rest now... yes, I meant class

>
> If you have only one array to maintain, what do you need objects for?
> You can do that, but then your methods should be class methods, not
> object methods.

The ultimate goal is to emulate Ruby-style arrays, i.e. arrays as
objects (not just one array in particular necessarily).  This is mainly
for fun and readability.  It's easier to read and maintain '$ao->randomize()'
than code and maintain an array randomizing subroutine.

<snip>

> > }
> > ###########################################
> >
> > Now, what I would like to be able to do is:
> >
> > my $so = Some::Object->new(1,2,3,4,5,2,3,4);
> > my $length = $array->unique()->length();           # Want to return '5'
>
> Method chaining is possible, as long as every method returns an object.
> Since you plan to return various things, depending on context, that
> approach won't work here.

Ok - I didn't have my Conway book handy at the time.  :) I see my mistake
in this regard now.   I can get around this in a cheesy way by allowing an
'inline' hash-style argument that always returns $self so I chain any
number of methods together

e.g. $length = $ao->randomize(inline=>1)->compact(inline=>1)->length()

I've tried it and it works fine, though it's annoying to have to specify that
argument each time.  The other option is to always return $self, and force
the user to specify that they want a return value.  I thought that was even
more annoying.

>
> Frankly, your code above doesn't make much sense.  You seem confused
> about the role of classes vs. objects, and where to put the data.
> Probably perltoot (an object-oriented tutorial for Perl) could help
> you make a more focused design.
>
> Anno

Maybe.

Thanks.

-Mr Sunblade

--
"Evil will always triumph because Good is *dumb*."
-- Dark Helmet, 'Spaceballs: The Movie'





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

Date: Wed, 15 Aug 2001 15:28:56 -0500
From: Mr Sunblade <djberge@uswest.com>
Subject: Re: Evaluation order of object methods
Message-Id: <3B7ADB88.74151981@uswest.com>

Uri Guttman wrote:

> >>>>> "DB" == Daniel Berger <djberg96@hotmail.com> writes:
>
>   DB> It's late.  Couldn't sleep.  Hopefully this makes sense.
>
> well, we shall see.
>
>   DB> I've got question on object methods.  Setting up methods is easy,
>   DB> as is calling individual methods.  For this particular object that
>   DB> I have created, I would like to return $self if called in void
>   DB> context or an array or array ref if called in list or scalar
>   DB> context, respectively.  No problem.
>
> hmm, why do you want to return anything when called in a void context?
> that means you have nothing to store the returned value. so that doesn't
> make any sense. the only proper thing to do in a void context is a plain
> return.

So I can chain method calls on an object.  I need an object to do that so...

>
> that is called class data. you don't need objects to manage class data,
> just class methods. many times objects are created which manage class
> data as well.

I didn't mean for this to become the focus of the critique.  The point is to
eventually create Ruby-like arrays  - i.e. arrays as objects so that
I can do something like:

my $sa = Some::Object->new(1,2,3,4,5,2,3,4);
print $sa->unique()->length();

 ...rather than boring, old, well known goof-ball perl syntax that
just doesn't look as elegant. :)

<some snippage>

>
>   DB> sub unique{
>   DB>    my $self = shift;
>   DB>    my %item;
>   DB>    foreach(@array){ $item{$_}++ }
>
>         @item{ @array } = () ;

Heh - sweet.  Didn't see that one in the cookbook.  <mental note made>

<more snippage>

>
> it looks like you don't save the unique keys unless it is called in a
> void context.
>
>   DB> my $so = Some::Object->new(1,2,3,4,5,2,3,4);
>   DB> my $length = $array->unique()->length();           # Want to return '5'
>                     ^^^^^
>
> shouldn't that be $so?

Yep - I was tired.

>
>
> unique is called in a scalar context as its return value is used as the
> object for length. so it will not return $self, but \@array which is
> wrong.
>
>   DB> This would ideally modify the object itself first (with a call to
>   DB> 'unique'), then call 'length()', and assign it to $length.
>   DB> However, since the 'unique()' method returns a value in list or
>   DB> scalar context, it's going to get evaluated first and assigned to
>   DB> $length *before* the length() method is called and will die, since
>   DB> I'm not operating on the object any longer at that point.
>
> no, it tries to call the method length on a non-object (a ref to
> @array). $length won't get assigned because the code will die.

Yep, I had the precedence wrong, though either way I knew it was trying to
call a method on a non-blessed thingy.

>
>   DB> Is there a non-cheesy way for me to accomplish what I want?  Am I even
>   DB> making sense?
>
> you can't have a scalar return and a void return overlap so you are not
> making sense.
>
> you can cascade method calls only if each earlier method returns the
> invocant (thanx damian!) object. it is a well known api feature.

Now pounded into my head as I review the Conway book.

>
>
> uri

Thanks for the input.  Sorry for not being more clear.

Regards,

Mr. Sunblade


--
"Evil will always triumph because Good is *dumb*."
-- Dark Helmet, 'Spaceballs: The Movie'





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

Date: Wed, 15 Aug 2001 18:17:08 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I print to more than one file at once?
Message-Id: <E0ze7.126$V3.171395072@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How do I print to more than one file at once?

    If you only have to do this once, you can do this:

        for $fh (FH1, FH2, FH3) { print $fh "whatever\n" }

    One way is to use the IO::Tee module from CPAN:

        use IO::Tee;
        my $tee = IO::Tee->new(\*STDOUT, $fh, ">file.txt");
            or die "Error teeing output: $!\n";
        print $tee "whatever\n";

    This way anything printed to "$tee" will be written to the filehandles
    "STDOUT", "$fh", and to the file named "file.txt".

    Another way to connect one filehandle to several output filehandles, is
    to use the tee(1) program if you have it, and let it take care of the
    multiplexing:

        open (FH, "| tee file1 file2 file3");

    Or even:

        # make STDOUT go to three files, plus original STDOUT
        open (STDOUT, "| tee file1 file2 file3") or die "Teeing off: $!\n";
        print "whatever\n"                       or die "Writing: $!\n";
        close(STDOUT)                            or die "Closing: $!\n";

    You might also find the script at
    http://www.perl.com/CPAN/authors/id/TOMC/scripts/tct.gz interesting.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           05.23
-- 
    This space intentionally left blank


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

Date: Wed, 15 Aug 2001 13:33:00 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Function prototype causing type error??
Message-Id: <slrn9nlcic.29p.tadmc@tadmc26.august.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:

>I am looking at including function prototypes in my sub definitions


   "Far More Than Everything You've Ever Wanted to Know 
    about Prototypes in Perl"   by Tom Christiansen 


      http://www.perl.com/pub/a/language/misc/fmproto.html


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 15 Aug 2001 19:02:06 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Function prototype causing type error??
Message-Id: <MPG.15e473ec86e0a465989759@news.edmonton.telusplanet.net>

In article <slrn9nlcic.29p.tadmc@tadmc26.august.net>, Tad McClellan at 
tadmc@augustmail.com says...

>       http://www.perl.com/pub/a/language/misc/fmproto.html

Well after reading that...scratch prototype use for me.  I guess I will 
just have to write out a little sub heading to do what I wanted to do.  

Thanks Tad. 

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Wed, 15 Aug 2001 20:37:02 +0100
From: "Big Banana" <bigbanana@mailandnews.com>
Subject: How do I get a message back from the server?
Message-Id: <9lefk1$v52$1@newsg2.svr.pol.co.uk>

I'm writing an app. in Flash to send an email.
I want the server to send a message back to the caller saying, that the
command has been executed.
I'm using a small script I found that uses Blat.
I'm not very familar with CGI... but do know Perl fairly well.
Can someone give me the minimal code that I would need in order  to
communicate back...?

I'd really appreciate any help.

Thanks.


BB




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

Date: Wed, 15 Aug 2001 21:01:51 +0200
From: "Acacia" <acacia@online.no>
Subject: Re: How do I: Count characters between < > in a string?
Message-Id: <iGze7.2271$Y53.47972@news1.oke.nextra.no>

Whoa! Thanks a bunch! :)

"Peter Søgaard" <peter.sogaard@tjgroup.com> wrote in message
news:3b7a8d00$0$20948$edfadb0f@dspool01.news.tele.dk...
> > It's like this... I have a webpage and on the main page I want only
> > the first 200 characters of each news post. However, when I include
> > a HTML link (or any other <> tag) such as <a href="http://yadadaya">
> > amongst the first 200 characters, it outputs only 174 visible characters
> > (200 minus the given link code). How would I go about editing the
> following
> > code in order for this to work?
>
> Maybe you can use something along the lines of this - it's not completely
> foolproof( doesn't handle all tricky nested <'s and >'s ), but it's a step
> in the right direction :)
>
> $chars = 200;
> $position = 0;
> $flag = 0;
> $subPos = 0;
> foreach $char ( split(//,$newstext) ){
>   $subPos++;
>   if( $char eq "<" ) {$flag++;}
>   if( $flag == 0 ) {$position++;}
>   if( $char eq ">" && $flag > 0 ) {$flag--;}
>   if($position == $chars) {last;}
> }
> $shortsummary = substr($newstext,0,$subPos);
>
>




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

Date: Wed, 15 Aug 2001 14:04:50 -0400
From: Gary Fu <gfu@gscmail.gsfc.nasa.gov>
Subject: Re: How to send output to both a file and stdout
Message-Id: <3B7AB9C1.52D415AD@gscmail.gsfc.nasa.gov>

> Hi,
>
> Is there a simple way to use one print statement to send the output
> to both a file and the stdout ?
> TIA.
>
> Gary

I tried the following example and I got both stdout and stderr outputs
to the screen and to the file.  However, I think due to the pipe and
buffering
problems, the ouputs are not in the right order.  Any idea ?
Thanks.

Gary

#!/usr/local/bin/perl

use strict;

$| = 1;

open(STDOUT, "|tee  test_tee.dat") or die "no open";
open(STDERR, "|tee -a test_tee.dat") or die "no open err";

for (1..50) {
    print "stdout $_\n";
    warn  "stderr $_";
}
exit;





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

Date: Wed, 15 Aug 2001 19:59:52 GMT
From: John Porter <johndporter@yahoo.com>
Subject: Re: How to send output to both a file and stdout
Message-Id: <3B7AD3E8.D424D9EB@yahoo.com>

Gary Fu wrote:
> Is there a simple way to use one print statement to send the output
> to both a file and the stdout ?

perldoc Tie::Handle

-- 
John Porter


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

Date: Wed, 15 Aug 2001 14:30:18 -0400
From: "Asgar" <asgar@tkusa.com>
Subject: Ignoring The First Line
Message-Id: <3b7abe03$0$145@wodc7nh6.news.uu.net>

Folks,
I am manipulating a file of records, consisting of two dozens fileds.
How can I ignore the entire first line of the file, the header.  I am
openinig the file, do some work with one of the fields, saving it to another
file.
I have seen a one liner perl line doing it, but can't figure it out how to
do it in a file.
I would appreciate a little help.
(looked at FAQ and couldn't find this!)




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

Date: 15 Aug 2001 22:41:27 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Ignoring The First Line
Message-Id: <87lmkl4148.fsf@abra.ru>


A> Folks,
A> I am manipulating a file of records, consisting of two dozens fileds.
A> How can I ignore the entire first line of the file, the header.  I am
A> openinig the file, do some work with one of the fields, saving it to another
A> file.
A> I have seen a one liner perl line doing it, but can't figure it out how to
A> do it in a file.
A> I would appreciate a little help.
A> (looked at FAQ and couldn't find this!)

You code should look like:

open FILE, 'filename' or die "Can't open file: $!";
while(my $line = <FILE>) {
    next if $. < 2; # skips first line

    # process next line
    do_something($line);
}
close FILE;

See 'perldoc perlvar' for description of $.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Wed, 15 Aug 2001 14:09:46 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Ignoring The First Line
Message-Id: <slrn9nlena.2d4.tadmc@tadmc26.august.net>

Ilya Martynov <ilya@martynov.org> wrote:
>
>A> How can I ignore the entire first line of the file, the header. 


>A> I have seen a one liner perl line doing it, 
>A>but can't figure it out how to
>A> do it in a file.


But you aren't going to show it to us so that we could
translate it for you?

Why not?


>You code should look like:
>
>open FILE, 'filename' or die "Can't open file: $!";


<FILE>;   # read and discard first line


>while(my $line = <FILE>) {
>    next if $. < 2; # skips first line


No need for the next now.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 15 Aug 2001 20:12:56 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Ignoring The First Line
Message-Id: <3B7AD833.B29D41A2@acm.org>

Asgar wrote:
> 
> Folks,
> I am manipulating a file of records, consisting of two dozens fileds.
> How can I ignore the entire first line of the file, the header.  I am
> openinig the file, do some work with one of the fields, saving it to another
> file.
> I have seen a one liner perl line doing it, but can't figure it out how to
> do it in a file.
> I would appreciate a little help.
> (looked at FAQ and couldn't find this!)


#!/usr/bin/perl -w
use strict;

my @date = localtime;

open IN,  '< inputfile.txt'  or die "Cannot read from 'inputfile.txt':
$!";
open OUT, '> outputfile.txt' or die "Cannot write to 'outputfile.txt':
$!";

while ( <IN> ) {
    if ( m|^(\S+\s\S+\s\d\d/\d\d/)\d\d(\d\d\s\S+)$| ) {
        printf OUT "$1$2 %02d/%02d/%02d\n", $date[4] + 1, $date[3],
$date[5] % 100;
        }
    }

close OUT;
close IN;

__END__


John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 15 Aug 2001 22:03:18 GMT
From: plew@csus.edu (Paul Lew)
Subject: Re: Ignoring The First Line
Message-Id: <slrn9nlsfc.169.plew@crane.li-po.edu>

In article <87lmkl4148.fsf@abra.ru>, Ilya Martynov wrote:
> 
> A> Folks,
> A> I am manipulating a file of records, consisting of two dozens fileds.
> A> How can I ignore the entire first line of the file, the header.  I am
> A> openinig the file, do some work with one of the fields,
saving it to another
> A> file.
> A> I have seen a one liner perl line doing it, but can't figure it out how to
> A> do it in a file.
> A> I would appreciate a little help.
> A> (looked at FAQ and couldn't find this!)
> 
> You code should look like:
> 
> open FILE, 'filename' or die "Can't open file: $!";
> while(my $line = <FILE>) {
>     next if $. < 2; # skips first line
> 
>     # process next line
>     do_something($line);
> }
> close FILE;
> 
> See 'perldoc perlvar' for description of $.
> 
I've got the "reverse" problem in that my 1st line is ignored!!
As a beginner, I did a "quick & dirty" to remove the "\000" that
was passed into my resolv.conf; the "\000" is in ascii readable/printable
mode.  I have since did a shell script that just executes
"/usr/bin/perl -pe ......etc" which works but still wonder why my perl
script loosed the 1st line.  The code is as follows:
  =================================================================

#!/usr/bin/perl
#
#
# to remove the '\000' created by /sbin/dhclient-script
#  
#
print "running /usr/local/sbin/resolvchg................"
#
open (OLDFILE, "/etc/resolv.conf");
open (NEWFILE, ">/etc/resolv.conf.new");
while (<OLDFILE>)    {
      s/'\000'//; 
      print NEWFILE <OLDFILE>;
                     }
close OLDFILE;
close NEWFILE;
rename ('/etc/resolv.conf.new', '/etc/resolv.conf');
#












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

Date: Wed, 15 Aug 2001 13:06:32 -0500
From: Steve Postlewait <porter96@lycos.com>
Subject: Installing Gd-1.18 problems
Message-Id: <3B7ABA28.58CA0FB4@lycos.com>

This will probably be classified by some as a "off topic" question, and
if so ... please point me in the correct direction.

I'm trying to install the GD-1.18 graphics program on a Windows 2000
Advanced Server.  Since I'm tying to install a Perl module, I figured
that someone here will have had a similar problem.

The instructions say:

        a.  cd GD-1.18
        b.  perl Makefile.PL INSTALLDIRS=site \
                             INSTALLSITELIB=/home/fred/lib \
                             INSTALLSITEARCH=/home/fred/lib/arch
        c.  make
        d.  make install

A & B go fine.  When I get to C, I get "bad command or file name".  I
don't see a "make.exe", or any other "make" for that matter, on the
system.  Since ver 1.18 is pretty old, maybe there are modified
instructions for a Windows 2000 OS.

Thanks for any help.

Steve



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

Date: Wed, 15 Aug 2001 15:00:14 -0500
From: Jerry Preston <g-preston1@ti.com>
To: Steve Postlewait <porter96@lycos.com>
Subject: Re: Installing Gd-1.18 problems
Message-Id: <3B7AD4CE.B317DE43@ti.com>

Steve,

Have you looked at this page? 
http://www.boutell.com/gd/manual1.8.4.html

I have been trying to install this on a sun setup with little luck.

Jerry


Steve Postlewait wrote:
> 
> This will probably be classified by some as a "off topic" question, and
> if so ... please point me in the correct direction.
> 
> I'm trying to install the GD-1.18 graphics program on a Windows 2000
> Advanced Server.  Since I'm tying to install a Perl module, I figured
> that someone here will have had a similar problem.
> 
> The instructions say:
> 
>         a.  cd GD-1.18
>         b.  perl Makefile.PL INSTALLDIRS=site \
>                              INSTALLSITELIB=/home/fred/lib \
>                              INSTALLSITEARCH=/home/fred/lib/arch
>         c.  make
>         d.  make install
> 
> A & B go fine.  When I get to C, I get "bad command or file name".  I
> don't see a "make.exe", or any other "make" for that matter, on the
> system.  Since ver 1.18 is pretty old, maybe there are modified
> instructions for a Windows 2000 OS.
> 
> Thanks for any help.
> 
> Steve


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

Date: Wed, 15 Aug 2001 21:19:02 +0200
From: Philip Newton <pne-news-20010815@newton.digitalspace.net>
Subject: Re: Is $! a number or a string?
Message-Id: <fkilntgemeamkee0o16686ak4l5d41v91a@4ax.com>

On 15 Aug 2001 02:16:36 -0700, johnlin@chttl.com.tw (John Lin) wrote:

> Now my question is: Is $x the same kind of variable as $! ?

Sort of. It has both numeric and string slots filled. Initially, the
"string OK" flag is on but the public "number OK" flag is off. If you
use the variable in a numeric context -- even if you just say $x + 0 and
discard the value -- then the "number OK" flag gets turned on.

However, $x is not magic in the sense that $! is (it's a PVMG, but it
doesn't have any magic flags turned on).

> If yes, why #6: doesn't print a message string (like #3: does)?

Because it's not a dual-valued variable any more.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 15 Aug 2001 14:40:15 -0700
From: tmesbah@hotmail.com (T Mesbah)
Subject: Looking for Script
Message-Id: <6e9d9699.0108151340.4493cafd@posting.google.com>

Hi,

1) I have two Cisco router routerA and routerB.
2) In routerA I have static route "ip route X.X.X.X Y.Y.Y.Y Z.Z.Z.Z"
to access routerB.

I am looking for script that ping routerB each 5 minutes and if
routerB is down then the script need to telnet to routerA and remove
these static route.

Many Thanks


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

Date: 15 Aug 2001 12:18:38 -0700
From: adamone11@yahoo.com (Adamone11)
Subject: Math::Matica, Perl Modules in general
Message-Id: <2c1772aa.0108151118.57daf2a1@posting.google.com>

Hi, I'm attempting to interface a Win32 (ActivePerl) perl program with
Mathematica (4.0.2) so that I can calculate some hairy double
integrals, and I'm having some trouble either with perl modules or
with this particular one.

You see, I've been able to install and use Math::Polynomial and
Math::Interpolate just by copying the .pm to the lib directory.  I
would then use "use Math::Blah;" at the beginning to declare the
module.  Everything would work, I've used both of those math libraries
with no problems.  However, when I do either

use Math::Ematica;
-or-
use Math::ematica qw(:PACKET :TYPE :FUNC);

like it says in the documentation, under synopsis, it gives me the
error

Can't locate loadable object for module Math::ematica in @INC (@INC
contains: . C:\PERL\5.00502\lib/MSWin32-x86-object C:\PERL\5.00502\lib
C:\PERL\site\5.00502\lib/MSWin32-x86-object C:\PERL\site\5.00502\lib
C:\PERL\site\lib .) at ematicatest.pl line 1
BEGIN failed--compilation aborted at ematicatest.pl line 1.

Even though I have the pm in c:\perl\5.00502\lib\math.  I don't have a
c++/c compiler on this computer, and I've always ignored the
"Make/Make test/make install" because I don't even have a make.exe or
make.pl (I do have a makemaker.pm, I think).  Could someone please
help me?  To tell you the truth, I'm at my wits' end--my Perl for
Dummies book doesn't have anything on OOP past using already installed
modules.  Don't laugh! :)

I could get djgpp if I really needed to, but I'd rather not.  There's
so many references of people who "used" Math::ematica, but no one
gives any details!

Thanks alot,
Adam


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

Date: 15 Aug 2001 20:11:13 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Math::Matica, Perl Modules in general
Message-Id: <9lel11$fnk$1@canopus.cc.umanitoba.ca>

In comp.lang.perl.misc, Adamone11 <adamone11@yahoo.com> wrote:
> Hi, I'm attempting to interface a Win32 (ActivePerl) perl program with
> Mathematica (4.0.2) so that I can calculate some hairy double
> integrals, and I'm having some trouble either with perl modules or
> with this particular one.

> [ ... ] However, when I do either

> use Math::Ematica;
> -or-
> use Math::ematica qw(:PACKET :TYPE :FUNC);

> like it says in the documentation, under synopsis, it gives me the
> error

> Can't locate loadable object for module Math::ematica in @INC
[ ... ]

Math::ematica requires a C compiler to build, so you'd
either have to get one, or else find a ppm package
(ActiveState, at http://www.activestate.com/ppmpackages/, doesn't
appear to have it). 

If the integrals aren't too hairy, perhaps Math::Integral::Romberg 
would be able to handle them.

best regards,
randy kobes


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

Date: 15 Aug 2001 21:58:05 GMT
From: abigail@foad.org (Abigail)
Subject: Re: multiple striping of leading/trailing chars
Message-Id: <slrn9nls41.9sn.abigail@alexandra.xs4all.nl>

Tassos Chatzithomaoglou (achatz@forthnet.gr) wrote on MMCMV September
MCMXCIII in <URL:news:3B793C75.8CC37ACF@forthnet.gr>:
][ I'm using the following 6 lines in order to strip off the leading/trailing * or spaces
][ of a particular string:
][ 
][ $interface_descr =~ s/^\s+//;                           # erase leading spaces
][ $interface_descr =~ s/\s+$//;                           # erase trailing spaces
][ $interface_descr =~ s/^\*+//;                           # erase leading *
][ $interface_descr =~ s/\*+$//;                           # erase trailing *
][ $interface_descr =~ s/^\s+//;                           # erase leading spaces
][ $interface_descr =~ s/\s+$//;                           # erase trailing spaces
][ 
][ before : "  ******  testing ***       "
][ after  : "testing"
][ 
][ Is there a way i can do it faster?


What should "**  **  ** testing  **** " become? Your sequence makes it
"**  ** testing". Is that what you want?

If you want to remove all the leading whitespace/*'s, you should do:

    $interface_descr =~ s/^[\s*]+//;
    $interface_descr =~ s/[\s*]+$//;

the last line could, if $interface_descr is large and contains quite
some whitespace and/or asteriks, be optimized to:

    chop $interface_descr while $interface_descr =~ /[\s*]\z/;


If you want identical behaviour as your code, go for:

    $interface_descr =~ s/^\s*\**\s*//;
    $interface_descr =~ s/\s*\**\s*$//;


Abigail
-- 
perl -wle'print"Êõóô áîïôèåò Ðåòì Èáãëåò"^"\x80"x24'
#    A bee crawling in
#    a she-oak tree. The Queen near
#    the beach. Eshun sits.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1534
***************************************


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