[6982] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 607 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 12 14:07:19 1997

Date: Thu, 12 Jun 97 11:00:48 -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           Thu, 12 Jun 1997     Volume: 8 Number: 607

Today's topics:
     Re: "Large Files" (Bob Shair)
     [Sys::Syslog] can't make it work on AIX 4.1.4 <dutka@rantanplan.dr.gdf.fr>
     Re: [Sys::Syslog] can't make it work on AIX 4.1.4 (Bob Shair)
     Re: C type macros? <psrc@corp.airmedia.com>
     Re: call perl script from c program? <msingh@cosmo.ny.jpmorgan.com>
     Re: Comparing dates. <michael.cameron@mci.com>
     Re: Comparing dates. (Michael Fuhr)
     Re: Comparing dates. (Sylvain Robitaille)
     Re: Does print() buffer output? <jbokma@caiw.nl>
     Help me with Perl <djoz@netins.net>
     Help with Comm.pl (Luc)
     Help with Perl print statement <bricr01@execpc.com>
     Re: how-to recognize numeric input? (Craig Berry)
     Re: MS-DOS port of the Perl programming language <jhi@alpha.hut.fi>
     Nee help for "truncate" in PERL5 (Jun Zhuang)
     Opening Files <amerar@unsu.com>
     Perl for Win32 and sockets programming --- is it possib <richard@inxpress.net>
     Re: Perl Patterns for CGI (David Tauzell)
     Re: Perl Patterns for CGI (Craig Berry)
     Reading Cookies <mark@sierra-inc.com>
     Re: Reading Cookies <thuja@internauts.ca>
     Re: regexp needed <sfairey@metrica.co.uk>
     Re: Regexp to get rid of foo without bar? (A. Deckers)
     Removing spaces <robert@duey.iminet.com>
     Re: RFD: comp.lang.perl reorganization (A. Deckers)
     Re: Running other Perl scripts within and returning the <dada@divinf.it>
     Small prog., Large file, core dump <jamon@apk.net>
     Sysopen still uses stdio <wanda@io.com>
     Re: Un-taint a variable how? (Michael Fuhr)
     Using TELNET with a SCRIPT <Dave@Coastal-Internet.Com>
     Re: UUencoding between UNIX and PC - newlines (Matthew Burnham)
     Webserver requires explicit exit(0) statement in perl s x@apocalypse.org
     Re: WIN32 modules Wanted <jwilson@ic.ac.uk>
     Re: XS:Keeping a variable btwn c calls <jheck@merck.com>
     Re: XS:Keeping a variable btwn c calls <jheck@merck.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 12 Jun 1997 17:54:51 GMT
From: rmshair@uiuc.edu (Bob Shair)
Subject: Re: "Large Files"
Message-Id: <5npd5b$jhn$1@vixen.cso.uiuc.edu>

John Pillans <jpillan@indiana.edu> writes:

>I would like to know if anyone has been able to get Perl to write files
>larger than 2^^30-1?  I am running Perl on AIX 4.2.1 which supports file
>sizes up to 32 gig.  I have tried adding a #define to perl.h.  One was
>_LARGE_FILES this got a compile error.  The other was _LARGE_FILE_API. 
>Perl compiled fine, but wrote a test program and the file grew to about
>2^^30-1 and stopped.  Anyone done this or is it just impossible under
>Perl?

These changes to the default config.sh work for me.  Don't mess with perl.h

(long lines warning):
ccflags='-qmaxmem=8192 -D_LARGE_FILES -qarch=com -qtune=604 -qflag=I:E -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -I/mnt/include -D_NO_PROTO'
cppflags='-qmaxmem=8192 -D_LARGE_FILES -qarch=com -qtune=604 -qflag=I:E -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE -I/mnt/include -D_NO_PROTO'
fpostype='fpos64_t'
lseektype='off64_t'

These, on AIX 4.2.0.0 with Perl 5.003, generate a perl which can read
and write large files.  I can't seek beyond 2GB, though.
This program 
	open (FILE, ">initials") || die "$!\n";
	$start=1;
	while (1) {
	$start = $start*2;
	print $start, "\n";
	print FILE $start, "\n";
	seek (FILE,$start,0) || die "cannot seek:$!\n";
	}
dies thus:
2
4
8
 ...
536870912
1073741824
2147483648
cannot seek:Invalid argument


-- 
Bob Shair                          Open Systems Consultant
1018 W. Springfield Avenue         rmshair@uiuc.edu
Champaign, IL 61821		   217/356-2684
< Not employed by or representing the University of Illinois >


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

Date: 12 Jun 1997 17:14:38 +0200
From: DUTKA-MALEN Ivan <dutka@rantanplan.dr.gdf.fr>
Subject: [Sys::Syslog] can't make it work on AIX 4.1.4
Message-Id: <xllu3j3ontt.fsf@rantanplan.dr.gdf.fr>


I've just installed PERL 5.004 on our RS/6000 machine (AIX 4.1.4)
All test were successful, but when I use the Camel book example of
client/server connexion (on pages 348-355), I have the following error
message :

(dutka) ./server.pl
Can't locate syscall.ph in @INC (did you run h2ph?) 
at /usr/local/lib/perl5/Sys/Hostname.pm line 74.

The problem is that I have NO syscall.h file on my RS/6000 to build
the syscall.ph file !

