[16368] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3780 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 23 14:05:27 2000

Date: Sun, 23 Jul 2000 11:05:14 -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: <964375514-v9-i3780@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 23 Jul 2000     Volume: 9 Number: 3780

Today's topics:
    Re: <newbie>How to determine current location (pwd) in  (Joe Smith)
    Re: CGI.pm Cookies and images together <Connected@btinternet.com>
    Re: DB_FILE  --> recovery?  HELP <gellyfish@gellyfish.com>
    Re: DB_FILE  --> recovery?  HELP <jcorso@charm.net>
    Re: Determining File Size with FTP (Colin Keith)
    Re: How to detect when an output file is removed <bernie@fantasyfarm.com>
    Re: How to loop like this - for(a000 ... x999) ??? <thoren@southern-division.com>
    Re: How to loop like this - for(a000 ... x999) ??? <rhys.tucker@dtn.ntl.com>
    Re: How to loop like this - for(a000 ... x999) ??? (M.J.T. Guy)
    Re: How to loop like this - for(a000 ... x999) ??? (Keith Calvert Ivey)
    Re: I print localtime and get seconds. Great!  But in m (Joe Smith)
    Re: IO:Socket and Timeout => "5" ? <gellyfish@gellyfish.com>
    Re: Length of TTF string in pixels? (Colin Keith)
    Re: Length of TTF string in pixels? (Marc Lehmann)
    Re: looking to learn perl (Colin Keith)
    Re: looking to learn perl <jbc@west.net>
        LWP UserAgent yaacovs@my-deja.com
    Re: LWP UserAgent (Decklin Foster)
    Re: LWP UserAgent <tony_curtis32@yahoo.com>
    Re: MySQL sample code? <jbc@west.net>
    Re: NFS Client in perl? (Colin Keith)
        Perl 5.* <Dwarf3@casema.net>
    Re: Perl 5.* (Colin Keith)
    Re: perl v. tcl (Eric Bohlman)
    Re: perl v. tcl <mo@nospam.com>
    Re: perl v. tcl <kuchler@ajubasolutions.com>
    Re: perl v. tcl (David N. Welton)
        Q:Converting Perl script to Win32 dll file <jari@subspace.nu>
    Re: Question on Reversing the contents of an array.. <uri@sysarch.com>
    Re: Question on Reversing the contents of an array.. <gellyfish@gellyfish.com>
    Re: Questions on GD PERL module... (Colin Keith)
    Re: Read a file into a hash ? (M.J.T. Guy)
        Setting $/ from variable - accepting meta characters kjeldahl@hotmail.com
    Re: Setting $/ from variable - accepting meta character aqutiv@my-deja.com
    Re: Some security questions? <care227@attglobal.net>
    Re: Strange behavior in do while loops in perl 5.00503 (Joe Smith)
    Re: uninitialized variable value? (M.J.T. Guy)
    Re: Writing to a file error : Pt 2 (Colin Keith)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 23 Jul 2000 14:56:50 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: <newbie>How to determine current location (pwd) in CGI script?</newbie>
Message-Id: <8lf13i$2nh0$1@nntp1.ba.best.com>

In article <39634692.1385362445@news.itn.is>,
Helgi Briem <helgi@NOSPAMdecode.is> wrote:
>On 5 Jul 2000 04:55:34 GMT, "Colin Reinhardt"
><colinrei@oz.net> wrote:
>
>>I need to dynamically set a path for a Location: redirect in my Perl script.
>>I'd like to do something like this...
>>
>>print "Location: ", get_current_path(), "/index2.html\n\n";
>>
>use Cwd;
>my $current_path = cwd;

That answers the poster's question, but what the poster is trying to do
won't work.  The current path is not a valid URL.  The contents of
the "Location:" header has to be a virtual (valid to the web server)
directory name, not a real directory name.
	-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Sun, 23 Jul 2000 18:46:50 +0100
From: Jerry Pank <Connected@btinternet.com>
Subject: Re: CGI.pm Cookies and images together
Message-Id: <ywa$nUAK+ye5EwJB@btinternet.com>

In article <slrn8njpca.2pa.efflandt@efflandt.xnet.com>, David Efflandt
<efflandt@xnet.com> writes
>On Sat, 22 Jul 2000 15:08:30 +0100, Jerry Pank <Connected@btinternet.com> wrote:
>>I am trying to use CGI.pm to return an image *and* drop a cookie at the
>>same time and am nearly there, but not quite!
>>
>>eg:
>>
>>Calling document:
>>
>>..<body><img src='cookie.pl height='10' width='20'>..
>>
>>CGI part of script 
>>
>>sub return_img {
>>   my $image  = &get_image;
>>   my $cookie = &test_data;   
>>   print header('-type' => 'image/gif',
>>                '-cookie' => $cookie),
>>                  $image;
>>}
>>
>>The above returns the image, but only drops the cookie once the image
>>source is viewed from the browser.  Not quite what I want!
>
>What are you attempting to read the cookie with.  You certainly could not
>read it from the same page that has the <img src> tag, because the cookie
>does not exist until after that <img src> is loaded.  But if you set the
>path correctly in the cookie, any subsequent page should have it.
>

