[10715] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4314 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 28 16:07:26 1998

Date: Sat, 28 Nov 98 13:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 28 Nov 1998     Volume: 8 Number: 4314

Today's topics:
    Re: about upgrading perl version (5.001-->5.005_02) <rootbeer@teleport.com>
        Crypt command <crewsys@nbnet.nb.ca>
    Re: Crypt command (brian d foy)
    Re: Crypt command <crewsys@nbnet.nb.ca>
    Re: Crypt command <crewsys@nbnet.nb.ca>
    Re: Easily searchable database format <rootbeer@teleport.com>
    Re: Easily searchable database format <gellyfish@btinternet.com>
    Re: File diff <r28629@email.sps.mot.com>
    Re: File Too Big? (Andrew M. Langmead)
    Re: Globbing don't work <gellyfish@btinternet.com>
    Re: HELP/QUES: regexp and strings <rootbeer@teleport.com>
    Re: Hiding "To:" field (Tad McClellan)
    Re: html vs. cgi via perl (brian d foy)
    Re: list processes <rootbeer@teleport.com>
    Re: localtime () - perl's  bug ? (Larry Rosler)
    Re: locking files in Perl <tchrist@mox.perl.com>
    Re: locking files <r28629@email.sps.mot.com>
        Newbie question conc. file operations <ruedas@geophysik.uni-frankfurt.de>
    Re: Newbie question conc. file operations <rick.delaney@shaw.wave.ca>
    Re: Newbie question conc. file operations <rootbeer@teleport.com>
    Re: Newbie: Need to split comma-delimited data into sca <r28629@email.sps.mot.com>
    Re: Perl compiler? <tchrist@mox.perl.com>
    Re: perlwin32(5.005_02) causes a page violation error u <rootbeer@teleport.com>
    Re: quote & print confusion <gellyfish@btinternet.com>
    Re: rename() on NT <gellyfish@btinternet.com>
    Re: Security: Overwriting directory file when removing  <rootbeer@teleport.com>
    Re: sysread / need help w/ single byte I/O, urgent!  pl <rootbeer@teleport.com>
    Re: Training wheels for Perl (brian d foy)
    Re: variable interpolation inside a hash <tchrist@mox.perl.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 28 Nov 1998 19:16:11 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: about upgrading perl version (5.001-->5.005_02)
Message-Id: <Pine.GSO.4.02A.9811281112260.15581-100000@user2.teleport.com>

On Fri, 27 Nov 1998, b333727 wrote:

> I have followed the instruction of "build and install guide for perl
> 5",but it doesn't work.
> 
> Would anyone tell me how to upgrade my perl 5 step by step
> briefly.

If you mean the INSTALL document from the perl source when you say "build
and install guide for perl 5", then you should try again to do what that
says. If you can be more specific about what "doesn't work", maybe someone
could help you more. Good luck!

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



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

Date: Sat, 28 Nov 1998 15:15:44 -0400
From: "Bryan Duchesne" <crewsys@nbnet.nb.ca>
Subject: Crypt command
Message-Id: <73pi46$gtc$1@garnet.nbnet.nb.ca>

I have used the crypt command in Perl but am at a loss as to where the
associated command to decrypt something is located.  I have pored throught
just about every available piece of documentation without success.

I want to be able to decrypt using the same seed that was used to encrypt a
password but because of this limitation, I cannot.

Can anyone give me a sane reason as to why there is not decrypt command or
if there is such a creature in Perl, what on earth is it called?

Bryan




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

Date: Sat, 28 Nov 1998 14:39:21 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Crypt command
Message-Id: <comdog-ya02408000R2811981439210001@news.panix.com>

In article <73pim7$fnv$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com (Tom Christiansen) posted:

> In comp.lang.perl.misc, 
>     "Bryan Duchesne" <crewsys@nbnet.nb.ca> writes:

> :associated command to decrypt something is located.  I have pored throught
>                                                              poured

