[17580] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5000 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 30 18:05:43 2000

Date: Thu, 30 Nov 2000 15:05:17 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975625517-v9-i5000@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 30 Nov 2000     Volume: 9 Number: 5000

Today's topics:
        [OT] Re: force the browser to download instead of viewi <joe+usenet@sunstarsys.com>
        [Q] Running DOS based program from CGI <kjlim@ecn.purdue.edu>
    Re: About to slit my own throat (Craig Berry)
        Calling Perl from Perl??? ilwilson@frontiernet.net
    Re: Calling Perl from Perl??? dtbaker_dejanews@my-deja.com
    Re: checking if mail address is valid <mischief@velma.motion.net>
        compute time difference bing-du@tamu.edu
    Re: compute time difference eggrock@my-deja.com
        Debug a forked/exec Perl script started from another Pe <Johan.Vermeire@alcatel.be>
    Re: Debug a forked/exec Perl script started from anothe dtbaker_dejanews@my-deja.com
        Exporter mark@Mark-Walter.org
        FAQ 4.27:   How can I count the number of occurrences o <faq@denver.pm.org>
        Getting properties of a word-file with Win::32OLE <gauthier.vandemoortele@win.be>
        Hashes and printing values with CGI.pm xlr6drone@my-deja.com
    Re: Hashes and printing values with CGI.pm dtbaker_dejanews@my-deja.com
        HELP BEFORE ME HEAD EXPLODES neurofase@my-deja.com
    Re: HELP! flock problem on NFS mounted dev? <ddunham@redwood.taos.com>
    Re: How do I format my message string ? <gjchap99@my-deja.com>
    Re: How do I format my message string ? <W.Hielscher@mssys.com>
    Re: How do I format my message string ? <gjchap99@my-deja.com>
    Re: how to determine the image size by perl? <kjlim@ecn.purdue.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 30 Nov 2000 14:31:47 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: [OT] Re: force the browser to download instead of viewing the file.
Message-Id: <m3bsuxuuho.fsf@mumonkan.sunstarsys.com>

tmai@prince.carleton.ca (Trung Mai) writes:

>  I want to have a link in perl which will force the browser to download
> the file. I'v a link <a href="http://link.com/linktofile/files.zip"> this
> will do only if the file is zip,gzip,rar,... However, if the file is
> file.txt the browser won't download. It's display the file. 
>  I think I have to do some thing with the MINE type, but I don't know
> how.. please help??

s/MINE/MIME/ and you've hit the nail on the head.  This is webserver-related,
not perl-related (and therefore offtopic) so what you need to do is read your 
webserver doc's for setting the MIME type of a file based on the file's 
extension.

HTH
-- 
Joe Schaefer


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

Date: Thu, 30 Nov 2000 15:03:10 -0500
From: KJ <kjlim@ecn.purdue.edu>
Subject: [Q] Running DOS based program from CGI
Message-Id: <3A26B27E.EB4959A@ecn.purdue.edu>

I try to run DOS based program from my CGI.

This DOS based program needs user input.
If user enter 11 for Illinois state, then it display all counties in
Illinois.
then if i enter county_id, then it display all cities in that counties.

I would like to run this interactive DOS-based program from the WWW.

Here is a copy of my CGI.

This DOS program doesn't read paramter as an input file name.
So I need to do something for carridge return.

KJ


--0=-=--==


-=-=-=-=-=

#!c:\perl\bin\perl

print "Content-Type: text/html\n\n";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
        foreach $pair (@pairs) {
                ($name, $value) = split(/=/, $pair);
                $value =~ tr/+/ /;
                $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
hex($1))/eg;
                $in{$name} = $value;
                }



$filename= $in{'filename'} ;

system("/DOSPROGRAM/CITYUSA.exe") ;

print "\n" ;
print "11\n" ;
print "1\n" ;
print "$filename\n" ;
print "n\n" ;

-=-=


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

Date: Thu, 30 Nov 2000 23:00:23 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: About to slit my own throat
Message-Id: <t2dn079e9ld650@corp.supernews.com>

