[7309] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 934 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 27 20:17:25 1997

Date: Wed, 27 Aug 97 17:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 27 Aug 1997     Volume: 8 Number: 934

Today's topics:
     "Rename-File-Names" Script Needed, Please (Mark Harrison)
     ($p=$pc) =~ s/\.[0-9]*/substr($1,3,length($1))=""/g; <rbush@btc4.up.net>
     Re: <> operator memory leak? (Mark Daku)
     Re: [Q] Awk's "s in A" Hash Test In Perl? <rootbeer@teleport.com>
     basic question <lchiriac@sarnoff.com>
     Re: complex pattern?!? it shouldn't be, i think :) <justinb@springer.cray.com>
     Re: extracting a pattern... <boutilie@ipa.net>
     Re: HELP - What is "interpretive" vs. "compiled" (Greg Bacon)
     Re: HELP! WinNT/perl cgi newbie <beadles@nortel.com>
     Re: How does Perl do flock() on non-BSD? <rootbeer@teleport.com>
     Re: How to print a html page from Perl into netscape <rootbeer@teleport.com>
     Re: How to treat "\n" as "\n" ? <packrat@ucnet.canberra.edu.au>
     Re: Is there a perl IDE? (Charlie Stross)
     Re: Is this a permissions problem Opening and reading a <jaydee@worsdall.demon.co.uk>
     Re: Is this a permissions problem Opening and reading a (Jot Powers)
     Re: Is this a permissions problem Opening and reading a <rootbeer@teleport.com>
     Re: Loop until a key is pressed? <justinb@springer.cray.com>
     Re: NO, you SHAN'T INTERPRET them no!no!no!no..no.....n <rootbeer@teleport.com>
     NT 4.0 Server ans Perl5 307 (Changuk Sohn)
     Re: Perl 4.036 <mike@stripme.fc.hp.com>
     Re: Perl and document conversion to HTML (Mike King)
     perl calling servlets <bryn@fangio.ucsc.edu>
     Re: Problem with opendir or readdir??? <rootbeer@teleport.com>
     Re: Random Numbers <rootbeer@teleport.com>
     Re: Some Assistance Please... <rootbeer@teleport.com>
     Re: timeout for getc function <rootbeer@teleport.com>
     Re: Which version of PERL is running on the server? <rootbeer@teleport.com>
     Re: Win95 + Perl back-quotes or fx(<system command>) as (Parillo)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 27 Aug 1997 16:59:02 -0500
From: mark@purple.tmn.com (Mark Harrison)
Subject: "Rename-File-Names" Script Needed, Please
Message-Id: <mark-2708971659020001@ip187.tmn.com>

My Guru Perl Friends:

I'm trying to write a quick script to rename a few thousand files in
sequential order.  Before I tax my novice skills creating a bug-filled
script, I'd like to see if this has been done before and is sitting on
someone's harddrive.

Thanks for any help!

Sie koennen auf Deutsch antworten.
On peut repondre en Francais.
Se puede contestar en Espanol.


I'm trying to rename a few thousand files in sequential order.

ie.

I have:
I want to change it to:

blah.txt   -->       00000001.txt
blub.txt       -->         00000002.txt
this.txt   -->   00000003.txt
that.txt   -->       00000004.txt
etc.txt           -->         00000005.txt


and so on...

At a later date, more files will show up, so I'd like to be able to start
at whatever number I choose.

ie.

>what number do you want to start at?
2409

>ok

blah.txt   -->       00002409.txt
blub.txt       -->         00002410.txt
this.txt   -->   00002411.txt
that.txt   -->       00002412.txt
etc.txt           -->         00002413.txt


I'll probably be running off a Windows box... I've heard there are
differences in the versions of perl.

Cheers, and thanks!

Mark Harrison
<mark@tmn.com>


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

Date: Wed, 27 Aug 1997 17:22:59 -0400
From: "Raymond K. Bush" <rbush@btc4.up.net>
Subject: ($p=$pc) =~ s/\.[0-9]*/substr($1,3,length($1))=""/g;
Message-Id: <34049AB3.132F@btc4.up.net>

i would like to do something like this to a list of random numbers and
letters of random sizes i have read in from a file.  

each line has a form like: 

sdfsd 32423.3245 erye5rye eryter 234.234311111666  12314.3543254322222
4456.111111111 4545.345345 dftgdfgdf.345rfwdcf34 234.dgfg 234 345 1.00