if you are going to flame for spelling, you should check the
dictionary to make sure you know how to spell it.  he used the
correct word.  you did not.

but all of this is rather petty, don't you think?

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sat, 28 Nov 1998 15:38:56 -0400
From: "Bryan Duchesne" <crewsys@nbnet.nb.ca>
Subject: Re: Crypt command
Message-Id: <73pjfk$hsd$1@garnet.nbnet.nb.ca>

Brian..  What is the answer?  I didn't ask for a spell check.....

brian d foy wrote in message ...
>In article <73pim7$fnv$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com (Tom
Christiansen) posted:
>
>> In comp.lang.perl.misc,
>>     "Bryan Duchesne" <crewsys@nbnet.nb.ca> writes:
>
>> :associated command to decrypt something is located.  I have pored
throught
>>                                                              poured
>
>if you are going to flame for spelling, you should check the
>dictionary to make sure you know how to spell it.  he used the
>correct word.  you did not.
>
>but all of this is rather petty, don't you think?
>
>--
>brian d foy                                  <comdog@computerdog.com>
>CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>




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

Date: Sat, 28 Nov 1998 15:38:27 -0400
From: "Bryan Duchesne" <crewsys@nbnet.nb.ca>
Subject: Re: Crypt command
Message-Id: <73pjen$hs1$1@garnet.nbnet.nb.ca>

I still don't know the answer.   Tom, you indicate that there is a UNIX
crypt command and it is bidirectional.  What is the complement to "crypt"
and how does one use both of these in Perl?

Bryan
Tom Christiansen wrote in message <73pim7$fnv$1@csnews.cs.colorado.edu>...
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc,
>    "Bryan Duchesne" <crewsys@nbnet.nb.ca> writes:
>:I have used the crypt command in Perl but am at a loss as to where the
>        function, not command
>:associated command to decrypt something is located.  I have pored throught
>      poured
>:just about every available piece of documentation without success.
>
>That's because it's not really an encryption as you're thinking of that
>word.  It's a one-way hashing.  Hashing cannot be unambigiously reversed.
>Perhaps you're thinking of the Unix crypt command (yes, that one
>is a command) accessible from the shell, which is bidirectional.
>
>There's a big difference between crypt(3) and crypt(1).
>
>--tom
>--
>Personally, I don't care whether someone is cool enough to quote Doug
>Gwyn--I only care whether Doug Gwyn is cool enough to quote. --Larry Wall




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

Date: Sat, 28 Nov 1998 19:44:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Easily searchable database format
Message-Id: <Pine.GSO.4.02A.9811281142210.15581-100000@user2.teleport.com>

On Sat, 28 Nov 1998, Tim Hicks wrote:

> My real question at the moment is, what format should I create my db
> in?

Some format that you can conveniently read, write, search, and maintain.
If you're using Perl, there's probably a module which will help. But other
than that, there's nothing Perl-specific here; maybe you should check out
the docs, FAQs, and newsgroups about databases and related issues. Good
luck!

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



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

Date: 28 Nov 1998 19:19:18 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Easily searchable database format
Message-Id: <73pibm$15k$1@gellyfish.btinternet.com>

On Sat, 28 Nov 1998 13:49:22 -0000 Tim Hicks <tim.hicks@lineone.net> wrote:
> I am quite new to perl (so go easy on me), but have read through 'Learning
> Perl' (once).  I would like to setup a simple database file that is then
> searchable with a perl script.  I hope that the end result will work from a
> web page, but that is a way off at the moment.
> My real question at the moment is, what format should I create my db in?  I
> am sure that the file will be some sort of simple text file, but how should
> I separate the entries?  The entire database shouldn't contain more than
> about 200 or so entries, if this makes any difference to your response.
> 

With the number of records then a flat text file should be adequate.  You
would probebly want to delimit the fields with some character that is the
most appropriate to your data (that is it is unlikely to be in your data - I
tend to use the solidus '|' in these cases).