Any solutions or workaround ?
Any help appreciated.

-- Ivan

------------------------------------------------------------------------------
Ivan DUTKA-MALEN
dutka@dr.gdf.fr


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

Date: 12 Jun 1997 17:34:33 GMT
From: rmshair@uiuc.edu (Bob Shair)
Subject: Re: [Sys::Syslog] can't make it work on AIX 4.1.4
Message-Id: <5npbv9$igi$1@vixen.cso.uiuc.edu>

DUTKA-MALEN Ivan <dutka@rantanplan.dr.gdf.fr> writes:


>I've just installed PERL 5.004 on our RS/6000 machine (AIX 4.1.4)
>All test were successful, but when I use the Camel book example of
>client/server connexion (on pages 348-355), I have the following error
>message :
>
>(dutka) ./server.pl
>Can't locate syscall.ph in @INC (did you run h2ph?) 
>at /usr/local/lib/perl5/Sys/Hostname.pm line 74.
>
>The problem is that I have NO syscall.h file on my RS/6000 to build
>the syscall.ph file !
>
>Any solutions or workaround ?

if you do a $host = `hostname`; 
before you reach this point in your program, it looks to me as if
Hostname.pm notice you already have it, and not try to do the syscall.

Otherwise you can comment out this method in Hostname.pm, and it will
fall through to use of the "hostname" command, which DOES work on AIX.

Bonne Chance!
-- 
Bob Shair                          Open Systems Consultant
1018 W. Springfield Avenue         rmshair@uiuc.edu
Champaign, IL 61821		   217/356-2684
< Not employed by or representing the University of Illinois >


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

Date: Thu, 12 Jun 1997 12:09:15 -0400
From: Paul S R Chisholm <psrc@corp.airmedia.com>
To: Eric Finley <ez041407@bullwinkle.ucdavis.edu>
Subject: Re: C type macros?
Message-Id: <33A01F2B.616A@corp.airmedia.com>

Eric Finley wrote:
> Is there a perl equivalent to a C macro.

You can use perl -P (which invokes the C preprocessor) and use C
macros.-)

I don't recommend this. I inherited some scripts that worked that way
and didn't like the experience. In particular, the debugger reports line
numbers and file names on the preprocessor *output*, so it's very hard
to follow along with an editor in another window.

> I find that I use some [regular] expressions very frequently.

Note that the preprocessor will have the same effect as copying and
pasting the regex (except you can make changes in one place and have
them updated everywhere). Perl regular expressions are "not first class
objects"; there's no way to build one now and use it later. But see
Friedl's book "Mastering Regular Expressions: Powerful Techniques for
Perl and Other Tools" (from O'Reilly) for *lots* more useful
information!

> My favorite [regex] seems to be /(\s+)?\n/ to check for empty lines.

That expression will match every string with a \n in it; try:
	/^\s*$/
or:
	/^\s*\n$/  # can be improved; see Friedl's book!
instead.
--
Paul S. R. Chisholm, AirMedia, Inc.        (formerly Ex Machina)
mailto:psrc@corp.airmedia.com http://www.corp.airmedia.com/~psrc
  I'm not speaking for the company, I'm just speaking my mind


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

Date: 12 Jun 1997 10:16:44 -0400
From: Mandeep Singh <msingh@cosmo.ny.jpmorgan.com>
Subject: Re: call perl script from c program?
Message-Id: <v8hzpsvhpo3.fsf@cosmo.ny.jpmorgan.com>


here's an example: 
---------------------------------------
c file: hello.c
---------------------------------------
#include <stdio.h>
#include <EXTERN.h>
#include <perl.h>
 
static void xs_init _((void));
static PerlInterpreter *my_perl;
 
int main (int argc, char **argv, char **env)
{
    int status;
    my_perl = perl_alloc();
    perl_construct(my_perl);
    status = perl_parse(my_perl, xs_init, argc, argv, NULL);
    if (status) exit (status);
 
    perl_call_argv("greet", G_DISCARD | G_NOARGS, argv);
    perl_destruct(my_perl);
    perl_free(my_perl);
    exit(status);
}
static void xs_init() {}

