[17654] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5074 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 10 00:07:26 2000

Date: Sat, 9 Dec 2000 21:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976424709-v9-i5074@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 9 Dec 2000     Volume: 9 Number: 5074

Today's topics:
    Re: Anywhere to put my scripts? <harrisr@bignet.net>
        ascii -> unicode file <dwl@slip.net>
        CGI.pm and uploadInfo() <g.soper@soundhouse.co.uk>
    Re: CHMOD (David Efflandt)
    Re: CHMOD (Martien Verbruggen)
    Re: compiling scripts with Active State perl <carvdawg@patriot.net>
    Re: compiling scripts with Active State perl <zarathustra@enviroweb.org>
    Re: Console use of Ruby/Perl compared to REBOL <jeffp@crusoe.net>
    Re: HELP PLEASE! (Craig Berry)
        How do ya read a cookie? (Loans2001)
    Re: How do ya read a cookie? <iltzu@sci.invalid>
    Re: How do ya read a cookie? <jmsystems1@home.com>
    Re: Image::Magick docs <ron@savage.net.au>
    Re: Image::Magick docs (Martien Verbruggen)
        Images and Flash movie   NOT displaying <athar@look.ca>
    Re: Images and Flash movie   NOT displaying <jmsystems1@home.com>
        inflation failed using Compress::Zlib andre_sanchez@my-deja.com
    Re: Lured by JSP. Limited study time. Need guru to argu (Logan Shaw)
        MakeMaker question <starfire@zipcon.net>
        Module install problem under Tru64 yongli01@my-deja.com
        need help with split <jmourney@hotmail.com>
    Re: need help with split <carvdawg@patriot.net>
    Re: need help with split <wyzelli@yahoo.com>
    Re: need help with split <krahnj@acm.org>
    Re: Perl and DOS windows <zarathustra@enviroweb.org>
    Re: problem with script <iltzu@sci.invalid>
    Re: problem with script (Garry Williams)
    Re: problem with script <iltzu@sci.invalid>
        Trouble making use of 'eval' to prevent fatal division  <tailor@u.washington.edu>
    Re: Uploading file via CGI <g.soper@soundhouse.co.uk>
        Why doesn't this work?????  (Location: redirection....) me
    Re: Why doesn't this work?????  (Location: redirection. (David Efflandt)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 9 Dec 2000 20:29:39 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Anywhere to put my scripts?
Message-Id: <t35n2vctcaqg13@corp.supernews.com>

> Does anyone know of a good place to put my scripts?
>
> Well guys, I kind of meant a whole new server
>

Frankly, I don't think anyone here has a clue as to what you are asking.
What's wrong with where you are putting your scripts now?




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

Date: Sun, 10 Dec 2000 01:00:37 -0000
From: David Lee <dwl@slip.net>
Subject: ascii -> unicode file
Message-Id: <t35ldlngajai93@corp.supernews.com>

Hi,

Some questions:

1) Is perl v5.006 available for Win32 systems? Pre-built version?

2) Are the unicode modules from CPAN buildable on Win32 systems?

3) Is there a hack I can do in perl 5.004 to read an ascii file
and save it as a unicode file or convert an ascii file 
to unicode? 

Thanks
David

Please reply to DWL@slip.net





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

Date: Sun, 10 Dec 2000 00:23:49 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: CGI.pm and uploadInfo()
Message-Id: <4a2a718663g.soper@soundhouse.co.uk>

Using the CGI.pm module I can call uploadInfo() which will return 'a
reference to an associative array containing all the document headers.' I
want to access the 'Content-Type' value.

I thought I could do:
   %upload_info = uploadInfo($upload_name);
   $type = $upload_info{'Content-Type'};

But this doesn't seem to work. I'm guessing this is because of my lack of
understanding of references. Could somebody explain where I've gone wrong
and how I should go about this?

Many thanks

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Sun, 10 Dec 2000 03:37:29 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: CHMOD
Message-Id: <slrn935uj1.4q7.efflandt@efflandt.xnet.com>

On 09 Dec 2000 23:01:15 GMT, Fryar386 <fryar386@aol.com> wrote:
>What CHMODE should I have to write files to a directory?  And could someone
>please give me a list of all the CHMODES  I always forget them

I assume you are asking this because you do not have shell access to a
Unix system to read 'man chmod'.

