[6343] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 965 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 17 20:27:16 1997

Date: Mon, 17 Feb 97 17:00:25 -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           Mon, 17 Feb 1997     Volume: 7 Number: 965

Today's topics:
     Re: $ls = `ls $file`;  but not in NT Perl (Abigail)
     Re: (Q) return inside a grep BLOCK (John L. Allen)
     Attatch Mail Script? <sy94jma@blg.du.se>
     Re: Attatch Mail Script? (Nathan V. Patwardhan)
     Re: Calling C from perl: help needed <jasons@infinity.cs.unm.edu>
     Compilation problem on DG/UX 4.11 <alan@protix.com>
     Re: D hashes to DBMs and CGI question. (Jot Powers)
     Date Script <jsteven@sirris.com>
     DB_File errors on perl upgrade <chris@ixlabs.com>
     File Locking (John Boekhout)
     Re: File Locking (Boulder SQA)
     Re: H: How to associate the .pl extention with perl.exe (Nathan V. Patwardhan)
     HELP: limitaion of the numbers of key in all the DBMish <kom_dp@ix.netcom.com>
     Re: HELP: limitaion of the numbers of key in all the DB (Nathan V. Patwardhan)
     MacPerl and Web* (Christopher V)
     Re: Match any char EXCEPT [char] (Jeffrey)
     mkdir / chmod weirdness (Jeff Yoak)
     Re: mkdir / chmod weirdness (Brian L. Matthews)
     Perl "if" error? (David Martin)
     Re: Perl "if" error? (Dave Thomas)
     Re: Perl "if" error? <safwan@programmer.net>
     Re: Perl "if" error? <dbenhur@emarket.com>
     Re: Perl "if" error? (Brian L. Matthews)
     Perl consultant needed in NYC (Aimee Schneider)
     Perl for Win32 wrapper for Java <Joe.Bragg@nt.com>
     Re: Pig Latin <99borns@ionaprep.pvt.k12.ny.us>
     Re: Pig Latin <99borns@ionaprep.pvt.k12.ny.us>
     Re: Problem with '-s' switch.. (Dave Thomas)
     Problems with Perl 5.003. Please help! <houde@fox.cisti.nrc.ca>
     Re: QUES: what is "undump"? (Nathan V. Patwardhan)
     Re: Questions (Dave Thomas)
     Sorting an associative array by values (Milan Saini)
     Re: Sorting an associative array by values (Piotr Piatkowski)
     Re: Uploading cgi script (with perl?) (Jeff Carnahan)
     Using -s Perl switch in SSI <bcrane@tradecards.com>
     Re: Way to send stdout to an X-Windows app (Paul Tomblin)
     What does flock do? (John Boekhout)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Mon, 17 Feb 1997 20:07:10 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: $ls = `ls $file`;  but not in NT Perl
Message-Id: <E5rJvy.3n6@nonexistent.com>

