[12198] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5798 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 26 22:07:24 1999

Date: Wed, 26 May 99 19:00:18 -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           Wed, 26 May 1999     Volume: 8 Number: 5798

Today's topics:
    Re: @INC  - Require Problem (David Efflandt)
        CGI::Announce <dkubilo@oxnardsd.org>
    Re: Help, I'll pay money for solution!!! (David Efflandt)
        installing module fails <hector29@icubed.com>
    Re: installing module fails (Alastair)
    Re: Perl compiler...If or when (Ilya Zakharevich)
    Re: Perl for beginners <cassell@mail.cor.epa.gov>
    Re: Permission denied (David Efflandt)
        RE: Programming Web Graphics with Perl and GNU Software <dsaff@tvisions.com>
        RE: Programming Web Graphics with Perl and GNU Software (Chris Davies)
        Sorting Problem <aef@pangea.ca>
    Re: Sorting Problem RABM@prodigy.net
    Re: system command to string (DATE) (Jim Britain)
        Trimming function...?? (Bhavesh Gosar)
    Re: Trimming function...?? <tchrist@mox.perl.com>
    Re: Trimming function...?? <emschwar@rmi.net>
    Re: Trimming function...?? (Bob Trieger)
    Re: Trimming function...?? (Larry Rosler)
        two backspaces georgee1631@my-deja.com
    Re: unexponentialize field from text file (Ilya Zakharevich)
        Use of parenthesis : General question <thierry.metoudi@francemel.com>
    Re: Use of parenthesis : General question <tchrist@mox.perl.com>
    Re: Use of parenthesis : General question zenin@bawdycaste.org
    Re: variables and arrays <cassell@mail.cor.epa.gov>
        writing binary stuff back to a browser, funky format <meatzio@norcov.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 27 May 1999 00:09:56 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: @INC  - Require Problem
Message-Id: <slrn7kp375.iu.efflandt@efflandt.xnet.com>

On Mon, 24 May 1999 22:33:26 GMT, Mike Hagstrom <mch@publinx.com> wrote:
>Hi folks - 
>
>I'm new to the group, and this is my first posting, so please bear with me.
>
>I'm attempting to port a UNIX Perl program for use on NT Server. The
>overall program contains a number of ".cgi" files which require the module
>"options.pm". One file, "start.cgi" This file and the other ".cgi" files
>all contain the following opening two lines
>
>unshift (@INC, ".");
>require (options); 

I think that is an old perl4 thing.  For perl5 instead of 'unshift' you
should say:

use lib '.';	# puts '.' in front of search path

However, there may be several problems with this on a webserver, since the
current directory may not be what you think it is (especially with SSI),
and is considered insecure.  You should use a full hard path (which may be
difficult to determine unless you write a simple test script to output the
current working directory from where you would normally call the script).

>Here's the issue: the files seem to run OK from a command prompt. However,
>if I attempt to call the ".cgi" files from an HTML page (e.g., 
> <FORM Method="POST" Action="http://www.mydomain.com/cgi-bin/start.cgi">
>
>I get the following error message:
>
>	"The specified CGI application misbehaved by not returning a complete set
>of HTTP headers. 
>The headers it did return are:
>Can't locate options.pm in @INC at
>C:\InetPub\wwwroot\sss\Hm\cgi-bin\start.cgi line 25."
>
>If I remove the first line completely, and change the second line to read
>  require 'options.pm'
>
> I still get the same error message, even though "@INC" has been removed.
>I can't seem to get around the @INC.
>
>Any ideas or suggestions?

Never been on NT, never want to be.
-- 
David Efflandt    efflandt@xnet.com
http://www.xnet.com/~efflandt/


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

Date: Wed, 26 May 1999 18:30:50 -0700
From: "Dan Kubilos" <dkubilo@oxnardsd.org>
Subject: CGI::Announce
Message-Id: <374ca2a8.0@news.vcss.k12.ca.us>

I am trying to locate
_________
CGI::Announce
This module maintains an "important announcements" page for your site. It
uses standard HTML files and a special place-holder so that new
announcements can be programmatically added.

listed under CGI at the perl language page.

URL listed is

http://olympia2.adhost.com/~maurice/

But the maintainer no longer has CGI::Announce available there.

Could anyone please tell me where this module is available?

Thank you.



--
Dan Kubilos, Technology Coordinator
Oxnard School District
805-487-3918  ext. 467
http://www.oxnardsd.org




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

Date: 27 May 1999 00:29:28 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Help, I'll pay money for solution!!!
Message-Id: <slrn7kp4bo.iu.efflandt@efflandt.xnet.com>

On Wed, 26 May 1999 21:14:10 GMT, Barr <barr@hancock.net> wrote:
>Sorry about being so long, but I think it's required.  Please read.
>
>History of problem:
>1. I have a cgi program that creates mail based on an html form. I made the
>message look like it comes from an email address filled out in the form.
>This cgi program uses my "hosters" sendmail program on his NT server.

Sorry to hear that (NT).  8-)
   