---------------------------------------
perl file: world.pl
---------------------------------------
print "I will NOT be printed.";
sub greet
{
    print "Hello World!\n";
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
to compile (solaris 5.5.1)

gcc -o hello hello.c -L/home/msingh/temp/utils/perl5.003/lib/sun4-solaris/5.003/CORE -I/home/msingh/temp/utils/perl5.003/lib/sun4-solaris/5.003/CORE -lperl -lm -lsocket -lnsl
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
to run 

$./hello world.pl
Hello World!


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

Date: Thu, 12 Jun 1997 15:00:49 +0000
From: Michael James Cameron <michael.cameron@mci.com>
Subject: Re: Comparing dates.
Message-Id: <33A00F21.76D2@mci.com>

Brian Mcandrews wrote:
> 
> How can I compare two dates (ie, todays date being greater than a date
> 2 months ago)?
> 
> Thanks
> Brian

If your dates are formatted as a number of seconds since Jan 1, 1970
(like the output of time) then it should be pretty easy.  

If they are not then use timelocal.pl and call the function timelocal to
convert your dates to this format.

Comparisons are then just straightforward integer comparisons.


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

Date: 12 Jun 1997 09:37:03 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Comparing dates.
Message-Id: <5np52v$7pl@flatland.dimensional.com>

bmcandre@shrike.depaul.edu (Brian Mcandrews) writes:

> How can I compare two dates (ie, todays date being greater than a date 
> 2 months ago)?

Take a look at the Date::Manip, Date::DateCalc, or Time::Local modules.
Time::Local is probably included with your Perl distribution; the
other modules are available from the Comprehensive Perl Archive
Network (CPAN):

    http://www.perl.org/CPAN/

Hope this helps.

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: 12 Jun 1997 16:53:36 GMT
From: sp_robi@sinclair.concordia.ca (Sylvain Robitaille)
Subject: Re: Comparing dates.
Message-Id: <slrn5q0ac1.4m0.sp_robi@sinclair.concordia.ca>

On 12 Jun 1997 09:29:32 -0500, Brian Mcandrews <bmcandre@shrike.depaul.edu>
wrote:

>How can I compare two dates (ie, todays date being greater than a date 
>2 months ago)?

Here's what I do. It's kind of kludgy, 'cause it doesn't know how many
days are really in a month, but it comes close:

# $otherday has already been determined by some other means. Let's
# say it's a files last access time.
$months = 2;
$today = time;

if $today - $otherday > 60 * 60 * 24 * 30 * $months {
	# note: assumes 30 days in a month
	print "more than $months months ago.\n";
} else {
	print "less than $months months ago.\n";
}

-- 
----------------------------------------------------------------------
Sylvain Robitaille                          sp_robi@alcor.concordia.ca

Assistant to the System Manager
Computing Services Department
Concordia University                          Montreal, Quebec, Canada
----------------------------------------------------------------------


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

Date: 12 Jun 1997 16:35:09 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: Does print() buffer output?
Message-Id: <01bc774e$c0fa12e0$d70ab2c2@tschai>



Anthony J Terlecki <ajt@terlecki.demon.co.uk> wrote in article
<5nkmtg$29@terlecki.demon.co.uk>...
> When I run the following script I do not get the results I
expected. What I
> wanted was the initial message following by a . every second. What
I get is
> the initial message and all 9 dots at once 9 seconds after the
script begins
> execution.
> 
> Can anyone tell me why this is and how I might get around it?
> 
> #!/usr/bin/perl
> print "processing";
> for ($i=1; $i<10; $i++) {
>         print ".";
>         sleep 1; # emulating a process in the loop taking time
> }

Use $| = 1; this disables buffering

Regards,

John


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

Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)

http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]

email: jbokma@caiw.nl  phone: +31 10 4291827



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

Date: 12 Jun 1997 16:49:22 GMT
From: "Dean Ausdemore" <djoz@netins.net>
Subject: Help me with Perl
Message-Id: <01bc7750$b69a8440$292db1cf@djoz.netins.net>

I need help putting something with Perl on my home page.  Please email me
if you are willing to help me.  djoz@netins.net



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

Date: Thu, 12 Jun 1997 15:47:26 GMT
From: lrosier@planetinternet.be (Luc)
Subject: Help with Comm.pl
Message-Id: <5np5lm$nro$1@antwerpen.planetinternet.be>

Hi,

What I want to do from Perl is :

  telnet myhost.domain.com 25
  VRFY name
  QUIT

to check if 'name' is a valid email-address.
Tried to do this with 'Comm.pl' and got as far as 
getting a connection :

  220 myhost.domain.com ESMTP Sendmail 8.8; Thu, 12 Jun...

 ...Using this code :
-----
#!/usr/local/bin/perl

require 'Comm.pl';
&Comm'init(1.5);

$handle=&open_port('myhost.domain.com', 25, 2) || die "Open : $!";

(@recv)=&expect($handle, 3, '(.*)', 'print "$1\n"');
print @recv;

Comm::close($handle);
-----

Now, how do I : 1. send the 'VRFY name' to the $handle 
            and 2. get the results back ? 
