[26236] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8421 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 15 06:05:28 2005

Date: Thu, 15 Sep 2005 03:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 15 Sep 2005     Volume: 10 Number: 8421

Today's topics:
        Better way of checking file/directory spec in Win32? <news@lawshouse.org>
    Re: File Modification Date <josef.moellers@fujitsu-siemens.com>
    Re: Newbie Q: Is it Possible to ? <josef.moellers@fujitsu-siemens.com>
    Re: Open variable txt file <josef.moellers@fujitsu-siemens.com>
    Re: perl or php (middleagedgeek)
        Suggestions needed for text extraction <goth1938@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 15 Sep 2005 08:49:04 +0100
From: Henry Law <news@lawshouse.org>
Subject: Better way of checking file/directory spec in Win32?
Message-Id: <1126770544.14988.0@ersa.uk.clara.net>

Running under Activestate on Windows XP I have need to feed a series of 
directory and file specifications to a program, which then interprets 
them.  Specifications can be directories, single file names, or wildcard 
combinations like c:\foo\bar\*.pdf which result in lists of matching files.

The specifications need to be validated to weed out those that don't 
refer to an existing directory, or that result in no matching files. 
I've Googled and searched CPAN for a module that does this, since it 
must be a common requirement, but without success.  Can someone suggest one?

Here's the subroutine I wrote to do the job, so you'll see what I'm 
trying to do.  If it needs to exist then comments on how to smarten it 
up would be welcome.

#! /usr/bin.perl

use strict;
use warnings;

use constant VALID_DIRECTORY => -1;
use constant VALID_FILE => -2;

print "Enter spec: ";
my $spec = <STDIN>;
chomp $spec;
while ($spec) {
	my $ret = interpret_spec($spec);
	if ($ret == VALID_DIRECTORY) {
		print "'$spec' is a valid directory\n";
	} elsif ($ret == VALID_FILE) {
		print "'$spec' is an existing file\n";
	} elsif ($ret) {
		print "'$spec' results in $ret files\n";
	} else {
		print "'$spec' doesn't match any file or directory\n";
	}
	print "=> ";
	$spec=<STDIN>;
	chomp $spec;
}

sub interpret_spec{
	# Checks a file/directory specification.  Returns
	#	0		Spec matches nothing
	#	-1		It's a valid directory specification
	#	-2		It's a valid single file specification
	#	number	It's a glob, resulting in "number" files
	
	my $spec = shift;
	return VALID_DIRECTORY if (-d $spec);
	return VALID_FILE if (-f $spec);
	my @globs = glob $spec;
	if (scalar @globs == 1){
		return ((-f $globs[0]) ? 1 : 0);
	} else {
		return scalar @globs;
	}
}


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

Date: Thu, 15 Sep 2005 08:28:05 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: File Modification Date
Message-Id: <dgb45a$2sl$1@nntp.fujitsu-siemens.com>

Vance M. Allen wrote:
> Sorry for the confusion; for this project, I needed the modification da=
te,=20
> but if anyone knows how to get the creation date too, that's great.  I'=
m=20

You're not really asking that question, do you, since

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrndig6ml.30j.tadmc@magna.augustmail.com...

>    perldoc -f stat
 >    perldoc -f -X
 >    perldoc -f localtime

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Thu, 15 Sep 2005 08:54:22 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Newbie Q: Is it Possible to ?
Message-Id: <dgb5mc$cs7$1@nntp.fujitsu-siemens.com>

Harvey Rothenberg wrote:
> To Whom It May Concern :
>=20
> I am new to Perl.  I am looking for direction as to being able to compi=
le
> self running programs regardless of OS with Perl.  I know that it is ca=
pable
> to compile a Perl program ( which I have not done yet either),  but I
> thought the difficulty would be to create one that works in any Intel
> hardware based Platform but disregarding the Op Sys ?

No. Plain and simple "No".

While certain problems can be solved, no matter what OS the program runs =

on top of, OS-specific problems cannot be solved OS-independently.
Obviously you could code for a number of OSes ("if ($^O eq 'MSWin32')",=20
"if ($^O eq 'linux')", but look at the caveat in perldoc pervar).
If you do try to write highly portable code, be carefull to separate the =

OS-dependent code from the OS-independent code.

"any" is a limitless word.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Thu, 15 Sep 2005 08:42:54 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Open variable txt file
Message-Id: <dgb50v$7rk$2@nntp.fujitsu-siemens.com>

Brian Wakem wrote:
> Tony Heagren wrote:
>=20
>=20
>>Hi All,
>>
>>new to this so forgive if this is a very obvious question.
>>
>>Is there a way to tell perl to open a txt file from a variable passed
>>(in this case) from Flash.
>>
>>ie instead of using this:
>>open(FILE,">../www/folder/exact_filename.txt") or print
>>"response=3Dtrouble";
>>
>>could I use something like this:
>>open(FILE,">$a_txt_file_name_passed_from_flash_as_a_variable") or print=

>>"response=3Dtrouble";
>=20
>=20
>=20
> You could, but don't.
>=20
> What if someone passes in /etc/passwd ?

Yes, what if?
If the program is run under root, then, indeed, that would be a problem. =

If an ordinary user did that, he'd get slapped on his wrist.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Thu, 15 Sep 2005 09:55:56 GMT
From: NOSPAM_mrcabdriver@canada.com (middleagedgeek)
Subject: Re: perl or php
Message-Id: <43294521.6746218@aioe.org>

i read somewhere that PHP was more exploitable than perl....


On Tue, 6 Sep 2005 22:19:52 +1000, "eddiec"
<chalk@no.spam.netspace.net.au> wrote:

>hi everyone,
>
>given I have a choice in a new company if we will use mysql together with
>either perl or php does anyone have any thoughts which we should go for?
>
>pros of perl: looks cleaner: is closer to unix scripting
>
>any reason to go for php?
>
>any advice would be much appreciated
>
>TIA
>
>eddiec :-)
>
>



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

Date: Thu, 15 Sep 2005 17:34:23 +0800
From: "Just in" <goth1938@hotmail.com>
Subject: Suggestions needed for text extraction
Message-Id: <dgbf70$jgr$1@news01.intel.com>

I'm running 5.6.1 on Linux and have written code utilising X11::GUITest to
perform some very labour intensive click and expand routines. I am very
pleased with what has been achieved thus far, but I would like to achieve
more.

On execution of the code the GUI pops a window up. This window contains
letters that need selection by double clicking, dragging and dropping to
another window that can be spawned from the main GUI.

I've written code to ensure that the click and drag from one window to
another using X11::GUITest actually works. But in order to realise this the
code needs to know the XY coordinates of the letters that need to be
selected, dragged and dropped.

The problem is with the letters themselves, since they are of variable
length and can start at various coordinates since they are preceded with
line numbers that run from 1..9999 e.g.:

1 (A, B, CC, D, EE)
2 (X, Y)
 .
 .
 .
5896 (PP, Q, RR, T, SSS)
 .
 .
 .
9999 (N, M)

I'm able to control what line I want to select, but based on the above if I
wanted to select and drag PP, Q, RR, T, SSS how can I determine their
respective coordinates?

I was wondering if there is a way of capturing the screen image and parsing
it for anything in between brackets. From there I could determine how many
items need selecting, dragging and dropping and then from there I could look
for their XY coordinates from the captured image. I though of this wild idea
as I vaguely remember there being modules to do this sort of thing.

Does this sound feasible? If so what modules exist that would help me, and
if not what better suggestions do you have?

Any input [+-]'ve would be appreciated.

Thanks

Just in




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 8421
***************************************


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