I have not even tried to read the cookie because I don't get the browser
`leaving a cookie` warning unless I actually try to right click and read
the source of the image. 
-- j :wq


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

Date: 23 Jul 2000 18:39:12 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: DB_FILE  --> recovery?  HELP
Message-Id: <8lfak0$b2r$1@orpheus.gellyfish.com>

In comp.lang.perl.misc Jason J Corso <jcorso@charm.net> wrote:
> I have a DB_File interfaced database that has become corrupted!!!!
> 
> How do I recover it?
> 

Probably from the backup tapes that you have regularly made right ...

;-}

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 23 Jul 2000 13:01:28 -0400
From: "Jason J Corso" <jcorso@charm.net>
Subject: Re: DB_FILE  --> recovery?  HELP
Message-Id: <snm8tiptjjt30@corp.supernews.com>

Yes from the backup tapes...which is what I resorted to...

But I have read about logging and checkpoint functionality that is bulit
into the Berkeley DB System.  However, I cannot find any documentation
pertaining to using this logging and checkpoint functionality via the Perl
DB_File interface...so as to prevent the need to revert back to  back-up
tapes and instead use built-in recovery functionality via the checkpoint
system...

Know how to use the logging and checkpoint?

thanks again!
jason


Jonathan Stowe wrote in message <8lfak0$b2r$1@orpheus.gellyfish.com>...
>In comp.lang.perl.misc Jason J Corso <jcorso@charm.net> wrote:
>> I have a DB_File interfaced database that has become corrupted!!!!
>>
>> How do I recover it?
>>
>
>Probably from the backup tapes that you have regularly made right ...
>
>;-}
>
>/J\
>--
>yapc::Europe in assocation with the Institute Of Contemporary Arts
>   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>




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

Date: Sun, 23 Jul 2000 13:51:47 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: Determining File Size with FTP
Message-Id: <TLCe5.7$DT4.1220257@nnrp2.clara.net>

In article <vWqe5.50068$3E6.488959@news1.alsv1.occa.home.com>, "Larry Kite" <lorenzo@wwa.com> wrote:
>But if $file was, for example, ftp://domain.com/directory/paper.ps.gz, this
>would not work. It seems that one must:
>    1) parse the URL for the ftp server name, the directory name and the
>file name
>    2) use Net::FTP to login, change directory, get a dir listing, and 
parse
>the listing to get the file size.

"DESCRIPTION
       Net::FTP is a class implementing a simple FTP client in"
I think the word *simple* should be underlined. Its only a few more lines 
than the example you gave to do what you want though:


maia% perl -w -Mstrict -MNet::FTP

$_ = 'ftp://username:password@ftp.clara.net/win95/00index.txt';
die "Invalid format"   
if(!m!^ftp://(([^:]+):([^@]+)@)?([a-zA-Z0-9.-]+)(:(\d))?(/.+)$!);

my($ftp) = Net::FTP->new($4, Port=>$5||21) || die "Failed to connect";
$ftp->login($2||'anonymous', $3|| 'user@localhost') || die "Login Failed";
$ftp->binary();
print "Size of $7: ", $ftp->size($7), "\n";
$ftp->quit();

Note that, as the docs say size() maybe 'incorrect' because of binary/ascii 
EOL character sequences, hence the binary() method call.

>If there is not already a module that performs this function, is there one
>that reliably parses URLs for directory and file name information (it
>doesn't seem that URI::URL does this)? I have already written some code to
>parse the directory listing if I have to.
>
>Thanks very much, in advance, for your help.
>
>Larry Kite
>lorenzo@wwa.com


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 23 Jul 2000 10:15:24 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: How to detect when an output file is removed
Message-Id: <12vlns8i9olfquna0d3hb8u3cn1qkg507o@news.supernews.net>

mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:

} Drew Simonis  <care227@attglobal.net> wrote:
} >timhood@bigfoot.com wrote:
} >> 
} >> I have a process that writes output to a log file. It seems though that
} >> if someone removes the logfile after the program redirects the output
} >> that all future output goes to nowhere-land.
} 
} In the Unix world, you're at liberty to delete a file even though it
} is currently open.    Or more strictly, you can delete a link to a file
} (directory entry).    The file itself isn't deleted;   rather it will
} go away when the last handle to it disappears (in this case, when
} the program closes the file).

And that's why many programs, for which the loss of log data is potentially
a problem, close and re-open the log file with each entry -- a bit more
overhead but unless your program has gone _wild_ making log entries it
shouldn't be that severe, and it does ensure that your log entries will
make it to an (at least temporarily) visible file.  As a rule, IMO,
programs that hold their log files open for the entire run of the program
are bad-Unix-citizens... it just makes life too difficult [e.g, you can't
"roll" the logs or snapshot them or anything if the program has glommed
onto the file].  At the least, if you must do this, you really ought to
provide a signal that'll force your program to close and reopen the log
file.