On 16 Feb 1997 23:06:43 -0800, Brian L. Matthews wrote in comp.lang.perl.misc:
++ In article <3307B306.439F@bgraham.com>, Bo Graham  <bgraham@bgraham.com>
++ wrote:
++ |$ls = `ls $file`; works in unix but not in Windows version of perl.
++ 
++ Not surprising. Backticks simply run the given command and slurp its
++ output. Stock Windows systems don't come with an ls, so perl can't
++ run it.
++ 
++ |.. How do I do this then?  
++ 
++ You could write your own ls. You could use opendir/readdir and/or stat.
++ You could use the Find module. And if you're really just doing
++ $ls = `ls $file`, just replace it with $ls = $file (although I suspect
++ you're doing something more complex and just simplified for the posting.)
++ 

Bzzt! $ls = $file might work if $file is a simple file which
exists, but it won't work if $file is a directory, empty, 
contains spaces, starts with a dash, or is a nonexisting name.



Abigail



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

Date: 17 Feb 1997 16:48:49 -0500
From: allen@gateway.grumman.com (John L. Allen)
Subject: Re: (Q) return inside a grep BLOCK
Message-Id: <5eajo1$qu4@gateway.grumman.com>

In article <5e8voe$p36$1@halcyon.com>,
Brian L. Matthews <blm@halcyon.com> wrote:
>In article <bierman-1602971416200001@bierpe3.apple.com>,
>Peter Bierman <bierman@apple.com> wrote:
>|Why does return inside a grep BLOCK return me out of the entire sub that
>|I'm in?
>
>Because that's what return does. It bails out of the current subroutine.
>When you're in a grep BLOCK, the current subroutine is still the one
>containing the call to grep. A BLOCK is not necessarily a subroutine,
>and in the case of grep, it surely isn't.
>
>|Is there any simpler way to write a complex grep BLOCK than nesting lots
>|of if (foo) else 0; to return a value or false?

This does work, but BIITEOTB:

print grep {
  ;
  {
  $x=1, last if /0/;
  $x=0, last if /1/;
  $x=1 if $_ > 5;
  }
  $x
} 0..9

Don't ask about that first semicolon :)

John.


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

Date: Mon, 17 Feb 1997 22:14:44 +0100
From: Jonas Mensson <sy94jma@blg.du.se>
Subject: Attatch Mail Script?
Message-Id: <3308CA44.F66@blg.du.se>

Does anyone know where I can get a script that sends a user defined 
file from a webpage as an attachment?

/Jonas


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

Date: 17 Feb 1997 22:02:12 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Attatch Mail Script?
Message-Id: <5eakh4$3b0@fridge-nf0.shore.net>

Jonas Mensson (sy94jma@blg.du.se) wrote:
: Does anyone know where I can get a script that sends a user defined 
: file from a webpage as an attachment?

In terms of the "webpage stuff," you should re-direct your posting to 
comp.infosystems.www.authoring.cgi, or check one of the free, script
archives, like Matt's script archive.  In terms of the mail attachment,
you should check out the MIME::* modules available at a CPAN near you!

--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
	--Chris Cornell from Soundgarden


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

Date: 17 Feb 1997 12:13:05 -0700
From: Jason Stewart <jasons@infinity.cs.unm.edu>
Subject: Re: Calling C from perl: help needed
Message-Id: <xjnhgjbjlfi.fsf@infinity.cs.unm.edu>

If you get rid of the space in the margin, it works...


#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif


MODULE = Test1		PACKAGE = Test1

void
hello()
	CODE:
	printf("Hello, world!\n");


not exactly sure why,

jas.

Dmitrij Frishman <frishman@mips.biochem.mpg.de> writes:

> 
> I am trying to reproduce the first example Test1 in the perlxstut man
> page in order to understand how to connect C subroutines to my perl
> code. I follow exactly the instructions in the example:
> 
> 1. h2xs -A -n Test1
> 2. Append C code to the end of Test1.xs: 
>         void
>         hello()
>         
>                 CODE:
>                 printf("Hello, world!\n");
> 3. perl Makefile.PL
> 4. make
> 
> Here is what I get on a DEC ALpha machine after running make:
> 
> > make
> cp Test1.pm ./blib/lib/Test1.pm
> /usr/local/bin/perl -I/usr/local/lib/perl5/alpha-dec_osf/5.003
> -I/usr/local/lib/perl5 /usr/local/lib/perl5/ExtUtils/xsubpp  -typemac
> Code is not inside a function in Test1.xs, line 13
> *** Exit 1
> Stop.
> 
> Here's how my Test1.xs actually looks:
> 
> ------------------------------------------------------
> #ifdef __cplusplus
> extern "C" {
> #endif
> #include "EXTERN.h"
> #include "perl.h"
> #include "XSUB.h"
> #ifdef __cplusplus
> }
> #endif
> 
> 
> MODULE = Test1		PACKAGE = Test1
> 
>         void
>         hello()
>         
>                 CODE:
>                 printf("Hello, world!\n");
> 
> -----------------------------------------------------
> 
> I checked everything many times and could not find any difference
> between what I am doing and the example in the man page.
> 
> You help will be greatly appreciated.
> 
> -- 
> Dmitrij Frishman, PhD				| Tel. +49-(0)89-8578-2664
> Max-Plank-Institute for Biochemistry		| Fax. +49-(0)89-8578-2655
> Martinsried Institute for Protein Sequences	| e-mail:
> frishman@mips.biochem.mpg.de
> Am Klopferspitz 18a, 82152 Martinsried, Germany	| WWW:
> http://www.mips.biochem.mpg.de/~frishman/


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

Date: 18 Feb 1997 00:11:41 GMT
From: "Alan Fahrner" <alan@protix.com>
Subject: Compilation problem on DG/UX 4.11
Message-Id: <01bc1d2f$c5f88c00$040792cf@cult>

Hi Folks...

I'd greatly appreciate any suggestions on finding out why compilation on a
DG/UX box running 4.11 is failing...

The message:
        LD_RUN_PATH="/usr/sde/m88kdgux/usr/lib" gcc -o
 ../../lib/auto/POSIX/POSIX.so -shared -L/usr/local/lib POSIX.o    -lm
-lposix 
ld: ../../lib/auto/POSIX/POSIX.so: fatal error: relocations remain against
allocatable but non-writable section: .text
*** Error code 1

The output of uname -a:
dgux potomac R4.11 generic AViiON mc88100

It may be as simple as going to R4.11MU03 (a box with that on it compiles
fine).  The two boxes are entirely different hardware-wise (other than both
not being intel-based).

Even a pointer to a FAQ I should read would be greatly appreciated.

Thanks,

Alan
alan@protix.com


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

Date: 17 Feb 1997 21:34:28 GMT
From: jot.feb97@tmp.medtronic.com (Jot Powers)
Subject: Re: D hashes to DBMs and CGI question.
Message-Id: <5eait4$372@gazette.medtronic.com>

In article <In26eKm00WB_06Jl40@andrew.cmu.edu>, Michael George Schwern <stupid+@andrew.cmu.edu> writes:
>I have a few questions.  
>
>My data is modeled as 2D hashes... a database lookup table (a
>hash-of-hashes  $database{uniqueID}{attribute} = value) and an index for
>searching (hash-of-hashes-of-lists  @{$database_index{attribute}{value}}
>= @list_of_uniqueIDs).  This all works out very well (Order 1 lookups
>AND searches are QUITE nice) however, it seems to me it will get to be a
>bit of a memory hog, having the entire database in memory all the time. 
>I'd like to tie the database to a DBM file, but it seems that I can only
>do that with regular hashes.  Is there a (useful) way to tie a 2D hash
>(or any other complex Perl structure) to a DBM file?
>

The MLDBM package available at the CPAN site nearest you.  I've used it
in conjunction with the CGI module to produce fairly useful CGI programs
using Perl.

[*snip*]

>The other problem is that concerning my client/server setup.  I didn't
>want the database to be directly called by the CGI gateway because I
>don't like the idea of loading up the whole database for every request. 
>I'd rather it stay resident.  So, my current setup has the database
>running resident, with CGI programs running as clients (using
>socketing).  My question is, is there a way to make a resident program
>(my database server) talk to the CGI gateway (ie. be called as a CGI
>program)?

This is not a Perl question, as near as I can tell.

>BTW This is to run with Netscape Commerce Server.

This is not nearly as relevant as the OS you're running on.  If it
is a non-Unix type OS, all bets are off.

[*snip 7 line sig.  Who do you think you are, Randal?  ;)*]