If the script is running as you, you really only need 0700 permission, but
if you want somebody else to be able to read files from a directory you
would typically set it at 0755 (usually the default).

If you are talking about CGI (subject for another newsgroup), you have to 
figure out who CGI is running as, you or a common other user.

The numbers are additive for user, group and other:

4 read
2 write
1 execute (or search for directory)

For a directory you typically need 5 to read or list a dir (4+1) or 7 to
read, write and list (4+2+1).

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sun, 10 Dec 2000 15:40:50 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: CHMOD
Message-Id: <slrn9362ai.20m.mgjv@martien.heliotrope.home>

On 09 Dec 2000 23:01:15 GMT,
	Fryar386 <fryar386@aol.com> wrote:
> What CHMODE should I have to write files to a directory?  And could someone
> please give me a list of all the CHMODES  I always forget them

It's chmod. Not CHMODE

Many manual pages for Unix commands of various origins and vendors are
available on the Internet. One place you can find links is:

http://www.freebsd.org/docs.html#man

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | life ain't fair, but the root
Commercial Dynamics Pty. Ltd.   | password helps. -- BOFH
NSW, Australia                  | 


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

Date: Sat, 09 Dec 2000 19:17:23 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: compiling scripts with Active State perl
Message-Id: <3A32CB93.13C3A809@patriot.net>



> Which solutions would these be then?

ActiveState provides one in their PDK, but I prefer Perl2Exe...



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

Date: Sun, 10 Dec 2000 01:51:42 GMT
From: "Zarathustra" <zarathustra@enviroweb.org>
Subject: Re: compiling scripts with Active State perl
Message-Id: <OkBY5.53805$II2.4887260@newsread2.prod.itd.earthlink.net>

> Which solutions would these be then?

Get the trial copy of ActiveState's PDK and look at PerlApp.





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

Date: Sat, 9 Dec 2000 18:24:08 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Console use of Ruby/Perl compared to REBOL
Message-Id: <Pine.GSO.4.21.0012091812520.9725-100000@crusoe.crusoe.net>

[posted & mailed]

On Dec 9, Terrence Brannon said:

>But, still, the Perl/Ruby code will never be intuitive to the non-technical
>architect. And so we have computer application architects unable to
>actually implement the top-level design of large complex systems
>because they find the non-english nature of Ruby and Perl
>unintuitive. Either that or the implementation is as non-English-like
>as the things above.