is this possible without using split or would splits be faster ...?

what i really wish i could do is something like:

($p=$pc) =~ s/\.[0-9][0-9]* /substr($1,3,length($1))=""/g; 

aka replace everything from 3rd place past the period to space while
recognizing on .[0-9] but not recognizing anything else

hence my lines would become:

sdfsd 32423.32 erye5rye eryter 234.234 12314.35
4456.11 4545.34 dftgdfgdf.34 234.dgfg 234 345 1.00

the problem is clear to me yet i am not sure how i would express such a
thing ....

Anybody know of a nonsplit-if suroutine to do this in a oneline
statement? 
--Ray
 .70~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~07.
      --- reply to rbush - at - up - dot - net ---
--- please include indication of past correspondence ---
      --- in order to receive a faster response ---


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

Date: 27 Aug 1997 19:29:05 -0400
From: daku@nortel.ca (Mark Daku)
Subject: Re: <> operator memory leak?
Message-Id: <esqk9h78ata.fsf@nortel.ca>

joshu@diku.dk (Gargle Zndflxtzyh) writes:

> I'm trying to write a program that's supposed to run
> for hours on end, but it globs up too much memory, and
> to begin with I thought it was a memory leak in 
> my database-driver which is fairly beta, so I decided
> to do a wrapper that restarts the program every hour.
> 
> But then another program that didnt use the database
> exhibited the same problem...And after staring at my
> code for hours to find circular references or hashes
> that aren't deleted properly and so forth I've found 
> that this short code snippet can use up all my RAM
> in quite a short while
> (and Im working on an SGI IRIX machine with 128 megs of RAM):
> 
> =====================================
> #!/usr/bin/perl
> 
> $ROOT = "/usr/local/data/";
> 
> for (;;) {
>   opendir DIR,$ROOT;
>   for (readdir DIR) {
>     open (FIL,$ROOT.$_);
>     while (<FIL>) {
>     }
>     close FIL;
>   }
>   closedir DIR;
> }
> =====================================
> 

No leak on my system:
---------------------------------------------------------------------------
Summary of my perl5 (5.0 patchlevel 4 subversion 0) configuration:
  Platform:
    osname=solaris, osvers=2.5.1, archname=sun4-solaris
    uname='sunos bcarsdea 5.5.1 generic sun4m sparc sunw,sparcstation-5 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=y useperlio= d_sfio=
  Compiler:
    cc='cc-4.0', optimize='-xO5', gccversion=
    cppflags='-I/usr/local/include -I/users/daku/local/include'
    ccflags ='-I/usr/local/include -I/users/daku/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, randbits=15
  Linker and Libraries:
    ld='cc-4.0', ldflags ='-L/usr/local/lib -L/users/daku/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib /users/daku/local/lib
    libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags=' '
    cccdlflags='-Kpic', lddlflags='-G -L/usr/local/lib -L/users/daku/local/lib'
 
 
Characteristics of this binary (from libperl): 
  Built under solaris
  Compiled at May 16 1997 14:23:30
  @INC:
    /opt/perl5/lib/sun4-solaris/5.004
    /opt/perl5/lib
    /opt/perl5/lib/site_perl/sun4-solaris
    /opt/perl5/lib/site_perl
    .


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

Date: Wed, 27 Aug 1997 14:35:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: [Q] Awk's "s in A" Hash Test In Perl?
Message-Id: <Pine.GSO.3.96.970827142923.9989I-100000@julie.teleport.com>

On 27 Aug 1997, Tom Grydeland wrote:

> Tom Phoenix <rootbeer@teleport.com> writes:
> 
> > On Wed, 27 Aug 1997, Eric Bohlman wrote:
> > > TMTOWTDI, but "defined($words{$name})" should do it.
> 
> > I prefer exists to defined, in this case. Hope this helps!
> 
> Perhaps a2p should be doctored to use exists over defined for this?

It doesn't? Maybe you're right... But I don't know awk, so I can't say
whether that's an accurate 'translation'. (That is, it may be that the awk
construct does the equivalent of defined(), so Perl should do the same.) 

Of course, the output of a2p should be manually optimized by someone who
understands the program. That person should probably know when to safely
s/defined/exists/ , but a little documentation could serve as a reminder. 