-- 
Jot Powers  jot.feb97@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."




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

Date: Mon, 17 Feb 1997 13:42:08 -0800
From: "James Steven" <jsteven@sirris.com>
Subject: Date Script
Message-Id: <jsteven-1702971342080001@blv-pm109-ip9.halcyon.com>

Could someone please tell me where I could get a script that determines
todays date and then displays a month file (ex. february.gif), one or two
day files, (ex. 1, 7, for the 17th), a th (xx h) file if nessisary and then
a year file (1997)?

Thanks, reply or e-mail jsteven@sirris.com

---------------------------------------
James Steven - jsteven@sirris.com
Sirris Web-Site: http://www.sirris.com/
---------------------------------------



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

Date: Mon, 17 Feb 1997 12:48:52 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: DB_File errors on perl upgrade
Message-Id: <3308C434.5DA96203@ixlabs.com>

Recently we upgraded from a static Perl 5.003_07 to a dynamic
Perl5.003_07.
We fixed some new warnings about odd numbers of elements in hash, but
I'm 
puzzled by this error from DB_File (output from our die trapper):

Perl Die Trap

DB_File::BTREEINFO=HASH(0x80ea168) does not define the method
DB_File::BTREEINFO 
at /usr/local/apache/cgi-bin/testscript line 0 

Context is: 
Line 0 in File /usr/local/apache/cgi-bin/testscript called
DB_File::HASHINFO::DESTROY. 
Line 94 in File /usr/local/lib/perl5.003_07/DB_File.pm called
DB_File::HASHINFO::CLEAR. 
Line 97 in File /usr/local/lib/perl5.003_07/DB_File.pm called
DB_File::HASHINFO::NotHere. 
Line 91 in File /usr/local/lib/perl5.003_07/DB_File.pm called
Carp::croak. 

we always use -Tw and use strict.

Any ideas? More info needed?

Thanks
Chris


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

Date: Mon, 17 Feb 1997 23:38:33 GMT
From: boekhout@azww.com (John Boekhout)
Subject: File Locking
Message-Id: <5eaq69$gj4@argentina.earthlink.net>

I've got  a Perl CGI script that changes a file (from a
form) and I am having problems with more than one user
submitting the form at the same time and not handling the
file operation properly.

I found this example in the Perl documentation on using
flock to handle a counter file, but I don't understand it:

     $counter = "/home/shishir/counter.dat";
     print "Content-type: text/plain", "\n\n";

     open (FILE, $counter) || die "Cannot read from the
counter file.\n";
     flock (FILE, 2);   #step 1
     $visitors = <FILE>;
     flock (FILE, 8);  #step 2
     close (FILE);

     open (FILE, ">" . $counter) || die "Cannot write to