A Unix trick: this is a standard hack for making "for sure cleaned up" temp
files.  What you do is open a temp file, then 'unlink' it --- if you opened
it "+<" you can move around in it and read and write and generally use it
for a scratch pad or anything you need it for.. and then when your process
goes away...poof.. the file does too.  No muss,no fuss, no cleanup, no bugs
or abort or signal problems leaving [potentially sensitive] temp info
around.

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Sun, 23 Jul 2000 14:59:42 +0200
From: "Thoren Johne" <thoren@southern-division.com>
Subject: Re: How to loop like this - for(a000 ... x999) ???
Message-Id: <8leqpi$srq$12$1@news.t-online.com>

rhys <rhys.tucker@dtn.ntl.com> wrote in message
news:397AE1F5.B7F65F63@dtn.ntl.com...
> I'm trying to produce numbers in this sort of format [a-z]\d{3}. I've
> tried all sorts of notation to achieve this, even printf, without
> success as yet. There must be a straightforward way to do it.

#!/usr/local/bin/perl -w
use strict;

for my $char ( 'a'..'z' ) {
    printf "%s%03u\n", $char, $_ for 0..999;
}

gruß
thoren
8#X

--
----------------------------------------------------------------------
Thoren Johne - 8#X - thoren@southern-division.com
Southern Division Classic Bikes - www.southern-division.com




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

Date: Sun, 23 Jul 2000 15:13:28 +0000
From: rhys <rhys.tucker@dtn.ntl.com>
Subject: Re: How to loop like this - for(a000 ... x999) ???
Message-Id: <397B0B98.7D4F0EEC@dtn.ntl.com>

Thanks for everyone's help. This one is the most efficient yet
(according to time -v).

rhys


Nnickee wrote:
> 
> On Sun, 23 Jul 2000 12:15:49 +0000, someone claiming to be rhys
> <rhys.tucker@dtn.ntl.com> said:
> 
> >I'm trying to produce numbers in this sort of format [a-z]\d{3}. I've
> >tried all sorts of notation to achieve this, even printf, without
> >success as yet. There must be a straightforward way to do it.
> 
> This isn't very elegant (and I'm sure the Gurus will give you much
> more elegant ways of doing it, but it didn't produce any warnings for
> me... :)
> 
> @ALPH = ('a'...'x');
> @NUMS = ('000'...'999');
> foreach $alph (@ALPH) {
>         foreach $num (@NUMS) {
>                 print "$alph$num\n";
>         }
> }
> 
> HTH
> Nnickee


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

Date: 23 Jul 2000 14:48:32 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: How to loop like this - for(a000 ... x999) ???
Message-Id: <8lf0k0$4pl$1@pegasus.csx.cam.ac.uk>

rhys  <rhys.tucker@dtn.ntl.com> wrote:
>I'm trying to produce numbers in this sort of format [a-z]\d{3}. I've
>tried all sorts of notation to achieve this, even printf, without
>success as yet. There must be a straightforward way to do it.
>
>thanks,
>rhys

You almost had it in your Subject: .

Magic autoincrement is what you want:

	perl -wle 'print for "a000".."z999"'


Mike Guy


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

Date: Sun, 23 Jul 2000 15:12:46 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: How to loop like this - for(a000 ... x999) ???
Message-Id: <397b0aef.120854370@news.newsguy.com>

rhys <rhys.tucker@dtn.ntl.com> wrote:

>I'm trying to produce numbers in this sort of format [a-z]\d{3}. I've
>tried all sorts of notation to achieve this, even printf, without
>success as yet. There must be a straightforward way to do it.

perl -le "print for 'a000' .. 'x999'"

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: 23 Jul 2000 13:55:12 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: I print localtime and get seconds. Great!  But in my script, seconds convert to DMDTY
Message-Id: <8letg0$2isk$1@nntp1.ba.best.com>

In article <A9CB10141E703D04.D27A4EE0A7723E42.89DA4C81570F478B@lp.airnews.net>,
Ariel Lia <Ariellia@garden.com> wrote:
>If you notice, I even insert localtime into the $seccs variable...but my 
>results are lacking.

FYI: Using <<DELIMITER is an easier way of producing a string with quotes.

>$replace = '<!--begin--><FONT face="times new roman" size="3" 
>color="white" edittag="' . $name1. '">
><edittag name=$name2 type="Area" Prompt="Paste or Type Next Status Report 
>below' .  $name2 .'" pos=top>
><pre><h3>Header</h3>Paragraphs here</pre></EDITTAG></font><!--end-->
><!--replace-->';

Can be written as
 
  $replace = <<EOM
<!--begin--><FONT face="times new roman" size="3" 
color="white" edittag="$name1">
<edittag name="$name2" type="Area" Prompt="Paste or Type Next Status Report 
below: $name2" pos=top>
<pre><h3>Header</h3>Paragraphs here</pre></EDITTAG></font><!--end-->
<!--replace-->
EOM

	-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: 23 Jul 2000 18:36:13 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: IO:Socket and Timeout => "5" ?