Cheers!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 17:25:55 -0400
From: Liviu Chiriac <lchiriac@sarnoff.com>
Subject: basic question
Message-Id: <34049B63.6123@sarnoff.com>

I have a cgi program written in perl, to which I pass parameters when
calling it from an HTML page like this:

"myprogram.cgi?parameter1=1+parameter2=2" ... for example.

how do I run the perl script from a terminal window passing the same
parameters?

"myprogram parameter 1 parameter2=2"  ?

Liviu


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

Date: 27 Aug 1997 18:43:30 -0500
From: Justin Banks <justinb@springer.cray.com>
To: slippy@mailexcite.com
Subject: Re: complex pattern?!? it shouldn't be, i think :)
Message-Id: <o8noh6j8a59.fsf@springer.cray.com>

jonathan.hulatt@unilever.com writes:

> hi.
> 
> I have an scalar srting with lines of an html file in. I would really
> like to chop the tags out. I've had success using split etc. but isn't
> there a pattern that would do it? I tried several ideas, but just end
> up pulling out everything from first < to the last >.
> 
> ie
> 

This program takes stdin and does what you want, perhaps you could modify
it :

#!/opt/local/bin/perl

$outfile = shift;
open OUT, ">$outfile";

while($ch = getone()) {
  if($ch eq '<') {
    while(getone() ne '>') {
	;
    }
    next;
  }
  print OUT $ch;
}
exit 0;


BEGIN {
    use POSIX qw(:termios_h);
    my($term, $otherm, $echo, $noecho, $fd_stdin);
    $fd_stdin = fileno(STDIN);
    $term = POSIX::Termios->new();
    $term->getattr($fd_stdin);
    $oterm = $term->getlflag();
    $echo = ECHO|ECHOK|ICANON;
    $noecho = $oterm & ~$echo;
    
    sub cbreak {
        $term->setlflag($noecho);
        $term->setcc(VTIME, 1);
        $term->setattr($fd_stdin, TCSANOW);
    }
    sub cooked {
        $term->setlflag($oterm);
        $term->setcc(VTIME, 0);
        $term->setattr($fd_stdin, TCSANOW);
    }
    sub getone {
        my $key = "";
        cbreak();
        sysread(STDIN, $key, 1);
        cooked();
        return $key;
    }
}

END { 
    cooked() 
};


-- 
Justin Banks      \ If you spam me, I promise to go upstream from you until I
Silicon Graphics  \ find someone that cares. Then, I'll think about charging
Eagan, Minnesota  \ you for my time. Do it at your own risk


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

Date: Wed, 27 Aug 1997 17:21:30 -0700
From: Dave Boutilier <boutilie@ipa.net>
Subject: Re: extracting a pattern...
Message-Id: <3404C48A.4A48FD28@ipa.net>


--------------E46F3C65D32DF17D70219259
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Doug Seay wrote:

> Joe Shaw wrote:
> >
> > I'm wondering if anyone could help me with a problem I'm having.  I
> need
> > to extract an IP address from a string, but there is a ton of info
> in the
> > line.  I'm thinking about just loading every character into an array
> and
> > then removing all the white space, then the letters.  This seems
> like the
> > wrong way to do it, and I'm still stuck with the problem of trying
> to
> > extract the IP address.  Anyone know of a more efficient way of
> doing it?
> >
> > an example of the lines I'm trying to get the information out of it
> > follow:
> >
> > Apr 13 15:39:08 propaghandi pppd[478]: local  IP address
> 153.36.194.204
> > Apr 13 15:39:08 propaghandi pppd[478]: remote IP address
> 207.76.48.25
>
> Doing what you say isn't enough.  Removeing letters and whitespace
> still
> leaves the pid, the time and date in addition to the ip addr that you
> want.
>
> if ( $line =~ m/(\d\d\d\.\d\d\d.\d\d\d\.\d\d\d)$/ )
>         { $ip_addr = $1; }
>
> will this do the trick?  I just looks for ddd.ddd.ddd.ddd at the end
> of
> a line.  If it finds it, the match is in $1.
>
> - doug

try this:
open FOO, "<temp.dat" || die "darn";

while (<FOO>) {
   if ( /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/o ) {
     print "ip address:", $&, "\n";
     }
   }

close FOO;

This will match the first ip address (if any) on the line, and print
it.  Doesn't require 3 digits to be present.  I've tested on the sample
data you gave.