counter file.\n";
     flock (FILE, 2);
     print FILE $visitors;
     flock (FILE, 8);
     close (FILE);

My question is, what good did it do to lock the file at step
1 when it is unlocked at step 2 before writing out the new
counter value?  Why wasn't the file kept locked before
reading and then unlocked after writing out the new counter
value.

I'm guessing I just don't understand what flock does???

Also, I spent quite a while searching the Perl web site for
a clear description of what flock does, and couldn't find
it.  Any description of flock just said "calls flock(2) on
filehandle" and "see manual page for flock(2)" neither of
which could be found (by me).  Any help finding this info
would be appreciated.

Please help.  Thanks.
John Boekhout
boekhout@azww.com



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

Date: 17 Feb 1997 20:13:44 GMT
From: stampes@xilinx.com (Boulder SQA)
Subject: Re: File Locking
Message-Id: <5eae5o$so@neocad.xilinx.com>

Matthew Enger (menger@mindless.com) wrote:
: Hello,
: 	I want to be able to lock a file up so 2 people don't access it at the
: same time. Can anyone help?


If you're running on UNIX-ish platforms on a non-NFS system, there's
flock...

What?  you say it's an NFS system, and multiple UNIX platforms?  Ok,
go with Fcntl and determine the correct struct to pass for each
platform.

Oh Really?  You are cursed to eternal damnation like I am, and
need to to work on Win32 systems also?  Lockfiles and a prayer....

Jeff

--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: 17 Feb 1997 19:36:55 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: H: How to associate the .pl extention with perl.exe in win95??
Message-Id: <5eac0n$mld@fridge-nf0.shore.net>

Hank LeMieux (hanklem@ibm.net) wrote:

: Some important points: On windows, it's best to
: install perl into a directory whose full path contains directory names
: of 8 characters or less (ie: NOT in a directory, or nested in a
[snip]

>From my experience with NTPerl, "size doesn't matter."  :-)  Honestly,
I've had success with both:

$varname = 'C:\\Program Files';
-and-
$varname = 'C:\\progra~1\';

Just make sure you're returning errors, and you'll be okay.

In terms of the associations between files, and .pl, NT Perl 5.001 PL110
used to include a file called PL2BAT.BAT, which wrapped Perl scripts into
a .bat file.  NTPerl 5.003_07 doesn't seem to have this.

--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
	--Chris Cornell from Soundgarden


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

Date: Mon, 17 Feb 1997 00:28:56 -0800
From: adminstrator <kom_dp@ix.netcom.com>
Subject: HELP: limitaion of the numbers of key in all the DBMish packages?????
Message-Id: <330816C8.68E8@ix.netcom.com>

Any body has clear idear about the limitation of the numbers of key for
the DBMish packages, i.e. ODBM, NDBM, SDBM, GDBM, BSD-DB?

I wrote a program to create a data base. When I use NDBM, then the
*.db.dir stop at size of 4096Kb, and *.db.data stop at certain size.
When I use GDBM, the *.db stop at 4440141Kb. In both case the program
later complain about "use of uninitailzed value in (certain line
number)".

My guess is that I have hit the boundary, since I have about 400k keys
for this data base, am I right on this?

But according to Camel book, there is block size limit on GDBM. Is that
mean that I can have unlimited keys in single db file?

Any other idea, or suggestion for using different DB?

David

PS:  I can provide my perl program if you want have a look.


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

Date: 17 Feb 1997 21:57:52 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: HELP: limitaion of the numbers of key in all the DBMish packages?????
Message-Id: <5eak90$3b0@fridge-nf0.shore.net>

adminstrator (kom_dp@ix.netcom.com) wrote:

: I wrote a program to create a data base. When I use NDBM, then the
: *.db.dir stop at size of 4096Kb, and *.db.data stop at certain size.
: When I use GDBM, the *.db stop at 4440141Kb. In both case the program

In this case, "size matters."  :-)  You might look into berkeley dbm,
and Perl's DB_File module.

--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
	--Chris Cornell from Soundgarden


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

Date: Mon, 17 Feb 1997 15:06:51 -0600
From: cvinall@cause.org (Christopher V)
Subject: MacPerl and Web*
Message-Id: <cvinall-1702971506510001@cmac02.cause.org>

I'm having trouble getting Web* talking with MacPerl.  I am setting up a
form that will return an html page.
- My script works fine in MacPerl
- Web* recognizes that file type .pl is MacPerl
However the results are not being returned to the server. Any help or
direction is appreciated.

Chris
cvinall@cause.org

-- 
Christopher
cvinall@cause.org


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