Perhaps, then, you'd be happier with a language like OmniMark
(http://www.omnimark.com/) which touts itself as "the language to use
instead of Perl".

>1- Whitespace is a natural separator of items. At least some items,
>commas are better for separating list items. However, REBOL opts for
>blocks over commas. Example:
>apples: [ powerbook ibook mac-classic ]
>mac-classic: [ age: 20 weight: 20]
>ibook [age: 1 weight: 1]
>
>print mac-classic/age

This is very confusing -- why does REBOL use / as the member-to-data
operator?  If you want an english-looking method (which I find difficult
for non-English-speaking people to like), perhaps REBOL should do

  print mac-classic's age

where the 's postfix operator signifies the next term is going to be an
attribute/key/whatever.  It even allows for cascading.

  mac: [ dimension: [ height: 10 width: 12 ] weight: 14 ]
  print mac's dimension's height

Just a thought.  But now it looks like you're programming in English.

And that / is now apparently quite overloaded.  It does division, too,
doesn't it?  I dunno.  Something doesn't vibe with me.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com    http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource  (my id:  PINYAN)       http://search.cpan.org/
PerlMonks - An Online Perl Community          http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc.   http://www.perlarchive.com/



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

Date: Sun, 10 Dec 2000 03:39:24 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: HELP PLEASE!
Message-Id: <t35uncqbgtaf8@corp.supernews.com>

Fryar386 (fryar386@aol.com) wrote:
: >Take peek at 'perldoc perlre' and see if it would be easier to come up
: >with a regular expression listing "all the symbols like that" (whatever
: >'that' might be, since I don't see a pattern), or an expression that just
: >retains what you want to keep
: 
: I want to make people have their own file when the sign up.  But it gives me an
: error when I try to create a file with the _ @ ! # $ % ^ & * ( ) = +, so I
: wanted to know how to take those out 

The easiest way to strip individual characters from a string is with
tr///, like this:

  $filename =~ tr/_@!#$%^&*()=+//d;

But you'll always have the problem of trying to enumerate all the illegal
characters.  Better would be to figure out what's legal, and remove
anything *not* in that set:

  $filename =~ tr/A-Za-z0-9-//cd;

Obviously, substitute whatever your own list of legal characters is.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


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

Date: 10 Dec 2000 00:59:42 GMT
From: loans2001@aol.com (Loans2001)
Subject: How do ya read a cookie?
Message-Id: <20001209195942.15149.00001554@ng-mj1.aol.com>

I have an affiliate program that places a cookie in someones browser to help
identify that person when they return to the website.  If they originally heard
of the site from the affiliate, and they decided to bookmark us for later after
clicking thorugh to us, when they come back later, I need to be able to
identify them by reading the cookie in the browser which was supposed to store
the affiliate referring them.

Is this a simple procedure to do in perl?

Scot King
mortgage-pros.com


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

Date: 10 Dec 2000 03:01:48 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: How do ya read a cookie?
Message-Id: <976416540.19243@itz.pp.sci.fi>

In article <20001209195942.15149.00001554@ng-mj1.aol.com>, Loans2001 wrote:
>I have an affiliate program that places a cookie in someones browser to help
>identify that person when they return to the website.  If they originally heard
>of the site from the affiliate, and they decided to bookmark us for later after
>clicking thorugh to us, when they come back later, I need to be able to
>identify them by reading the cookie in the browser which was supposed to store
>the affiliate referring them.
>
>Is this a simple procedure to do in perl?

Yes, fairly simple.  People do occasionally post here because they
have problems with it, so it can't be quite idiot proof.  The good
thing about it is that you can search for those earlier threads to
find out what kind of answers they got.

You'll probably want to use CGI.pm, which comes with perl.  It has
fairly good documentation available simply by typing "perldoc CGI"
at the command line on a system with perl installed.  Look for the
heading "HTTP COOKIES".

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm




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

Date: Sun, 10 Dec 2000 04:46:24 GMT
From: "JMS" <jmsystems1@home.com>
Subject: Re: How do ya read a cookie?
Message-Id: <AUDY5.87292$P82.9515247@news1.rdc1.ct.home.com>


This should work...

$cookie_path = "/path/to/script/cgi-bin";
$Affiliate   = "$FORM{'Affiliate'}";
$AF = "AF";

if ($Affiliate ne "")
 {
 print "Set-Cookie: $AF=$Affiliate; path=$cookie_path;\n";
 print "Content-type: text/html \n\n";
} else {
 print "Content-type: text/html \n\n";
}




Loans2001 <loans2001@aol.com> wrote in message
news:20001209195942.15149.00001554@ng-mj1.aol.com...
> I have an affiliate program that places a cookie in someones browser to
help
> identify that person when they return to the website.  If they originally
heard
> of the site from the affiliate, and they decided to bookmark us for later
after
> clicking thorugh to us, when they come back later, I need to be able to
> identify them by reading the cookie in the browser which was supposed to
store
> the affiliate referring them.
>
> Is this a simple procedure to do in perl?
>
> Scot King
> mortgage-pros.com




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

Date: Sun, 10 Dec 2000 15:32:15 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Image::Magick docs
Message-Id: <6PCY5.5994$Vu1.129742@ozemail.com.au>

ImageMagick has a new home. Hit
http://www.simplesystems.org/ImageMagick/www/perl.html

--
Cheers
Ron  Savage
ron@savage.net.au
http://savage.net.au/index.html

Jordan Hiller <jhiller@online-testing.net> wrote in message
news:3A328336.1F50939B@online-testing.net...
[snip]




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

Date: Sun, 10 Dec 2000 14:51:19 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Image::Magick docs
Message-Id: <slrn935vdn.20m.mgjv@martien.heliotrope.home>

On Sat, 09 Dec 2000 19:06:18 GMT,
	Jordan Hiller <jhiller@online-testing.net> wrote:
> Hi,
> I'm trying to use Image::Magick to simply check an image's size, resize
> it, and save it as a different image. It would be nice if I could find
> some documentation...the perldoc docs contain basically no information
> and the web page help does not work
> (http://www.wizards.dupont.com/cristy/www/perl.html). Can someone help

http://www.imagemagick.org/
http://www.imagemagick.org/www/perl.html

You're looking for the Resize, Scale, Sample, Transform, Minify or
Maxify methods.

Martien
-- 
Martien Verbruggen              | My friend has a baby. I'm writing
Interactive Media Division      | down all the noises the baby makes so
Commercial Dynamics Pty. Ltd.   | later I can ask him what he meant -
NSW, Australia                  | Steven Wright


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

Date: Sun, 10 Dec 2000 04:17:08 GMT
From: "ATHAR IQBAL" <athar@look.ca>
Subject: Images and Flash movie   NOT displaying
Message-Id: <8tDY5.10693$7.419812@quark.idirect.com>

As a novice , I am using a perl script for login and password . When the
User logs in, the page called by script DOES NOT display any image or Flash
Contents. The content types are set to"text/html" in the script.

Could anybody  please advise me how this can be corrected ? I will be highly
obliged.

Thanks

Iqbal




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

Date: Sun, 10 Dec 2000 04:39:36 GMT
From: "JMS" <jmsystems1@home.com>
Subject: Re: Images and Flash movie   NOT displaying
Message-Id: <cODY5.87291$P82.9514733@news1.rdc1.ct.home.com>

Sounds like your cgi-bin folder doesn't allow images to be displayed.

Try referencing them from another directory.

Hope this helps.


ATHAR IQBAL <athar@look.ca> wrote in message
news:8tDY5.10693$7.419812@quark.idirect.com...
> As a novice , I am using a perl script for login and password . When the
> User logs in, the page called by script DOES NOT display any image or
Flash
> Contents. The content types are set to"text/html" in the script.
>
> Could anybody  please advise me how this can be corrected ? I will be
highly
> obliged.
>
> Thanks
>
> Iqbal
>
>




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

Date: Sat, 09 Dec 2000 22:58:14 GMT
From: andre_sanchez@my-deja.com
Subject: inflation failed using Compress::Zlib
Message-Id: <90ude4$71a$1@nnrp1.deja.com>

I am compressing a file on a windows machine and uncompressing it on a
Linux machine using Compress::Zlib. See code below. The uncompressing
is failing:

inflation failed
status = 0  at uncomp.pl line 19.

Any hints on isolating the cause of the problem would be appreciated.

Thanks.

--Andre Sanchez

# -------------- Deflate Script --------------------------

#!/usr/bin/perl -w

use strict;
use Compress::Zlib;
my $file = 'inload.csv';
my $small = 'small.z';
open(BIG, "<$file") or die "$_";
open(SMALL, ">$small") or die "$_";
binmode BIG;
binmode SMALL;
my $x = deflateInit()
    or die "Cannot create a deflation stream\n" ;
my ($output, $status);
while (<BIG>){
    ($output, $status) = $x->deflate($_) ;
    $status == Z_OK
	or die "deflation failed\n" ;
    print SMALL $output ;
}
($output, $status) = $x->flush() ;
$status == Z_OK
    or die "deflation failed\n" ;
close BIG;
close SMALL;
exit 0;

# -------------- Inflate Script --------------------------

#!/usr/bin/perl -w

use strict;
use Compress::Zlib;
my $file = 'compact.txt';
my $small = 'small.z';
open(BIG, ">$file") or die "$_";
open(SMALL, "<$small") or die "$_";
my ($x, $input, $output, $status);
$x = inflateInit()
    or die "Cannot create a inflation stream\n" ;
$input = '' ;
while (read(SMALL, $input, 4096)){
    ($output, $status) = $x->inflate(\$input) ;
    print BIG $output
	if $status == Z_OK or $status == Z_STREAM_END ;
    last if $status != Z_OK ;
}
die "inflation failed\nstatus = $status " unless $status ==
Z_STREAM_END ;
close BIG;
close SMALL;
exit 0;


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


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

Date: 9 Dec 2000 17:18:35 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Lured by JSP. Limited study time. Need guru to argue Perl's advantages
Message-Id: <90uekb$hmh$1@boomer.cs.utexas.edu>

In article <90u8ji$cvk$1@newsg2.svr.pol.co.uk>,
Garry Heaton <garry@heaton6.freeserve.co.uk> wrote:
> I am faced
>with the difficult choice of maybe dropping my Perl studies simply because
>everywhere I hear about the advantages of the Java/JSP approach
>(scalability, server resources, servlet advantages etc.) Haven't heard much
>in defence of Perl's advantages over Java. Is there a Perl guru out there
>who can put a good case for choosing Perl over the new JSP technology?

Basically, the way I perceive the situation is that JSP contains some
technology that Perl doesn't, and this can potentially make it more
scalable.  Perl, on the other hand, is more mature than Java at this
particular time, probably because it has been around longer.

Those are both factors relating to the performance of the system.
There are also factors that relate to the performance of the
developers.  I think it's reasonable to argue that a strong developer
can solve a problem in Perl faster than in Java.  On the other hand,
there is at least a perception that a Java developer is easier to find
than a Perl developer.

To complicate things a little bit, Perl has the option (for web
servers) of mod_perl, which makes things more efficient but also makes
them more difficult and time-consuming to develop.  Which means that
when you add mod_perl into the mix, Perl as a server side web tool
becomes alot like what I've characterized Java as.  :-)

  - Logan


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

Date: 9 Dec 2000 16:26:28 -0800
From: starfire <starfire@zipcon.net>
Subject: MakeMaker question
Message-Id: <976407744.372367@news.zipcon.net>

I am preparing a module for CPAN release.  There is a subdirectory tree 
that should be copied recursively to /usr/local/etc when "make install" 
is typed.  I assume that I should write a perl script that does the
copy, but I don't see anything in the ExtUtils::MakeMaker man page that
lets me indicate that this script should be run during "make install".
The PL_FILES attribute looks promising, but I don't think this does 
what I need.

How can I do this?

Richard.Anderson@unixscripts.com


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

Date: Sat, 09 Dec 2000 23:46:46 GMT
From: yongli01@my-deja.com
Subject: Module install problem under Tru64
Message-Id: <90ug96$8sc$1@nnrp1.deja.com>

Hi, all,

I tried to install Data-Dumper-2.101 on a machine (Tru64 Unix version
5.0). The Perl is version 5.004. I use the following command:

perl Makefile.PL PREFIX=/vol/local
make
make test
make install

The first three commands ran successfully. But I got the following
message when I run 'make install':

Writing
/vol/local/lib/perl5/site_perl/alpha-dec_osf/auto/Data/Dumper/.packlist
sh: /vol/local/lib/perl5/alpha-dec_osf/5.00404/perllocal.pod: cannot
create
*** Exit 1
Stop.

Any suggestions? Thanks in advance.

Yong Li


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


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

Date: Sat, 09 Dec 2000 23:34:23 GMT
From: Joe <jmourney@hotmail.com>
Subject: need help with split
Message-Id: <90ufi0$8d4$1@nnrp1.deja.com>

i need to convert raw data from flat text file.
each records have the same number of fields, but
the problem is that:
1) the fields do not align at the same columns
2) there is no separator between fields (well,
   kind of, but the separator is one or more
   spaces)

here's an example of the raw data:
MVCD01      Qa1.B75        1,2,3,4    FRE   Au Revoir les Enfants
MVCD02    Ha4.B32        1,*,2,3    GRK Euripides Medea

what i have so far to extract these data is:
  @fields=split(/\s+\b/,$record);
  $id=shift(@fields);
  $callnum=shift(@fields);
  $copies=shift(@fields);
  $lang=shift(@fields);
  $title="@fields";

but i discovered that occasionally there are records like this:
MVCD03    Pn3.B77       *,2,3    GER     Faust 1 Teil

one field starts with '*' and the expression i used to split in the
above does not work properly anymore.

i tried many ways but can't get a solution. any help would be much
appreciated. thank's in advance.

-joe


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


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

Date: Sat, 09 Dec 2000 19:19:42 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: need help with split
Message-Id: <3A32CC1D.E3EC920B@patriot.net>

How well does this work for you?

my @fields = split(/\s+/,$record,5);

Joe wrote:

> i need to convert raw data from flat text file.
> each records have the same number of fields, but
> the problem is that:
> 1) the fields do not align at the same columns
> 2) there is no separator between fields (well,
>    kind of, but the separator is one or more
>    spaces)
>
> here's an example of the raw data:
> MVCD01      Qa1.B75        1,2,3,4    FRE   Au Revoir les Enfants
> MVCD02    Ha4.B32        1,*,2,3    GRK Euripides Medea
>
> what i have so far to extract these data is:
>   @fields=split(/\s+\b/,$record);
>   $id=shift(@fields);
>   $callnum=shift(@fields);
>   $copies=shift(@fields);
>   $lang=shift(@fields);
>   $title="@fields";
>
> but i discovered that occasionally there are records like this:
> MVCD03    Pn3.B77       *,2,3    GER     Faust 1 Teil
>
> one field starts with '*' and the expression i used to split in the
> above does not work properly anymore.
>
> i tried many ways but can't get a solution. any help would be much
> appreciated. thank's in advance.
>
> -joe
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Sun, 10 Dec 2000 10:48:15 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: need help with split
Message-Id: <MRAY5.3$od.1746@vic.nntp.telstra.net>