Jerome O'Neil (jerome@activeindexing.com) wrote:
: cberry@cinenet.net (Craig Berry) elucidates:
: > Anthony (apsaffer@hotmail.com) wrote:
: >: No, it is NOT a spam generator. It is an anonymous email program made
: >: for a legitimate organization that will not use it for spam.  
: > 
: > I can't think of any legitimate use for automated anonymous email.
: 
: Whistle blowers.

That is many-to-one, and could be handled trivially by a simple
form-to-mail app.  Let me clarify that I can see no legitimate need for
automated anonymous email to a large number of recipients, as in the OP's
scenario. 

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Here's to the struggles of the silent war,
   |   here's to the closing of the age." -The Call


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

Date: Thu, 30 Nov 2000 21:45:26 GMT
From: ilwilson@frontiernet.net
Subject: Calling Perl from Perl???
Message-Id: <906hpk$pok$1@nnrp1.deja.com>

I have a Perl password maintenance script in Unix, which is controlled
online via HTML calls. The script is abviously called using something
like myscript.cgi?USER=username&PASSWORD=password ..... etc.  I would
also like to call the script from the Unix prompt as well as from HTML,
but with as little code-changing as possible.

Is there a simple method of calling the script from the command-line so
that I can still retrieve the info using the standard "read_input"
routine, via the ENV variables?  ie. Different manner of calling, but
same method of retrieval.

Thanks
Ian


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


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

Date: Thu, 30 Nov 2000 21:51:26 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Calling Perl from Perl???
Message-Id: <906i4r$puf$1@nnrp1.deja.com>

In article <906hpk$pok$1@nnrp1.deja.com>,
  ilwilson@frontiernet.net wrote:
> I have a Perl password maintenance script in Unix, which is controlled
> online via HTML calls. The script is abviously called using something
> like myscript.cgi?USER=username&PASSWORD=password ..... etc.  I would
> also like to call the script from the Unix prompt as well as from
HTML,
> but with as little code-changing as possible.
>
> Is there a simple method of calling the script from the command-line
so
> that I can still retrieve the info using the standard "read_input"
> routine, via the ENV variables?  ie. Different manner of calling, but
> same method of retrieval.
>
-------------
at the top of you script you can check for @ARGV and loads your vars....
and only use the param() to load them if there are no command lines
args. be careful though, you can only use 9 command-line args.

your alternative is to use the command-line variable loading techniques
allowed and documented in CGI.pm  Basically, you fire up your script and
if you are using CGI to handle your variables, it will ask you to load
the values interactively.

Dan


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


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

Date: Thu, 30 Nov 2000 20:58:12 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: checking if mail address is valid
Message-Id: <t2dfr47o9qe2d5@corp.supernews.com>

Sander van Gennip <sander@veenhoven.com> wrote:
> On Thu, 30 Nov 2000 16:02:01 +0100, Sebastian Meyer wrote:

>>sorry, mailprog crashed, here comes part 2:
>>first use regex to validate format of mail address and then try to resolve
>>via
>>DNS.
>>

> My routine already checks the syntax of the address, so this doesnt
> pose a problem. How do I resolve the addresss via DNS? Example:
> valid mail addresses exist on @finnforest.nl, but no server
> xxx.finnforest.nl exists.

You're not looking for an A record (host pointer). You are looking
for an MX record (mail transfer host) pointer. This has been pointed
out earlier in the thread. If an email address exists there, then
there most definitely is a mail server for it.

My mail server at home is neither www.anything nor smtp.anything
 - and not even mail.anything, which is popular, too. My home
mail server is, not surprisingly, funhouse.mischief.motion.net,
or at least it is in my hosts file - I haven't updated DNS at work
for this change yet.

Some sites use smtp1 through smtp<n>, where
n=numberofmailserversatdomain.

Some domains use another domain's email servers. For example,
mail.motion.net is the mail server for 284 domains as of today.