The searching of the data is at its simplest trivial:


Follows is a cut down version of an actual program (it was actually a CGI
program and I have removed all the CGI specific stuff :)


#!/usr/bin/perl -w

$PhoneBook="/DOS/develop/phone/phoneboo.txt";

if($name = shift @ARGV)
  {
   if(open(PHONE,$PhoneBook))
    {
      $Found = 0;
      while(<PHONE>)
         {
          s/\cM//g; # i only need this because of my data
          chomp;
          my ($Person,$Title,$Number,$Room,$Department) = split(",",$_);
          if ($Person =~ /$name/i)
            {
             print $Person,"\t";
             print $Title,"\t";
             print $Department,"\t";
             print $Number,"\n";
             $Found++;
            }
         }
      unless( $Found )
        {
          print "No Entries Found\n";
        }
   }
  else
   {
    print STDERR "Cannot read telephone directory - $!\n";
   }
 }
else
 {
    print STDERR "No search specified\n";
 }


The data in this case is a comma separated file of telephone book details
(the order of data is apparent from the split).  The commented substitution
is to do with the fact that the data file sits on a DOS partition on this
machine.

I make no apologies for the rendering of the variable names - this is from
a very old program - you might however read the perlstyle manpage to find
out what would be considered wrong with them.


/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Sat, 28 Nov 1998 12:59:57 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Thomas Schachner <Thomas.Schachner@awd.at>
Subject: Re: File diff
Message-Id: <36603A13.C0BCD674@email.sps.mot.com>

[posted to c.l.pm and copy emailed]

Thomas Schachner wrote:
> 
> I need to compare a Logfile against a file which is the correct master.
> If  Logfile =! master than a error mail is sent.
> How can i compare to files if they are equeal?
> 
> Thanx Thomas

You may use Unix's diff of the standard library File::Compare. Naturally, the
standard lib should be more portable.

Out of curiaosity, I try to compare the performance between File::Compare and
Unix's diff command. The result seem to favour the Perl module.

#--------------------------------------
#1/use/local/bin/perl

use Benchmark;
use File::Compare;

$file1 = 'a';     # this is a 1.8k-size text file
$file2 = 'b';     # same as 'a'

timethese(100, {
		compare => sub {
			$i = 1 unless compare($file1, $file2)
		},
		diff => sub {
			$j = 1 unless system('diff', $file1, $file2) 
		},
	}
);
#--------------------------------------
Benchmark: timing 100 iterations of compare, diff...
   compare:  1 wallclock secs ( 0.22 usr +  0.24 sys =  0.46 CPU)
      diff: 10 wallclock secs ( 0.04 usr  0.36 sys +  1.36 cusr  6.66 csys = 
0.00 CPU)
#--------------------------------------

HTH.

-TK


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

Date: Sat, 28 Nov 1998 18:22:24 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: File Too Big?
Message-Id: <F359pC.H6y@world.std.com>

"Amber Hayes" <sharone@kcnet.com> writes:

>  It works great on approx 5MB of text
>files but my client has 2GB of text data and the script is timing out.

Perl don't "just time out", it either performs its instructions or
returns some sort of diagnostic. Some built in functions have some
type of maximum time that the will take before the return an error,
but you should be able to know when that happens. 

Web browsers on the other hand do "time out" when HTTP servers don't
respond in time. HTTP servers sometime don't respond in time when they
are running a program that takes too long. So the question probably
is, why is your program taking too long. The best way of doing that is
to use either the perl debugger or the perl profiler. 

>Should I tell him to punt and get a real relational database, 

Not necessarily, does their data need relational modeling? Or just
faster than linear access?

>try rewriting the script in C or C++, 

Probably not.

>or is my Perl code just inefficient?  

Very likely. 

But its hard to tell for sure.