>2. The message includes a personal greeting which I must maintain (his/her
>name filled out in the form).
> 
>3. The message gets send to me.  This all works great.
>
>Requirement:
>1. I need to send it back to the address it came from (the address which
>came from the form) without changing the contents.
>
>2. I need to be able to set up a program to do this (to receive mail and
>send it back to the address it came from).
>
>Here's the catch:
>1. I need the requirement to work ONLY during specified hours of the day. I
>can turn it on and off at the appropriate time.
>
>OR HERE'S AN ALTERNATIVE...
>Make the server only send the mail during specified hours of the day. The
>form  must be available 24hrs everyday.
>
>Please help!!!

Does NT have something similar to the 'cron' that Unix systems have to run
programs at a specified time of day?  If so, it would be fairly easy to
use CGI.pm to store the data in a file and then use a cron job with CGI.pm
to read back the stored data and send it out at specified time(s).  If the
forms have any uploaded attachments, they could be handled with MIME::Lite
(Lite.pm).

-- 
David Efflandt    efflandt@xnet.com
http://www.xnet.com/~efflandt/


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

Date: Wed, 26 May 1999 19:38:12 -0400
From: LordHector <hector29@icubed.com>
Subject: installing module fails
Message-Id: <374C85E4.9D283E90@icubed.com>

Hi,

	I wanted to install some modules from CPAN. Seemed to work great until
the compile stage. The compile gives errors about not being able to find
stuff, and wont install without force. I can't seem to find any doc that
will tell you what is required.

	I have a regular install of perl 5.004_04 that came with linux and
seemed to work (perl -e 'print "Hello, Dork"\n'). I know how to use cpan
and indeed, installed some modules on a different machine just fine.
(Same distribution of Linux and perl -v).

	Has this happened to anyone else, am I just forgetting to set some
environment variables or what...Should I just reinstall perl?

Thanks for help!


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

Date: Thu, 27 May 1999 00:08:45 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: installing module fails
Message-Id: <slrn7kp6rj.5f.alastair@calliope.demon.co.uk>

LordHector <hector29@icubed.com> wrote:
>Hi,
>
>	I wanted to install some modules from CPAN. Seemed to work great until
>the compile stage. The compile gives errors about not being able to find
>stuff, and wont install without force. I can't seem to find any doc that
>will tell you what is required.

When a compile fails, it usually tells you what failed or gives some sort of
indication ('Cannot locate ...' or whatever). You should at least post the
relevant errors.


-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 27 May 1999 01:06:04 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl compiler...If or when
Message-Id: <7ii5ps$aim$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Eli the Bearded 
<*@qz.to>],
who wrote in article <eli$9905261732@qz.little-neck.ny.us>:
> The ActiveState installer for Windows95 crashed during the install
> for me. I wanted to run the test suite after that, but apparently it
> was not installed (grumble, MacPerl has it, so there is at least
> one binary distribution precedent). It passed 'Hello World' and it
> runs a socket program that was the reason I installed it. Not an
> install I've a lot of confidence in, however.

Would you like to spend an our or two of your time and write a CPAN
module which loads the tarball for the given version of Perl, extracts
the */t directory, and runs */t/harness?  [Be sure to *not* cd into *
or */t, since then @INC will be mutiliated.]

If you want example how to download a tarball from Makefile.PL, see
Math::Pari.  But you may also plug into CPAN.pm, which has 'get'
command already.  Hmm, maybe this is a better solution: write an
extension to CPAN.pm which calls CPAN's 'get', then calls harness.

Ilya


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

Date: Wed, 26 May 1999 17:26:38 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Lee & Helen <helee@globalnet.co.uk>
Subject: Re: Perl for beginners
Message-Id: <374C913E.482D61C9@mail.cor.epa.gov>

[courtesy cc sent to poster]