The only 100% accurate way to check for email validity is to
run the mail servers at both far ends. Short of that, you have
options. You can issue a VRFY command to the mail server that
serves the domain, upon which it will check to see if the mail is
forwarded and where and such, or it will reject the VRFY command
as a security loophole. You can connect to the mail server and
issue a MAIL FROM: and a RCPT TO: with no DATA statement, which
will accept or reject an email, but will not tell you anything
about where it might go from there. Either way, you have to get
the MX record. Guessing about smtp.domain, mail.domain, pop.domain,
droid.domain, toto.domain, dorothy.domain,
networkadminsneicesshortenedformmiddlename.somerandomotherdomain,
etc. is pretty much pointless if your goal is for high accuracy.

Give me Socket.pm, IO::Socket, or Net::Telnet to do most of these
tasks. I'd probably want a module for DNS, too, if you want it
portable. I'm not intimately familiar with how to do whois or
nslookup from scratch off the top of my head, so if I didn't use a
module I'd probably pipe to nslookup to get the MX record.

Chris

--
Christopher E. Stith -- mischief@motion.net



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

Date: Thu, 30 Nov 2000 19:56:10 GMT
From: bing-du@tamu.edu
Subject: compute time difference
Message-Id: <906bcm$jr7$1@nnrp1.deja.com>

Does Perl have a similar function to DateDiff in VB?

Thanks,

Bing


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


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

Date: Thu, 30 Nov 2000 20:52:31 GMT
From: eggrock@my-deja.com
Subject: Re: compute time difference
Message-Id: <906emd$mj7$1@nnrp1.deja.com>

In article <906bcm$jr7$1@nnrp1.deja.com>,
  bing-du@tamu.edu wrote:
> Does Perl have a similar function to DateDiff in VB?
>
> Thanks,
>
> Bing

There is a Date::Calc module available.

(Stolen from the Perl Cookbook)
use Date::Calc qw(Delta_Days);
$diff = Delta_Days( $year1, $month1, $day1, $year2, $month2, $day2 );

It'll do the hours, minutes and seconds as well (Delta_DHMS).

Otherwise, convert the dates to Epoch seconds and subtract, then divide
by 86400 for the difference in days.

Use the Time::localtime module to convert to Epoch seconds.

Happy hacking....


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


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

Date: Thu, 30 Nov 2000 22:11:25 +0100
From: Johan Vermeire <Johan.Vermeire@alcatel.be>
Subject: Debug a forked/exec Perl script started from another Perl script
Message-Id: <3A26C27B.AF700E56@alcatel.be>

This is a multi-part message in MIME format.
--------------313A175B7A980965ABD0005B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Does anybody known the correct method to debug a forked/exec Perl
script.
The forked/exec Perl script is started from a Parent Perl script during
debug mode.

When the Parent process forks a child process, the Perl debugger
activates
a separate x-term with the forked/exec Perl script (only when you step
into the fork statement!).
But when the exec process in the Child process starts, then the Perl
debugger looses control.


I'm using Perl 5.005_03 on Sparc Solaris 2.6

Thanks anyway, if you can give me a valuable hint.

Johan.Vermeire@alcatel.be


--------------313A175B7A980965ABD0005B
Content-Type: text/x-vcard; charset=us-ascii;
 name="Johan.Vermeire.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Johan Vermeire
Content-Disposition: attachment;
 filename="Johan.Vermeire.vcf"

begin:vcard 
n:Vermeire;Johan
tel;fax:+32 3 2409950
tel;work:+32 3 2404189
x-mozilla-html:FALSE
org:Alcatel Bell
adr:;;F. Wellesplein 1;Antwerp;;2018;
version:2.1
email;internet:Johan.Vermeire@alcatel.be
title:Tools & Technology Officer
fn:Johan Vermeire
end:vcard

--------------313A175B7A980965ABD0005B--



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

Date: Thu, 30 Nov 2000 21:54:40 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Debug a forked/exec Perl script started from another Perl script
Message-Id: <906ias$q0j$1@nnrp1.deja.com>