--------------E46F3C65D32DF17D70219259
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Doug Seay wrote:
<BLOCKQUOTE TYPE=CITE>Joe Shaw wrote:
<BR>>
<BR>> I'm wondering if anyone could help me with a problem I'm having.&nbsp;
I need
<BR>> to extract an IP address from a string, but there is a ton of info
in the
<BR>> line.&nbsp; I'm thinking about just loading every character into
an array and
<BR>> then removing all the white space, then the letters.&nbsp; This seems
like the
<BR>> wrong way to do it, and I'm still stuck with the problem of trying
to
<BR>> extract the IP address.&nbsp; Anyone know of a more efficient way
of doing it?
<BR>>
<BR>> an example of the lines I'm trying to get the information out of
it
<BR>> follow:
<BR>>
<BR>> Apr 13 15:39:08 propaghandi pppd[478]: local&nbsp; IP address 153.36.194.204
<BR>> Apr 13 15:39:08 propaghandi pppd[478]: remote IP address 207.76.48.25

<P>Doing what you say isn't enough.&nbsp; Removeing letters and whitespace
still
<BR>leaves the pid, the time and date in addition to the ip addr that you
<BR>want.

<P>if ( $line =~ m/(\d\d\d\.\d\d\d.\d\d\d\.\d\d\d)$/ )
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { $ip_addr = $1; }

<P>will this do the trick?&nbsp; I just looks for ddd.ddd.ddd.ddd at the
end of
<BR>a line.&nbsp; If it finds it, the match is in $1.

<P>- doug</BLOCKQUOTE>
try this:
<BR><FONT FACE="Courier New,Courier">open FOO, "&lt;temp.dat" || die "darn";</FONT><FONT FACE="Courier New,Courier"></FONT>

