[16972] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4384 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 20 09:05:28 2000

Date: Wed, 20 Sep 2000 06:05:12 -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: <969455112-v9-i4384@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 20 Sep 2000     Volume: 9 Number: 4384

Today's topics:
    Re: Can you store a condition in a variable? <gellyfish@gellyfish.com>
    Re: Char to Octoal... ? <gellyfish@gellyfish.com>
    Re: Cygwin Perl failing - please help (Leo Schalkwyk)
        fcntl <jwills@orange.net.au>
    Re: File Parsing, Skipping lines <gellyfish@gellyfish.com>
    Re: FileMaker, DBI <ubl@schaffhausen.de>
        How do I shut down an oracle database from perl script <ssilv@rochester.rr.com>
    Re: How to upload a file from a remote machine nobull@mail.com
    Re: HTTP::Request lil prob <gellyfish@gellyfish.com>
        Installing the Oracle DBD- Howto? <webqueen@my-deja.com>
    Re: IP Address <mtaylorlrim@my-deja.com>
    Re: loop through file - how to loop back one line? <akelingos@petrosys-usa.com>
        MS-ACCESS <paspgo@logassist.fr>
        Naked chicks <powlow@my-deja.com>
    Re: Naked chicks (Tony L. Svanstrom)
    Re: newbie having problem with system command <gellyfish@gellyfish.com>
    Re: Numbers! (Eric Bohlman)
    Re: Numbers! nobull@mail.com
    Re: passing variables to and from scripts <gellyfish@gellyfish.com>
    Re: Perl economy (Rafael Garcia-Suarez)
    Re: Perl economy scott@mobinfo.com.au
    Re: Pure perl encrypt/decryption? grymoire@my-deja.com
    Re: Pure perl encrypt/decryption? grymoire@my-deja.com
    Re: Pure perl encrypt/decryption? <andrew.flisher@onyx.net>
        Q: about @ARGV and open on Windows <sanface@sanface.com>
        reading from a file <powlow@my-deja.com>
    Re: rename Vs system mv <gellyfish@gellyfish.com>
    Re: Running lengthly perl scripts over cgi <gellyfish@gellyfish.com>
        Searching text in hash/array or db file ? <post2menow@hotmail.com>
    Re: Shortest code for Fibonacci? <bart.lateur@skynet.be>
    Re: Variable Handling <gellyfish@gellyfish.com>
    Re: Variable Handling nobull@mail.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 20 Sep 2000 07:15:08 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Can you store a condition in a variable?
Message-Id: <8q9klc$cpq$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 12:21:04 -0700 Larry Rosler wrote:
> In article <slrn8sf5vb.5fq.abigail@alexandra.foad.org> on 19 Sep 2000 
> 16:45:37 GMT, Abigail <abigail@foad.org> says...
>> 
>> (Yellow and green? *shudder*)
> 
> Check out the Australiam team's colors.  Also the University of Oregon 
> (Ducks!, how appropriate),  But *shudder* anyway.  :-)
> 

Brazilian footbal team too.

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


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

Date: 20 Sep 2000 07:35:16 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Char to Octoal... ?
Message-Id: <8q9lr4$crn$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 20:30:17 +0100 D Borland wrote:
> Can anyone here, inform me of how you can return the octal value of a char,
> from a $... ?

perldoc -f ord
perldoc -f sprintf

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


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

Date: 20 Sep 2000 10:05:55 GMT
From: L.Schalkwyk@z138-234.iop.kcl.ac.uk (Leo Schalkwyk)
Subject: Re: Cygwin Perl failing - please help
Message-Id: <slrn8sh302.3vudam9.L.Schalkwyk@leoschalkwyk.iop.kcl.ac.uk>

On Tue, 19 Sep 2000 12:52:25 -0700, Mike Ayers <mayers@bmc.com> wrote:
>
>	Even better - here is a minimal script to reproduce the failure:
>
>====================8<-----------------SNIP-
>
>use strict;
>use FileHandle;
>use vars qw( $InstallDir );
>
>$InstallDir = qx( pwd );
>print( $InstallDir, "\n" );
>
>====================8<-----------------SNIP-
>
>	Also, I'm on NT4SP5.  I'm now looking into using IO::File instead of
>Filehandle, but would still appreciate any info on why the FileHandle
>lib appears to be so unfriendly.

-the above doesn't make any use that I can see of FileHandle.
-on my system (perl 5.6 under cygwin 1.1 , win 98) the snippet does
exactly the expected.  Your installation must be broken!