If you are linearly searching through the file, a file 400 times
bigger will take much longer to search through than the smaller one.
You could keep your text file and build indexes for it. You might be
able to use one of the DBM modules the come with perl. You might be
able to build, find or purchase all sorts fo things that can handle
your data, but you have to figure out what sort of handling your data
needs.

-- 
Andrew Langmead


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

Date: 28 Nov 1998 18:31:02 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Globbing don't work
Message-Id: <73pfh6$12h$1@gellyfish.btinternet.com>

On 28 Nov 1998 07:18:27 GMT CHOU KEI HONG <kelvinee@net1.hkbu.edu.hk> wrote:
> hi all,
> 
> I have tried writing a script to count the no. of files with extension .pic
> with a directory.
> It works fine when invoke locally from a dos prompt (perl test.pl).
> But when I invoke this script as a CGI, it was found that the script can't
> report the no. of files and always is zero.
> 

Whilst the code that Larry is absolutely right you might find that nonetheless
it will not work.  This is because of the rights given to the user that the
HTTP server runs as (usually IUSR_<servername>) it is probable that this
user does not have the right to the directories you are interested in.

Alternatively it could be that if the d: drive is a network drive then
the user does not have permission to access network resources (it doesnt
by default)  If you need to map a network drive from within a Win32 Perl
application then you will need to use the Win32::NetResource module.

You might find it more helpful to ask on a newsgroup concerned with NT
servers if you need information about configuring users on your system.


/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Sat, 28 Nov 1998 19:23:46 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: HELP/QUES: regexp and strings
Message-Id: <Pine.GSO.4.02A.9811281123010.15581-100000@user2.teleport.com>

On Fri, 27 Nov 1998, Andrew Collington wrote:

> The only problem is that I'm reading lines from an HTML file, and
> whereas I'd like to wrap that tag around any text, I don't want it
> going inside any tags already in the line,

So, you need to parse the HTML. Try HTML::Parser from CPAN. Hope this
helps!

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



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

Date: Sat, 28 Nov 1998 08:14:44 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Hiding "To:" field
Message-Id: <kg0p37.6ug.ln@flash.net>

brian d foy (comdog@computerdog.com) wrote:
: In article <365CAB84.561E4D2E@viper.net>, Todd Smith <tbsmith@viper.net> posted:

: > brian d foy wrote:
: > 
: > > In article <3659F287.3025@digi-q.com>, alex@digi-q.com posted:
: > >
: > > > Does anybody know if it's possible to hide "To:" field when sending a
: > > > message through mailprog?
: > >
: > > how is the message going to know where to go?  perhaps you have a
: > > different question with more context though.  it would belong in
: > 
: > wouldn't?

: your right.  that's what i meant.  yeah, that's the ticket ;)
  ^^^^

   you're?

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


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

Date: Sat, 28 Nov 1998 13:33:15 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: html vs. cgi via perl
Message-Id: <comdog-ya02408000R2811981333150001@news.panix.com>

In article <73p53d$pu$1@gellyfish.btinternet.com>, Jonathan Stowe <gellyfish@btinternet.com> posted:

> On Sat, 28 Nov 1998 03:28:02 +0100 Mike <mike@lovetalk.de> wrote:
> > Does anyone have any idea on how to ping a cgi-script ?? (not just the 
> > ip)
> > 

there's an article in a Perl Journal sometime in the last year
that describes a web server torture tester.  it's probably what
you would like to do.

> > I would like to write a script that compares html vs. cgi response times 
> > on a server.....

or you could just use LWP and Benchmark.

> Of course this not a reasonable comparison in most cases because of the
> different nature of the two things - intuition (in the presence of no other
> guidance) would suggest that simply retrieving an HTML page is going to be
> faster than a CGI program that would generate an identical page.

if you find that your CGI is too slow, you could move over to mod_perl
which i find to be pretty speedy - as fast as loading a file according
to my wristwatch :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sat, 28 Nov 1998 19:31:32 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: list processes
Message-Id: <Pine.GSO.4.02A.9811281130560.15581-100000@user2.teleport.com>