<P><FONT FACE="Courier New,Courier">while (&lt;FOO>) {</FONT>
<BR><FONT FACE="Courier New,Courier">&nbsp;&nbsp; if ( /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/o
) {</FONT>
<BR><FONT FACE="Courier New,Courier">&nbsp;&nbsp;&nbsp;&nbsp; print "ip
address:", $&amp;, "\n";</FONT>
<BR><FONT FACE="Courier New,Courier">&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT FACE="Courier New,Courier">&nbsp;&nbsp; }</FONT><FONT FACE="Courier New,Courier"></FONT>

<P><FONT FACE="Courier New,Courier">close FOO;</FONT>

<P>This will match the first ip address (if any) on the line, and print
it.&nbsp; Doesn't require 3 digits to be present.&nbsp; I've tested on
the sample data you gave.</HTML>

--------------E46F3C65D32DF17D70219259--



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

Date: 27 Aug 1997 21:23:29 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Chemist Box <i@hate.spam>
Subject: Re: HELP - What is "interpretive" vs. "compiled"
Message-Id: <5u25sh$bu4$1@info.uah.edu>

[Posted and mailed]

In article <340481AD.7553@hate.spam>,
	Chemist Box <i@hate.spam> writes:
: Can someone explain to me what INTERPRETIVE vs. COMPILED Perl means?

See http://www.perl.com/CPAN/doc/FMTEYEWTK/comp-vs-interp.html

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Wed, 27 Aug 1997 17:21:38 -0500
From: "John T. Beadles" <beadles@nortel.com>
To: Marty Blase <mblase@ncsa.uiuc.edu>
Subject: Re: HELP! WinNT/perl cgi newbie
Message-Id: <3404A872.1563@nortel.com>

> > - what's the NT equivalent of sendmail, and how to I call it?
> 
> Blat 1.5 comes well-recommended for WinNT, apparently.
> (http://gepasi.dbs.aber.ac.uk/softw/Blat.html) I also found something
> called Windmail 2.0, which is basically a port of UNIX sendmail, but it's
> a commercial product. (http://www.geocel.com/windmail/)
> 

Two comments:

Blat works well as an NT command line mailer, but I've had trouble
getting it to run dynamically from perl.  Essentially, doing

$Status = `blat ######`;

would hang, though it would work from the command line.  Haven't figured
that one out yet.

Also, you still need an smtp server to relay Blat's outgoing emails. 
I've used the EMWAC IMS freeware service with great success.  You can
find it at:

http://www.emwac.ed.ac.uk/html/internet_toolchest/ims/ims.htm


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

Date: Wed, 27 Aug 1997 14:27:41 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bryan Miller <millerb@fc.hp.com>
Subject: Re: How does Perl do flock() on non-BSD?
Message-Id: <Pine.GSO.3.96.970827142553.9989H-100000@julie.teleport.com>

On 27 Aug 1997, Bryan Miller wrote:

> I have noticed that all my Perl scripts that abuse flock()
> seem to work just fine on systems that don't natively support
> flock() such as SysV.  I suspect that Perl must map flock()
> to fcntl().  Does anyone know how this is done?

Yes; it tries to provide a machine-independent way to flock. Additional
details are found in the source. :-)  (But you don't really need to know
anything more just to _use_ it, AFAIK.) Hope this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 15:39:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Pascal AMRAM <pascal_amram@ml.com>
Subject: Re: How to print a html page from Perl into netscape
Message-Id: <Pine.GSO.3.96.970827153839.9989U-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Pascal AMRAM wrote:

> Do you know if meta tag in netscape exist to do this ?

It's possible. Why don't you check with the docs, FAQs, and newsgroups
about Netscape? Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 27 Aug 1997 22:58:07 GMT
From: "Alex Satrapa" <packrat@ucnet.canberra.edu.au>
Subject: Re: How to treat "\n" as "\n" ?
Message-Id: <01bcb33c$791ec2c0$c845a8c0@tanya.camelot.net.au>



Charles DeRykus <ced@bcstec.ca.boeing.com> wrote in article
<EF324A.MM@bcstec.ca.boeing.com>...
> In article <5snkqs$lj3$1@news.cs.tu-berlin.de>,
> Thomas Bahls <thommy@cs.tu-berlin.de> wrote:
>  > How can I do this?

>  > 		$a= 'This is the first line.\n"Nope!"';
>  > 		print $a

> Here're a couple of possibilities:
> 
>   print do { $a=~s/\\n/\n/; $a};

Or howabout
	$a = 'This is the first line.' . "\n" . "Yes!";
or even just
	$a = "This is the first line.\nYes!";

Or am I missing something really important?
-Alex


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

Date: Wed, 27 Aug 1997 23:15:19 +0100
From: charlie@nospam.antipope.mapson.org (Charlie Stross)
Subject: Re: Is there a perl IDE?
Message-Id: <slrn6099nn.ld.charlie@SPAMBLOCKED>


Brian Wheeler<bdwheele@indiana.edu> wrote 
(in article <5tevoa$mec$1@dismay.ucs.indiana.edu>):
>
>	You forgot the "one true editor": emacs.  It has a perl mode which
>indents for you and will flash matching parens/brackets/braces.

Apropos which: anyone know how to turn indenting off in cperl-mode? I
HATE HATE HATE having some idiot editor decide how to indent my code
for me!


-- Charlie

-- 
"Many computer scientists have fallen into the trap of trying to define
languages like George Orwell's Newspeak, in which it is impossible to
think bad thoughts. What they end up doing is killing the creativity
of programming." -- Larry Wall

>> To reply: remove NOSPAM and anagrams, or see http://www.antipope.org/ <<


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

Date: Wed, 27 Aug 1997 22:16:17 +0100
From: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: Re: Is this a permissions problem Opening and reading a URL
Message-Id: <pkxGeIAhkJB0Ew2i@worsdall.demon.co.uk>

People have being telling me to use the or Die stuff, no problem. But
how would one implement that in an if condition as below?

        if (open (TRACE, "$traceprog $surfer|")) {
                while (<TRACE>) {
                        print MAIL;
                }
                close TRACE;
        }


-- 
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydee@worsdall.demon.co.uk  WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmaster@shadow.org.uk    WEB site:- http://www.shadow.org.uk


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

Date: 27 Aug 1997 21:48:30 GMT
From: news@bofh.com (Jot Powers)
Subject: Re: Is this a permissions problem Opening and reading a URL
Message-Id: <5u27be$2ce$1@gazette.corp.medtronic.com>

In article <pkxGeIAhkJB0Ew2i@worsdall.demon.co.uk>, Mark Worsdall wrote:
>People have being telling me to use the or Die stuff, no problem. But
>how would one implement that in an if condition as below?
>
>        if (open (TRACE, "$traceprog $surfer|")) {
>                while (<TRACE>) {
>                        print MAIL;
>                }
>                close TRACE;
>        }

What have you tried?

FWIW:

  DB<2> if (open(BOB,'/etc/passwd') or die "Gack! $!\n") { print "Bob.\n";}
Bob.
 
  DB<3> close(BOB) or die "$!\n";

-Jot

-- 
Jot Powers  news@bofh.com
Unix System Administrator
"Sometimes you just have to grab the bull by the tail and face the situation."


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

Date: Wed, 27 Aug 1997 15:49:19 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: Re: Is this a permissions problem Opening and reading a URL
Message-Id: <Pine.GSO.3.96.970827154804.9989W-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Mark Worsdall wrote:

> People have being telling me to use the or Die stuff, no problem. But
> how would one implement that in an if condition as below?
> 
>         if (open (TRACE, "$traceprog $surfer|")) {
>                 while (<TRACE>) {
>                         print MAIL;
>                 }
>                 close TRACE;
>         }

    unless (open(WHATEVER, "somepipe|")) {
	die "fork error...";
    }
    while ...

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 27 Aug 1997 18:26:41 -0500
From: Justin Banks <justinb@springer.cray.com>
Subject: Re: Loop until a key is pressed?
Message-Id: <o8npvqz8axa.fsf@springer.cray.com>

"Espen Bjarnx" <espen.bjarno@myres.no> writes:

>  All,
> 
> I'm trying to make a script that dump some information until a key is
> pressed.
> Ie. the key 'q' is pressed for quit aso. (It works with CTRL-C but.. :-))
> 
> How?
> 

See the Camel book page 474 - it may be of some use.

-- 
Justin Banks      \ If you spam me, I promise to go upstream from you until I
Silicon Graphics  \ find someone that cares. Then, I'll think about charging
Eagan, Minnesota  \ you for my time. Do it at your own risk


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

Date: Wed, 27 Aug 1997 14:25:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Markus Moll <markus.moll@off1.siemens.de>
Subject: Re: NO, you SHAN'T INTERPRET them no!no!no!no..no.....nooo.....
Message-Id: <Pine.GSO.3.96.970827141430.9989G-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Markus Moll wrote:

> I want my Perlscript not to interpret the backslashes,dollar chars etc.

Do you mean Perlscript or Perl? And do you mean that you want certain
characters to have special meanings, or not?

>     >  $here =~ s/\$(\w+)/${$1}/g;

> Actually, this works great with all those $.  But I don't manage to get
> the same with \ ! 

No, that's much harder.

> $text =~ s/\\(\w+)/\{$1}/g But for any reason this doesn't work ! 

It's not that easy. Somebody is going to tell you to use eval (or some /e
trickery). That's easy, but it's not very safe. The better way was posted
here by Mike Heins a little while ago, in which you search for meaningful
backslash (or other) escapes and interpolated them as needed. And that
_still_ doesn't let you do magic like \Q and \u - for that, you'll have to
actually parse the string. You may be able to use this information on your
favorite Usenet archive to track down the article.