"Joe" <jmourney@hotmail.com> wrote in message
news:90ufi0$8d4$1@nnrp1.deja.com...
> i need to convert raw data from flat text file.
> each records have the same number of fields, but
> the problem is that:
> 1) the fields do not align at the same columns
> 2) there is no separator between fields (well,
>    kind of, but the separator is one or more
>    spaces)
>
> here's an example of the raw data:
> MVCD01      Qa1.B75        1,2,3,4    FRE   Au Revoir les Enfants
> MVCD02    Ha4.B32        1,*,2,3    GRK Euripides Medea
>
> what i have so far to extract these data is:
>   @fields=split(/\s+\b/,$record);
>   $id=shift(@fields);
>   $callnum=shift(@fields);
>   $copies=shift(@fields);
>   $lang=shift(@fields);
>   $title="@fields";
>
> but i discovered that occasionally there are records like this:
> MVCD03    Pn3.B77       *,2,3    GER     Faust 1 Teil
>
> one field starts with '*' and the expression i used to split in the
> above does not work properly anymore.
>

Couple of pointers:
split returns a list, so you can assign it to a list directly and skip the
@fields assignment if you wish (see below).

The \b is what is breaking your code, since the * is not a word boundary.
If you remove the \b it works fine since any number letter or * is still not
whitespace.