Whatever I tried untill now failed 8-((

Thanks for your help
Luc




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

Date: Thu, 12 Jun 1997 10:50:32 -0500
From: Colleen <bricr01@execpc.com>
Subject: Help with Perl print statement
Message-Id: <33A01AC8.5319@execpc.com>

i am trying to run a perl5 script and running into some problems.  i am
getting:

Can't find string terminator "END_PRINT" anywhere before EOF at
register.cgi line 72.

here is the section of the script that's having the problem:

sub no_name
{
print <<"END_PRINT";
<HTML><HEAD><TITLE>Form Incomplete</TITLE></HEAD>
<BODY>
<H1>Form Incomplete</H1>
I'm sorry, the form was not filled completely.<br>
Please Return to the form and fill it out completely.<p>
Thank you.
<HR>
#         <a href=\"$referer\">Return to the registration page</a>
</BODY></HTML>
END_PRINT 

exit;
}


the funny thing about my problem is that i have other scripts that
compile/run just fine.  i have tryed to cut/paste the statements from my
other scripts that work, but, end up with the same error message.

please email me at bricr01@execpc.com with your solution.  i REALLY
appreciate any help you can provide....colleen


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

Date: 12 Jun 1997 17:31:10 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how-to recognize numeric input?
Message-Id: <5npbou$sja$2@marina.cinenet.net>

hkchan (hkchan@singnet.com.sg) wrote:
:  I'm a beginner of Perl. Currently I'm facing a problem of wrinting cgi
: program, that is  trying to  differentiate the input data is numeric
: integer but not string literals.
:  Can anyone teach me how-to ?

To determine if a string $input consists of exactly one integer with an 
optional leading sign and possible whitespace on either end, use:

  $input =~ /^\s*[+-]?\d+\s*$/;

In English, that's roughly: "The start of the string, possibly followed by
some whitespace, an optional sign, one or more decimal digits, then
possibly some more whitespace, followed by the end of the string." 

Note that ^$ really mark logical-line boundaries, but these are equivalent
to string boundaries in most common cases. 

Hope this helps!

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 11 Jun 1997 22:07:34 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: MS-DOS port of the Perl programming language
Message-Id: <oee910h3qmh.fsf@alpha.hut.fi>


Tom Phoenix <rootbeer@teleport.com> wrote:
:On 10 Jun 1997, it was written:
:> From: 13j5;l@jumbo.com
:Hmmm... Smells like spam...
:> Get NEW MS-DOS port of the Perl programming language Shareware As It's
:> Written! 
:Perl is not shareware. Never has been. Never will be.
:What do you do for Perl that CPAN doesn't already do better?

As the CPAN Janitor I took a look.  Fear not.  The dos perls they have
are not new, they are OLD, perl4.  As you said, slight whiff of spam.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: 12 Jun 1997 17:02:48 GMT
From: jzhuang@ringer.cs.utsa.edu (Jun Zhuang)
Subject: Nee help for "truncate" in PERL5
Message-Id: <5npa3o$dk9@ringer.cs.utsa.edu>

I tried to delete some line within a file and insert some new lines.
I try to use "seek" tehn "truncate" then "write".
But, how can i determine the "length" for the "truncate" function?
i.e. If I try to truncate from the line begin with "Record #34" until
the line begin with "end of record #34".And then insert a new record.
Thanks in advance.

--
Jun Zhuang                         |Jun Zhuang 
Department of Computer Science     |Department of Pharmacology
University of Texas                |UT Health Science Center
San Antonio, Texas                 |San Antonio, Texas
Email: jzhuang@ringer.utsa.edu     |Email: zhuang@arwen.uthscsa.edu
                                   |       zhuang@mail.uthscsa.dcci.com


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

Date: Sat, 07 Jun 1997 10:03:28 -0500
From: Arthur Merar <amerar@unsu.com>
Subject: Opening Files
Message-Id: <33997840.63B3@unsu.com>

If I open a file for output, OPEN(FILE,">filename"), and the file
already exists, will Perl overwrite the file that is there?

Arthur
amerar@unsu.com
http://www.unsu.com


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

Date: 12 Jun 1997 15:59:00 GMT
From: "Richard" <richard@inxpress.net>
Subject: Perl for Win32 and sockets programming --- is it possible?
Message-Id: <01bc7749$5b821160$e525a8c0@cube444a>

Hello,

Is it possible to use Perl for Win32 and windows sockets api to write perl
base TCP/IP scripts?



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

Date: 12 Jun 1997 16:08:32 GMT
From: tauzell@math.umn.edu (David Tauzell)
Subject: Re: Perl Patterns for CGI
Message-Id: <5np6u0$o4a@epx.cis.umn.edu>

A great way of handling errors in cgi scripts is to eval everything and
also redirect standard error.  This way, at the end of your *normal* processing and output you print out the standard error.  In addition, any fatal errors can be caught by the eval.
--
---
David Tauzell.  I like unix.


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

Date: 12 Jun 1997 17:17:07 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl Patterns for CGI
Message-Id: <5npauj$sja$1@marina.cinenet.net>

David Tauzell (tauzell@math.umn.edu) wrote:
: A great way of handling errors in cgi scripts is to eval everything and
: also redirect standard error.  This way, at the end of your *normal* processing and output you print out the standard error.  In addition, any fatal errors can be caught by the eval.

The problem is that evals have a very high processing-overhead cost.  For 
a CGI script that won't get hit frequently this needn't be a concern, but 
on a 'hot' page the cpu can add up fast.

I prefer to print the basic header info to stdout early in the script, so 
the page is well-formed regardless of what else happens.  Then I use a 
small function to print an HTML-formatted error message and exit if 
anything goes badly wrong; I call mine 'cdie', and it looks more or less 
like this:

  sub cdie
  {
    my $msg = shift || "No message provided.";

    print "\n<p><b>$0 fatal error: $msg</b>\n</body></html>\n";
    exit;
  }

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Thu, 12 Jun 1997 12:52:02 -0400
From: mark <mark@sierra-inc.com>
Subject: Reading Cookies
Message-Id: <33A02932.3C94@sierra-inc.com>

I'm trying to create a CGI script which, among other things, reads
cookies.  I came across the following shell script on the Netscape site:

>#! /bin/sh
>
>echo "Content-type: text/html"
>echo ""
>echo "Here is your cookie (munch munch):<P>"
>echo "$HTTP_COOKIE<P>"    

It works fine as shell, but my perl equivilant ignores the $HTTP_COOKIE

>#!/usr/bin/perl
>
>print "Content-type: text/html\n\n";
>print "Here is your cookie (munch munch):<P>\n";
>print "$HTTP_COOKIE<P>\n";      

Any ideas on how to read cookies?  Please send email.

Mark


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

Date: Thu, 12 Jun 1997 13:31:22 -0400
From: Michael Iles <thuja@internauts.ca>
Subject: Re: Reading Cookies
Message-Id: <33A0326A.4D8F@internauts.ca>

mark wrote:
> >print "$HTTP_COOKIE<P>\n";
> 
> Any ideas on how to read cookies?  Please send email.

In a shell script all the environment variables exist in the namespace
of your program. In Perl they exist in the %ENV hash, so you would say

    print $ENV{'HTTP_COOKIE'};

but you'll almost certainly want to use the CGI.pm module.

Mike.

-- 
Michael Iles, michaeli@dra.com                  PGP Fingerprint:
sub perl_mind { for ( <LIFE> ) { breathe; } }    CB 51 3B 92 A7 25 FB 74
      Ceci n'est pas une .sig                    68 5A 2D 37 34 D5 39 5B


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

Date: Thu, 12 Jun 1997 18:01:24 +0100
From: Simon Fairey <sfairey@metrica.co.uk>
To: webadmin <webadmin@prestel.net>
Subject: Re: regexp needed
Message-Id: <33A02B64.59E2@metrica.co.uk>

webadmin wrote:
> 
> Hi
> 
> I have the following line
> 
> www.domain.co.uk,   19.87  6.03       253526      153 | /
> 
> I need to split it. the thing is that I have several lines, but the no.
> of spaces in between the elements variies, so I can't have a fixed
> split. The number I am interested in getting is the one before the pipe
> symbol.
> 
> How can i get this.
> 
> Iqbal

Two options spring to my novice mind:

1. You can use a regexp along the lines of:
  /^\s*\S+\s+\S+\s+\S+\s+\S+\s+(\S+)\s+\|\s+\/\s*$/
  This is assuming the number of items and general layout of the line is
  the same each time.

or

2. You can actually split on a regexp, so the following would work:
  split( /\s+/, $dataline )
  Which would the split the line into fields seperated by one or more
  spaces, then you would only need to ensure that the number you wanted
  was in a certain position from either the start or the end of the line
  ( assuming you store the split result in an array ).

I would guess that 1. is quicker, even if it looks a bit messy ( I am
sure someone will post a neater version ), but 2. does give you a bit
more flexibility in the layout of the line.

Have fun

Simon


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

Date: 12 Jun 1997 17:19:15 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: Regexp to get rid of foo without bar?
Message-Id: <slrn5q0bsj.ajg.deckers@nessie.mcc.ac.uk>

In <339b665a.9890913@news.ntplx.net>,
	Decklin Foster <mookid@ntplx.net> wrote:
>I would like to use a regular expression to remove any occurence of some
>regexp (foo) that is not followed by something else (bar). I'm not sure how to
>go about this - can someone give me an example? Thanks (Cc's are appreciated.)

>From p. 68 of the Blue Camel book:

(?!...)
  A zero-width negative lookahead assertion. For example /foo(?!bar)/
  matches any occurence of "foo" that isn't followed by "bar". Note,
  however, that lookahead and lookbehind are not the same thing. [...]

Did you check the documentation (FAQ, man pages, perldoc, etc.) before
posting your question? It's probably explained in there too.

HTH,

Alain

-- 
Perl language home page: <URL:http://www.perl.com/perl/>
               Perl FAQ: <URL:http://www.perl.com/perl/faq/>
           Perl archive: <URL:http://www.perl.com/CPAN/>
>>>>>>>> comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<


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

Date: Thu, 12 Jun 1997 10:14:18 -0500
From: Robert Saunders <robert@duey.iminet.com>
Subject: Removing spaces
Message-Id: <DA83B69B38707704.3183EC252D42AB19.D047946B7D56E7FF@library-proxy.airnews.net>

I have a record that I wish to remove 4 leading spaces from, here is a
example of the record

This|donuts|    apples||||

I need to remove the spaces from the apples area.. What would be the
best and correct way of doing this in perl. I am using Perl 5.x ...

Thanks.. Robert
robert@duey.iminet.com



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

Date: 12 Jun 1997 15:05:56 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: RFD: comp.lang.perl reorganization
Message-Id: <slrn5q042j.nj7.deckers@news.rediris.es>

[NB: Followup-To: news.groups]

In <33A00180.3C74@mathematica-mpr.com>,
	the count <eglamkowski@mathematica-mpr.com> wrote:
>A. Deckers wrote:
>>                      REQUEST FOR DISCUSSION (RFD)
>>             moderated group comp.lang.perl.data-structure
>>              moderated group comp.lang.perl.inter-process
>>               moderated group comp.lang.perl.programmer
>>                  moderated group comp.lang.perl.regex
>
>I'm generally opposed to moderated newsgroups in principle, 
>but since these are technical topics (as opposed to, say 
>political or religious), it probably isn't as much a problem.  
[...]
>> CHARTER: all groups
>> The moderation script will escrow submissions from first-time
>> posters, who will be sent registration instructions in addition
>> to the group charter and pointers to relevant references.
>> Submitions from registered users will be auto-approved provided
>> their posts comply with all the criteria set out in this charter.
>
>This is bad, and I would vote no on the creation of these groups 
>just on this basis alone.  There should NOT be any registration 
>for any newsgroup.  At that point, why not just set up a closed 
>mailing list instead?  That is essentially what these newsgroups
>would be.

No, they wouldn't. As a general rule, mailing lists are more difficult
to find than newsgroups, for more closed than even a newsgroup with
registration, and a pain in the neck once the volume goes above a few
dozen articles per day.

The idea of registration is that posters have to think about what they
are doing rather than blindly firing off a question to the newsgroup.
I don't think this is an unreasonable imposition.

[...]
>> Posters are requested not to post answers to questions which are
>> explicitly addressed in the documentation, including the relevant
>> FAQs.  A pointer to the relevant resource should instead be
>> emailed to the questionner.
>
>What if there *is* a solution in the docs, *but* someone wants 
>to post an alternate solution that is not in any documentation?  
>Would this be acceptable?

Of course, common sense would dictate that new solutions, criticisms of
and ammendments to existing docs, etc. could be posted to the groups,
though in some cases this would not necessarily be the most appropriate
place to post them: the FAQ maintainers or perl5-porters are the one's
who actually have the ability to change the docs, so posters would have
to use their common sense to decide where the most appropriate place to
post is.

[...]
>> While permission to routinely cross-post to the group will not be
>> granted in other cases, the moderation panel will consider
>> requests on a case-by-case basis, and grant their approval if
>> they deem that this would be of significant benefit to the
>> readership of the group. This provision applies especially, but
>> is not limited to, relevant FAQs.
>
>So if I understand this correctly, since crossposted messages
>are, in general, automatically rejected, if someone does want
>to crosspost, they have to send their post directly to a 
>moderator?

In principle yes. Routine xposting will not be allowed, and as the
charter says, the moderators would only allow it in exceptional
circumstances.

Suitable use of an auto-responder and mailfiltering should reduce the
nuisance factor of innapropriate requests to xpost to an tolerable
level.

>> Sites wishing to receive posts approved by the moderation script
>> via email, shall apply to the moderation panel, which shall
>> maintain a mailing list for this purpose. This provision is
>> primarily intended to help poorly connected sites to reduce
>> propagation delay for the proposed groups.
>
>Aha!  A mailing list!  ;)

>bit.listserv.perl-rx
[etc.]
>
>:)

Smiley noted, but it has to be pointed out that bit.* doesn't have the
propagation of comp.*.

>> CHARTER: comp.lang.perl.inter-process
>> 
>> The group comp.lang.perl.inter-process will deal with issues
>> related to the implementation of interprocess communications
>> (signals, fifos, pipes, safe subprocesses, sockets, semaphores
>> and related issues) in Perl.
>
>I assume CGI related posts are NOT acceptable here?
>(just for the record)

Posts specifically related to the Common Gateway Interface should go to
comp.infosystems.www.authoring.cgi, which is where they belong.

I think it is highly unlikely that people with CGI questions would look
at clp.i-p and think "Aha! This looks like the right place to post!",
and if they cross-post, the article will be rejected by the bot.

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: Thu, 12 Jun 1997 17:28:32 +0200
From: Aldo Calpini <dada@divinf.it>
To: Brian Caldwell <brian@nemonet.com>
Subject: Re: Running other Perl scripts within and returning the results to a variable
Message-Id: <33A015A0.16B829EE@divinf.it>

Brian Caldwell wrote:
> 
> Hello.  I'm running a simple perl script "account_info.pl" that calls
> another script via the line:
> 
> $info=`userlog.pl`;
> 
> Userlog.pl is SUPPOSED to return text which will be stored in the
> variable $info as stated above.  The programs are run but nothing is 
> returned. Is the above the wrong syntax for Perl 5 for NT?  I've even 
> set the userlog.pl file to a two line script that prints "Hello World" 
> but it is not returned even.

Hi,
the syntax "userlog.pl" is actually supported by NT in a very premilinar
phase (it will probably be implemented in the Windows Scripting Host
with NT 5.0), and it doesn't handle neither input nor output yet.
If you try it from the command line:

userlog.pl >output

it will create a file named "output", but with length=0. The output is
lost somewhere...
Replace your line with:

$info=`perl userlog.pl`;

 ...and wait for NT 5.0 :-)