Subject:      Re: How to treat "\n" as "\n" ?
From:         mheins@prairienet.org (Mike Heins)
Date:         1997/08/12
Message-Id:   <5spn5j$gou$1@vixen.cso.uiuc.edu>
Newsgroups:   comp.lang.perl.misc

Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 27 Aug 97 23:16:18 GMT
From: csohn@cgocable.net (Changuk Sohn)
Subject: NT 4.0 Server ans Perl5 307
Message-Id: <3404b542.0@news.cgocable.net>

Hello, People?
I'm having problem with Perl and NT.
Since, When I installed Perl5, my computer's CPU and MEM usage goes crazy 
(100%)
Please help me....
 



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

Date: Wed, 27 Aug 1997 17:05:33 -0600
From: Mike McNelly <mike@stripme.fc.hp.com>
Subject: Re: Perl 4.036
Message-Id: <3404B2BD.75DC@stripme.fc.hp.com>

smeyyappan@pyrasol.com wrote:
> 
> Hi,
> I am trying to load Perl 4.036 in HP B.10.20 9000/803
> I got a couple of warnings when I did a make.
> 
> cc: "perl.h", line 1032: warning 533: Inconsistent type declaration for
> function "time".
> 
> cc: yylex(): warning 6062: Optdriver: Exceeding compiler resource limits
> in yylex; some optimizations skipped.  Use +Onolimit if override desired.
> 
> But it did install perl.  Is it ok if we go head and use the perl or do I
> have to make any changes and try to install it again.
> 
> Thanks.
> Saradha Meyyappan
> 
The first warning has to do with the definition of type time_t. Various
implementations of unix do it differently. On HP-UX, the compiler is
giving you a warning but the types are compatible anyway so there is
no real problem.