On Fri, 27 Nov 1998 vicengle@ix.netcom.com wrote:

> Is there a way to list processes on an NT system.

If there is, it should be covered in the docs, FAQs, or newsgroups about
NT systems. Hope this helps!

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



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

Date: Sat, 28 Nov 1998 10:51:37 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: localtime () - perl's  bug ?
Message-Id: <MPG.10c9e61741bd8dde98992f@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <73p5pq$vud$1@Masala.CC.UH.EDU> on Sat, 28 Nov 1998 09:50:03 
-0600, Sean Mintz <stmintz@yahoo.com> says...
> Roberto Slepetys Ferreira wrote in message
> <365F3834.34B838F6@homeworks.com.br>...
> >($sec,$min,$hour,$day,$month,$year)=localtime ();
> >$data = "$day/$month/$year";
> >$horario = "$hour:$min:$sec";

Y2K bug alert!

> $timestamp = time();
> 
> sub get_date_string
> {
>   local ($timestamp) = @_;
>   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> localtime($timestamp);
>   $mon++;
>   $mon =  do date_pad($mon);
>   $mday = do date_pad($mday);
>   $hour = do date_pad($hour);
>   $min =  do date_pad($min);
>   $sec =  do date_pad($sec);
>   ("${year}.${mon}.${mday}", "${hour}:${min}:${sec}");
> }

Y2K bug alert!

> sub date_pad
> {
>   local ($n) = @_;
>   if ($n < 10) {
>     return "0$n";
>   }
>   else {
>     return "$n";
>   }
> }

All this is much easier with sprintf -- almost a one-liner.  And you 
want to use 'my' (not 'local'), and you do not need 'do' to call a 
subroutine.

  $timestamp = time; # () superfluous for already defined function.
  
  sub get_date_string
  {
    my ($sec, $min, $hour, $mday, $mon, $year) = localtime shift;
    sprintf('%.2d.%.2d.%.2d', $year % 100, $mon + 1, $mday), 
    sprintf('%.2d:%.2d:%.2d', $hour, $min, $sec);
  }

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


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

Date: 27 Nov 1998 21:10:11 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: locking files in Perl
Message-Id: <73n4fj$rki$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Andre Kopostynski" <andre@airmail.net> writes:
:I'm trying to lock my counter file in anticipating multiple users submitting
:their results simultaneously on my online questionnaire form.  Here's what I
:have.  it's working fine, but how do I lock the file until the submission is
:completed and how do I unlock for next submission?
:
:Your expertise is greatly appreciated.

Thank you so much for your appreciation.  You'll find that this question
was answered many years ago.  It's called a FAQ.  Please consult the
Perl FAQ for the answer.

--tom
-- 
 PS/2 -- Half a computer
 OS/2 -- Half an operating system
 PS/2: Yesterday's hardware today. OS/2: Yesterday's software tomorrow


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

Date: Sat, 28 Nov 1998 13:13:35 -0500
From: Tk Soh <r28629@email.sps.mot.com>
To: Marty Landman <marty@catnmoose.com>
Subject: Re: locking files
Message-Id: <36603D44.72EA9806@email.sps.mot.com>

[posed to c.l.p.m and copy emailed]