Bye,
Aldo Calpini
---/\-----------------------------------------------------------
--/  \--------------------------------- mailto:dada@divinf.it --
-<dada>-- POPULUS VULT DECIPI, -------- mailto:sis@divinf.it ---
--\  /------- ERGO DECIPIATUR --------- http://sis.divinf.it ---
---\/-----------------------------------------------------------


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

Date: Thu, 12 Jun 1997 11:15:59 -0400
From: "Jennifer R. Amon" <jamon@apk.net>
Subject: Small prog., Large file, core dump
Message-Id: <Pine.GSO.3.95.970612110522.5667A-100000@junior.apk.net>


I have a very small program which strips trailing blanks from 
the quoted, comma-delimited strings in a data file.

The input file looks like this:

  "ACEPP               ","SALES,CS/ACE SHT  ","00000*","920213"
  "BAR001              ","REF DWG FCT ASSY  ","00000C","950907"

The program looks like this:

  #!/usr/local/bin/perl $infile = "PARTREV.txt"; 

  open(IN_FILE, $infile); 
  open(OUT_FILE, $outfile);

  while ($line = <IN_FILE>)  
  {
    $line =~ s/ +"/"/g;
    printf OUT_FILE $line;
  }
  close(OUT_FILE);
  close(IN_FILE);