The second warning is just a memo to you that the optimizer has exceeded
its preset limits of internal resources needed to do an optimization.
If you "really" want that optimization, recompile as it suggests.
Otherwise, the compiler just falls back to a lower level of optimization
for that file and continues. The code it generates is still correct.
In most cases, you won't be able to tell the difference in generated
code quality anyway.

BTW, you could do yourself a favor and get a newer version of Perl
than 4.036. It's been obsoleted for a couple of years now.  Perl 5.004
is out. It's compatible in all essentials and it has a lot more
functionality.

Speaking only for myself,
Mike McNelly
mike@stripme.fc.hp.com


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

Date: Wed, 27 Aug 1997 23:14:20 GMT
From: m.king@praxa.com.garbage.au (Mike King)
Subject: Re: Perl and document conversion to HTML
Message-Id: <3404b49f.582215741@news.ozemail.com.au>

On Wed, 27 Aug 1997 16:24:13 GMT, xyzmats@laplaza.org (Mats Wichmann)
wrote:

>
>>The file format for Word documents is proprietary. Microsoft does not
>>publish it. It also tends to change with each new version of Word. 
>
>Somehow, every other wordprocessor on the face of the earth manages to
>produce Word import and export filters.  How proprietary can it be?

That makes sense, so what does one have to do to be on the 'inside'
here ?

===== Spam Filter:
===== You can email me at the following address after putting out the trash ...
garbage.m.king@praxa.com.garbage.au


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

Date: Wed, 27 Aug 1997 12:55:47 -0700
From: Bryn Weiser <bryn@fangio.ucsc.edu>
Subject: perl calling servlets
Message-Id: <34048643.119F@fangio.ucsc.edu>

Is it possible to call a java servlet from a perl script?
If a servlet returns a string that I need and is refered to by:
http://eno:8080/servlet/SnoopServlet/foo/bar?a=z
then how can I set a variable in a perl script with this string.
I can do this with a java applet by opening an URLConnection
do a POST and then do a read back, so I'm wondering if anyone
knows how to do this with perl.
thanks for any help.
Bryn Weiser


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

Date: Wed, 27 Aug 1997 14:43:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: IGOREK <IGOREK@prodigy.net>
Subject: Re: Problem with opendir or readdir???
Message-Id: <Pine.GSO.3.96.970827144230.9989K-100000@julie.teleport.com>

On 27 Aug 1997, IGOREK wrote:

> opendir(DIR,"/home/igor/manhat/new/")  || die "Can't open$name";

> foreach $entry (@sorted) {

>   if (-r $entry) {

-r doesn't know that you're talking about files in another directory - it
thinks you're looking in the current one, since you haven't told it
otherwise. (readdir doesn't give you any path stuff, just the bare name.)
Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 15:47:02 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: dt king <dtking@weblabs.com>
Subject: Re: Random Numbers
Message-Id: <Pine.GSO.3.96.970827154012.9989V-100000@julie.teleport.com>

On Wed, 27 Aug 1997, dt king wrote:

> I'm doing a slot machine that needs me to draw three random numbers in a
> row.  The first random number is fine,

That's good...

> the second seems sluggish 

How can a number be sluggish? :-)

> and the third gives me long runs of the same number. 

How can that be? You must not be using (a properly configured) rand()
function, or maybe I'm seriously misunderstanding you.

Of course, modern slot machines don't choose how to spin the "wheels" at
random. Instead, they first randomly choose the payoff, then choose some
(more-or-less random) configuration of the wheels which gives that payoff
- or, more often, a non-winner which was ever-so-close. The same goes for
scratch-off lottery tickets, which explains why it's so frequent to get
BAR-BAR-PLUM-BAR. "I was soooo close! Next time, maybe I'll get it. I'd
better try this game again!" :-) 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 14:49:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tadd Bryan <tbryan@ghz.com>
Subject: Re: Some Assistance Please...
Message-Id: <Pine.GSO.3.96.970827144447.9989L-100000@julie.teleport.com>

On 27 Aug 1997, Tadd Bryan wrote:

> I need to know how to put " inside a print statement.

No problem: You just put that mark inside the string you want to print.
:-)

    print 'I have "quote marks"';

Of course, if you want that string to be delimited by double quote marks,
that's trickier. In that case, you could just backwhack the mark, to make
it unspecial.

    print "I've got \"quote marks\"\n";

That can be hard to read. So I prefer to use flexible qq// quoting, which
allows all of the magic of double quotes, but lets me choose my own
punctuation mark. (Choose one which doesn't appear in the string, of
course! :-)

    print qq{I've got "quote marks", _and_ I'm easier to read!\n};

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 14:52:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ted Pavlic <tpavlic@netwalk.com>
Subject: Re: timeout for getc function
Message-Id: <Pine.GSO.3.96.970827145104.9989M-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Ted Pavlic wrote:

> Does anyone know how to tell getc to either:
> 
> a) Timeout if no data is received after a certain time