Date: 17 Feb 1997 20:03:00 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: Augusto Roman <aroman@nmsu.edu>
Subject: Re: Match any char EXCEPT [char]
Message-Id: <JFRIEDL.97Feb18050300@tubby.nff.ncl.omron.co.jp>


[post and mail]

Augusto Roman <aroman@nmsu.edu> wrote:
|> In a program I'm working on, I need to search through a string and match
|> a pattern that contains any character except one specific char.  Can
|> this be done?!

It sounds like you want the [^...] notation. For example, [^B] means
``a non-B byte''.

The match /[^B]/ means to find a string that has a non-B byte
(i.e. all strings except "" and "B").

The match /^[^B]*$/ means to find a string that does not have a "B"
(has only non-B, if anything, between the start and end of the string).
It might be faster to just use:
	not /B/
though.

Trivia Question:
   The /^[^B]*$/ pattern will work for all values of B except for newline.
   Why? (answer way down below sig)

	Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/



























Q: The /^[^B]*$/ pattern will work for all values of B except for newline.
   Why?

A: Because /$/ is always able to match before a string-ending newline.
   It is also true for \Z.             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   This is true without regard to /m or /s.

(see Hip Owls, p235)


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

Date: Mon, 17 Feb 1997 20:30:15 GMT
From: jeff@yoak.com (Jeff Yoak)
Subject: mkdir / chmod weirdness
Message-Id: <5eapib$rj7@sjx-ixn2.ix.netcom.com>

Hi All,

	On a system running BSD, I'm running a script with the following
lines:

mkdir($maindir,0777) || die "Can't create directory: $maindir\nDied ";
chmod(0777,$maindir) || die "Can't chmod directory: $maindir\nDied ";

With only the first line, the script creates the directory with 755
permissions.  (my default) but it works as intended with both lines.
Anyone have any ideas?

Also, if appropriate, if anyone has any advice on how I might have
figured this out on my own, i.e. return values of function calls or
something that I could have looked for, that would be very much
appreciated.

Thanks,
Jeff

Jeff Yoak  jeff@yoak.com  http://yoak.com/



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

Date: 17 Feb 1997 16:09:55 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: mkdir / chmod weirdness
Message-Id: <5eas0j$o0s$1@halcyon.com>

In article <5eapib$rj7@sjx-ixn2.ix.netcom.com>,
Jeff Yoak <jeff@yoak.com> wrote:
|mkdir($maindir,0777) || die "Can't create directory: $maindir\nDied ";
|chmod(0777,$maindir) || die "Can't chmod directory: $maindir\nDied ";
|With only the first line, the script creates the directory with 755
|permissions but it works as intended with both lines.

On Unix, when you create a file, the mode actually used is the mode
you specify bitwise anded with the complement of your umask. While in
your shell, type umask and hit return. It will print out 022. So
when creating a file or directory and specifying a mode of 0777,
Unix will use a mode of 0777 & ~022, which is 0755. Being perl just
uses the system's mkdir, perl does the same thing. If you really
want a directory writable by everyone in the known Universe, following
the mkdir with the chmod as you've done is about the best way to go
about it. You could also use the perl function umask to set your umask
to 0 before the mkdir, but then you need to make sure it's set back
to 022, even in error cases and such, and is probably more dangerous
than its worth.

|Also, if appropriate, if anyone has any advice on how I might have
|figured this out on my own, i.e. return values of function calls or
|something that I could have looked for, that would be very much
|appreciated.

Well, this is one area where knowing Unix already is a big help. The
entry for mkdir in perlfunc says, in part:

    Creates the directory specified by FILENAME, with permissions
    specified by MODE (as modified by umask).

Being your mode is being modified, the above might lead you to
believe it was being done by umask. You could then do a man umask,
where you'd fine something like:

    The low-order nine bits of numask are used whenever a file is
    created, clearing corresponding bits in the file mode.

It also tells you to see chmod, which describes the bits in the file
mode. From this you could figure out your umask must be 022, because
those are the bits that are being cleared.

So, like I said, it would help if you already knew Unix. :-)

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: Mon, 17 Feb 1997 20:11:11 GMT
From: dbmartin@netcom.com (David Martin)
Subject: Perl "if" error?
Message-Id: <dbmartinE5rK2o.AFn@netcom.com>

I am creating a short perl script using Perl 4 on MSDOS and I have an
problem with a IF statement. The following statment will return TRUE even
when the var. is not equal to the specified value:
 
$t1 = substr($_,16,6);
if ($t1 == "[22;1H")
{
  print $_;
} 
 
Is the format of the "if" statment incorrect or could this be a bug with 
my version of Perl?  

Thanks



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

Date: 17 Feb 1997 21:03:34 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Perl "if" error?
Message-Id: <slrn5ghho4.2ul.dave@fast.thomases.com>