Marty Landman wrote:
> 
> do it like this:
> 
> # Beginning of writefile function
> 
> sub writetofile {
> # Creating a variable the value of which is the name of the counter file
> 
> $counter_file = "counter.file";
> 
> # Opening the counter file and reading the next number from this file
> open (FILE, "<" . $counter_file);
                                  ^ or die "Can't open file: $!\n"

you _must_ always check the return value to make sure open() is successful.
 
> flock(FILE, 2);
> $next_numb = <FILE>;
> flock(FILE, 8);
> close (FILE);
> 

you don't need to unlock and close at the same time. When a file is closed,
the lock is automatically released. 

> # Opening the counter file again and rewriting the next number to this
> file
> $next_numb++;
> open (FILE, ">" . "counter.file");
> flock(FILE, 2);
> print FILE $next_numb;
> flock(FILE, 8);
> close (FILE);
> 

same for the above open, flock and close.

> "Andre Kopostynski"  wrote:
> 
> I'm trying to lock my counter file in anticipating multiple users
> submitting
> their results simultaneously on my online questionnaire form.  Here's
> what I
> have.  it's working fine, but how do I lock the file until the
> submission is
> completed and how do I unlock for next submission?
> 
> Your expertise is greatly appreciated.

Lastly, you should always _reply_ to the original post, instead of creating a
new subject line (which create a new thread unnecessarily). This helps to make
the ng more organized (hopefully ;) and avoid confusing others with
disconnected posts.

-TK


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

Date: Sat, 28 Nov 1998 20:32:50 +0100
From: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
Subject: Newbie question conc. file operations
Message-Id: <36604FE2.7DE1@geophysik.uni-frankfurt.de>

Hello,
I'm new with Perl and trying to write a script for searching a database
for several strings by doing the following:
1.) open an input file: open(SRCBIB,"<database");
2.) open an output file:
	$tempout="cgi-tmp/srch_out$$.tmp";
	open(OUTPUT,">$tempout");
3.) search the whole SRCBIB for a certain string
4.) close SRCBIB; and close OUTPUT;
5.) rename the former output file in the following way:
	$tempin=rename $tempout, "cgi-tmp/srch_in$$.tmp";
6.) open that file as a new input file using the filehandle SRCBIB:
	open(SRCBIB,"<$tempin");
7.) go to 2.) and repeat the process with another search pattern.
In the first pass through the loop everything seems to work until 6.) is
reached. The opening of SRCBIB in 6.) seems to fail; everything I could
find out indicates that this file is not opened. I used tell to find out
file positions during the run, and it gives these results in my test:
In the 1st pass:
	after 2.): SRCBIB at 0, OUTPUT at 0
	after 3.): SRCBIB at 57199, OUTPUT at 3284
which is OK; in the 2nd pass:
	after 2.): SRCBIB at -1, OUTPUT at 0
	after 3.): SRCBIB at -1, OUTPUT at 0
Can anybody please explain me why this happens and what I must do to
open a new input file as SRCBIB in 6.). BTW, I do *not* want to search
for all strings simultaneously.
Please answer by email as well, as I cannot read this NG regularly.
Thanks in advance for any help
-- 
--------------------------------------------
Thomas Ruedas
Institute of Meteorology and Geophysics, 
J.W. Goethe University Frankfurt/Main
Feldbergstrasse 47			D-60323 Frankfurt/Main, Germany
Phone:+49-(0)69-798-24949		Fax:+49-(0)69-798-23280
e-mail: ruedas@geophysik.uni-frankfurt.de
http://www.geophysik.uni-frankfurt.de/~ruedas/
--------------------------------------------


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

Date: Sat, 28 Nov 1998 20:01:25 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Newbie question conc. file operations
Message-Id: <3660584C.C82BF912@shaw.wave.ca>

[posted & mailed]

Thomas Ruedas wrote:
> 
> 6.) open that file as a new input file using the filehandle SRCBIB:
>         open(SRCBIB,"<$tempin");
> 7.) go to 2.) and repeat the process with another search pattern.
> In the first pass through the loop everything seems to work until 6.) 
> is reached. The opening of SRCBIB in 6.) seems to fail; everything I 
                                           ^^^^^^^^^^^^^
> could find out indicates that this file is not opened.
                                
You're trying to find this out using deduction instead of just checking
open() directly.

    open(SRCBIB, $tempin) or die "Can't open $tempin:  $!\n";

Notice that I have removed the unnecessary quotes and '<' symbol.

> Please answer by email as well, as I cannot read this NG regularly.