Leo


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

Date: Wed, 20 Sep 2000 23:51:40 +1100
From: Justin Wills <jwills@orange.net.au>
Subject: fcntl
Message-Id: <39C8B2DB.A7073D0D@orange.net.au>

I'm using fcntl to implement file locking for reasons which are beyond
my control.

I can happily set locks with perl, and a C program can see that the file
is locked using the fcntl() functions as would be expected.

The C prog can also detect (der) a lock created by a C fcntl() routine.

the problem I am facing is that under x86 solaris (so far), I cannot get
the return values for fcntl() when I test for the lock.  all the values
seem to come back as zeros.  funilly enough, it works on a linux box
with no dramas.


here's some code:


#!/usr/local/bin/perl
use Fcntl;

$file=shift;

if($lockval=islocked($file))
{
    die "Locked by $lockval\n";
}


die "cannot lock $file\n" if(!setlock($file));
sleep 30;

sub setlock
{
    $locktype=F_WRLCK;
    $whence=0;   # seek set
    $start=0;
    $len=0;

    $fcntl=pack("sslli", $locktype, $whence, $start, $len, 0);

    if((fcntl(LOCKFILE, &F_SETLK, $fcntl)) < 0)
    {
         die "cannot get locks\n";
    }

    return 1;
}


sub islocked
{
 ($filename)=@_;



 if(!open(LOCKFILE, "+>$filename"))
 {
  die "cannot open $filename: $!\n";
 }

 $locktype=F_WRLCK;
 $whence=0;   # seek set
 $start=0;
 $len=0;

 $fcntl=pack("sslli");

 if((fcntl(LOCKFILE, &F_GETLK, $fcntl)) < 0)
 {
     die "cannot get locks\n";
 }
 else
 {
     ($locktype, $whence, $start, $len, $pid)=unpack("sslli", $fcntl);

     print "locktype = $locktype\n";
     if($locktype!=F_WRLCK)
    {
         print "unlocked";
         return 0;
    }
    else
    {
         print "locked";
         return 1;
         return $pid;  # doesn't work :( returns 0
    }

  }
}




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