On Mon, 17 Feb 1997 20:11:11 GMT, David Martin <dbmartin@netcom.com> wrote:
> I am creating a short perl script using Perl 4 on MSDOS and I have an
> problem with a IF statement. The following statment will return TRUE even
> when the var. is not equal to the specified value:
>  
> $t1 = substr($_,16,6);
> if ($t1 == "[22;1H")


==  - numeric comparison
eq  - string comparison

 "[22;1H" is a string.
 
 
Dave


-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 17 Feb 1997 21:35:41 GMT
From: "safwan A.Hak" <safwan@programmer.net>
Subject: Re: Perl "if" error?
Message-Id: <01bc1d19$dec14fd0$154b278e@pce41>

David Martin <dbmartin@netcom.com> wrote in article 
> I am creating a short perl script using Perl 4 on MSDOS and I have an
> problem with a IF statement. The following statment will return TRUE even
> when the var. is not equal to the specified value:
>  
> $t1 = substr($_,16,6);
> if ($t1 == "[22;1H")
> {
>   print $_;
> } 

if '$t1' is text then you should probably do this..

if ($t1 eq  "[22;1H")



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

Date: Mon, 17 Feb 1997 12:57:33 -0800
From: Devin Ben-Hur <dbenhur@emarket.com>
To: David Martin <dbmartin@netcom.com>
Subject: Re: Perl "if" error?
Message-Id: <3308C63D.1A39@emarket.com>

David Martin wrote:
> $t1 = substr($_,16,6);
> if ($t1 == "[22;1H")
> Is the format of the "if" statment incorrect or could this be a bug with
> my version of Perl?

== is a numeric comparison.
use eq to compare strings:
  if ($t1 eq "[22;1H")
will do the trick.
--
Devin Ben-Hur      <dbenhur@emarket.com>
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

Date: 17 Feb 1997 15:50:45 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: Perl "if" error?
Message-Id: <5eaqsl$n60$1@halcyon.com>

In article <dbmartinE5rK2o.AFn@netcom.com>,
David Martin <dbmartin@netcom.com> wrote:
|$t1 = substr($_,16,6);
|if ($t1 == "[22;1H")
|{
|  print $_;
|} 

Read your documentation about perl operators, paying particular
attention to the difference between == and eq.

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 17 Feb 1997 20:27:06 GMT
From: aimee@interport.net (Aimee Schneider)
Subject: Perl consultant needed in NYC
Message-Id: <5eaeuq$6e0@park.interport.net>

 Hello,

 The company I work for in New York City, Evolution Online Systems, may be
looking to hire a Perl consultant for a few days in the next week or two.
The job will be figuring out a way of maintaining source code secrecy for
a Perl application that runs on WindowsNT 4.0. This might entail porting
some Perl tools (the Filter module and/or the Perl Compiler) to NT or
coming up with an alternate solution.

 If you are interested, please reply as soon as possible to the address
below with your full name and daytime phone number or, if you know of
*anyone* else who might be interested, please have them contact me with
the same information.


 If this is an inappropriate post, please ignore it.


Thanks for your time,

Eric Schneider
roark@evolution.com



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

Date: Mon, 17 Feb 1997 15:40:34 -0600
From: Joe Bragg <Joe.Bragg@nt.com>
Subject: Perl for Win32 wrapper for Java
Message-Id: <3308D052.645C@nt.com>

I am using Perl for Win32 Build 303 on a Window NT 4.0 machine with
Microsoft IIS 2.0 Version 4.0 and JDK 1.0.2. 

The problem I am having is executing a Java application from within a
Perl CGI. If I run the Perl script from the DOS command line it works
fine, but when I try to run it though my Netscape browser I get
"Document contains no data". The header information is sent from the
Perl script but the content (<HTML>...</HTML>) is created in the Java
application and passed back though a scalar ($java=qx(java Report parm1
parm2 ...)) then printed (print"$java";).

The same Perl script and Java application work great on my Windows 95
machine using WebSite 1.1 and Perl 4.036.

Can anybody give me some insight into what the problem might be?

Thanks in Advance,
Joe Bragg
Email: Joe.Bragg@nt.com


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

Date: Mon, 17 Feb 1997 13:55:07 -0800
From: Stephen Bornet <99borns@ionaprep.pvt.k12.ny.us>
To: Dave@Thomases.com
Subject: Re: Pig Latin
Message-Id: <3308D3BB.604B@ionaprep.pvt.k12.ny.us>

Dave,
	I agree with you completely here.

> Whether a comparison takes 200 or 300 microseconds makes not a jot of >difference unless you do it a million times. Mostly, its just fun to 
> talk about :-)

	All this talk about my one stupid program! Imagine if it did something
impressive