The default argument to split is to split on whitespace with the $_ variable
so you couls also write it like this:

while (<DATA>){
 ($id, $callnum, $copies, $lang, $title) = split;
 print "$id\n$callnum\n$copies\n$lang\n$title\n";
}

__END__
MVCD01 Qa1.B75 1,2,3,4 FRE Au Revoir les Enfants
MVCD02 Ha4.B32 1,*,2,3 GRK Euripides Medea
MVCD03 Pn3.B77 *,2,3 GER Faust 1 Teil

However, it may still be better to be explicit about what you are doing (so
when you come back in six months you know what is going on) so

($id, $callnum, $copies, $lang, $title) = split /\s+/,$record;

Is what I would probably recommend.

Naturally if you need @fields elswhere, then I would do:

@fields = split /\s+/,$record;
($id, $callnum, $copies, $lang, $title) = @fields;

Naturally all those variables have been scoped with 'my' and you are running
with -w and strict.

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: Sun, 10 Dec 2000 01:24:24 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: need help with split
Message-Id: <3A32DBB0.2F06D94C@acm.org>

Joe wrote:
> 
> i need to convert raw data from flat text file.
> each records have the same number of fields, but
> the problem is that:
> 1) the fields do not align at the same columns
> 2) there is no separator between fields (well,
>    kind of, but the separator is one or more
>    spaces)
> 
> here's an example of the raw data:
> MVCD01      Qa1.B75        1,2,3,4    FRE   Au Revoir les Enfants
> MVCD02    Ha4.B32        1,*,2,3    GRK Euripides Medea
> 
> what i have so far to extract these data is:
>   @fields=split(/\s+\b/,$record);
>   $id=shift(@fields);
>   $callnum=shift(@fields);
>   $copies=shift(@fields);
>   $lang=shift(@fields);
>   $title="@fields";
> 
> but i discovered that occasionally there are records like this:
> MVCD03    Pn3.B77       *,2,3    GER     Faust 1 Teil
> 
> one field starts with '*' and the expression i used to split in the
> above does not work properly anymore.
> 
> i tried many ways but can't get a solution. any help would be much
> appreciated. thank's in advance.