Date: 20 Sep 2000 07:29:36 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: File Parsing, Skipping lines
Message-Id: <8q9lgg$cqk$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 19:15:57 GMT darkrabbit@my-deja.com wrote:
>  J. Stone <jstone211@my-deja.com> wrote:
>> If I know I need to move ahead a certain number of lines once I've
>> found an item in my file, what is the best way to do this?
> 
> I use ...
> 
> open( FILEHANDLE, "< $file);

The success of this open should be tested before the filehandle is used:

  open(FILEHANDLE, "<$file") || die "Can't open $file - $!\n";


> @filearray = <FILEHANDLE>;
> 
> ... then I have an array I can use to hop to specific line numbers.  This
> might be slow if you are parseing a long file.
> 

for a large file (indeed even a modest one ) it might be better to read
in line by line and just throw away the ones you don't want :

  my $skipto;

  while(<FILEHANDLE>)
  {
    
    next if $. < $skipto;

    if ( /WHATEVER/ )
    {
      $skipto = $. + $lines_to_skip;
    } 
      
  }

or

  while(<FILEHANDLE>)
  {
    
    if ( /WHATEVER/ )
    {
      <FILEHANDLE> for ( 1 .. $lines_to_skip);
    } 
      
  }


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


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

Date: Wed, 20 Sep 2000 11:42:29 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: FileMaker, DBI
Message-Id: <39C88684.A7F13FBD@schaffhausen.de>

Hi,

I have the same problem. Would be cool if you post here (or even mail me)
if you
find a nice way to solve this problem.

Thanx,

malte

kevin metcalf schrieb:

> I did a comprehensive search on CPAN and was unable to come up with a
> way to use perl to make changes to my filemaker database.  Anybody out
> there have a solution to this problem?  BTW:  I did a search on the last
> 2235+ messages of this news group, but did not see anything remotly
> resembling this topic.  While on the CPAN site I did see a refrence to
> the DBI::ODBC by jeff Urlwin, but from the readmes it isn't a solution
> due to the platform limitation.  That's the real kicker, it's on a
> Macintosh G4 server.  It's for a small group called @ONE who are working
> off a grant from the california state chancelor's office and they don't
> have the cashflow to upgrade to something like Oracle, etc.  Any
> responses appriciated.
>
> Kevin



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

Date: Wed, 20 Sep 2000 11:28:31 GMT
From: "orassilv" <ssilv@rochester.rr.com>
Subject: How do I shut down an oracle database from perl script
Message-Id: <zb1y5.14944$%h6.3374732@typhoon.nyroc.rr.com>

I am trying to shutdown an Oracle database.
In unix I would have in my bourne shell script the following:

ORACLE_SID=abcd; export ORACLE_SID
svrmgrl <<EOF
connect internal
@some_sql_script
shutdown immediate
exit

I have tried this in perl - no good - any ideas how to do this for
perl/nt4.0?


Thanks,
orassilv




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

Date: 20 Sep 2000 13:47:50 +0100
From: nobull@mail.com
Subject: Re: How to upload a file from a remote machine
Message-Id: <u9vgvrqlft.fsf@wcl-l.bham.ac.uk>

Hugo Bouckaert <hugo@fractalgraphics.com.au> writes:

> I would like to have a html page with several form fields, one of which
> is an upload button.

See GCI.pm documentation for examples of handling forms with upload fields.

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


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

Date: 20 Sep 2000 07:08:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: HTTP::Request lil prob
Message-Id: <8q9k8n$cp2$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 14:20:02 +0200 Alain BARBET wrote:
> Hi,
> 
>> Why do keep getting "Error: 400 URL is missing" but when I paste it in
>> the browser it works fine ?
>>                 my $req = HTTP::Request->new
>> (POST 'http://testserver/commerce/shop/shop/esdposttest.asp',
> 
> When you test in browser, you use method "GET". May be error come from
> here ?

There should be a comma between the POST and the URL :

my $req = HTTP::Request->new (POST => 
             'http://testserver/commerce/shop/shop/esdposttest.asp');

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


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

Date: Wed, 20 Sep 2000 11:54:51 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: Installing the Oracle DBD- Howto?
Message-Id: <8qa8i2$bvt$1@nnrp1.deja.com>

hi there:

I'm trying to install the Oracle DBD DBD-Oracle-1.06 on an UltraSparc to
run against a DB on an Intel box running Solaris. I'm not making much
progress as the install almost immediately dies with:

  The ORACLE_HOME environment variable value (219.218.23.21) (*not the
actual IP) is not valid.
  It must be set to hold the path to an Oracle installation directory
  on this machine (or a compatible archtecture (*sic)).
  See the README.clients file for more information.

The IP I sent is the right one, and I tried various directories as well
all with the same result. I looked in the README.clients to find
assorted messages related to clients, but no HowTo.

Does anyone have a page I can look at with a real example of someone
that did this? They mentioned SQL*NET also- do I need that on the Sparc?
Where would I get it?

Thanks, and HUG!
WQ

--


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


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

Date: Wed, 20 Sep 2000 11:46:54 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: IP Address
Message-Id: <8qa838$bd1$1@nnrp1.deja.com>

If reverse host lookups are enabled on the web server, the environment
variables $ENV{REMOTE_HOST} and $ENV{REMOTE_ADDR} contains the
information you seek.

Mark



In article <MPG.14325fd11004d18698968a@news.siol.net>,
  Marvin <ales.romaniuk@zag.si> wrote:
> Hello !
>
> I would like to make a CGI form and that every person can submit only
> once. Is there any function that returns IP of remote host properly
> (remote_addr() returns always "").
>
> Thanks
>

--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


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


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

Date: Wed, 20 Sep 2000 08:04:04 -0500
From: "Alec Kelingos" <akelingos@petrosys-usa.com>
Subject: Re: loop through file - how to loop back one line?
Message-Id: <sshd9ih58a21f5@corp.supernews.com>

Thanks for the tips.  I'm still kind'a new at Perl and this type of info. is
very helpful.

Alec



Alec Kelingos <akelingos@petrosys-usa.com> wrote in message
news:ssfsfondqa8h2d@corp.supernews.com...
> While looping through a file, how can I 'move back' one line.  eg.
>
> Open(fh,"myfile.dat");
> While (<fh>) {
>     If ( bla bla bla) {  # I need to start the next read from the previous
> line }
> }
>
> Is this possible or will I have to make a temporary copy of the previous
> line?
>
> I know I could easily do it by loading the file into an array, but I'm
> trying to avoid this as the files can be over 100 megs.
>
> Thanks in advance
> Alec
>
>
>




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

Date: Wed, 20 Sep 2000 13:38:09 +0200
From: "FNAC" <paspgo@logassist.fr>
Subject: MS-ACCESS
Message-Id: <8qa6hs$2qdh$1@news6.isdnet.net>

Where could I find any code example to open an MS-ACCESS database and update
a record ?

Thanks for your help.


Pascal




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

Date: Wed, 20 Sep 2000 11:03:16 GMT
From: Powlow <powlow@my-deja.com>
Subject: Naked chicks
Message-Id: <8qa5hb$8of$1@nnrp1.deja.com>

maybe now someone will look at this....
anyone?

-paulo

In article <8qa3b7$6ap$1@nnrp1.deja.com>,
  Powlow <powlow@my-deja.com> wrote:
> hey,
>
> reading two lines from a text file,
>
> open(USERFILE,$namein);        # open file for reading

  # lock file here $eatit = <USERFILE>;  # reads first line of USERFILE into
variable $mess = <USERFILE>;  # reads next line of USERFILE into variable
close(USERFILE);  # close file

>
> $eatit and $mess have what looks to me like a space (in html) or a newline
> (in unix shell) as the last character. i've tried doing all sorts of
> substitutions assuming its a space or a newline. i've also used chomp. none
> of these seem to work. am i missing something? is there a way to do this
> other than adding a space on the end of what i'm comparing them to?
>
> can someone please post something as this is really frustrating and i can't
> see any obvious solution, being new to perl.

-paulo


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


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

Date: Wed, 20 Sep 2000 13:35:26 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Naked chicks
Message-Id: <1eh9f08.k8o39af22tdkN%tony@svanstrom.com>

Powlow <powlow@my-deja.com> wrote:

> maybe now someone will look at this....
> anyone?

I did, but I don't feel like helping idiots that panic half when they
don't get an answer after half an hour and that try stupid things like
this.

So... welcome to spend 30 days in my killfile...

*PLONK*


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: 20 Sep 2000 07:05:36 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: newbie having problem with system command
Message-Id: <8q9k3g$coi$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 01:46:25 GMT orassilv wrote:
> I am trying to run a script to shut down an Oracle database.
> 
> When I try to run a batch file or a .cmd file using system, it fails.
>    $ret = system("dbdown.cmd");  # does NOT work but I CAN run the .cmd file
> from command line
> 
> ... but when I try to use the system command as folows, it works fine.
>    $ret = system("del /Q sqldown.sql");  # this works - deletes a .sql file
> 

A batch file relies on the command interpreter - you may have to run
the file by passing it as an argument to cmd.exe .

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


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

Date: 20 Sep 2000 11:55:45 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Numbers!
Message-Id: <8qa8k1$eq5$1@slb7.atl.mindspring.net>

Eric Mosley (ericm@iol.ie) wrote:
: I need to be able to generate a unique number for a series of digital gift
: certificates.
: 
: I would like it to be quite hard for a scamster to make up his own valid
: numbers and try his look - therefore I need the numbers I use to be hard
: to replicate more valid numbers - if you know what I mean!
: 
: Is there an algorithm where I can spit out some fairly unique numbers?

Is there information that differs from certificate to certificate?  If 
so, concatenate it into a string, append some reasonably-long secret key 
that only you know (same key for all certificates), and then compute an 
MD5 or SHA1 hash of the whole thing and use that as the unique number.  
You'll then be able to verify any certificate presented to you.



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

Date: 20 Sep 2000 13:20:58 +0100
From: nobull@mail.com
Subject: Re: Numbers!
Message-Id: <u9ya0nqmol.fsf@wcl-l.bham.ac.uk>

ericm@iol.ie (Eric Mosley) writes:

> I need to be able to generate a unique number for a series of digital gift
> certificates.
> 
> I would like it to be quite hard for a scamster to make up his own valid
> numbers and try his look - therefore I need the numbers I use to be hard
> to replicate more valid numbers - if you know what I mean!
> 
> Is there an algorithm where I can spit out some fairly unique numbers?

What does any of this have to do with Perl?  You are talking about an
algorithm.  Algorithms are, by definition, independant of the language
used to implement them.

Since you need to maintain a list of which certificates have been
redeemed you may as well keep a list of which ones have been issued.
That being the case you can simply use random numbers.  The scamster's
guess isn't on your list it's not valid.

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


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

Date: 20 Sep 2000 07:33:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: passing variables to and from scripts
Message-Id: <8q9lnp$cr4$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 18:53:55 GMT potato_salad@my-deja.com wrote:
> Hi, I am wanting to pass information from an entry box to a script to
> simply ping a host for example. Can someone please explain how to
>   store the info entered into the entry box as a variable and then pass
> it to my other script. thanks for any help. Yamar
> 

Perl doesnt have 'entry boxes' - you will have to be a bit more specific
or people will think you are talking about a CGI program.

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


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

Date: Wed, 20 Sep 2000 10:15:23 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Perl economy
Message-Id: <slrn8sh3u2.tr7.rgarciasuarez@rafael.kazibao.net>

scott@mobinfo.com.au wrote in comp.lang.perl.misc:
>Hi there,
>
>Is there a more succinct way to do this:
>
>$a = '/home/scott/inc /usr/include /home/scott/program/include'
>x join(' ', map({ $_ = '-I' . $_ } split(/\s+/, $a)))
>0  '-I/home/scott/inc -I/usr/include -I/home/scott/program/include'
>
>This *almost* does what I want:
>x join(' -I', split(/\s+/, $a))
>0  '/home/scott/inc -I/usr/include -I/home/scott/program/include'
>
>but it doesn't prefix the 1st dir with '-I', which is why I
>resorted to using 'map' above.
>
>Anyone know a more efficient (less maninpulation &/or lines-of-code) way?

If directory names are "regular" (letters, numbers and underscores) and
begin with a '/' (as in your example) :

  $a=~s,\B/,-I/,g;

-- 
Rafael Garcia-Suarez | http://rgarciasuarez.free.fr/


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

Date: Wed, 20 Sep 2000 10:31:45 GMT
From: scott@mobinfo.com.au
Subject: Re: Perl economy
Message-Id: <lm0y5.9$ii2.829@vic.nntp.telstra.net>

Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:

> If directory names are "regular" (letters, numbers and underscores) and
> begin with a '/' (as in your example) :

>   $a=~s,\B/,-I/,g;

Legendary! Thanks. (Why didn't I think of that?)

I ended up using:

s/(^|\s+)/$1-I/g

SCoTT! :)
--------------------
scott@mobinfo.com.au


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

Date: Wed, 20 Sep 2000 10:14:13 GMT
From: grymoire@my-deja.com
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <8qa2l9$5l1$1@nnrp1.deja.com>

In article <MPG.14317ae9c5de7dc3989687@nntp.onyx.net>,
  Andy Flisher <andrew.flisher@onyx.net> wrote:

> Splitting text on the way in is easier as it's 8 chars, but there's no
> guarantee that you're gonna get 8 chars back.

Really? Oh my. That may complicate things.  I only need to encrypt a
credit card number, but if I get chunks of varying size, it will be
messy.


When I tested it, it always returned chunks of 8 bytes.
How sure are you about this? How often does it happen?


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


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

Date: Wed, 20 Sep 2000 10:54:35 GMT
From: grymoire@my-deja.com
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <8qa515$84t$1@nnrp1.deja.com>

In article <MPG.14317ae9c5de7dc3989687@nntp.onyx.net>,
  Andy Flisher <andrew.flisher@onyx.net> wrote:
>
> The only thought that sprang to mind was to either seperate the chunks
> with \n and then chomp on the way back in, but to be honest haven't
tried
> it.  Theories would be useful on this one, else I'm back to piping
output
> through PGP again :-(

I tested it, and the following code works.
I am not sure I beilieve your statement that sometimes Blowfish_PP
returns blocks of size different from 8. I ran some text cases through
it, and it seems fine.


sub ENCRYPT {
# Big crypt - handles big chunks
  my $plain = shift;
  my $results = "";
  while (length($plain) > 0) {
    # take first 8 bytes
    my $piece = substr($plain,0,8);
    substr($plain,0,8) = "";
    $results .= &encrypt($piece);
  }
  return $results;
}
sub DECRYPT {
# Big decrypt - handles big chunks
  my $cipher = shift;
  my $plain = "";
  while (length($cipher) > 0) {
    # take first 8 bytes
    my $piece = substr($cipher,0,8);
    substr($cipher,0,8) = "";
    $plain .= &decrypt($piece);
  }
  return $plain;
}


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


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

Date: Wed, 20 Sep 2000 13:08:26 +0100
From: Andy Flisher <andrew.flisher@onyx.net>
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <MPG.1432b915e3c628e598968e@nntp.onyx.net>

In article <8qa515$84t$1@nnrp1.deja.com>, grymoire@my-deja.com says...
 
> I tested it, and the following code works.
> I am not sure I beilieve your statement that sometimes Blowfish_PP
> returns blocks of size different from 8. I ran some text cases through
> it, and it seems fine.

You may well be correct, however I was mainly relying on output to 
console which can go a little mad, in one example a sting or 8 chars 
echoes out 2 'spaces' and another char.  This may just be the console 
misinterpreting I don't know.

I decided to play safe in the end by using \n to seperate, it's no 
hardship on the code and means that I know categorically where the 
seperators should be.

I'm only using this for passwords anyway so the 8 char business was for 
my own benefit as opposed to necessity.

I already use a pipe to PGP for credit card numbers and the like, my 
customers seem to prefer this as it uses keys that they have created, and 
gives them a feeling of better control.


-- 
Andy Flisher

'All postings are a reflection of my state of mind,
and not necessarily of any worthwhile opinion'

news@flish.co.uk    http://www.flish.co.uk


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

Date: Wed, 20 Sep 2000 10:39:14 GMT
From: SANFACE Software <sanface@sanface.com>
Subject: Q: about @ARGV and open on Windows
Message-Id: <8qa44h$6vi$1@nnrp1.deja.com>

Hello,

This is the problem I'd like to solve.
I'd like to pass like input parameter to a script on Windows a file with
inside the path a blank and use inside the script like a true file (open
it, write it, close it, ...)
e.g. c:\this is the directory\myfile.txt

Do you know if there is a possible solution?
Can you help me?

Ciao

Fabrizio

--
SANFACE Software
Your technology glasses. We help you see your full potential.
http://www.sanface.com
mailto:sanface@sanface.com
WAP       http://www.sanface.com/wap/
i-mode  http://www.sanface.com/i/


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


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

Date: Wed, 20 Sep 2000 10:25:59 GMT
From: Powlow <powlow@my-deja.com>
Subject: reading from a file
Message-Id: <8qa3b7$6ap$1@nnrp1.deja.com>

hey,

reading two lines from a text file,

open(USERFILE,$namein);  # open file for reading  # lock file here $eatit =
<USERFILE>;  # reads first line of USERFILE into variable $mess = <USERFILE>;
	# reads next line of USERFILE into variable close(USERFILE);  # close
file

$eatit and $mess have what looks to me like a space (in html) or a newline
(in unix shell) as the last character. i've tried doing all sorts of
substitutions assuming its a space or a newline. i've also used chomp. none
of these seem to work. am i missing something? is there a way to do this
other than adding a space on the end of what i'm comparing them to?

can someone please post something as this is really frustrating and i can't
see any obvious solution, being new to perl. -paulo
___________________________  http://powlow.com/ ___________________________

--
___________________________
       http://powlow.com/
___________________________


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


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

Date: 20 Sep 2000 07:12:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: rename Vs system mv
Message-Id: <8q9kgs$cpf$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 15:01:11 GMT tonyforster@zoom.co.uk wrote:
> 
> Although when I use system("mv"...) in the perl script, the file gets
> moved, but $! catches an "Illegal seek".

Why are you looking at $! ?  the exit code of a program executed by
system is to be found in $? - the 'illegal seek' is just some random
stuff left in $! by some previous operation.

Randal explained about the difference between rename() and 'mv'.

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


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

Date: 20 Sep 2000 07:31:17 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Running lengthly perl scripts over cgi
Message-Id: <8q9ljl$cr1$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 17:56:49 GMT dj_morri@my-deja.com wrote:
> 
> Can I use my script to run a child script in the background, and exit
> leaving the child to run on the system, not through CGI.
> 
> The starter script would write a HTML file to the server with a
> "refresh" directive in, then return a redirect to this file.
> The child script will then append status updates to that
> HTML page.  (So as far as the user is concerned it appears that it is
> only one script running throughout) supplying progress reports.
> 
> Does that make sense?

Thats fine.  You will want to use fork().

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


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

Date: Tue, 19 Sep 2000 16:44:08 +0200
From: "Ed Bras" <post2menow@hotmail.com>
Subject: Searching text in hash/array or db file ?
Message-Id: <8qacgf$74i$1@enterprise.cistron.net>

I have a lists of words stored in a array (contains 3000 and more words) and
check if a word exist.
I do that now through a while loop.

I like to know if this can be done in a faster way, as speed in this case is
rather important.
I was thinking about putting the words in a hash table as a key, or putting
them in a db file ?

Can someone please tell me what the best method is to get high performance
when searching a word ??

Regards,
Ed Bras




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

Date: Wed, 20 Sep 2000 11:03:58 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <dc3hss88k7get5f9c5m70j3co2cs3im9n7@4ax.com>

Gwyn Judd wrote:

>On the other hand, in general it is not possible to
>raise powers of arbitrary real numbers in constant time.

Eh? I thought that the function

	exp($y*log($x))

(but with base 2, not e)

was the basis for powers $x**$y of arbitry numbers ($x is positive)?
That must be pretty much in constant time, or at least, in reasonable
time?

Reduce the number $x to a power of 2 (exponent) multiplied by a factor
between 1 (inclusive) and 2 (exclusive) (mantissa), and you can do a
table lookup for the mantissa. Add some nonlinear interpolation, and
you're through, for log().

Exponentiation: subtract the integer part, which gives you the exponent,
and the fractional part between 0 (inclusive) and 1 (exclusive), and
again, you can do table lookup plus interpolation. That gives you the
manissa.

-- 
	Bart.


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

Date: 20 Sep 2000 07:16:47 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Variable Handling
Message-Id: <8q9kof$cpt$1@orpheus.gellyfish.com>

On Tue, 19 Sep 2000 15:59:31 GMT M. Monti wrote:
> I'm a beginner trying to create a 2-component search-engine type form.
> 
> 
> Component 1: Radio buttons set up to determine which fields of a data
> file to search on. 
> Component 2: Text field for keyword to find matches on. 
> 
> My strategy was to set the values of radio buttons to indicate the
> slice of the array to search on (Button A value=0..2, Button B=3..5) .
> 
> 
> Ideally, the value would then get plugged in to the line where I use
> the match command. But I can't get this to work. (I do get it to work
> when I replace the variable with the slice it should be [i.e., 0..2].)
> 
> Do I misunderstand how to use the variables?  
> 
> Here's what I mean: 
> 
> ...
> # split and clean up query
> @queryelems=split ("&",$query);
> foreach $piece(@queryelems){	
> 	#clean up pieces
> 	$piece=~ s/....=//g;
> 	$piece=~ s/\+/ /g;
> 	$piece=~ s/%(..)/chr(hex($1))/ge;


Stop that right now ! You will be a lot happier if use the CGI module
which has been standard with Perl for a while now.

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


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

Date: 20 Sep 2000 13:41:05 +0100
From: nobull@mail.com
Subject: Re: Variable Handling
Message-Id: <u9wvg7qlr2.fsf@wcl-l.bham.ac.uk>

mmonti@cswe.org (M. Monti) writes:

> I'm a beginner

Standard beginner advice:

  Use strict.

  Enable wanings.

  Check return values from system calls.

  Use maintained modules (like CGI.pm) rather than re-inventing wheels
  or using anchient libraries.

  Use only books/tutorials about Perl5 not ones about Perl4.

> My strategy was to set the values of radio buttons to indicate the
> slice of the array to search on (Button A value=0..2, Button B=3..5) .

OK.

> 	@list=split("\t",$_);
> 	if ($list[$ab]=~m/$bc/i) {
> 		print "Match found\n";

OK here you are really confused.  You say you want a list slice. The
syntax of a list slice is @list[LIST] but $ab is the scalar string '0..2' not
the LIST (0,1,2).  You could write this as @list[eval $ab] but using
eval like this on a value submitted by an untrusted user is a security
hole you could sail an oil tanker through unless you check that $ab
really is of the form you expect.

Also the thing on the LHS of a =~ operator is evaluated in a scalar
context for you can't meaningfully put an array slice there.  To apply
a condition to a small list the simplest thing to do is use grep().

The simplest way to fix your code is:

        die unless $ab=~/\d+\.\.\d+/;
 	if (grep { m/$bc/i } @list[eval $ab]) {

Note I'd precompile the regular repression too:

        die unless $ab=~/\d+(\.\.\d+)?(,\d+(\.\.\d+)?)*/;
        $bc = qr/$bc/i;
 	if (grep { /$bc/ } @list[eval $ab]) {

Some people have such a rabid hate of eval that they'd tell you to get
rid of it but unless time is of the essence I'd not sure it's worth it.

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


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

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


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