That's too bad because this is mentioned here at least a dozen times a
day.  It is also suggested by the docs.

    perldoc -f open

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Sat, 28 Nov 1998 20:10:40 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Newbie question conc. file operations
Message-Id: <Pine.GSO.4.02A.9811281205330.15581-100000@user2.teleport.com>

On Sat, 28 Nov 1998, Thomas Ruedas wrote:

> 1.) open an input file: open(SRCBIB,"<database");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

> 2.) open an output file:
> 	$tempout="cgi-tmp/srch_out$$.tmp";
> 	open(OUTPUT,">$tempout");
> 3.) search the whole SRCBIB for a certain string
> 4.) close SRCBIB; and close OUTPUT;
> 5.) rename the former output file in the following way:
> 	$tempin=rename $tempout, "cgi-tmp/srch_in$$.tmp";

I'm not sure that the return value from rename is what you think it is. Of
course, you do want to check that value in case the rename has failed,
too.

> 6.) open that file as a new input file using the filehandle SRCBIB:
> 	open(SRCBIB,"<$tempin");
> 7.) go to 2.) and repeat the process with another search pattern.

Sounds as if you're looking for sections which contain all of the
search patterns. Wouldn't it be better to search for all patterns in one
pass? That seems to me that it would be faster, due to less I/O.

Cheers!

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




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

Date: Sat, 28 Nov 1998 12:12:46 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Newbie: Need to split comma-delimited data into scalars or an array.
Message-Id: <36602F07.1F7DCC6A@email.sps.mot.com>

Simon Whitaker wrote:
> 
> On Fri, 27 Nov 1998 16:53:12 GMT, tcpeter@iname.com wrote:
[...]
> We newbies should stick together. Go forth and code, brother!

perhaps 'we' should start a 'comp.lang.perl.newbies' newsgroup ;-) But I don't
supposed you want to staty as newbies forever, do you? 

-TK


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

Date: 27 Nov 1998 20:46:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl compiler?
Message-Id: <73n32h$pst$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    silk@interlog.com (Robin D.F. Silk) writes:
:Perl programs do not need to be compiled -- it is an interpreted language.

I have very bad news for you: all programming languages are interpreted.

--tom
-- 
    X-Windows: Flakey and built to stay that way.
	--Jamie Zawinski


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

Date: Sat, 28 Nov 1998 19:07:58 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: perlwin32(5.005_02) causes a page violation error under Windows95
Message-Id: <Pine.GSO.4.02A.9811281104530.15581-100000@user2.teleport.com>

On Fri, 27 Nov 1998, SUZUKI Norio wrote:

> After compiling perlwin32(5.005_02) 

Why not just use the pre-compiled binary, if you're on a Windows machine?
It's not unlikely that the problems you're having are due to a buggy
compilation, so going with an already-successfully-compiled binary would
seem like a good plan. If you really must compile it yourself, you'll
probably need to use your system's debugging tools to find out what's
wrong. Good luck!

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



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

Date: 28 Nov 1998 20:19:34 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: quote & print confusion
Message-Id: <73plsm$16g$1@gellyfish.btinternet.com>

On Fri, 27 Nov 1998 13:58:20 -0500 Marty Landman <marty@catnmoose.com> wrote:
> I'm trying to save a line of code if possible by saying
> 
>   print "<td>substr($rhs,$i,1)</td> \n";
> 
 The problem here is that function calls are not interpolated in quoted
strings.

You could use :

print "<td>@{[substr($rhs,$i,1)]}</td>\n";

which does cause the function to be expanded.  However it looks nasty and 
will probable upset the next person who has to maintain your code.

I would probably recommend you to go with Andy's advice and just put some
extra commas in your print statement (along with the necessary quotes of
course).

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: 28 Nov 1998 19:32:57 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: rename() on NT
Message-Id: <73pj59$15o$1@gellyfish.btinternet.com>

On Sat, 28 Nov 1998 17:47:58 +0100 Mats Westholm <mats@webhandel.nu> wrote:
> This is a multi-part message in MIME format.
> --------------292E1E5EE1A74CD76AFB5531
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 