Lee & Helen wrote:
> 
> Hello all
> 
> Sorry to be a nuisence but does anyone know a good newsgroup or mailing
> list for beginners in Perl

This is a reasonable place to ask questions.  But be forewarned.
The teachers here expect you to do your homework first.  :-)
Since you (apparently) haven't munged your e-mail address, you
should get an e-mail from gnat (well, his bot, actually) telling
you about Perl resources and programming tips.  If you actually
follow the directions in that e-mail, you'll be in good shape,
assuming...
 
> I am just learning this wonderful but sometimes confusing language by book
> and would love for someone to answer my questions.

We can do that.  Particularly if you have code that doesn't
work as expected, and you want programming help or explanation.
Just please don't be learning Perl out of a book that has
the word 'Dummies' in the title.  If you go to
http://reference.perl.com/ 
you can find some book reviews, which admittedly are for
people with some scripting or programming experience.
 
> The problem is I ask too many questions so I need someone patient.

Well, if they're *good* questions, you'll find a lot of 
patient people here.  If they're questions to which you already
have the answers, you'll find some flamage.  

Do you know how to access the Perl FAQ?  Re-read gnat's
e-mail, and also you might want to try to go to this URL:
  http://www.perlmonth.com/articles//rtfm.html
to learn about all the docs Perl comes with, and how to
get at some good bits.

You might also be surprised at how extensive the docs are.
There's a wealth of Perl info at your fingertips.. assuming
you're sitting at your machine while you read this.  Try
this.. at your command prompt, type:
  perldoc perldoc
  perldoc perl

> Thanks in advance

You're welcome
 
> Id prefer you to email me with your comments as well as post them here

That's acceptable Usenet protocol.  However, it is considered
rude to ask only for e-mailed comments with no posting.
 
HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 27 May 1999 00:54:22 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Permission denied
Message-Id: <slrn7kp5qe.iu.efflandt@efflandt.xnet.com>

On Mon, 24 May 1999 21:46:08 -0400, Gary L. Carrington
<garycarrington@mindspring.com> wrote:
>I am haveing problems creating a file under a scratch directory.  I
>chmod the directory to 0666, changed the group ownership to nobody, and
>I still cannot create a file under the directory.  I get the error
>message stating Permission denied.  How would I correct this problem.

Not a perl question.  But the directory needs execute permission in order
to create a file in it (not sure why, but that is the way it is).  Try
0777 (you could try 0707 to see if that works).  The directory does not
need to be in group 'nobody', since 'nobody' is included in the last slot
'others'.

>--
>Gary L. Carrington
>garycarrington@mindspring.com
>919-598-6585
>
>


-- 
David Efflandt    efflandt@xnet.com
http://www.xnet.com/~efflandt/


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

Date: Wed, 26 May 1999 12:55:43 +0100 (Eas)
From: David Saff <dsaff@tvisions.com>
Subject: RE: Programming Web Graphics with Perl and GNU Software
Message-Id: <14155.57663.863000.466673@gargle.gargle.HOWL>


Jeremy Fowler writes:
 > http://www.as220.org/shawn/pwgexamples/10ex.htm

Looks like it's actually

      http://www.as220.org/shawn/pwgexamples/10ex.html

 > First off, if I leave the second line out of the countfile.txt

Don't do that.  Follow the interface specified.

To figure out better what's going on here, you can try inserting the
following before line 51 of the unmodified example script (right after
the comment "requisite referrer, send back an error"):

open TEST, '>test.txt' or die "can't open a new file";
print TEST "referrer: $referrer\n";
print TEST "script wants: http://$users\n";
close TEST

If this works, then the next time you run it, you should have created
a file called test.txt that will contain both the referrer, and the
URL that the script is comparing the referrer against.  This should
give you some clues.

 > "Segmentation Fault"

It's possible this is coming from GD.  Hopefully fixing the first
problem will solve the second.

Good luck,

     David Saff
     TVisions


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

Date: Wed, 26 May 1999 20:33 +0100 (BST)
From: news@roaima.demon.co.uk (Chris Davies)
Subject: RE: Programming Web Graphics with Perl and GNU Software
Message-Id: <memo.19990526203316.18109A@roaima.demon.co.uk>

In article <7iek4s$fl2$1@remarQ.com>, jeremy@microlink.net (Jeremy Fowler) 
wrote:
> The source can be found on the author's page here:
> 
> http://www.as220.org/shawn/pwgexamples/10ex.htm

