[15676] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3089 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 18 14:14:11 2000

Date: Thu, 18 May 2000 11:10:23 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958673423-v9-i3089@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 18 May 2000     Volume: 9 Number: 3089

Today's topics:
    Re: help - undef $/; ? (Tad McClellan)
    Re: Help on namespaces <notacceptingspam@nowhere.can>
    Re: How can I read the volume label of a CDROM on Linux <rbratt@home.com>
    Re: How can I read the volume label of a CDROM on Linux nobull@mail.com
    Re: How Do I Source a File with Environment Variables? (Cory Phillips)
    Re: How Do I Source a File with Environment Variables? (Rafael Garcia-Suarez)
    Re: How to execute "cat *.c" ??? <Petri_member@newsguy.com>
        How to leave socket open... <tomp@sci.fi>
    Re: If slices are so great <gellyfish@gellyfish.com>
    Re: IPC: 1 to n communication (Paul David Fardy)
    Re: Large hash handling (Abigail)
        largefile awareness and perl <joe.potenzaNOjoSPAM@abacus-direct.com.invalid>
    Re: largefile awareness and perl (M.J.T. Guy)
    Re: my cgi script (Michel Dalle)
    Re: need advice on strategy... <rootbeer@redcat.com>
    Re: Object Oriented Perl Question <aqumsieh@hyperchip.com>
        Perl & Frames <richard@avocation.demon.co.uk>
    Re: Perl-5.06 Build Error <dan@tuatha.sidhe.org>
    Re: PerlIS printing out header info. <rootbeer@redcat.com>
        printing output directly to a file crtopf@sgi.net
    Re: printing output directly to a file <jhelman@wsb.com>
        Problem with different Perl version <saddek@arch.chalmers.se>
    Re: re-evaluation (newbie) nobull@mail.com
    Re: re-evaluation (newbie) nobull@mail.com
    Re: re-evaluation (newbie) <aqumsieh@hyperchip.com>
    Re: regex mind bender (for me) <lr@hpl.hp.com>
    Re: Remove leading zero (Tad McClellan)
        Search Eng for Website <chrisd@amcorp.com.au>
    Re: Search Eng for Website <jhelman@wsb.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 18 May 2000 10:21:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help - undef $/; ?
Message-Id: <slrn8i7v2d.4vr.tadmc@magna.metronet.com>

On Thu, 18 May 2000 01:28:08 +0100, Nadja Herkova <spam-abuse@uk2.net> wrote:


>so, if i undef $/ - it will only affect if i use $/ elsewhere in the
>program ? or does it have affect on other commands - i will look


$/ affects the behavior of the <input operator>, so you should
control the scope of the change to $/:


{   local $/;   # set slurp mode

    while (<>) {
       ...
    }
}

# here the value of $/ is whatever it was before the block above
( newline be default).



-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 18 May 2000 15:21:39 GMT
From: "Jim Stout" <notacceptingspam@nowhere.can>
Subject: Re: Help on namespaces
Message-Id: <7UTU4.311$T41.10276@newsread1.prod.itd.earthlink.net>


Jeff Helman wrote in message <392405D7.90F28D04@wsb.com>...
>Jim Stout wrote:
>>
>While you're in package foo, you can call subroutine bar with
>
>&bar;
>
>Outside of package foo, you'll need to use an explicit package
>reference:
>
>&foo::bar();


Thanks much Jeff! I assumed this but wasn't sure as the perldocs are
quite explicit about variables and equally mum about subroutine names.


>It's a good programming practice, though, to use explicit packages
>references even where perl lets you get away without them, since it
>makes debugging your code 6 months down the line a hell of a lot
>easier.
>
>Hope this helps,
>JH


AMEN!!!  I get lost in 6 minutes...6 months later I'd be knawing at the
restraints...

Jim




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

Date: Thu, 18 May 2000 10:25:40 -0500
From: rgb <rbratt@home.com>
Subject: Re: How can I read the volume label of a CDROM on Linux?
Message-Id: <0D3FA27B9F96B7CE.4FF1C8281A3A52ED.884E36249C278AF1@lp.airnews.net>

Sorry nobull, my message was not clear.  I need this information for a
perl script and I was hoping that someone would know of a perl module
that returns this information.  I haven't been able to find one, but
i'm a perl newbie so I thought i'd ask for pointers..

My comment about "how to do it in linux" was because I knew I could
back-tick a linux command also to get the information if only I could
find a linux command to do it.