The input file has 40000+ lines. 
The program dies consistently on line 14589.
This is true even if I edit the input file and delete line
14589 and a few lines before and after that line. The program
then dies on the "new" line 14589.

The error message is simply:

   Bus error (core dumped)

The platform: SGI IRIX v5.3
        Perl: 5.003

It feels like I'm running over some limit of some sort.

Suggestions?

Thanks,
  Jennifer
_______________________________________________________________________
Jennifer R. Amon                       Phone: 216-962-2000 ext. 2471 
Sr. Programmer/Analyst                   FAX: 216-962-2739 
Moen Incorporated                   Personal: jamon@apk.net 
25300 Al Moen Drive                 Business: jamon@moen.com 
North Olmsted, OH 44070            Web: http://junior.apk.net/~jamon/
_______________________________________________________________________ 
I love music, nature, animals, books, antiques, children, family, 
travel, and Thin Mint Girl Scout cookies! :-) 
_______________________________________________________________________




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

Date: 12 Jun 1997 16:39:55 GMT
From: Warren AND Amanda <wanda@io.com>
Subject: Sysopen still uses stdio
Message-Id: <5np8or$fj0$1@nntp-2.io.com>
Keywords: sysopen open fdopen stdio descriptors

All of the perl documentation leads a user to believe that stdio can be
completely avoided on file accesses if a user limits onesself to using
just sysopen/sysread/syswrite/sysseek/close.