-- 
!Stephen!
Maintainer of the Punk and Metal Midi Archives
	http://www.geocities.com/SiliconValley/4063/index.html


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

Date: Mon, 17 Feb 1997 13:56:37 -0800
From: Stephen Bornet <99borns@ionaprep.pvt.k12.ny.us>
To: Honza Pazdziora <adelton@fi.muni.cz>
Subject: Re: Pig Latin
Message-Id: <3308D415.4BFC@ionaprep.pvt.k12.ny.us>

Honza,
	I'm trying to convert text to Pig Latin. You know, Iay owknay igPay
atinLay! Thanx for the help!

-- 
!Stephen!
Maintainer of the Punk and Metal Midi Archives
	http://www.geocities.com/SiliconValley/4063/index.html


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

Date: 17 Feb 1997 21:01:35 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Problem with '-s' switch..
Message-Id: <slrn5ghhkd.2ul.dave@fast.thomases.com>

On 17 Feb 1997 18:35:30 GMT, sukumar <sukku@menudo.uh.edu> wrote:
> Hi there,
> 	I am trying to parse the command line switches in my script.
> My script should  take '-m arg1 -l arg2' as command args.
> 

'arg1' is taken as a filename argument, and so terminated -s processing.

Have a look at the various GetOpt:: modules in cpan for a far better way to
handle command lines. GetOpt::Long is my personal choice.

Regards

Dave


-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Mon, 17 Feb 1997 16:26:38 -0500
From: Pascal Houde <houde@fox.cisti.nrc.ca>
Subject: Problems with Perl 5.003. Please help!
Message-Id: <3308CD0E.5AB@fox.cisti.nrc.ca>

Since we upgraded Perl 5.001 to 5.003, all scripts using sock.pl
does not work anymore.  I suspected that was because we haven't
converted ".h" files to ".ph" using h2ph. But by doing it, it didn't
solve the problem. Any hints??

Thanks!
Please reply directly to me.


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

Date: 17 Feb 1997 19:27:57 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: QUES: what is "undump"?
Message-Id: <5eabft$mld@fridge-nf0.shore.net>

Steven L. Kunz (skunz@iastate.edu) wrote:

: As proof, here are some stats on the one-line 'print "Hello, world!\n";'
: program compiled with Perl5.003 (with the alpha3-compiler extension) on
: Ultrix 4.3a (using staticly-linked extensions): 
:      806912 Feb 17 09:30 hello

WOW!  My experience will the Perl compiler suggested that files were
about 50% the size of those created with undump.  My "hello" example
was 150K+/-10K.

Thanks for sharing your findings - interesting stuff.  :-)

--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
	--Chris Cornell from Soundgarden


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

Date: 17 Feb 1997 20:57:56 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Questions
Message-Id: <slrn5ghhdi.2ul.dave@fast.thomases.com>

On Mon, 17 Feb 1997 16:49:15 GMT, Edward Brown <reb@pobox.com> wrote:
> open(PROCESS, "sccs get SCCS/s.$file |") || 
> 	die "Unable to open sccs\n";
 
> Some of the errors (like "does not exist") apparently print to STDERR
> and don't show up in the while(<PROCESS>) loop.

>  open(STDERR, ">&STDOUT") || die "Can't dup stdout";
 
> but that doesn't help.