I did post the question in a linux newsgroup too.  So far, no one has
been able to help me.  If you can point me in the right direction I
sure would appreaciate it.  It seems hard to believe, but maybe there
is no way to get this information :<<

-Dick
	I

On 18 May 2000 12:41:15 +0100, nobull@mail.com wrote:

>rgb <tiemaster@home.com> writes:
>
>> The title says it all.  I looked for a Linux program to do this, but I
>> must be blind or not very good at searching for things.  Can anyone
>> point me in the right direction?
>
>Try a Linux newsgroup, this is a Perl newsgroup.



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

Date: 18 May 2000 18:04:32 +0100
From: nobull@mail.com
Subject: Re: How can I read the volume label of a CDROM on Linux?
Message-Id: <u9k8grlrhb.fsf@wcl-l.bham.ac.uk>

rgb <rbratt@home.com> writes:

> Sorry nobull, my message was not clear.  I need this information for a
> perl script and I was hoping that someone would know of a perl module
> that returns this information.  I haven't been able to find one, but
> i'm a perl newbie so I thought i'd ask for pointers..

Well I'm not aware of any Perl modules to manipulate ISO filesystem
images.  I can tell you where you can get find lots of info about CD
formats if you contact me directly.

> My comment about "how to do it in linux" was because I knew I could
> back-tick a linux command also to get the information if only I could
> find a linux command to do it.

I too have never found Linux programs to do this, but then I haven't
looked very hard or very recently.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 18 May 2000 15:04:41 GMT
From: cory-p@usa.net (Cory Phillips)
Subject: Re: How Do I Source a File with Environment Variables?
Message-Id: <392405df.5943587@news.jsc.nasa.gov>

Unfortunately the environment file is not that clean.  Here is why.

if [ "$ORACLE_HOME" != "" ] ; then
   new_path=`echo $PATH | sed s@$ORACLE_HOME/bin@@g | sed s/::/:/g`
   export PATH=$new_path
fi

export PATH=`echo $PATH | sed s/::/:/g`
if [[ -z $LOCALHOST ]]; then
  export LOCALHOST=$(uname -n).jsc.nasa.gov
fi
if [[ -z $HTTP_HOST ]]; then
  export HTTP_HOST=$(uname -n).jsc.nasa.gov
fi

It would be dificult to parse a file that has a bunch of conditional
elements in it.

Is there any other way?



On Thu, 18 May 2000 14:04:48 GMT, garcia_suarez@hotmail.com (Rafael
Garcia-Suarez) wrote:

>Cory Phillips wrote in comp.lang.perl.misc:
>>We have a text file on our web systems with a bunch of environment
>>variables in it.  We have some CGI scripts written in Unix shell and
>>it's easy to source the file for the variables with
>>
>>. /path/to/file/env_vars
>>
>>How do I accomplish this same thing from Perl?  Do I do it with back
>>quotes?
>
>No. Backquotes (or the 'system' function) launch a subprocess and thus
>only the subprocess environment is altered.
>You have to read the file and alter environment yourself.
>Something like that may help: (assuming the file containing env vars
>looks like
>  VAR1=value1
>  VAR2=value2
>  etc...
>)
>
>open FILE, 'envfile.sh' or die "Can't open it: $!\n";
>while (<FILE>) {
>  my ($a,$b) = split /\s*=\s*/, $_, 2;
>  $ENV{$a} = $b;
>}
>close FILE;
>
>Note: Of course this code is not very secure. You must at least ensure
>that the envvar file and its directory are writable only by root. Or
>something like that.



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

Date: Thu, 18 May 2000 15:45:57 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: How Do I Source a File with Environment Variables?
Message-Id: <slrn8i847j.3nl.garcia_suarez@r-garcia.kazibao.net>

Cory Phillips wrote in comp.lang.perl.misc:
>Unfortunately the environment file is not that clean.  Here is why.
>
>if [ "$ORACLE_HOME" != "" ] ; then
>   new_path=`echo $PATH | sed s@$ORACLE_HOME/bin@@g | sed s/::/:/g`
>   export PATH=$new_path
>fi
>
>export PATH=`echo $PATH | sed s/::/:/g`
>if [[ -z $LOCALHOST ]]; then
>  export LOCALHOST=$(uname -n).jsc.nasa.gov
>fi
>if [[ -z $HTTP_HOST ]]; then
>  export HTTP_HOST=$(uname -n).jsc.nasa.gov
>fi
>
>It would be dificult to parse a file that has a bunch of conditional
>elements in it.
>Is there any other way?