Message-Id: <8lfaed$b2n$1@orpheus.gellyfish.com>

On Sat, 22 Jul 2000 22:10:41 GMT Coy wrote:
> 
> Not sure why noone knew this or replied..
> works fine know.
> 

Its highly possible that in the five hours between your two posts your
original article hadn't propagated to all of the servers that it might have,
and consequently hadn't been read by all of the people that might have 
answered you.  Then again your question might simply have not been 
interesting to people.  Here, on Usenet, patience really is a virtue.  If
you want instant gratification you can chance your arm on IRC, if you want
consistent reliable solutions to your problems hire a consultant or get
a support contract.

On the other hand your original problem was already answered in previous
posts to this group and could have been find with judicious searching at
Deja News ...

Oh well, glad you sorted it out in the end.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 23 Jul 2000 16:25:42 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: Length of TTF string in pixels?
Message-Id: <a0Fe5.12$DT4.1238129@nnrp2.clara.net>

In article <3979216C.4F4B02A6@att.net>, "Henry E. Thorpe" <henry.thorpe@att.net> wrote:
>Can anyone provide any pointer to where I might look for example code in
>Perl, C, or Java?

http://www.wotsit.org/search.asp?page=4&s=windows
Look in the TTF section.

Sorry its not perl. If you find out, turn it into a module and post it to 
CPAN (Think of the fame, glory and praise:)

Hope it helps.
Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 23 Jul 2000 19:51:36 +0200
From: root@plan9.de (Marc Lehmann)
Subject: Re: Length of TTF string in pixels?
Message-Id: <slrn8nmc5i.g9q.root@cerebro.laendle>

On Sat, 22 Jul 2000 04:23:18 GMT, Henry E. Thorpe <henry.thorpe@att.net> wrote:
>figure out how many pixels wide a particular text string will be when
>
>a single Web-ish true-type font in 11pts), how can I determine the 

You cannot calculate a pixel size from the pointsize, as this depends
entirely on the configuration at the destination machine. You'd need to
know the height in pixels.

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg@opengroup.org |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |


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

Date: Sun, 23 Jul 2000 15:02:53 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: looking to learn perl
Message-Id: <xODe5.9$DT4.1228119@nnrp2.clara.net>

In article <8ld4kk$p1u$1@nnrp1.deja.com>, sopmac@my-deja.com wrote:
>Any one know where to learn perl, free

http://www.perl.com/

Look at the documentation section. Read the perl man pages in sequence.
If you're after tutorials, click the drop down menu and go to tutorials.

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 23 Jul 2000 10:49:41 -0700
From: John Callender <jbc@west.net>
Subject: Re: looking to learn perl
Message-Id: <397B3035.68509CA8@west.net>

Greg Alton wrote:
> 
> sopmac@my-deja.com wrote in message <8ld4kk$p1u$1@nnrp1.deja.com>...
> >Any one know where to learn perl, free
>
> I recommend Learning Perl by Randal L. Schwartz and Tom Christiansen.
> (Almost free!) http://www.oreilly.com .You'll find that both authors are
> actively involved in this and other perl newsgroups as well as the above
> sites.

Unfortunately, Tom C. is no longer actively involved in this
newsgroup, nor does he seem to be doing much Usenetting at all,
at least within the limits of my ability to hunt down his
writings. I asked him at TPC if there was any chance of his
coming back here, and the answer was pretty much, "No, not ever."

On a brighter note, when I asked about the extent of his
contribution to the 3rd edition of the Camel, he told me that
roughly 80% of the new material was his. So I've been reading
that, and getting my Tom fix that way.

John


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

Date: Sun, 23 Jul 2000 14:41:42 GMT
From: yaacovs@my-deja.com
Subject: LWP UserAgent
Message-Id: <8lf077$up4$1@nnrp1.deja.com>

Hi,

I am using the LWP::USERAGENT with HTTP::Request and I seem to be
having problems with frames.

Is there any way I can support the use of frames?

All I get is the main frame, without the wanted page.

Please E-mail to:

yaacovs@icsavings.com

Thank You in Advance.

Yaacov S.


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


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

Date: 23 Jul 2000 15:33:51 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: LWP UserAgent
Message-Id: <8lf38v$4cjhm$1@ID-10059.news.cis.dfn.de>

yaacovs@my-deja.com <yaacovs@my-deja.com> writes:

> All I get is the main frame, without the wanted page.

So request the page you want, instead of the page containing the
frameset.

-- 
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)


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

Date: 23 Jul 2000 11:36:15 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: LWP UserAgent
Message-Id: <87vgxwst1c.fsf@limey.hpcc.uh.edu>

>> On Sun, 23 Jul 2000 14:41:42 GMT,
>> yaacovs@my-deja.com said:

> Hi, I am using the LWP::USERAGENT with HTTP::Request and
> I seem to be having problems with frames.
> Is there any way I can support the use of frames?
> All I get is the main frame, without the wanted page.