However, even when using sysopen to get a file descriptor, Perl (doio.c)
still follows the open with fdopen to get an input stream, then later
calls fdopen again to get a separate output stream if the file was a
socket or character special file and was opened for writing.

I would have hoped that Perl would truly and completely avoid using
stdio if asked to use sysopen, and not bother trying to set up stdio
streams at all, due to bugs in stdio on many platforms.

Is there any way a future version of Perl will avoid stdio completely
when a descriptor is obtained using sysopen, then refuse to perform
stdio operations on the sysopen-ed descriptor?  It would make sense that
a file opened with sysopen may only be acted upon with sysread, syswrite,
sysseek and close, and that Perl should *strongly* deny the existance
of stdio for that particular file descriptor.

Please comment.

Drat,
--
Warren_Hyde@email.sps.mot.com
"If it makes goo on the windshield, we'll call it a bug." --Larry Wall


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

Date: 12 Jun 1997 09:30:24 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Un-taint a variable how?
Message-Id: <5np4mg$7k2@flatland.dimensional.com>

gerdemb@rice.edu (Ben Neil Gerdemann) writes:

> We are running a setuid script and have need to un-taint a variable. How
> is this possible? 

Take a look at the perlsec manual page -- it discusses tainted variables.

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Thu, 12 Jun 1997 13:02:55 -0300
From: Dave Leger <Dave@Coastal-Internet.Com>
Subject: Using TELNET with a SCRIPT
Message-Id: <33A01DAF.42B4@Coastal-Internet.Com>

Good day..

I would like to add something in a PERL script that would execute a
telnet session and automagically login and execute a command.  I've done
simular things with FTP..