Yes, there is one: filter it through a programmer :-)
Additionally, this may improve the efficiency of your script because
no new processes (such as 'sed') will be needed.

Alternatively, you can try to parse and filter the result of
  `sh -c '/path/to/envfile && set'`
(untested) (notice ticks and backticks) but this is not a very
clean method indeed.

-- 
Rafael Garcia-Suarez


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

Date: 18 May 2000 05:26:31 -0700
From: Petri Oksanen <Petri_member@newsguy.com>
Subject: Re: How to execute "cat *.c" ???
Message-Id: <8g0nhn$310c@edrn.newsguy.com>

In article <8fgm86$gui$1@nnrp1.deja.com>, ovarene@webmails.com says...

>I'd like to make a system call with an asterix wild card (*), like for
>exemple: cat *.c.

>I tried things based on system();
>>@sys_args=("cat","*.c");
>>system(@sys_args);

>but always get the following error message:
>>cat: Cannot open *.c: No such file or directory

You can put your wildcard pattern directly into <> like this: while(<*.c>)
Combine that with an inner loop to do your stuff with each file and I guess you
have what you asked for.

This solves your example:
while(<*.c>) { # Get each filename matching the pattern.
   open C, $_ or die "Cannot open $_: $!\n";
   while(<C>) { # Get each line in the current file.
      print;
   }
}


Petri Oksanen



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

Date: Thu, 18 May 2000 21:04:35 +0300
From: zc <tomp@sci.fi>
Subject: How to leave socket open...
Message-Id: <392430B3.8D278E99@sci.fi>