In article <3A26C27B.AF700E56@alcatel.be>,
  Johan Vermeire <Johan.Vermeire@alcatel.be> wrote:
> This is a multi-part message in MIME format.
> --------------313A175B7A980965ABD0005B
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Does anybody known the correct method to debug a forked/exec Perl
> script.
> The forked/exec Perl script is started from a Parent Perl script
during
> debug mode.
>
---------------
I dunno how correct it is, but sometimes I embed print statements that
either have a conditional flag, or go back and comment them out later.
You can get the error code for child procs, but it isnt very useful for
examining variable values at runtime.

D


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


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

Date: Thu, 30 Nov 2000 23:06:38 +0100
From: mark@Mark-Walter.org
Subject: Exporter
Message-Id: <906j1e$6cl$04$1@news.t-online.com>

Would like to know the reason for using the exporter modul. E.g.
I have a script where I reference annonymus arrays. I'am able to use 
them in my main routine differencing from the script where I stored 
the variables. I've seen this usage in the most cases while grepping 
over my linux system but where's the major field of application for 
this technique ?    

cu

Mark


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

Date: Thu, 30 Nov 2000 19:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ 4.27:   How can I count the number of occurrences of a substring within a string?
Message-Id: <MIxV5.31$_g6.189930496@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How can I count the number of occurrences of a substring within a string?

    There are a number of ways, with varying efficiency: If you want a count
    of a certain single character (X) within a string, you can use the
    `tr///' function like so:

        $string = "ThisXlineXhasXsomeXx'sXinXit";
        $count = ($string =~ tr/X//);
        print "There are $count X characters in the string";

    This is fine if you are just looking for a single character. However, if
    you are trying to count multiple character substrings within a larger
    string, `tr///' won't work. What you can do is wrap a while() loop
    around a global pattern match. For example, let's count negative
    integers:

        $string = "-9 55 48 -2 23 -76 4 14 -44";
        while ($string =~ /-\d+/g) { $count++ }
        print "There are $count negative numbers in the string";

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep comming up.  If you are some how irritated by
seeing these postings you are free to ignore them or add the sender
to your killfile.  If you find errors or other problems with these
postings please send corrections or comments to the posting email
address.

If you are not able to find this or other Perl documentation from
your installation you may access it via the web by following the
appropriate links from one of the addresses listed below.

    http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search
    http://www.perldoc.com
    http://www.cpan.org
    http://www.perl.com

Answers to questions about LOTS of other stuff, mostly not related to
Perl, can be found at

    news:news.answers

and in the many thousands of other useful Usenet news groups.

The perlfaq manual pages contain the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

    When included as an integrated part of the Standard
    Distribution of Perl or of its documentation (printed or
    otherwise), this work is covered under Perl's Artistic
    License.  For separate distributions of all or part of
    this FAQ outside of that, see the perlfaq manpage.

    Irrespective of its distribution, all code examples here
    are public domain.  You are permitted and encouraged to
    use this code and any derivatives thereof in your own
    programs for fun or for profit as you see fit.  A simple
    comment in the code giving credit to the FAQ would be
    courteous but is not required.

-- 
    This space intentionally left blank


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

Date: Thu, 30 Nov 2000 20:50:21 +0100
From: Gauthier Vandemoortele <gauthier.vandemoortele@win.be>
Subject: Getting properties of a word-file with Win::32OLE
Message-Id: <3A26AF7D.37A8F26B@win.be>

Hello,

I've done a little script that "walks" through a tree of directories and
creates in each an HTML-file giving a summary of certain types of files
within. So, with a browser, you can navigate and get some information
about the files ; this is extracted from <title> and <meta-tags> of the
HTML-files, from "{\info }" strings of the RTF, same with PDF where you
have strings like "/Producer (GNU Ghostscript 4.03)" and so.  But this
script was initially used on a linux-box for the maintenance of a
website, and now I try to adapt it at work on Windows-NT, where most of
files are microsoft-doc.