( $id, $callnum, $copies, $lang, $title ) = split ' ', $record, 5;

John


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

Date: Sun, 10 Dec 2000 02:31:04 GMT
From: "Zarathustra" <zarathustra@enviroweb.org>
Subject: Re: Perl and DOS windows
Message-Id: <IVBY5.53887$II2.4896521@newsread2.prod.itd.earthlink.net>


"Graham Knight" <graham@purplemtn.com> wrote in message
news:3A310E99.C283C749@purplemtn.com...
> Does anyone know of a way to run the program so that it does not pop
> up a DOS window every time it runs? If it popped up the window in a
> minimized state that would be great too[...]

Call your script from a .bat file and have the scheduler call the .bat file.
Set the Run property of the .bat file to "Minimized".  You could also select
the "Close on exit" option so the minimized window would vanish after the
script completed.




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

Date: 10 Dec 2000 00:18:36 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: problem with script
Message-Id: <976407031.2011@itz.pp.sci.fi>

In article <20001209174215.02444.00003022@ng-fb1.aol.com>, Fryar386 wrote:
>
>Bareword "e" not allowed while "strict subs" in use at joinform.cgi line 95.
>Unquoted string "e" may clash with future reserved word at joinform.cgi line 95.
>Execution of joinform.cgi aborted due to compilation errors.
>
 [snip]