yessss... But you'd probably be better off (with current versions of Perl,
at least) by using the four-argument form of select to see whether or not
input is ready. Documented, of course, in the perlfunc(1) manpage. Hope
this helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 27 Aug 1997 14:41:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: bob@cafemedia.com
Subject: Re: Which version of PERL is running on the server?
Message-Id: <Pine.GSO.3.96.970827143705.9989J-100000@julie.teleport.com>

On Wed, 27 Aug 1997, Bob Maillet wrote:

> How would I go about finding which version of PERL is running on a unix
> server?

Ask the webmaster. :-)  If you can run the same Perl binary from the
command line, you can use the -v (or -V) option to ask it what version it
is. If you can install CGI scripts which it will run, you can use this
quick-and-dirty script.

    #!/usr/bin/perl
    print "Content-type: text/plain\n\nPerl version $] on $^O\n";

But the best way is to ask the webmaster. And if the answer is anything
before 5.004, scream "Your data are on fire! Upgrade! Upgrade! Now!" :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 27 Aug 1997 21:52:52 GMT
From: lparillo@newshost.li.net (Parillo)
Subject: Re: Win95 + Perl back-quotes or fx(<system command>) assignment not working.
Message-Id: <5u27jk$hlr$1@news01.li.net>

I am on build 306 and when I execute:
  @term = `dir`;
  $i = 0;
  while ($i < 10) {
    $i = $i + 1;
    print $i, " ", $term[$i];
  }
I get:
C:\TEMP>perl -w foo.pl2
1  Volume in drive C is PW_GTC
2  Volume Serial Number is 3381-A956
3  Directory of C:\TEMP
4
5 .              <DIR>        05-14-97  5:46p .
6 ..             <DIR>        05-14-97  5:46p ..
7 BONUS    EXE         9,511  06-17-97  7:59a bonus.exe
8 BAANQUIZ PL2        10,507  06-18-97  7:37a baanquiz.pl2
9 MAR96HCL DOC       475,121  03-04-96  9:14a MAR96HCL.DOC
10 BAANREQ  PL2         9,074  06-18-97  7:37a baanreq.pl2

As a generalization, I would suggest that using Perl functions
(search for readdir in perlfunc) will be more portable than
using OS commands.

lparillo at suffolk dot lib dot ny dot us


Alten Limited (alten@dial.pipex.com) wrote:
: I've downloaded Perl 5 (build 307) from ActiveWare and installed it on
: the Windows 95 machine I'm using (for my sins).

: My problem is that in the statement:

: @catch_variable = `dir`;

: or:

: @catch_variable = fx(dir);

: the yield of the command (dir) is sent to screen instead of being placed
: in @catch_variable as expected.

: I had the same problem with build 110, infact that's where I discovered
: the problem, since the test.bat supplied with this build makes extensive
: use of back-quotes.  So I'm suprised if no one's come across the problem
: before ... unless there's something wierd with the incarnation of Win95
: that I have.

: I've searched all the doc's and FAQa that I can find.  The only mention
: of what look like similar Win95/Perl problems are concerning 'system
: escapes', perportedly fixed by Cmd32.exe which I have installed.

: Any ideas or help on this problem'd be much appreciated.

: Ian Ashton-Reader
: -- 
: Alten Ltd, Linton House
: 164/180 Union Street - Waterloo		Tel: 0171 401 8222
: London SE1 OLH - United Kingdom		Fax: 0171 401 3553
: alten@dial.pipex.com & http://dialspace.dial.pipex.com/alten



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

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

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