Actually it's 10ex.html, but no matter.

Now you can all weep with me. This code claims to be "secure", yet it 
accepts 
an ARBITRARY filename for the counter file from the calling HTML. Oh 
goodie. 
How many people are running this code "as is"? Especially as it's trivial 
to 
fudge a Referer field anyway. Fun, fun, fun. Sigh. Whimper.

> First off, if I leave the second line out of the countfile.txt (allowed
> hosts), perl gives me this error:
> (If I run it at a command line: $ ./counter.pl countfile=countfile.txt
> style=default > output.txt)
> 
> "Use of uninitiated value at ./counter.pl line 69, <COUNT> chunk 1."
> "Use of uninitiated value at ./counter.pl line 73, <COUNT> chunk 1."
> "Use of uninitiated value at ./counter.pl line 88, <COUNT> chunk 1."
> "Segmentation Fault"

Doubly strange, because (a) in the tarball I've just downloaded, it's 
counter.cgi, and (b) on the lines you mention I've not got any assignments 
that could cause these errors. Perhaps you've an older version?

> If I try calling it from a html document all I get is a broken Image.

OK. Let's start with the following.

1. Replace the "-w" flag on the first line with "-T"  :-)

2. Change the assignment of $countfile (line 17) to be a hard-coded value. 
UNDER NO CIRCUMSTANCES should this assignment be from a field obtained 
from 
the user's form. Here's an example,

        my $countfile = '/tmp/countfile_for_JFowler';

3. Change the test for a referer (lines 51 et seq) to be this,

        unless ($referer eq '' or $referer =~ /http:\/\/($users)(.*)/) {
            exit $error->black_box('You do not have privileges' .
                        ' to access this counter.');
        }

Notice the new test for the referer being empty.

> However, I still get the segmentation fault if I run it from the command
> prompt.

I can't help with the segfault. Perhaps your GD libraries have been 
compiled 
for a different system...?


Regards,
Chris
-- 
FLARE Solutions Ltd, LEEDS, UK
Tel: 07970 987909  Email: <info@roaima.demon.co.uk>


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

Date: Wed, 26 May 1999 19:31:20 -0500
From: "AEF" <aef@pangea.ca>
Subject: Sorting Problem
Message-Id: <7ii3nj$edl$1@pumpkin.pangea.ca>

I have a wage survey script for pilot wages on my site (non-profit BTW, and
the scripting as a NON commercial venture, ie hobby for me).

I used reference hashes, and it just isn't cutting it for sorting (or my
level of knowledge for sorting at least.)

I am a relative newbie to Perl and programming in general, and have been at
this for about 8 months (and my total programming career!).

I've worked throught the O'Reilly books, Perl Cookbook, Adv. Prog Perl, etc,
but still need help on working with objects, which I think may be the way to
go.

The script has about a dozen Job Categories (Major, Charter, Connector)
airlines, etc.

Under those jobs are various Type Categories of aircraft that the each job
might fly (B747, B747, A320, etc) a list of about 50 possibilities, with
each Type having 3 possible positions (Captain, First Officer, Second O) .

So that is the hardest part of the sorting problem, because I have most of
the other ones like the various countries, years of service, year commercial
flying working ok, but really think that the script is far too bulky, and
probably could be sped up, and chopped down maybe with objects.