>
>I don't quite know what line is line 95 (sorry, I'm a newbie, and I'm 9), but
>I've found the general location.  SO could somebody tell me what the error
>means and how I can fix it?

I don't think line 95 is any of the lines you quoted.  For one thing,
none of them have an "e" except as a part of a longer word.

What editor do you use?  There are plenty of good text editors around
that can show you line numbers.  Some can even highlight Perl syntax
for you, take care of indentation automatically and so on.  Myself, I
use emacs, which I suppose can be a bit daunting to a beginner, but it
_is_ a really good editor (and just about everything else too).

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



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

Date: Sun, 10 Dec 2000 00:42:02 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: problem with script
Message-Id: <ujAY5.289$uF3.22992@eagle.america.net>

On 10 Dec 2000 00:18:36 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
>In article <20001209174215.02444.00003022@ng-fb1.aol.com>, Fryar386 wrote:
>>
>>Bareword "e" not allowed while "strict subs" in use at joinform.cgi line 95.
>>Unquoted string "e" may clash with future reserved word at joinform.cgi line 95.
>>Execution of joinform.cgi aborted due to compilation errors.
>>
> [snip]
>>
>>I don't quite know what line is line 95 (sorry, I'm a newbie, and I'm 9), but
>>I've found the general location.  SO could somebody tell me what the error
>>means and how I can fix it?
>
>I don't think line 95 is any of the lines you quoted.  For one thing,
>none of them have an "e" except as a part of a longer word.

Here's some of the original poster's quoted code *and* the offending
statement: 

    ($health = "100");
    ($maxhealth = "100");
    ($intel = "25");
    ...
    Username: $input{username}
    Password: $input{password}
--> E-mail: $input{e-mail}
    Attacks: $input{basic1}
    Main Goal: $input{main_goal}
    Planet: $planet

-- 
Garry Williams


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

Date: 10 Dec 2000 02:47:36 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: problem with script
Message-Id: <976416137.18207@itz.pp.sci.fi>

In article <ujAY5.289$uF3.22992@eagle.america.net>, Garry Williams wrote:
>On 10 Dec 2000 00:18:36 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
>>
>>I don't think line 95 is any of the lines you quoted.  For one thing,
>>none of them have an "e" except as a part of a longer word.
>
>Here's some of the original poster's quoted code *and* the offending
>statement: 
>
>--> E-mail: $input{e-mail}

Doh!  I wasn't paying attention to the contents of the here-doc, since
after all it's a string, and therefore can't have syntax errors in it,
right?  Silly me.  Must've left my brain somewhere.

The rest of my advice still holds, though.  Getting a good editor with
syntax highlighting makes programming *so* much easier.  Really.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



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

Date: Sat, 9 Dec 2000 18:35:09 -0800
From: "M. Taylor Monacelli" <tailor@u.washington.edu>
Subject: Trouble making use of 'eval' to prevent fatal division by zero.
Message-Id: <90uq4u$3qqo$1@nntp6.u.washington.edu>