Either GET the sub-document you want explicitly, or use an
HTML Parser, e.g. HTML::TokeParser, to retrieve the
frameset and then extract and follow the links to the
document you want.

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Sun, 23 Jul 2000 10:53:52 -0700
From: John Callender <jbc@west.net>
Subject: Re: MySQL sample code?
Message-Id: <397B3130.1A8BF61C@west.net>

brian d foy wrote:
> 
> In article <397A2BA6.4E64031A@my-deja.com>, Makarand Kulkarni <makarand_kulkarni@my-deja.com> posted:
> 
> > get this book
> > MySQL and mSQL (Nutshell Series)
> >                      by Randy Jay Yarger, George Reese, Tim King
> 
> that book has too many errors and omissions to be useful to a newbie.
> i hear that the New Riders book is much better though.

I was pretty close to an SQL (to say nothing of MySQL) newbie a
year ago, and found one part of the Yarger/Reese/King book very
useful: the chapter that explains database design and
normalization. Other than that, I did not get much out of it, and
found the New Riders book to be much more useful. But both books
combined were less important to my education than the DBI and
MySQL documentation.

John


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

Date: Sun, 23 Jul 2000 13:14:30 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: NFS Client in perl?
Message-Id: <WcCe5.6$DT4.1215495@nnrp2.clara.net>



In article <8lbrtr$rcb$1@orpheus.gellyfish.com>, Jonathan Stowe 
<gellyfish@gellyfish.com> wrote:
>On 20 Jul 2000 17:30:39 -0700 Greg Andrews wrote:
>> Otis Gospodnetic <otis@my-deja.com> writes:
>>>
>>>I need to be able to check whether a remote NFS server is up and
>>>whether the local machine has certain partitions from that NFS server
>>>mounted.
>>>Is there no perl NFS module or something such?

Why do you need a complete implementation of NFS?
open(PROC, "/usr/sbin/showmount $host|");
open(DF, "/usr/bin/df|");

should return the information you need ... 

or maybe just try mounting the nfs you want if isn't already

$ENV{PATH} = '/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:';
use Shell;
$SIG{ALRM} = sub { die "TIMEOUT";};
eval {
  alarm(4);
  mount('fileserver.domain.com:/path') if(!-e '/mnt/afile');
  alarm(0);
};
die "Timedout mounting the NFS" if($@ =~ /TIMEOUT/);
 

improving is left as an exercise to the reader.

>There is of course PerlFS - not that I would recommend it to my friends ;-}
*beep* Loading kernel ... perl.exe .. starting perlOS 1.1
:) :)

>/J\
Col.




---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 23 Jul 2000 15:49:32 +0200
From: "Roderik Hamers" <Dwarf3@casema.net>
Subject: Perl 5.*
Message-Id: <397afb96$0$6098@reader2>

Does someone know where a can download a Perl complitation program?

Roderik




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

Date: Sun, 23 Jul 2000 16:19:30 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: Perl 5.*
Message-Id: <mWEe5.11$DT4.1237384@nnrp2.clara.net>

In article <397afb96$0$6098@reader2>, "Roderik Hamers" <Dwarf3@casema.net> wrote:
>Does someone know where a can download a Perl complitation program?

Er.. Do you mean a program to produce stand alone executables from perl 
scripts, or a program that executes scripts?

1) See perlfaq3 "How can I compile my Perl program into byte code or C"
<http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html>

2) You have it, its called /usr/bin/perl, or c:\bin\perl.exe
(change as appropriate for your O/S)

>Roderik


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: 23 Jul 2000 13:20:08 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: perl v. tcl
Message-Id: <8lere8$ok$4@slb0.atl.mindspring.net>

sjfromm@my-deja.com wrote:
: I'm looking for a scripting language to automate simple tasks, such as
: asking a user for a few parameters, then running some binary files on
: some data and logging what was done, etc.; or providing nice wrappers
: for some UNIX commands.
: 
: What are the pros/cons of tcl vs. perl?  Right now, I'm using C, which

For the types of tasks you're looking at, the decision is going to be 
determined almost entirely by the amount of expertise in the two 
languages that you have access to, not by language features themselves.  
If you're going to be doing all the work yourself, go with whichever 
language gives you the best gut feel.  If others are going to be doing or 
maintaining the work, go with whichever language the most people are 
familiar with.

Again, the tasks you're looking at will use only a tiny fraction of 
either language's power, and there are *very* unlikely to be significant 
differences in efficiency; in fact the only aspects of efficiency that 
are even likely to be of concern are development time and maintainability.



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

Date: Sun, 23 Jul 2000 09:53:56 -0700
From: Mo <mo@nospam.com>
Subject: Re: perl v. tcl
Message-Id: <397B2324.A087C3F3@nospam.com>