But I don't know *anything* about this system, VisualBasic, OLE...

With some research in archives of forums and Visual Basic-help, I've
produced this ugly little piece of code, and it works in most of cases. 

##################################################################################
##

$application=Win32::OLE->new('Word.Application');
# (foreach $file_doc) 
$document=$application->Documents->Open("$file_doc");

$title=$document->BuiltinDocumentProperties->Title->{"Value"};
$subject=$document->BuiltinDocumentProperties->Subject->{"Value"};
$author=$document->BuiltinDocumentProperties->Author->{"Value"};
$keywords=$document->BuiltinDocumentProperties->Keywords->{"Value"};
$comments=$document->BuiltinDocumentProperties->Comments->{"Value"};
$date_cre=$document->BuiltinDocumentProperties->{"Creation
Date"}->{"Value"};

$document=$application->Documents->Close;
# and so...
$application->Quit;

##################################################################################
#
But I'm disappointed to see that when it encounters an error with a
particular file, the whole script dies !
By ex. :
OLE exception from "Microsoft Word":

Win32::OLE(0.1101) error 0x800a1066
    in METHOD/PROPERTYGET "Open" at H:\UTIL\Index_repertoires.pl line
122
Can't call method "BuiltinDocumentProperties" on an undefined value at
H:\UTIL\I
ndex_repertoires.pl line 123, <FICHIER_HTML> chunk 19.

  
Win32::OLE(0.1101) error 0x8001010a: "The message filter indicated that
the
application is busy"
    in METHOD/PROPERTYGET "" at H:\util\Index_repertoires.pl line 122
Can't use an undefined value as a HASH reference at
H:\util\Index_repertoires.pl
 line 122, <FICHIER_HTML> chunk 296.

It could be safer to open the doc-files read-only (in case of somebody
has all open it) but I don't know how translate the VisualBasic Code : 
Documents.Open FileName:="C:\MyFiles\MyDoc.doc", ReadOnly:=True
When I try 
$document=$application->Documents->Open("$fichier_doc, ReadOnly:=True
");
the string is of course considered as a whole filename. How add an
optional "Variant" to a VB-Method, like
"SaveChanges:=wdDoNotSaveChanges"
to "Quit" ?

Could someone give me a simple solution to do that, and, more generally,
to avoid this script dies whenever it meets an "OLE exception from
"Microsoft Word":" ?

It's not /so/ (!) important if I don't get the information from the
file,
but it's important that the script runs continuously without human
intervention, so Word *can't* open a undesirable window to propose to
save the file with another name and so...

Thanks by advance,

-- 


 #=---------------------------------------------------=#
 "          ^^      Gauthier Vandemoortele             "
 |   (_____/°°-ç    gauthier-vdm@ibelgique.com         |
 |   |     \_`-"                                       |
 |   )/@mmm||       Chée de Wavre, 135c                |
 |   \nn   \nn      B-1360 Perwez                      |
 |                  Belgique                           |
 " FOE-Belgium : http://www.ful.ac.be/hotes/amisterre  "
 #=---------------------------------------------------=#


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

Date: Thu, 30 Nov 2000 20:53:43 GMT
From: xlr6drone@my-deja.com
Subject: Hashes and printing values with CGI.pm
Message-Id: <906eom$mkm$1@nnrp1.deja.com>

Hello,

I am trying to obtain the values from a fill out form using CGI.pm

All of the code is here:

http://tmrdesign.netfirms.com/mycode.pl.txt (you'll need to reference
this)

The part of the code that I am having a problem with is below.
Basically I want to take the information that the users inputs into the
fields and get the value of each of those fields.

the fields that pertain to user input are stored in a hash called
%FIELDS.  This is then combined like so:

# accumulate the field names into %ALL_FIELDS;
foreach (values %FIELDS) {
    grep($ALL_FIELDS{$_}++,@$_);
}

With that done I then want to take what the user inputs and send it as an
email.  However when I try that below.  I get this in the body of the
email.

-value1-value1-value1-value1-value1-value1-value1-value1-value1

I don't understand enough of the script to realize what is going on here.
Can anyone explain more of what is going on in this script?  When you run
the script you get a bunch of fields that need user input (that span 3
different pages)  So I want to obtain the user inputted values and send
them as an email in addition to having the review page that it is in the
script now.

any suggestions would be greatly appreciated

best,
Tim



####
#sendmail test
####
open(MAIL,"|/usr/lib/sendmail -t") || &ErrorMessage("error opening
sendmail");

print MAIL "To: tim\@mcreative.com\n";
print MAIL "From: tim\@mcreative.com\n";
print MAIL "Subject: Testin CGIpm mail\n\n";
foreach (values %ALL_FIELDS) {
    print MAIL (-value=>$_);
}
close(MAIL);


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


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

Date: Thu, 30 Nov 2000 22:07:31 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Hashes and printing values with CGI.pm
Message-Id: <906j2t$qr9$1@nnrp1.deja.com>

In article <906eom$mkm$1@nnrp1.deja.com>,
  xlr6drone@my-deja.com wrote:
> Hello,
>
> I am trying to obtain the values from a fill out form using CGI.pm
---------
you are making this harder than it needs to be i think.... If you are
using CGI.pm, then a call to param() returns an array of all variable
names. You could then go thru and load up all the values. Be careful
whether you get the values in scalar or list context depending on how
the data is loaded into the variable!

most domain hosts have scripts available that do exactly what you are
wanting to do.... and you wont have to mess with figuring out sendmail,
unless you want to do some special preprocessing. Just check around for
order form scripts.

D


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


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

Date: Thu, 30 Nov 2000 22:42:52 GMT
From: neurofase@my-deja.com
Subject: HELP BEFORE ME HEAD EXPLODES
Message-Id: <906l5b$sht$1@nnrp1.deja.com>

I am a complete novice with perl, even though i first starting using it
a year ago.

All I do is use edit pad to cut and paste and alter perl forms that I
already have. I am trying to make up a new bit of perl but i keep
hitting brick walls.

Is there any good programs which most people use, like using
Dreamweaver for HTML.

Thanks for your help

neurofase@yahoo.com


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


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

Date: Thu, 30 Nov 2000 20:11:05 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: HELP! flock problem on NFS mounted dev?
Message-Id: <tvyV5.40221$Wq1.15880799@nnrp5-w.sbc.net>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Henry_Barta  <hbarta@enteract.com> wrote in comp.lang.perl.misc:

> [when flock() isn't available]

>>    For a situation like this, could directory creation/deletion
>>    be used as a pseudo-lock? The scheme I'm thinking of would be:
>>
>>	Create directory. If not successful, delay and retry or
>>	conclude failure.
>>
>>	Do whatever is controlled by the 'lock'.
>>
>>	Remove the directory.
>>
>>    I believe this has been used in other situations where reliable
>>    locking is not available. It will work if directory creation
>>    is atomic. (e.g. success guarantees that another process has not
>>    and now cannot create the same directory.)

> Yes, that, or creating a hard link (with a given name) to an existing
> file.  That's another way of using the file system for a test-and-set
> operation.  Both are supposedly atomic in the sense that they are
> accomplished in a single system call.  The mkdir solution may be
> marginally slower (it creates two hard links in addition to the new
> directory), but that's a small concern.

> Both methods have been known as the poor man's lock for a long while.
> Both have the drawback that they create a file which can potentially
> survive the process that has created it.  Careful catching of signals
> and a suitable END block can help, but kill -9 is a sure way to create
> a permanent lock.  That's why flock() is preferable where available.
> It locks file handles, which are reliably returned to the system when
> a process ends.

While they may be atomic on local disk, they are not necessarily atomic
via NFS.    Because NFS has to deal with packets possibly duplicated on
the network, things like this can get by.

I'm pretty sure there is no NFS2 call for "atomic file creation".  So it
may be possible for two machines to test and create on top of each
other.

It *may* be guaranteed if only one machine is talking to the server (but
with two processes on it writing), but I don't know how far I'd trust
that.

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
      < Please move on, ...nothing to see here,  please disperse >


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

Date: Thu, 30 Nov 2000 19:14:50 GMT
From: Jack Altradmon <gjchap99@my-deja.com>
Subject: Re: How do I format my message string ?
Message-Id: <9068v4$hm1$1@nnrp1.deja.com>

Thanks for that guys...  corrected that mistake but that really doesn't
solve my problem. I'll try and explain it abit better this time...

I have a subroutine which expects 2 arguments, a message string and a
user id.

The message string will be defined something like this before calling
the subroutine:

$string = "Header\n\nLine1\nLine2\n..etc";

I want the subroutine to send a net message that will appear like this
at the users terminal:

From : ServerPC
To   : FredBloggs
Header

Line1
Line2
 ..etc

I create an internal message string in the subroutine:

$internal_string = "From : ${computername}\nTo   : $ARGV[1]\n".$string;

but if you send this with Win32::Message it arrives as :

From : ServerPc\nTo  : FredBloggs\nHeader\n\nLine1\nLine2\n..etc

i.e not formatted as I want which is no good at all but is probably
something to do with how the Win32::Message module works internally.

As a test, I set the internal message in a semi-hardcoded HERE doc :

$internal_string =<<"EOM"
From : $computername
To   : $ARGV[1]
Header

Line1
Line2
 ..etc
EOM

sending this in Win32::Message gave me the result I wanted but if I did
this:

$internal_string =<<"EOM"
From : $computername
To   : $ARGV[1]
$string
EOM

all I get is

From : ServerPC
To   : FredBloggs
Header\n\nLine1\nLine2\n..etc

So what I need to know is how to convert a string such as

"Title\nLine1\nLine2\tTabbed

to a hardcoded HERE doc like this:

$x =<"HERE"
Title
Line1
Line2   Tabbed
HERE

Hope that makes the question clearer...

In article <da5d2t0utp370ugjfq7bgnpinhpo581btj@4ax.com>,
  Bart Lateur <bart.lateur@skynet.be> wrote:
> Jack Altradmon wrote:
>
> >However if I do something like this as a test :
> >
> >$message =<<'END_OF_MESSAGE'
> ...
>
> >and use this string I get my formatted message but no substitution.
>
> Of course not. You want:
>
> 	$message =<<"END_OF_MESSAGE"
>
> (double quotes)
>
> --
> 	Bart.
>


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


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

Date: Thu, 30 Nov 2000 21:33:49 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: How do I format my message string ?
Message-Id: <3A26B9AD.9C7AF808@mssys.com>

Jack Altradmon wrote:
> The message string will be defined something like this before calling
> the subroutine:
> 
> $string = "Header\n\nLine1\nLine2\n..etc";
[snip]
> As a test, I set the internal message in a semi-hardcoded HERE doc :
> 
> $internal_string =<<"EOM"
> From : $computername
> To   : $ARGV[1]
> Header
> 
> Line1
> Line2
> ..etc
> EOM
> 
> sending this in Win32::Message gave me the result I wanted but if I did
> this:
> 
> $internal_string =<<"EOM"
> From : $computername
> To   : $ARGV[1]
> $string
> EOM
> 
> all I get is
> 
> From : ServerPC
> To   : FredBloggs
> Header\n\nLine1\nLine2\n..etc

I don't think that you're precisely describing your problem especially
the description of the way your $string is defined. Try running this
piece of code:

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

my $str_yes = "Title\nLine1\nLine2\n";
my $str_no  = 'Title\nLine1\nLine2\n';
my $str_here = <<EOM;
Title
Line1
Line2
EOM

print "\$str_yes  eq  \$str_here\n"  if $str_yes  eq  $str_here;
print "\$str_no   eq  \$str_here\n"  if $str_no   eq  $str_here;

As you can see, $str_yes and $str_here are equal. This means for the
code you displayed  that the interpolation of your $string in your
here-document shouldn't make any difference.
So I think your $string gets defined similar to $str_no in my example,
where \n are _two_ characters, a literal backslash and a literal n.


If these hints still aren't enough, how about stripping your _real_ code
down to a minimal programm that, in conjunction with some data you
supply, still show your problem?!

Cheers
	Wolfgang


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

Date: Thu, 30 Nov 2000 21:41:13 GMT
From: Jack Altradmon <gjchap99@my-deja.com>
Subject: Re: How do I format my message string ?
Message-Id: <906hhn$pdc$1@nnrp1.deja.com>

Wolfgang...

Thanks, that snippet does work as you say. I think I can see my error
now. Cutting my program down to the very barest essentials, what I'm
effectively trying to do is this :

$message = shift;

print $message;

If I run this with an argument of "Title\n\nLine1\nLine2" it just
prints "Title\n\nLine1\nLine2". As you said, the \n's are interpreted
as two characters not escapes...

What I really should be doing is something like :

($message = shift) =~ s/\\n/\n/g;;

print $message;

Thanks for that.. a really basic error. Still, I needed to see the wood
amongst the trees..

In article <3A26B9AD.9C7AF808@mssys.com>,
  Wolfgang Hielscher <W.Hielscher@mssys.com> wrote:
> Jack Altradmon wrote:
> > The message string will be defined something like this before
calling
> > the subroutine:
> >
> > $string = "Header\n\nLine1\nLine2\n..etc";
> [snip]
> > As a test, I set the internal message in a semi-hardcoded HERE doc :
> >
> > $internal_string =<<"EOM"
> > From : $computername
> > To   : $ARGV[1]
> > Header
> >
> > Line1
> > Line2
> > ..etc
> > EOM
> >
> > sending this in Win32::Message gave me the result I wanted but if I
did
> > this:
> >
> > $internal_string =<<"EOM"
> > From : $computername
> > To   : $ARGV[1]
> > $string
> > EOM
> >
> > all I get is
> >
> > From : ServerPC
> > To   : FredBloggs
> > Header\n\nLine1\nLine2\n..etc
>
> I don't think that you're precisely describing your problem especially
> the description of the way your $string is defined. Try running this
> piece of code:
>
> #/usr/bin/perl -w
> use strict;
>
> my $str_yes = "Title\nLine1\nLine2\n";
> my $str_no  = 'Title\nLine1\nLine2\n';
> my $str_here = <<EOM;
> Title
> Line1
> Line2
> EOM
>
> print "\$str_yes  eq  \$str_here\n"  if $str_yes  eq  $str_here;
> print "\$str_no   eq  \$str_here\n"  if $str_no   eq  $str_here;
>
> As you can see, $str_yes and $str_here are equal. This means for the
> code you displayed  that the interpolation of your $string in your
> here-document shouldn't make any difference.
> So I think your $string gets defined similar to $str_no in my example,
> where \n are _two_ characters, a literal backslash and a literal n.
>
> If these hints still aren't enough, how about stripping your _real_
code
> down to a minimal programm that, in conjunction with some data you
> supply, still show your problem?!
>
> Cheers
> 	Wolfgang
>


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


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

Date: Thu, 30 Nov 2000 14:52:46 -0500
From: KJ <kjlim@ecn.purdue.edu>
Subject: Re: how to determine the image size by perl?
Message-Id: <3A26B00E.1F266307@ecn.purdue.edu>

check out wwwis on the search engine.
It reads all image file format and return width and height.

# for documentation - changelog and latest version
# see http://www.bungeezone.com/~ark/wwwis/
#  or http://www.tardis.ed.ac.uk/~ark/wwwis/
#

KJ


jin zengxiang wrote:
> 
> Hi,there:
> I want to develop a personal image search engineering that can "borrow"
> the images I want to my local disk ,but I
> found that many images are not really useful because the size of them is
> too small ,so does any one know how to
> determine the image size by perl modules? thanks very much.
> 
> Rgds ,
> Alan Jin Z.X.


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

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


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