For listening at time to time with while loop?
this while loop must no wait for connection, just check is there waiting
data.
$loc = IO::Socket::INET->new(Proto=>"tcp", LocalPort=>"1212", Listen=>1)
|| die "can't open socket 1212\n";
$remote = $loc->accept; #gets stuck here. and when breaked loses the
1212 port :(
please help.




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

Date: Thu, 18 May 2000 15:04:49 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: If slices are so great
Message-Id: <lETU4.146$6T1.21505@news.dircon.co.uk>

On Wed, 17 May 2000 21:33:20 -0700, "d" Wrote:
> oops

Eh ?

/J\


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

Date: 18 May 2000 16:55:49 GMT
From: pdf@morgan.ucs.mun.ca (Paul David Fardy)
Subject: Re: IPC: 1 to n communication
Message-Id: <8g17al$ahh$1@coranto.ucs.mun.ca>

>>>>>> "Gernot" == Gernot Homma <gernot@cat.at> writes:
>>>>>> "merlyn" == merlyn@stonehenge.com (Randal L. Schwartz) writes:

Gernot> Hello,
Gernot> i have a process that should pass some data to n other processes, which
Gernot> do something with the data. which mechanism is the best to this.

merlyn> Broadcast UDP is usually the best.
merlyn> Unless you want to maintain a separate TCP connection to each one.

I read "processes", not "hosts".  I don't believe one can broadcast
to multiple processes on the same system.  But I'm willing to learn...

I've done this before with a directory of named pipes.  Each client
needs a named pipe, so make a directory of named pipes.

	/var/project/pipes/channel1
	/var/project/pipes/channel2
	...
	/var/project/pipes/channelN

A client opens the first available channel for reading.  The server
writes to each channel that's ready to receive data.  But I'd do it
sockets now: it makes it easy to distribute the project to multiple
hosts.

Paul Fardy
-- 
Paul David Fardy             | Computing and Communications
Systems Administrator        | Memorial University of Newfoundland
e-mail: pdf@mun.ca           | St. John's, NF  A1C 5S7     CANADA


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

Date: 18 May 2000 16:38:09 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Large hash handling
Message-Id: <slrn8i873h.lb4.abigail@ucan.foad.org>

On Wed, 17 May 2000 18:36:11 -0500, Thomas Rock <thomas@x-tekcorp.com> wrote:
++ I have a very large hash (potentially 10's of millions of
++ entries) wherein each entry is a regular array reference. 
++ 
++ I was wondering a couple of things: 
++ 
++ First, is it possible for the OS (Unix or Windows) to use
++ swap space to hold part of the hash, or must it all be 
++ contained in memory?

Well, that depends on the OS, and that isn't a Perl question.

++ Second (kind of related to the first), is there a way
++ to explicitly buffer part of a hash out to a file so 
++ that it doesn't grow too large in memory?

Yes. From the dawn of time, Perl has come with an interface to dbm files,
which do exactly that.


Abigail


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

Date: Thu, 18 May 2000 09:05:40 -0700
From: joey <joe.potenzaNOjoSPAM@abacus-direct.com.invalid>
Subject: largefile awareness and perl
Message-Id: <15f8eaa0.6835d9fa@usw-ex0106-044.remarq.com>

I am trying to find out if any perl versions before 5.6.0 are largefile
(files larger than 2gig.) aware under Solaris 2.6 or 2.7. I tried to
compile 5.00503 to use largefiles using gcc version 2.7.2.3 but there
is no uselargefiles option in the config.sh and Configure reccognizies
the -Duselargefiles option but does nothing with it. I was able to
Configure and compile 5.6.0 with the -Duselargefiles and the same gcc
version compiler. Does anyone know when largefile awareness was
available to perl?  Thanks in advance.


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: 18 May 2000 16:37:09 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: largefile awareness and perl
Message-Id: <8g167l$16i$1@pegasus.csx.cam.ac.uk>

joey  <joe.potenzaNOjoSPAM@abacus-direct.com.invalid> wrote:
>I am trying to find out if any perl versions before 5.6.0 are largefile
>(files larger than 2gig.) aware under Solaris 2.6 or 2.7. I tried to
>compile 5.00503 to use largefiles using gcc version 2.7.2.3 but there
>is no uselargefiles option in the config.sh and Configure reccognizies
>the -Duselargefiles option but does nothing with it. I was able to
>Configure and compile 5.6.0 with the -Duselargefiles and the same gcc
>version compiler. Does anyone know when largefile awareness was
>available to perl?  Thanks in advance.

"uselargefiles" is new in 5.6.0.

See     perldoc perldelta        (in 5.6.0, of course)


Mike Guy


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

Date: Thu, 18 May 2000 16:47:49 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: my cgi script
Message-Id: <8g16u4$44l$1@news.mch.sbs.de>

In article <3923AF6C.70D7E0D7@pinesoft.co.uk>, Andrew McGuigan <amcguigan@pinesoft.co.uk> wrote:
>there's no question as such, unless i could say,  now i know this may sound
>simple, but i think i must be missing something here,
>You see i just need the code (perl) that collects the info on the Form and
>then writes it to a file on the server.That all. The bit i really like is
>writing a Visual Basic App to process the file.

From the CGI documentation :

SAVING THE STATE OF THE SCRIPT TO A FILE:

    $query->save(FILEHANDLE)

This will write the current state of the form to the provided filehandle.

HTH,

Michel.


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

Date: Thu, 18 May 2000 09:04:24 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: need advice on strategy...
Message-Id: <Pine.GSO.4.10.10005180901000.25459-100000@user2.teleport.com>

On Thu, 18 May 2000, webmaster wrote:

> 1) I want to be able to develop with scripting.

Use perl. :-)

> 2) it should be relatively simple to port those libraries to IIS
> and Apache out of a unique source code.

Use perl. :-)

> 3) the libraries will be distributed freely, but I would like
> to hide the code in order to enforce respect for the APIs

Use Filter::Rot13. :-)  Also, see the FAQ about hiding the source. But if
you really want to enforce something, apply the proper number of lawyers.

    http://search.cpan.org/search?dist=Filter

Cheers!

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



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

Date: Thu, 18 May 2000 15:05:08 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Object Oriented Perl Question
Message-Id: <7au2fvlx0b.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>


baccou@my-deja.com writes:

> Hi,
> 
> I have a question about Object Oriented programming using perl. My
> question is: "How do I perform a 'cast' (like in C++) to transform an
> instance in another class?".

You don't need to. Perl is not that paranoid ;-)

> Let's take an example:
> 
> I have an instance myShape of the class Shape. I want to transform this
> instance into a specialized object Circle in order to perform the method
> Circle::SetCenter(x, y).
> 
> In C++, I would write:
>   myCircle = (Circle) myShape;
>   myCircle->SetCenter(10, 10);


In Perl, you would write:

	$myShape->Circle::SetCenter(10, 10);


Easy, eh?

--Ala


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

Date: Thu, 18 May 2000 18:59:58 +0100
From: "Richard" <richard@avocation.demon.co.uk>
Subject: Perl & Frames
Message-Id: <958672996.18207.0.nnrp-09.d4e489f6@news.demon.co.uk>