Have you tried this with a simple shedd script emulating sccs? The dup
worked for me like that (as did open(PROCESS, "sccs get .. 2>&1|").

Maybe sccs tries to be clever and open /dev/tty for its errors? Don't know,
as I don't have it here.

Regards

Dave


-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 17 Feb 1997 22:36:11 GMT
From: milan@xilinx.com (Milan Saini)
Subject: Sorting an associative array by values
Message-Id: <5eamgr$fj3@mailman.xilinx>


Hi

   Is there a way to sort an asso array by values and be able
   to get the corresponding keys?


   Thanks
   Milan

-- 
  / 7\'7 Milan Saini (milan@xilinx.com)
  \ \ `  Xilinx                              Telephone: 408-559-7778
  / /    2100 Logic Drive                    Direct:    408-879-5300
  \_\/.\ San Jose, California 95124-3450     FAX:       408-879-4676


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

Date: 18 Feb 1997 00:54:59 +0100
From: kompas@galaxy.uci.agh.edu.pl (Piotr Piatkowski)
Subject: Re: Sorting an associative array by values
Message-Id: <5ear4j$5qa@galaxy.uci.agh.edu.pl>

Milan Saini <milan@xilinx.com> wrote:

: Hi

:    Is there a way to sort an asso array by values and be able
:    to get the corresponding keys?

man perlfunc:

                # this sorts the %age associative arrays by value
                # instead of key using an in-line function
                @eldest = sort { $age{$b} <=> $age{$a} } keys %age;

-- 
Piotr Pi1tkowski, Uczelniane Centrum Informatyki, AGH Krakow, POLAND


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

Date: Mon, 17 Feb 1997 18:36:18 GMT
From: tails@hooked.net (Jeff Carnahan)
Subject: Re: Uploading cgi script (with perl?)
Message-Id: <330ba4f9.83430226@news.wenet.net>

On 13 Feb 1997 18:27:41 GMT, strider@shadowmac.org (Raul Almquist)
wrote:

>dimakop@cti.gr wrote:
>: 	We are trying to set a service on our Web service where any
>: user can access a form through which he/she can upload a file to the
>: server. Although we have been able to write the html script to
>: implement the form and initiate the uploading we have problems with
>: the cgi script which runs on the server and receives the files.
>: 
>: 	So my question is if there is anywhere any script that could
>: do this job? Or if there is any function in the Perl libraries that
>: could do or, at least help us in this direction?
>
>  You will need to use a perl module like CGI_Lite.pm and a basic script 
>that you can find inside the module as a working example.

You could also stop by my Free Scripts Archive at:

	http://www.terminalp.com/scripts/

to pick up a free upload script... =)



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

Date: Mon, 17 Feb 1997 17:59:31 -0500
From: Ben Crane <bcrane@tradecards.com>
Subject: Using -s Perl switch in SSI
Message-Id: <3308E2D0.665@tradecards.com>

I'm brand new to this newsgroup so please excuse if this is an FAQ.

I'm trying to use the -s switch in an exec SSI, but my server doesn't
seem to understand it. Here is what I'm trying:

<!--#exec cgi="-s /cgi-bin/prog.cgi -card=a10" -->

which is trying to assign the value of "a10" to $card in Perl script
prog.cgi

When executed, the html page containing this line just contains a msg
saying that an error occurred rather than a value that I'm trying to
print.

Is what I'm trying to do impossible, or am I just making some stupid
neophyte mistake?

Any help would be appreciated.

Thanks,

Ben Crane


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

Date: 14 Feb 1997 15:45:19 -0500
From: tomblin@ekfido.kodak.com (Paul Tomblin)
Subject: Re: Way to send stdout to an X-Windows app
Message-Id: <5e2isv$eaa@apollo.cineon.kodak.com>

(Posted and mailed)

In a previous article, Richard Arnesen <rdarnese@nortel.ca> said:
>Basically I want a perl script (or something similiar) to be able to
>send it's output into an application like say x3270.  Is there a 
>way to do this (buffers or something).

You mean from a command line?  Use xterm -e.  For instance, to show a big file
in an xterm, I can say:
xterm -e less F1040.PS

Make sure your program doesn't exit before you are finished reading the
output, however - you might want to put a "hit any key to continue" type thing
at the end of your program.


-- 
Paul Tomblin, Contract Programmer.
I don't speak for Kodak, they don't speak for me.
(Email that is not work related should go to: ptomblin@xcski.com)
"You are in a twisty maze of Motif Widget resources, all inconsistent."


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

Date: Mon, 17 Feb 1997 23:42:51 GMT
From: boekhout@azww.com (John Boekhout)
Subject: What does flock do?
Message-Id: <5eaqeb$gj4@argentina.earthlink.net>

(this is a duplicate posting because I accidentally posted
the first one as a response to someone else's posting.  I
wanted this to be the beginning of the thread)

I've got  a Perl CGI script that changes a file (from a
form) and I am having problems with more than one user
submitting the form at the same time and not handling the
file operation properly.

I found this example in the Perl documentation on using
flock to handle a counter file, but I don't understand it:

     $counter = "/home/shishir/counter.dat";
     print "Content-type: text/plain", "\n\n";

     open (FILE, $counter) || die "Cannot read from the
counter file.\n";
     flock (FILE, 2);   #step 1
     $visitors = <FILE>;
     flock (FILE, 8);  #step 2
     close (FILE);

     open (FILE, ">" . $counter) || die "Cannot write to
counter file.\n";
     flock (FILE, 2);
     print FILE $visitors;
     flock (FILE, 8);
     close (FILE);

My question is, what good did it do to lock the file at step
1 when it is unlocked at step 2 before writing out the new
counter value?  Why wasn't the file kept locked before
reading and then unlocked after writing out the new counter
value.

I'm guessing I just don't understand what flock does???

Also, I spent quite a while searching the Perl web site for
a clear description of what flock does, and couldn't find
it.  Any description of flock just said "calls flock(2) on
filehandle" and "see manual page for flock(2)" neither of
which could be found (by me).  Any help finding this info
would be appreciated.

Please help.  Thanks.
John Boekhout
boekhout@azww.com



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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

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 V7 Issue 965
*************************************

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