system ("ftp -n host.com << FTP
user $login $password
get $file1 $file2
quit
FTP
");

I would like to do the same with telnet..  Is this possible?  If so how
do I go about doing this.  I am running Solaris 2.5 on both machines
that wish to talk..

Thanks for your time...

Dave Leger
dave@okweb.com


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

Date: Thu, 12 Jun 1997 17:44:52 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: Re: UUencoding between UNIX and PC - newlines
Message-Id: <33a4e63f.2268504@194.72.192.4>

aml@world.std.com (Andrew M. Langmead) wrote:

>>This is an extract from the script:
>
>>if (-e $filename)
>>{
>>	open(FILE, "<$filename");
>
>You probably want to say "binmode(FILE)" here. See
><URL:http://www.perl.com/CPAN/doc/manual/html/pod/perlfaq4/How_do_I_handle_binary_data_cor.html>
>for details.
Yeah, I do when running it on my PC, but not when I upload it to the
UNIX box (which doesn't need it?)

>>	while(<FILE>)
>Less importantly, you might want to either read chunks of data with
>read() and uuencode them separately, (choosing the amount to read to
>match uuencoding character, byte boundries correctly, and line
>boundries correctly. A multiple of 60 would be good.) or to slurp the
>file in one chunk. (With a very large read() or undef()ing $/).
>Reading on newline boundries make little sense with binary files.
The files shouldn't be too big, but I'll bear it in mind if I get
problems.

Thanks!


-- 
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.mindweb.co.uk/


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

Date: Thu, 12 Jun 1997 12:02:12 -0600
From: x@apocalypse.org
Subject: Webserver requires explicit exit(0) statement in perl scripts?!?
Message-Id: <866134172.12008@dejanews.com>

Will lack of an exit(0) statement in cgi scripts spam a webserver like
   Netscape Enterprise 2.0 (digital unix port - I'd use Linux and Apache
   but the boss won't let me...)? Spam in that further CGI requests
   after a certain point will just result in the user's browser icon
   spinning forever... (until time-out) seems like cgi requests are
   overloading our webserver... although it seems utterly ridiculous
   since we're using a DEC Alpha, and, frankly, the site doesn't really
   get a huge amount of hits.
   Netscape doesn't seem to know what's wrong, and I think they're
   grasping at straws by telling me I don't have any exit statements
   in some of my cgi scripts.
   So far as I know, as long as the script isn't stuck in a loop, when
   it reaches the last line of code, it will end, right? Or does
   Enterprise really require that one's scripts included a hard coded
   exit statement?

   During this time when the server "hangs", although CGI scripts won't
   work, regular html documents are served-up fine. Also, during the
   "hangs", users can't get to password protected areas...

   Any idea about what might be going wrong?

   Thanks in advance.

   Pissed because ports for Digital Unix generally suck,

        Xochi

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 12 Jun 1997 13:52:59 GMT
From: "Jeff Wilson" <jwilson@ic.ac.uk>
Subject: Re: WIN32 modules Wanted
Message-Id: <01bc7737$efc06000$1d34c69b@leicester.cc.ic.ac.uk>

I think what you're looking for is at http://www.activeware.com/
-- 
                                               Jeff Wilson
                                               CCS ~ Imperial College ~
London UK
                                              

Spiro Angeli <Spiro@uh.edu> wrote in article
<339debe4.4179780@news.uh.edu>...
> Hi,
> 
> I am looking for some win32 module for Perl 5 for NT that will
> allows me to manage the Windows NT Server.
> I have noticed that QUE book explains them and perhaps has them on
the
> CD-ROM. Is there any possibility to find them on the NET?
> 
> Thank you.  :-)
> 
> Spiro
> 


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

Date: Thu, 12 Jun 1997 11:13:54 -0400
From: "James J. Heck" <jheck@merck.com>
Subject: Re: XS:Keeping a variable btwn c calls
Message-Id: <33A01232.41C6@merck.com>

Ken,

[posted and mailed]

> First off, please read the perlxs documentation and tutorial.  It's
> really good stuff put together by a lot of talented people.

	I have read all of the associated documentation that I could
find.  You are right they are really good documents.

> I don't know what variable you mean.  Is it the return value of
> the function?  Or is it some sort of state variable that the
> function used?  I'm sure that XS and Perl can do what you need.
> You just have to tell us more about your problem.  If you want
> help, you'll have to show us the function prototypes and an
> example of how they are used together.

	I have a variable that is currently global to the C program.  
Both a read function and a write function access this variable.  The 
reader fills a data structure based on input and the write function 
streams the data out based on the structure.  THe structure is kept 
with a pointer.  So I just need to find a way to have the pointer 
made aware to the Perl program.  Then I need to make the pointer 
available to the write function.  I would like not to have to modify 
the current code if I don't have to, but if necessary will.  Both 
functions have an int return value as it is.  This is just a pointer 
they both use.

	So basically, is there a way to make a pointer seem global 
to a C function from Perl?  Or will I have to pass the 2nd C function 
the pointer?

	If you mail a response as well as post it, please mail it to: jheck@acm.org.  Thanks
again.

	James 
--------------------
James J. Heck
jheck@acm.org
http://www.bucknell.edu/~jheck


       The contents of this message express only the sender's opinion.
       This message does not necessarily reflect the policy or views of
       my employer, Merck & Co., Inc.  All responsibility for the statements
       made in this Usenet posting resides solely and completely with the
       sender.


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

Date: Thu, 12 Jun 1997 11:40:57 -0400
From: "James J. Heck" <jheck@merck.com>
Subject: Re: XS:Keeping a variable btwn c calls
Message-Id: <33A01889.167E@merck.com>

Ken,

> First off, please read the perlxs documentation and tutorial.  It's
> really good stuff put together by a lot of talented people.

	I have read all of the associated documentation that I could
find.  You are right they are really good documents.

> I don't know what variable you mean.  Is it the return value of
> the function?  Or is it some sort of state variable that the
> function used?  I'm sure that XS and Perl can do what you need.
> You just have to tell us more about your problem.  If you want
> help, you'll have to show us the function prototypes and an
> example of how they are used together.

	I have a variable that is currently global to the C program.  
Both a read function and a write function access this variable.  The 
reader fills a data structure based on input and the write function 
streams the data out based on the structure.  THe structure is kept 
with a pointer.  So I just need to find a way to have the pointer 
made aware to the Perl program.  Then I need to make the pointer 
available to the write function.  I would like not to have to modify 
the current code if I don't have to, but if necessary will.  Both 
functions have an int return value as it is.  This is just a pointer 
they both use.

	So basically, is there a way to make a pointer seem global 
to a C function from Perl?  Or will I have to pass the 2nd C function 
the pointer?

	If you mail a response as well as post it, please mail it to: jheck@acm.org.  Thanks
again.

	James 
--------------------
James J. Heck
jheck@acm.org
http://www.bucknell.edu/~jheck


       The contents of this message express only the sender's opinion.
       This message does not necessarily reflect the policy or views of
       my employer, Merck & Co., Inc.  All responsibility for the statements
       made in this Usenet posting resides solely and completely with the
       sender.


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 607
*************************************

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