Eric Bohlman wrote:
> 
> sjfromm@my-deja.com wrote:
> : I'm looking for a scripting language to automate simple tasks, such as
> : asking a user for a few parameters, then running some binary files on
> : some data and logging what was done, etc.; or providing nice wrappers
> : for some UNIX commands.
> :
> : What are the pros/cons of tcl vs. perl?  Right now, I'm using C, which
> 
> For the types of tasks you're looking at, the decision is going to be
> determined almost entirely by the amount of expertise in the two
> languages that you have access to, not by language features themselves.
> If you're going to be doing all the work yourself, go with whichever
> language gives you the best gut feel.  If others are going to be doing or
> maintaining the work, go with whichever language the most people are
> familiar with.
> 
> Again, the tasks you're looking at will use only a tiny fraction of
> either language's power, and there are *very* unlikely to be significant
> differences in efficiency; in fact the only aspects of efficiency that
> are even likely to be of concern are development time and maintainability.

Eric speaks the truth.

I would suggest that you try out both languages and see which one you
like the best. People will always suggest that you try the language that
they like the best, but the truth is that Perl/Tcl/Python provide
the same features in a slightly different way. I like Tcl, but I am
sure I could do all my scripting in Perl of Python if I felt like it.
The best thing about scripting is that it is not C :)

Mo DeJong
Red Hat Inc


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

Date: Sun, 23 Jul 2000 03:39:21 -0700
From: Dan Kuchler <kuchler@ajubasolutions.com>
To: sjfromm@my-deja.com
Subject: Re: perl v. tcl
Message-Id: <397ACB59.38A21BAF@ajubasolutions.com>

sjfromm@my-deja.com wrote:
> 
> I'm looking for a scripting language to automate simple tasks, such as
> asking a user for a few parameters, then running some binary files on
> some data and logging what was done, etc.; or providing nice wrappers
> for some UNIX commands.
> 
> What are the pros/cons of tcl vs. perl?  Right now, I'm using C, which
> needless to say isn't right for this job.  Some people I know wrote
> such scripts in csh, but the dogma is that csh should be avoided for
> scripting.  sh would appear attractive, but its syntax is a little too
> idiosyncratic for my taste; and my impression (very shallow, I'll
> admit) is that perl and tcl facilities for list manipulation are a
> little bit easier to learn than sh's.
> 
> I'm also interested in a reference about the different scripting
> languages (sh, tcl, perl, etc) that compares their syntax and merits.

tcl, perl, and python should all suit your needs.

As far as syntax goes, if you have a good bookstore (or library) near
by
that you can take a look at the O'reilly book "Learning Perl" or the
book "Practical Programming in Tcl/Tk" third edition by Brent Welch
they should give you a pretty good feel for what the syntax looks like
for Perl and Tcl/Tk.

If you intend to use a GUI to gather the user information, I would
suggest
tcl/tk because I prefer the tk syntax in tcl than the perl/tk syntax,
but that is just a personal preference.

Good Luck with whatever language you choose.

--Dan


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

Date: 23 Jul 2000 19:44:13 +0200
From: davidw@linuxcare.com (David N. Welton)
Subject: Re: perl v. tcl
Message-Id: <877lachhci.fsf@eugene.prosa.it>

Dan Kuchler <kuchler@ajubasolutions.com> writes:

> tcl, perl, and python should all suit your needs.

blatant plug:

        You could use elastiC, too: www.elasticworld.org

buzzword compliancy: object oriented, real garbage collection,
closures, C like syntax, small core extended with modules.  The author
is a fan of smalltalk, scheme, and python, and it shows:-)

Ciao,
-- 
David N. Welton, Responsabile Progetti Open Source, Linuxcare Italia spa
tel +39.049.8043411 fax +39.049.8043412 cel +39.348.2879508
davidw@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.


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

Date: Sun, 23 Jul 2000 19:40:23 +0300
From: Tk <jari@subspace.nu>
Subject: Q:Converting Perl script to Win32 dll file
Message-Id: <397B1FF7.F08F3A2E@subspace.nu>

Are there any mechanism to convert perl file to as windows  DLL file

perl2exe will convert the perl scripts to executable binary file .. But
I would like to know how to make dll files from my Perl scripts ?

- Jari




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

Date: Sun, 23 Jul 2000 15:55:19 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Question on Reversing the contents of an array..
Message-Id: <x73dl0c048.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> DS wrote:
  >> @raw = <DAT>; @raw = reverse(@raw);

  BL> Or:

  BL> 	@raw = reverse <DAT>;

if that is what is really wanted then File::ReadBackwards will use less
memory for large files.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 23 Jul 2000 14:46:30 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Question on Reversing the contents of an array..
Message-Id: <8lesvm$ake$1@orpheus.gellyfish.com>

On Sun, 23 Jul 2000 04:57:07 GMT DS wrote:
> Hello all-
>    I have a question on reversing the contents of an array. What I am trying
> to do is read a data file and then print the last line of the data file
> first. I think I may be using this "reverse" comand totally wrong but it
> sounds like what I needed. This is what I have so far:
> 

Others have pointed out your misundertanding of 'reverse' but you might
also be interested in Uri's module File::ReadBackward - available from CPAN.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 23 Jul 2000 14:43:15 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: Questions on GD PERL module...
Message-Id: <7wDe5.8$DT4.1225003@nnrp2.clara.net>