My immediate problem is to sort the Job Categories in order of the highest
paying job in the job category, print that as the table title, and a table
of the sorted types for that job_category in pay hierarchy sorted and the
positions, then the next.   The hash of
$bucks{$job_category}= $wages;
gives you the %job_category values for the \@seenjobs that can be referenced
for the $category{

So, I went at this two ways:

sub create_index {

my($job_category, $equip_type, $position, $wages) = @_;
#create an array for all of these
#use a reference
$rdata = [$job_category, $equip_type, $position, $wages];
push (@{$category_idx{$job_category}}, $rdata);
}

# or the next one

$bucks{$job_category} = $wages;
@sortjobs = sort { $bucks{$b} <=> $bucks{$a} } keys %bucks;

# but this sucks because you only get the last value
# the hash saw, an not necessarily the highest paid job_category.

$category{namelist} = \@sortjobs;

# could use the index
 # foreach $rdata (@{$category_index{$job_category}}){

# or the original way

 foreach $avjob (@{ $category{namelist} } ) {

 # the $avjob hash is created from the namelist, and references here.

  $category{$avjob} = \@$avjob;
  foreach $ref(@{ $category{$avjob} }) {
      ($ref, $plane, $seat, $money) = split (" ", $ref);
       $plane{$ref} = $plane;
       $seat{$ref} = $seat;
        $money{$ref} = $money;
   }

When I tried to dynamically create objects, I realized that I need MORE
information.  Please help. Thanks.
Jim.




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

Date: 26 May 1999 21:55:46 -0400
From: RABM@prodigy.net
Subject: Re: Sorting Problem
Message-Id: <u675fgtst.fsf@prodigy.net>

>>>>> "AEF" == AEF  <aef@pangea.ca> writes:

<-- snip -->
    AEF> The script has about a dozen Job Categories (Major, Charter, Connector)
    AEF> airlines, etc.

    AEF> Under those jobs are various Type Categories of aircraft that the each job
    AEF> might fly (B747, B747, A320, etc) a list of about 50 possibilities, with
    AEF> each Type having 3 possible positions (Captain, First Officer, Second O) .

    AEF> So that is the hardest part of the sorting problem, because I have most of
    AEF> the other ones like the various countries, years of service, year commercial
    AEF> flying working ok, but really think that the script is far too bulky, and
    AEF> probably could be sped up, and chopped down maybe with objects.

    AEF> My immediate problem is to sort the Job Categories in order of the highest
    AEF> paying job in the job category, print that as the table title, and a table
    AEF> of the sorted types for that job_category in pay hierarchy sorted and the
    AEF> positions, then the next.   The hash of
    AEF> $bucks{$job_category}= $wages;
    AEF> gives you the %job_category values for the \@seenjobs that can be referenced
    AEF> for the $category{

    AEF> So, I went at this two ways:

    AEF> sub create_index {

    AEF> my($job_category, $equip_type, $position, $wages) = @_;
    AEF> #create an array for all of these
    AEF> #use a reference
    AEF> $rdata = [$job_category, $equip_type, $position, $wages];
    AEF> push (@{$category_idx{$job_category}}, $rdata);
    AEF> }

Since $category_idx{$job_category} has the wages in it you can sort by it.
HTH

use strict;
use diagnostics; # for >= 5.004
while ( <DATA> ) {
    chomp;
    create_index(split /,/, $_);
}
my %category_idx;
sub create_index {
    my($job_category, $equip_type, $position, $wages) = @_;
    #create an array for all of these use a reference
    my $rdata = [$job_category, $equip_type, $position, $wages];
    push (@{$category_idx{"$job_category"}}, $rdata);
}
# sort by the job categories first
foreach my $k ( keys %category_idx ) {
    print $k, "\n";
    # now sort by the wages field
    foreach my $cat (sort { $a->[3] <=> $b->[3] }  @{$category_idx{$k}} ) {
	print "\t", map { "$cat->[$_]  " } 0,1,2,3;
	print "\n";
    }
}

__DATA__
Major,B747,Captain,12345
Charter,B757,First Officer,13452
Connector,A320,Second Officer,13425
Major,B747,First Officer,56789
Charter,B757,Captain,34567
Connector,A320,Second Officer,91234
Connector,B320,Captain,192134
Connector,C320,Captain,9234
Connector,D320,First Officer,1234
Connector,E320,Captain,912
Connector,F320,Captain,134
Connector,G320,Second Officer,134

-- 
Vinny


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

Date: Thu, 27 May 1999 00:26:01 GMT
From: jbritain@home.com (Jim Britain)
Subject: Re: system command to string (DATE)
Message-Id: <374c90b8.54742569@news>

[mailed and posted]
On Wed, 26 May 1999 19:36:40 GMT, "(BXTC)" <bxtc@forfree.at> wrote:

>To start let me tell you I am new to Perl.  This is what I need:
>	I need to get the date from my system (linux) and put the output into a
>string.

Try perldoc -f time
    perldoc -f localtime

for the builtin functions.


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

Date: 27 May 1999 00:13:21 GMT
From: gosar@bhavesh.ebay.sun.com (Bhavesh Gosar)
Subject: Trimming function...??
Message-Id: <7ii2n1$cno$2@ebaynews1.EBay.Sun.COM>

Hi,

Do we have a function in Perl to "trim" the
spaces before & after the data in a variable..

Thanks,
Bhavesh Gosar



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

Date: 26 May 1999 18:54:37 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Trimming function...??
Message-Id: <374c97cd@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    gosar@bhavesh.ebay.sun.com writes:
:Do we have a function in Perl to "trim" the
:spaces before & after the data in a variable..

No.  You have to use BASIC.  

Or you could just grep the standard documentation that comes with Perl,
which answers this question twice.

Sheesh.

--tom
-- 
  "Contempt, rather than celebration, is the proper response to 
   advertising and the system that makes it possible." --Neil Postman


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

Date: 26 May 1999 18:58:06 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Trimming function...??
Message-Id: <xkfd7znfhwh.fsf@valdemar.col.hp.com>

gosar@bhavesh.ebay.sun.com (Bhavesh Gosar) writes:
> Do we have a function in Perl to "trim" the
> spaces before & after the data in a variable..

No, but we do have a FAQ.

And we have DejaNews.

And we have people asking this VERY SAME QUESTION every two days, it
seems.

Perhaps you should follow the advice in news.newusers.questions and read
a newsgroup for a little while (it used to be a month or two, now you're
lucky to get a day or two) before posting?  And maybe even look up the
FAQ for the newsgroup before posting a Frequently Asked Question?
Especially when the FAQ is included on your hard disk with any modern
perl distribution?

Nah.  Too easy, I guess.

-=Eric


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

Date: Thu, 27 May 1999 01:27:04 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Trimming function...??
Message-Id: <7ii5f2$pbg$1@fir.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
gosar@bhavesh.ebay.sun.com wrote:
>Hi,
>
>Do we have a function in Perl to "trim" the
>spaces before & after the data in a variable..

This question is asked atleast a half-dozen times every week in c.l.p.m 
Please consult the FAQs or do a search on http://www.deja.com



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

Date: Wed, 26 May 1999 18:10:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Trimming function...??
Message-Id: <MPG.11b63b6b8cc0bfe9989b09@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7ii2n1$cno$2@ebaynews1.EBay.Sun.COM> on 27 May 1999 00:13:21 
GMT, Bhavesh Gosar <gosar@bhavesh.ebay.sun.com> says...
> Do we have a function in Perl to "trim" the
> spaces before & after the data in a variable..

How come everybody wants to do this and nobody can find the answer for 
themselves, so they Frequently Ask Questions here about it?

perlfaq4:  "How do I strip blank space from the beginning/end of a 
string?" 

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


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

Date: Thu, 27 May 1999 00:32:30 GMT
From: georgee1631@my-deja.com
Subject: two backspaces
Message-Id: <7ii3qu$lre$1@nnrp1.deja.com>

open(OUT, ">output");
print (OUT "delete the characters after this aa\b");

The above deletes the last "a", but

open(OUT, ">output");
print (OUT "delete the characters after this aa\b\b");

deletes one a and puts a ^H in its place. Can anyone help me on this.

Thanks

George.


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


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

Date: 27 May 1999 01:22:44 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: unexponentialize field from text file
Message-Id: <7ii6p4$b3c$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.11b6274e1829f2f9989b08@nntp.hpl.hp.com>:
> > I would really appreciate any help. I have a tab file with a field in
> > exponential form. I was wondering how I can convert this to a floating
> > point number in normal notation through regexp. thanks.
> > 
> > 0.20161E-01  to 0.020161
> > 0.49279E-02  to 0.004928
> 
> #!usr/bin/perl -w
> use strict;
> 
> while (<DATA>) {
>     s/((?:\d+(?:\.\d*)?|\.\d+)[Ee][+-]?\d+)/$1 + 0/eg;
>     print;
> }
> __END__
> 0.20161E-01 1e0 -.5e+1
> 0.49279E-02

Prints

	2.0161e-02 1 -5
	4.9279e-03

here.

Hope this helps,
Ilya


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

Date: Thu, 27 May 1999 02:11:52 +0200
From: Thierry METOUDI <thierry.metoudi@francemel.com>
Subject: Use of parenthesis : General question
Message-Id: <374C8DC8.9DF7F810@francemel.com>

Hello,
it's noticeable that Perl let us make up our own programming style, but
I would like to know if there were specific reasons when it comes to the
use of parenthesis, they seem so optionnal.
Maybe considerations of backward compatibility (unless it's a forward
one :-)
For instance what are the differences between:

open IN, $filename ;

    and

open (IN, $filename);

I know this may sound as a very simple question, but please answer only
if you have something serious to say about it.
Thanks





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

Date: 26 May 1999 18:50:43 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Use of parenthesis : General question
Message-Id: <374c96e3@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Thierry METOUDI <thierry.metoudi@francemel.com> writes:
:For instance what are the differences between:
:open IN, $filename ;
:    and
:open (IN, $filename);
:
:I know this may sound as a very simple question, but please answer only
:if you have something serious to say about it.

I don't know what "serious" would be.  

In the case you outline above, there is no difference.  With one notable
exception (eof), parentheses are neither required nor forbidden in
built-in function calls.  They are there for purposes of disambiguating
precedence conflicts.

Personally, I like to use them -- in most places.

--tom
-- 
If you take Fred Cohen's definition of virus, then Unix itself is
one of the most successful viruses ever written, since it tends to
result in the creation of modified versions of itself on other
computer systems!  -- Gene Spafford


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

Date: 27 May 1999 00:56:01 GMT
From: zenin@bawdycaste.org
Subject: Re: Use of parenthesis : General question
Message-Id: <927766717.759034@localhost>

Thierry METOUDI <thierry.metoudi@francemel.com> wrote:
: it's noticeable that Perl let us make up our own programming style, but I
: would like to know if there were specific reasons when it comes to the use
: of parenthesis, they seem so optionnal.

	Extraneous parenthesis tend to simply clutter code, making it harder
	to read.

: Maybe considerations of backward compatibility (unless it's a forward one
: :-) For instance what are the differences between:
: 
: open IN, $filename ;
:     and
: open (IN, $filename);

	Nothing, however you should consider the difference between:

	open IN, $filename || die "open: $!";
	    and
	open (IN, $filename) || die "open: $!";

	The first won't do what one probably wants because of precedence
	rules.  It is the idea of paren reduction that led to the low
	precedence versions of &&, ||, and friends:

	open IN, $filename or die "open: $!";

: I know this may sound as a very simple question, but please answer only if
: you have something serious to say about it. Thanks

	You do know you posted to USENET, right? :-)

-- 
-Zenin (zenin@archive.rhps.org)         Caffeine...for the mind.
                                        Pizza......for the body.
                                        Sushi......for the soul.
                                             -- User Friendly


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

Date: Wed, 26 May 1999 17:37:36 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: variables and arrays
Message-Id: <374C93D0.544CD20A@mail.cor.epa.gov>

Steven Fatine wrote:
> 
> --
> +------------------------------------+
> |                                    |
> |   Steven Fatine                    |
> |   sfatine@site.uottawa.ca          |
> |   Dept. of Electrical Engineering  |
> |  o__    o__    o__    o__    o__   |
> |  ,>/'_  ,>/'_  ,>/'_  ,>/'_  ,>/'_ |
> +-(_)\(_)(_)\(_)(_)\(_)(_)\(_)(_)\(_)+


I think that's a FAQ.
 
HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 26 May 1999 18:22:11 -0700
From: Mauricio Baiocchi <meatzio@norcov.com>
Subject: writing binary stuff back to a browser, funky format
Message-Id: <374C9E43.33CE583D@norcov.com>

attached is a format I've been trying to nail down with perl/cgi but
having done mostly ascii stuff in the past I need a pointer on where I'm
going wrong. Here's sortof where I've been heading with some cgi

binmode STDOUT;
$PAIR_X = "STATUS";
$PAIR_Y = "ERROR";
$sizeX = length $PAIR_X;
$sizeY = length $PAIR_Y;
$PACKAS = 'A2 A2 A16 A16';

print OUT pack($PACKAS , $sizeX, $sizeY, $PAIR_X, $PAIR_Y);

but I'm not sure if this is how you feed binary stuff back to the
browser or if appeases the format below. I throw myself at the mercy of
perl masters.

Here's the format
 
>>content type:application/x-netscape-autoconfigure-dialer
When Navigator sees this MIME type, it expects data in the format
described below. The binary file format used by this MIME type is
simple, yet extensible. It
consists of consecutive name/value pairs separated by 2 bytes of size
information: 

| 2 bytes | ------ x bytes ------ | 2 bytes | ------ y bytes ------ | 
(x)              (name)            (y)             (value)

The parser iterates as follows until it reaches the end of the stream:

     Read 2 bytes of binary data and cast to int for size of Name in
bytes (x) 
     Read (x) bytes of ASCII data for the name 
     Read 2 bytes of binary data and cast to int for size of Value in
bytes (y) 
     Read (y) bytes of ASCII data for the value


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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