I'd like to prevent division by zero errors when
testing my Ratio class, but I'm not sure how to
incorporate the 'eval' function.

my $ratio = Ratio->new(4/5);

I can make a Ratio instance like this with out any
problems, but when I try the following:

my $ratio = Ratio->new(4/0);

I get the 'Illegal division by zero error'.

I know *about* the 'eval' function, but I am not
sure how to make use if it in this case because
the division '4/0' is done before I get a chance
to catch the error.

Maybe if I did something like this:

my $ratio = Ratio->new( eval { 4/0 } );

but this is client code!  I can't tell the user to
use 'eval { 4/0 } )' instead of simply '4/0'
whenever they want to make a new Ratio.

Can someone offer me an alternative?




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

Date: Sat, 09 Dec 2000 23:08:54 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Uploading file via CGI
Message-Id: <4a2a6aaa94g.soper@soundhouse.co.uk>

In article <slrn9343q6.3l5.efflandt@efflandt.xnet.com>, David Efflandt
<efflandt@xnet.com> wrote:
> If you define an 'upload' function in your 'use CGI ..." statement then
> upload('upload_1') would be a custom function translated to the string
> "<upload>upload_1</upload>" which when printed to your browser is
> probably an unknown tag and therefore hidden.  As far as I know, all
> field values including uploaded file name and handle are passed as
> param('fieldname').

OK, if I use the line: 
   use CGI qw(:standard);

and then call upload() in my program I get:
   Undefined subroutine &main::upload called at ...

So given that the CGI.pm defines the upload() function what should I be
doing to make it avaible to my program?

Also checking back through the documentation I note that I 'must use the
new multipart encoding scheme for the form' which I wasn't doing. I see
this can achieved by:
   start_multipart_form();
while I'm not using Perl to generate the form I see this inserts 
   enctype="multipart/form-data"
into the form tag so I've added this to the form but with still no luck.

I'm sure it's something to do with the use statement and making the
upload() function available. I think that like you say the way I had the
use statement was effectively defining a new function of unload(). However
I lack the experience of Perl to fully understand the concept of modules
and the use statement.

Cheers

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Sat, 09 Dec 2000 01:25:31 GMT
From: me
Subject: Why doesn't this work?????  (Location: redirection....)
Message-Id: <3a318836.28060974@nntp.interaccess.com>

I have been having problems with my perl scripts on a linux server... 

For redirection: here's a script that will not work (it works on
another server I use with FreeBSD)


#!/usr/local/bin/perl

print "Location: http://www.cnn.com/\n\n";
                                                            
That's it.... It runs fine in telnet, but I always get "premature end
of script headers" when I try to execute it through Apache server...It
works fine on my FreeBSD installation. 


I'm assuming it's something set up incorrectly with the Apache Web
Server, but other scripts seem to work fine (but only when I use CGI
and it's commands, not normal print "text/html", etc.) 


Any ideas would be appreciated. 


Thanks... 

psantt@interaccess.com


                  


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

Date: Sun, 10 Dec 2000 03:57:41 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Why doesn't this work?????  (Location: redirection....)
Message-Id: <slrn935vov.4q7.efflandt@efflandt.xnet.com>

On Sat, 09 Dec 2000 01:25:31 GMT, me <me> wrote:
>I have been having problems with my perl scripts on a linux server... 
>
>For redirection: here's a script that will not work (it works on
>another server I use with FreeBSD)

Probably because the default path to perl on Linux is /usr/bin/perl.  I
suggest you do the following as root so it will work with either path:

ln -s /usr/bin/perl /usr/local/bin/perl


>#!/usr/local/bin/perl
>
>print "Location: http://www.cnn.com/\n\n";
>                                                            
>That's it.... It runs fine in telnet, but I always get "premature end
>of script headers" when I try to execute it through Apache server...It
>works fine on my FreeBSD installation. 
>
>
>I'm assuming it's something set up incorrectly with the Apache Web
>Server, but other scripts seem to work fine (but only when I use CGI
>and it's commands, not normal print "text/html", etc.) 
>
>
>Any ideas would be appreciated. 
>
>
>Thanks... 
>
>psantt@interaccess.com
>
>
>                  


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

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


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