In article <SFke5.148$wn.2732@typhoon.san.rr.com>, "Rusty Williamson" <rwilliamson@uno.gers.com> wrote:
>Hi,
>
>I'm kind of new at this and I'm not sure what the problem is.  I'm trying 
> to install an older version of GD version 1.18 on PERL 5.004 and I'm 

Ahh, wanting GIF's. You do know that they're copyrighted/IP Compypeeps which 
is why GD moved to using PNG?

>    gcc -c  -I/usr/local/include -O2     -DVERSION=\"1.18\"  
-DXS_VERSION=\"
>1.18\" -fpic -I/usr/local/lib/perl5/AViiON-dgux/5.00404/CORE  GD.c
>GD.c: In function `XS_GD_constant':
>GD.c:213: `PL_na' undeclared (first use this function)

PL_na is defined in XSUB.h so I assume that the directory the compiler is  
looking in, /usr/local/lib/perl5/AViiON-dgux/5.00404/CORE/XSUB.h, is 
incorrect or missing the header files.

It looks for mine in /usr/local/lib/perl5/5.00502/i386-freebsd/CORE so is 
that AViiON-dgux directory correct?

Col.



---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: 23 Jul 2000 14:41:18 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Read a file into a hash ?
Message-Id: <8lf06e$4cn$1@pegasus.csx.cam.ac.uk>

In article <8leq0u$2e8e$1@nntp1.ba.best.com>, Joe Smith <inwap@best.com> wrote:
>In article <MPG.13dd297feb3984b098abda@nntp.hpl.hp.com>,
>Larry Rosler  <lr@hpl.hp.com> wrote:
>>
>>Closing a file opened for reading is pointless, unless another process 
>>or later in this process intends to access it.
>
>Closing a file opened for reading is good programming, otherwise you
>could run out of available file descriptors.
>
>I'm willing to give Larry the benefit of doubt.  I believe he meant
>"Checking the return value from close() on a file opened for reading is
>pointless".  

But that is a silly thing to say as well.    If you don't check
the return from close(), you will end up ignoring I/O errors.
Hardly good programming practice.

Always check the return from *all* system calls.


Mike Guy


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

Date: Sun, 23 Jul 2000 13:25:13 GMT
From: kjeldahl@hotmail.com
Subject: Setting $/ from variable - accepting meta characters
Message-Id: <8lerno$rtf$1@nnrp1.deja.com>

Ok, I've read the faqs about interpolating variables in strings. I've
searched through usenet using many different combinations of keywords,
but no success.

Basically, what I want to do is to set the $/ (input record separator)
from a variable that gets passed through a cgi script. Sounds easy
enough? Well, I have had no success so far.

I have an input field, where I want to accept meta characters such as \n
and \t, but also normal characters. If I type the "\n" string in my
input field, how can I assign the interpolated value of that string to
$/?

I have tried different ways, even using eval's but so far no success.

Any suggestions?

In case you need some code, try this:

my $sep = '\n';
$/ = $sep;
print "[$/]\n";

Replacing the initial assignment to $sep with "\n" will work of course,
but then my strings will not be visible in the web form input fields.

I am able to get it to work by using s/\\n/\n/sg , but this forces me to
list all the metacharacters explicitely. I can also think of a way of
using a more generic s/// translation which evaluates whatever it finds,
but I am hoping there is a better way.

Any suggestions are appreciated.

Marius


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


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

Date: Sun, 23 Jul 2000 17:41:44 GMT
From: aqutiv@my-deja.com
Subject: Re: Setting $/ from variable - accepting meta characters
Message-Id: <8lfaoo$5rj$1@nnrp1.deja.com>

In article <8lerno$rtf$1@nnrp1.deja.com>,
  kjeldahl@hotmail.com wrote:
> Ok, I've read the faqs about interpolating variables in strings. I've
> searched through usenet using many different combinations of keywords,
> but no success.
>
> Basically, what I want to do is to set the $/ (input record separator)
> from a variable that gets passed through a cgi script. Sounds easy
> enough? Well, I have had no success so far.
>
> I have an input field, where I want to accept meta characters such as
\n
> and \t, but also normal characters. If I type the "\n" string in my
> input field, how can I assign the interpolated value of that string to
> $/?
>
> I have tried different ways, even using eval's but so far no success.
>
> Any suggestions?
>
> In case you need some code, try this:
>
> my $sep = '\n';
> $/ = $sep;
> print "[$/]\n";
>
> Replacing the initial assignment to $sep with "\n" will work of
course,
> but then my strings will not be visible in the web form input fields.
>
> I am able to get it to work by using s/\\n/\n/sg , but this forces me
to
> list all the metacharacters explicitely. I can also think of a way of
> using a more generic s/// translation which evaluates whatever it
finds,
> but I am hoping there is a better way.
>
> Any suggestions are appreciated.
>
> Marius
>

This has to work:
my $sep = '\n';
$sep = eval qq("$sep");
$/ = $sep;
print "[$/]\n";


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


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