I have a web page that calls a Perl script within a frame which is part of a
Frameset. When this Perl script is called it writes some HTML which I want
to become the Parent page and overwrite the Frameset.....problem is that
currently it's just re-writing in the frame!!

Can anyone suggest how I can make the HTML written by this script overwrite
the Frames and become the parent page!!

Hope that makes sense!

Thanks,

Richard

P.S. Sorry it's not a truly Perl question as such for this newsgroup.




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

Date: Thu, 18 May 2000 17:28:45 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl-5.06 Build Error
Message-Id: <hLVU4.87361$hT2.368585@news1.rdc1.ct.home.com>

bijua@my-deja.com wrote:


> Randy,

> I got the documentaiton from ur URL but failed to
> get Thread.pm
> module.

> I downloaded Perl-5.6.0 and trying to install with
> thread facility.

> but I am failing to make

> the Error is given below

> `sh  cflags libperl.a miniperlmain.o`
> miniperlmain.c
>           CCCMD =  /tools/gcc/bin/gcc -DPERL_CORE
> -c -D_HPUX_SOURCE -L/lib/pa1.1 -DUINT32_MAX_BROKEN
> -DPTHREAD_H_FIRST -I/usr/local/include -O
>         `sh  cflags libperl.a perl.o`  perl.c
>           CCCMD =  /tools/gcc/bin/gcc -DPERL_CORE
> -c -D_HPUX_SOURCE -L/lib/pa1.1 -DUINT32_MAX_BROKEN
> -DPTHREAD_H_FIRST -I/usr/local/include -O
> perl.c: In function `perl_construct':
> perl.c:169: incompatible type for argument 2 of
> `pthread_mutex_init'
> perl.c:174: incompatible type for argument 2 of
> `pthread_mutex_init'
> perl.c:175: incompatible type for argument 2 of
> `pthread_cond_init'
> perl.c:176: incompatible type for argument 2 of
> `pthread_mutex_init'
> perl.c:177: incompatible type for argument 2 of
> `pthread_cond_init'
> perl.c:179: incompatible type for argument 2 of
> `pthread_mutex_init'
> perl.c:182: incompatible type for argument 2 of
> `pthread_mutex_init'
> perl.c: In function `perl_destruct':
> perl.c:300: too few arguments to function
> `pthread_getspecific'
> perl.c:347: incompatible type for argument 1 of
> `pthread_detach'
> perl.c: In function `perl_parse':
> perl.c:802: too few arguments to function
> `pthread_getspecific'
> perl.c: In function `S_parse_body':
> perl.c:1212: incompatible type for argument 2 of
> `pthread_mutex_init'
> perl.c: In function `perl_run':
> perl.c:1307: too few arguments to function
> `pthread_getspecific'
> perl.c: In function `S_init_main_stash':
> perl.c:2400: incompatible type for argument 2 of
> `pthread_mutex_init'
> perl.c: In function `S_init_main_thread':
> perl.c:3446: incompatible type for argument 2 of
> `pthread_mutex_init'
> *** Error exit code 1


> PS:= I am able to install the same without therad
> feature ..

> Please help me out

> Regards,

> Biju A



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


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

Date: Thu, 18 May 2000 09:57:45 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: PerlIS printing out header info.
Message-Id: <Pine.GSO.4.10.10005180954290.25459-100000@user2.teleport.com>

On Thu, 18 May 2000, Steve wrote:

> It is HTTP headers put they actually print out like text on the wb
> page?  How can I hide this??

Generally, it's the web browser's job to hide the headers from the user.
So, maybe you want to fix the browser.

Of course, if there are duplicate headers being sent, the browser may (and
probably should) suppress only the first ones. So maybe it's a proxy or
server that needs fixing, in that case.

There are many sources of information on browsers, servers, and proxies;
a search engine like Yahoo can get you started. Good luck!

    http://www.yahoo.com/

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



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

Date: Thu, 18 May 2000 15:29:52 GMT
From: crtopf@sgi.net
Subject: printing output directly to a file
Message-Id: <8g128o$acr$1@nnrp1.deja.com>

I am trying to print output to a log file, and it is being printed to
the log file, but only after the perl script ends.  I have seen
documentation that says to set "$| = 1" and output will be written
immediately to a filehandle but I haven't seen that happen.  I open my
log file as follows:

open(LOG, "> $db1main/sch/dpfcst.process.log") || die ;

then I write to the log file with:

print LOG "ERROR!!  Your script failed\n" ;

I have several scripts which take hours to run through and the output
isn't written to the log file until that script ends.  I recently had a
script fail but because I didn't have anything written to the log file I
couldn't really tell where the error occured.

Thanks for any help,
Chris


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


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

Date: Thu, 18 May 2000 15:56:59 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: printing output directly to a file
Message-Id: <392412ED.7408632A@wsb.com>

Try something along these lines...

open (LOG, ">$db1main/sch/dpfcst.process.log") || die("Can't open
logfile");
select LOG;
$| = 1;
select STDOUT;

if (print LOG "Whatever...\n") {
	## IT PRINTED -- ANY OTHER PROCESSING CAN GO HERE
} else {
	## PRINT CALL FAILED -- NEED AN ERROR HANDLER
}

Setting the $| variable to 1 does indeed stop IO buffering, but you must
call it after having select()ed your open output file.

Hope this helps,
JH

crtopf@sgi.net wrote:
> 
> I am trying to print output to a log file, and it is being printed to
> the log file, but only after the perl script ends.  I have seen
> documentation that says to set "$| = 1" and output will be written
> immediately to a filehandle but I haven't seen that happen.  I open my
> log file as follows:
> 
> open(LOG, "> $db1main/sch/dpfcst.process.log") || die ;
> 
> then I write to the log file with:
> 
> print LOG "ERROR!!  Your script failed\n" ;
> 
> I have several scripts which take hours to run through and the output
> isn't written to the log file until that script ends.  I recently had a
> script fail but because I didn't have anything written to the log file I
> couldn't really tell where the error occured.
> 
> Thanks for any help,
> Chris
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

----------------------------------------------------------------
Jeff Helman                 Product Manager -- Internet Services
jhelman@wsb.com                    CCH Washington Service Bureau
----------------------------------------------------------------

99 little bugs in the code, 99 bugs in the code.
Fix one bug, compile again, 100 little bugs in the code.
100 little bugs in the code, 100 bugs in the code.
Fix one bug, compile again, 101 little bugs in the code...

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


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

Date: Thu, 18 May 2000 18:48:36 +0200
From: Saddek Rehal <saddek@arch.chalmers.se>
Subject: Problem with different Perl version
Message-Id: <39241EE3.437AEAC8@arch.chalmers.se>

Can someone tell me what is wrong with this bit of script:
$dateprg = "/apache/ActivePerl/bin/date1.exe"; #Unix date prog for Win
NT
$hdateprg = "/apache/ActivePerl/bin/hdate.exe"; # A program that convert
Gregorian date to Hijri date
$hdateout = `$hdateprg`;
$dateout = `$dateprg` ;
print "Content-type: text/plain
\n\n";
print "Today is: $dateout";
print "Today is: $hdateout";

The problem is that if I run the script with perl 5.003 the result is OK
and I get:
Today is: Thu May 18 18:28:55  2000
Today is: Thursday 13 Safar 1421 A.H.
But with Perl 5.6 I get this result:
Today is: Thu May 18 18:28:55  2000
Today is:

It seems that my program "hdate.exe" cant be called by the script under
Perl 5.6 Why this difference???
I am running Perl under Win NT.
Thank you.
--
Saddek Rehal



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

Date: 18 May 2000 17:42:38 +0100
From: nobull@mail.com
Subject: Re: re-evaluation (newbie)
Message-Id: <u9n1lnlsht.fsf@wcl-l.bham.ac.uk>

Ala Qumsieh <aqumsieh@hyperchip.com> writes:

> 	my $number = 1;
> 
> 	sub mystring { return "test$number" }
> 
> 	print mystring;
> 
> 	$number = 2;
> 
> 	print mystring;

This advice should carry a health warning.  Never do this inside a
loop  or subroutine.  It will only work the first time.  Thereafter it
will print "test2" every time.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 18 May 2000 17:39:45 +0100
From: nobull@mail.com
Subject: Re: re-evaluation (newbie)
Message-Id: <u9og63lsmm.fsf@wcl-l.bham.ac.uk>

Jesper Birkholm Marcher Hansen <crips@control.auc.dk> writes:

> How do I get the following code to print out "test2" when the variable
> $number has changed?

You don't.  Well you can, but it's one of those "if you think you want
to do that you must be doing something wrong" situations.

If you really want to do it the wrong way see where I asked the same
question as "Calling the interpolation function explicitly"
<u9hfehisxc.fsf@wcl-l.bham.ac.uk> back in March.

http://deja.com/[ST_rn=ap]/getdoc.xp?AN=594671416

> $number = 1;
> 
> $mystring = "test$number\n";
> 
> 	print $mystring;	#Prints "test1"
> 
> $number = 2;
> 	print $mystring;	#Prints "test1", but it should "test2"

One of the many right ways:

$number = 1;
 
$mycode = sub { "test$number\n" };

print &$mycode;	#Prints "test1"
 
$number = 2;
 	
print &$mycode;	#Prints "test2"

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 18 May 2000 17:57:50 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: re-evaluation (newbie)
Message-Id: <7a7lcrlp0h.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>


nobull@mail.com writes:

> Ala Qumsieh <aqumsieh@hyperchip.com> writes:
> 
> > 	my $number = 1;
> > 
> > 	sub mystring { return "test$number" }
> > 
> > 	print mystring;
> > 
> > 	$number = 2;
> > 
> > 	print mystring;
> 
> This advice should carry a health warning.  Never do this inside a
> loop  or subroutine.  It will only work the first time.  Thereafter it
> will print "test2" every time.

Not really. It depends on what you want to do. There is nothing wrong
with closures, and I think they are a very valuable tool. Plus, I don't
expect somebody to use closures unless they know exactly what they are.

In case somebody does not know what closures are:

	perldoc -q closure

--Ala


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

Date: Thu, 18 May 2000 10:17:14 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: regex mind bender (for me)
Message-Id: <MPG.138dc57786ec10ed98aa97@nntp.hpl.hp.com>

In article <8fvgmo$mvn$1@charm.magnus.acs.ohio-state.edu> on 18 May 2000 
01:23:36 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Larry Rosler 
> <lr@hpl.hp.com>],
> who wrote in article <MPG.138cb439308b6e2b98aa96@nntp.hpl.hp.com>:
> > > > and I need to check if it contains *only* spaces.
> > > > 
> > > > not empty,  but if it has 1 or more spaces and nothing else in it.
> >     ^^^^^^^^^
> > 
> >           print "yay" unless !length($var) || $var =~ /[^ ]/;
> > 
> >           print "yay" if      length($var) && $var !~ /[^ ]/;
> 
> Eh?  Why not /^ +\z/ ?

That had already been posted a few levels back in the thread.  I was 
trying to patch up the incorrect alternative offered, not rehashing the 
best solution.

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


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

Date: Thu, 18 May 2000 10:49:38 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Remove leading zero
Message-Id: <slrn8i80o2.54u.tadmc@magna.metronet.com>

On Thu, 18 May 2000 13:40:07 +0200, Koen Lesenne <koen_lesenne@inseurop.com> wrote:


>I'm new to perl.


type:

   perldoc perlre

   perldoc perlop


>I'm trying to find 
 ^^^^^^^^^^


Where have you looked?


>a way to remove one or more leading zero's of a string.
>Can someone help me with this please ?


The answer is already on your hard disk.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 16 May 2000 18:30:30 +1000
From: "chris du" <chrisd@amcorp.com.au>
Subject: Search Eng for Website
Message-Id: <8fr0v4$7pe$1@argon.syd.dav.net.au>

I am looking for a search.pl to search the txt file, that has all the link
and key words.
and it will be uses for IIS - NT.

PLease help!





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

Date: Thu, 18 May 2000 15:53:19 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Search Eng for Website
Message-Id: <39241210.B1FC708A@wsb.com>

chris du wrote:
> 
> I am looking for a search.pl to search the txt file, that has all the link
> and key words.
> and it will be uses for IIS - NT.
> 
> PLease help!

Uhhhh...I think your logic needs rethinking.  If you are using IIS, why
not just use the built-in search engine (Index Server), which is pretty
good (especially for a M$ product).  I'm betting that it will perform
much better than any pure-perl based solution that you could hack
together in any reasonable length of time.

Of course, perl can come in handy if you want to build a truly
customized front-end that does error-checking and handling, etc.  I did
this not too far back with Index Server (took about a week) and works
like a charm.

JH

----------------------------------------------------------------
Jeff Helman                 Product Manager -- Internet Services
jhelman@wsb.com                    CCH Washington Service Bureau
----------------------------------------------------------------


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

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


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