Please, please,please,please configure your browser so that it doesnt
include this vCard stuff in Usenet posts.  At best it totally unnecessary and
at worst it is terribly annoying and may result in the only responses to
your post being flames about your browser.

> I have moved a fully functioning perl-program from UNIX to
> NT and the
> rename() funktion is not working. It gives the error-code
> "File exists" (in
> $!). I'm renaming the new file to an existing filename.
> 
> 1. Anyone knows how to handle rename() in NT?
> 
> 2. Where can I read about the file commands in NT? (for
> example how to
> delete a file, rename or move it)
> 

I think you'll find that because of the way that the NT filesystem works
you will need to remove the existing file with the unlink() function.

You might also find that there is a more Win32 specific way of doing this
through some Win32::* module.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Sat, 28 Nov 1998 19:54:02 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Security: Overwriting directory file when removing directory?
Message-Id: <Pine.GSO.4.02A.9811281146240.15581-100000@user2.teleport.com>

On 28 Nov 1998, Anonymous wrote:

> I would like to overwrite the contents of a file before removing them
> (for instance when they contain privacy sensitive data). I can do that
> easily, by opening them and overwriting them full of junk and closing
> them again.
> 
> But I cannot find a way to do the same with the directory files (I'm
> on a unix system) and I'd like every trace of my files removed(even
> the names which may contain privacy sensitive info).

You should probably choose names that don't give anything away. If
necessary, you could have a small database to track the mapping of the
current (meaningful) names to new ones.

> I tried opening the directory as a file, the removing the directory
> and then overwriting the directory file and closing it. But I seem
> to be unable to open the directory file as normal file to do this.

No, you shouldn't be able to do this. And I don't think there's a
method to do this that's guaranteed to work on all systems. But if
you choose meaningless names, that won't be necessary.

Nevertheless, the better way to do this, if you're serious about it, would
be to make a filesystem driver which can, say, over-write each chunk of
disk three times with differing data before freeing it. But none of this
really has anything Perl-specific about it; perhaps you should try the
docs, FAQs, and newsgroups about security, filesystems, and related
topics. Good luck!

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



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

Date: Sat, 28 Nov 1998 19:33:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: sysread / need help w/ single byte I/O, urgent!  please!
Message-Id: <Pine.GSO.4.02A.9811281131450.15581-100000@user2.teleport.com>

On 27 Nov 1998, Ralph Forsythe wrote:

> It reads one time then hangs, giving me a value that ain't even close
> to what it should be.

Maybe you should make a small program for "the other end of the pipe", to
send known-good data for testing purposes. Then you would (if nothing
else) have a stand-alone example which others could try to use to
replicate your difficulties, and perhaps find a bug. Good luck!

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



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

Date: Sat, 28 Nov 1998 13:29:10 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Training wheels for Perl
Message-Id: <comdog-ya02408000R2811981329100001@news.panix.com>

In article <73pbbd$u3$1@gellyfish.btinternet.com>, Jonathan Stowe <gellyfish@btinternet.com> posted:

> Maybe if I get five-thousand grapefruit and a similar number of keyboards I
> might be able to come up with the Shell to Perl Converter.

why?  sh2perl already exists and is on CPAN :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 27 Nov 1998 21:20:05 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: variable interpolation inside a hash
Message-Id: <73n525$rki$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Maan Bsat <bsat@iprolink.ch> writes:
:I'm trying to do something like $myvar{"name_$i"} so that when $i = 1,
:it would give me the value $myvar{'name_1'}. How can I do it, since it
:doesn't really like it...

What you have already written, $myvar{"name_$i"}, works fine.

But usually it is better to write

    $myvar{"name"}[$i]

--tom
-- 
*** The previous line contains the naughty word "$&".\n
                if /(ibm|apple|awk)/;      # :-)
            --Larry Wall in the perl man page


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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