Date: Sun, 23 Jul 2000 09:40:44 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Some security questions?
Message-Id: <397AF5DC.E910A@attglobal.net>

Tad McClellan wrote:
> 
> On Sat, 22 Jul 2000 21:22:16 -0400, Drew Simonis <care227@attglobal.net> wrote:
> 
> >Open should not use the default
> >syntax when opening for reading. Example:
> >
> >open FILE, "$filename" or die "can't open: $!";
> 
> I sure hope that isn't _really_ the "default".
> 
>    open FILE, $filename or die "can't open: $!";
> 
> Useless quotes are..., well, useless.
> 
> ( I feel better now  :-)
> 

Hi Tad.
What I meant with default was not specifying an <, >, >>, or | when 
opening the file.  Your suggestion on sysopen, however, is a better 
option alltogether.


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

Date: 23 Jul 2000 15:17:07 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Strange behavior in do while loops in perl 5.00503
Message-Id: <8lf29j$2p4k$1@nntp1.ba.best.com>

In article <8k5jm6$9a$1@news.bayarea.net>,
Mark Allen <mallen@nospam.tuxtops.com> wrote:
>>> } while ( $foo < 1 or $foo > 3 or $foo ne "C" );
>> You conditional is wrong. It should be:
>> 	} while $foo ne 'C' and $foo < 1 or $foo > 3;
>> or
>> 	} until $foo eq 'C' or $foo > 0 and $foo < 4;
>> Note also that the above will generate a warning under -w when you type
>> in a letter since, if it's not 'C', the script will attempt to treat it
>> as a number.
>
>Thanks for the help. When I replaced "or" with "and" it works.  I'm trying
>to wrap my head around this and understand it.   I know why "and" works
>and why "or" doesn't; but it still seems odd to me. 

Did you notice that if $foo="C", then the expression $foo < 1 is true?
Non-numeric strings are equal to 0, which is less than 1.
	-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: 23 Jul 2000 14:23:52 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: uninitialized variable value?
Message-Id: <8lev5o$3lp$1@pegasus.csx.cam.ac.uk>

Abigail <abigail@foad.org> wrote:
>M.J.T. Guy (mjtg@cus.cam.ac.uk) wrote on MMDXVII September MCMXCIII in
><URL:news:8lc8nj$6ir$1@pegasus.csx.cam.ac.uk>:
>() Abigail <abigail@foad.org> wrote:
>() >
>() >Here's one way to test it:
>() >
>() >    eval 'local $^W = 1; "$certain_variable"';
>() >    if ($@ =~ /^Use of uninitialized value in string/) {
>() >        # Value is unitialized
>() >    }
>() 
>() Eh?   What are you expecting to see in $@ ?
>
>Did you try?

Yes, I did.    And it generates a message to STDERR and doesn't set $@.


Mike Guy


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

Date: Sun, 23 Jul 2000 15:58:32 GMT
From: ckeith@clara.net (Colin Keith)
Subject: Re: Writing to a file error : Pt 2
Message-Id: <ICEe5.10$DT4.1235076@nnrp2.clara.net>

In article <dMne5.30242$aS.233901@telenews.teleline.es>, "Colin Larcombe" <colin_larcombe@hotmail.com> wrote:
>Thanks for all your hints and tips. Have now got it working except for
>
>when I try to include  the path
>
>e.g.
>#!/usr/local/bin/perl
># Put all the bonds into an array, except the first two lines
>$filepath="/usr/users/larcombe/";
>$isinname="moody_bnd_upd.txt\n";
>$accept="acceptable.txt";
>$notaccept="notaccept.txt";
>
>open(ACCEPT,">$filepath"."$accept") || die "Cannot open $filepath$accept to
>write to";
>or
>open(ACCEPT,">$filepath"+"$accept") || die "Cannot open $filepath$accept to

*blink* Urm, don't you need to use operator overloading to use a + to 
concatenate scalar values, not numerically add their values?

>fail with the die
Which of the *two* ? :p

>open(ACCEPT,">$accept") || die "Cannot open $filepath$accept to write to";
>and writes a file in the /usr/users/larcombe directory.

Presumably because that's where you're running it from? Writing to "file" is 
perfectly acceptable and just writes to the current working directory. That 
said it is bad practice and not one you should allow yourself to fall into 
the habit of using.

>Any suggestions
Which one dies? The second should because you're numerically adding 
non-numbers. You would find out more details if you ran the program with 
a) -w, 
b) use strict 
c) included the reason for failure in the die: die "can't open .. $!" 

perseus% perl -w -Mstrict
my($a, $b) = ('xxx', 'ddd');
print $a+$b;

Argument "ddd" isn't numeric in add at - line 2.
Argument "xxx" isn't numeric in add at - line 2.
0

The first gives me no problems, but:
open(ACCEPT, ">$filepath/$accept");  # drop the trailing / first though
open(ACCEPT, (">$filepath". $accept)); 

(though I've never encountered perl requiring precedence to be forced like 
this)

>Colin L


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

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


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