Re: File uploading

2003-07-18 Thread fliptop
On Fri, 18 Jul 2003 at 12:03, Mike Harrison opined:

MH:I have a perl program that allows a user to upload a file (either .jpg or
MH:.gif) to the server, and returns a message if it exceeds a specified size
MH:(in my case 100kB).  Currently (and don't laugh - I am new to perl), I go
MH:through the motions of uploading the file in 1024-byte blocks (in binary
MH:mode), and increment a counter with each block.  If the counter exceeds 100
MH:(i.e. greater than 100kB), then it exits the loop, displays a warning
MH:message and deletes the file.
MH: 
MH:I am sure there would have to be an easier and more efficient way of doing
MH:this - that is, somehow finding out how large the file is without having to
MH:download it first.
MH: 
MH:Does perl have a module that can check the size of the file?  And for that
MH:matter, its type (.jpg, .gif etc.)?

hi mike - CGI provides a way to indicate if an form post exceeds a
pre-determined size limit.  it's the $CGI::POST_MAX variable, and if you
wanted to limit uploads to 100kbytes (for example), you'd do something
like this:

use CGI;
$CGI::POST_MAX = 100 * 1024;

my $cgi = new CGI;

if ($cgi-cgi_error) {
  # alert the user their post exceeded the limit
  exit();
}

you can find out more information by reading

perldoc CGI


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: File uploading

2003-07-18 Thread Mike
Thanks fliptop.

The $CGI::POST_MAX variable worked well.

What if I now want to upload 2 files.  The first can be up to 100k in size
and the second up to 80k in size?  That is pretty much the way I have it set
up at the moment...

Or should I admit defeat at this stage and allow 2 files to be uploaded that
have a combined size of 180k maximum?

Is there a way of knowing the file size after say:

my @pic_filenames = ($query-param('picfile1'), $query-param('picfile2'));

where picfile1  picfile2 are defined from the multipart/form-data post.
Can I then check the size along the lines of (where FILESIZE is some
function to get the size of a file)...

if (( FILESIZE (@pic_filenames[0])  1024*100) || (FILESIZE
(@pic_filenames[1])  1024*80)) {
   # print error message here
}

Thanks in advance,
Mike.


 On Fri, 18 Jul 2003 at 12:03, Mike Harrison opined:

 MH:I have a perl program that allows a user to upload a file (either .jpg
or
 MH:.gif) to the server, and returns a message if it exceeds a specified
size
 MH:(in my case 100kB).  Currently (and don't laugh - I am new to perl), I
go
 MH:through the motions of uploading the file in 1024-byte blocks (in
binary
 MH:mode), and increment a counter with each block.  If the counter exceeds
100
 MH:(i.e. greater than 100kB), then it exits the loop, displays a warning
 MH:message and deletes the file.
 MH:
 MH:I am sure there would have to be an easier and more efficient way of
doing
 MH:this - that is, somehow finding out how large the file is without
having to
 MH:download it first.
 MH:
 MH:Does perl have a module that can check the size of the file?  And for
that
 MH:matter, its type (.jpg, .gif etc.)?

 hi mike - CGI provides a way to indicate if an form post exceeds a
 pre-determined size limit.  it's the $CGI::POST_MAX variable, and if you
 wanted to limit uploads to 100kbytes (for example), you'd do something
 like this:

 use CGI;
 $CGI::POST_MAX = 100 * 1024;

 my $cgi = new CGI;

 if ($cgi-cgi_error) {
   # alert the user their post exceeded the limit
   exit();
 }

 you can find out more information by reading

 perldoc CGI


 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: File uploading

2003-07-18 Thread fliptop
On Fri, 18 Jul 2003 at 23:46, Mike opined:

M:What if I now want to upload 2 files.  The first can be up to 100k in size
M:and the second up to 80k in size?  That is pretty much the way I have it set
M:up at the moment...
M:
M:Or should I admit defeat at this stage and allow 2 files to be uploaded that
M:have a combined size of 180k maximum?

since $CGI::POST_MAX examines the overall size of the entire post, there
wouldn't be a way to use it to determine sizes of multiple files
individually.  in this case, you'd have to split the uploads into 2 forms,
or use one of the other methods that were suggested to examine each file 
on its own.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: File uploading

2003-07-18 Thread Octavian Rasnita
Just a warning.
This method doesn't work right under Windows.
The file is fully uploaded, then it is tested if the max size of the file is
overdone. If the file size is 10 GB, the file is fully uploaded first,
then... doesn't matter ... but the program will work, and after it finish
uploading, it tells the visitor that the file is too big.

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: fliptop [EMAIL PROTECTED]
To: Mike Harrison [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Friday, July 18, 2003 4:19 PM
Subject: Re: File uploading


On Fri, 18 Jul 2003 at 12:03, Mike Harrison opined:

MH:I have a perl program that allows a user to upload a file (either .jpg or
MH:.gif) to the server, and returns a message if it exceeds a specified size
MH:(in my case 100kB).  Currently (and don't laugh - I am new to perl), I go
MH:through the motions of uploading the file in 1024-byte blocks (in binary
MH:mode), and increment a counter with each block.  If the counter exceeds
100
MH:(i.e. greater than 100kB), then it exits the loop, displays a warning
MH:message and deletes the file.
MH:
MH:I am sure there would have to be an easier and more efficient way of
doing
MH:this - that is, somehow finding out how large the file is without having
to
MH:download it first.
MH:
MH:Does perl have a module that can check the size of the file?  And for
that
MH:matter, its type (.jpg, .gif etc.)?

hi mike - CGI provides a way to indicate if an form post exceeds a
pre-determined size limit.  it's the $CGI::POST_MAX variable, and if you
wanted to limit uploads to 100kbytes (for example), you'd do something
like this:

use CGI;
$CGI::POST_MAX = 100 * 1024;

my $cgi = new CGI;

if ($cgi-cgi_error) {
  # alert the user their post exceeded the limit
  exit();
}

you can find out more information by reading

perldoc CGI


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Assigning a singe value to a list

2003-07-18 Thread Paul D. Kraus
Is there a way to assign a single value to a list? other then doing the
obvious and spelling out each list assignment or running through a loop.

For instance...

my ( $var1, $var2, $var3, ... ) = Paul
assigning paul to all variables in the list.

or a more useful example

my  ($passed1, $passed2, ... ) = shift

Paul Kraus



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help

2003-07-18 Thread Paul D. Kraus
Keith Olmstead [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello,

 Been searching though this list for awhile now, and now I am needing some
help.  I am not asking for someone to do my code for me,  I am trying to
learn perl and the only way for me to do that is to dive staight into it.

 My problem is with the theory of the script that I am trying to write.  I
am needing something to backup logs for me from a central log server.  They
layout of these files are as follows.

 /host/ip/year/month/day/log1, log2, etc

 Every file and dir under dir1 is created dynamically by the logging
program, syslog-ng.

 What I am wanting to do is create a script that will tar and gzip the day
dirs at the end of the day and remove the dir after it has been backed up.
After the month is finished, I would like the same done for it.

 Currently there are 20ish host dirs, one of each server that is logging to
this box.  There will be more and when they get pointed to this server, the
ip dir will be created for that host and each dir under that will also be
created for the corresponding date.  The logs need to be kept for 2-3
months, and then deleted.

 I am needing help thinking this script out, maybe get ideas of how to set
it up.  From reading using File::Find, might be useful.

 I was thinking about writing a script that runs in cron each night that
tars and gzp the log dirs.  Currently I have a script that is getting a list
of the dir, but I don't really know  where to go from there.  I need to get
it to dive into the dir to the day lvl and archive the previous days logs.

 Here are 2 scripts that I have been playing with.  I don't even know if I
am going in the right direction.

 #!/usr/bin/perl
 use strict;
 use warnings;

 my $dir = '/opt/log/hosts/';

 opendir(DIR, $dir) or die Cannot open Directory;

 # read the dir contents into a list, and grep out the . and .. dir entries
 my @entries = grep (!/^\.\.?$/ , readdir (DIR));
 closedir(DIR);
 foreach (@entries)
 {
   print $_\n;
 }

 and

 #!/usr/bin/perl

 use File::Find;
 use strict;
 use warnings;
 my $startdir = $ARGV[0];
 my @dirlist;
 find(
 sub {
 return if -d and /^\.\.?$/;
 push @dirlist, $_ if -d;
 }, $startdir);

 #my $file_list = join 'BR', @dirlist;
 my $file_list = @dirlist;
 print $file_list;

 Like I said before, I am not asking for someone to do my work just some
guidiance in the right direction.

 TIA,

 Keith Olmstead




File Find is a good place to start. Also do a search on search.cpan.org for
Zip. Assuming the script is running on the server with the logs you should
be able to do everything you want with these two modules.

Paul Kraus



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Assigning a singe value to a list

2003-07-18 Thread Janek Schleicher
Paul D. Kraus wrote at Thu, 17 Jul 2003 15:33:11 -0400:

 Is there a way to assign a single value to a list? other then doing the
 obvious and spelling out each list assignment or running through a loop.
 
 For instance...
 
 my ( $var1, $var2, $var3, ... ) = Paul
 assigning paul to all variables in the list.
 
 or a more useful example
 
 my  ($passed1, $passed2, ... ) = shift


As you know how many items are on the left side of the list,
you can use the x operator:

my ( $var1, $var2, $var3, $var4 ) = (Paul) x 4;

That works the same with shift.
But note that in this way, $passed1 would be equal to $passed2 and so on

If you wanted to have $passed1 with the first passed argument,
$passed2 with the second one and so on,
you should use the @_ array directly:

my ($passed1, $passed2, $passed3 ) = @_;


BTW: If you would have an array instead of a list at the left side,
 everything becomes easier:
$_ = a value foreach @array;


Greetings,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Is there a simple way to include source code I've written in other files?

2003-07-18 Thread Janek Schleicher
Jamie Risk wrote at Thu, 17 Jul 2003 10:39:56 -0400:

 Until now, I've avoided writing modules by inlining the deisred code in the
 new files. Messy.  I'm avoiding modules for two reasons, laziness and naive
 conception that for what I'm trying to do it's overkill.
 
 Is there a method to reference code in other files, like, a simple
 include?

You can also check out
perldoc -f do EXPR


Greetings,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Regular Expression (fwd)

2003-07-18 Thread Janek Schleicher
Trensett wrote at Wed, 16 Jul 2003 18:29:51 -0500:

 The next will work:
 my @variable = $string =~ /\((.*?)\)/g;
 
 what's the exact implication of .*??
 Why wouldn't just .* in parenthesis work for this case?

A good answer can also be found in
perldoc perlre
and
perldoc -q greedy


Greetings,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Assigning a singe value to a list

2003-07-18 Thread Rob Dixon
Janek Schleicher wrote:
 Paul D. Kraus wrote at Thu, 17 Jul 2003 15:33:11 -0400:

  Is there a way to assign a single value to a list? other then
  doing the obvious and spelling out each list assignment or
  running through a loop.
 
  For instance...
 
  my ( $var1, $var2, $var3, ... ) = Paul
  assigning paul to all variables in the list.
 
  or a more useful example
 
  my  ($passed1, $passed2, ... ) = shift


 As you know how many items are on the left side of the list,
 you can use the x operator:

 my ( $var1, $var2, $var3, $var4 ) = (Paul) x 4;

 That works the same with shift.
 But note that in this way, $passed1 would be equal to $passed2 and
 so on

 If you wanted to have $passed1 with the first passed argument,
 $passed2 with the second one and so on,
 you should use the @_ array directly:

 my ($passed1, $passed2, $passed3 ) = @_;


 BTW: If you would have an array instead of a list at the left side,
  everything becomes easier:
 $_ = a value foreach @array;

This works with a list Janek, and would be my preferred solution.

  $_ = 'Paul' foreach my ( $var1, $var2, $var3, $var4 );

But note, Paul, that your second example is very different from
your first. Copying a subroutine's parameters into a number
of scalar variables is done just as Kanek hash said. This is
a standard Perl idiom.

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: File uploading

2003-07-18 Thread Ramon Chavez
Hello.

CGI.pm module can restrict the size of the file being uploaded.
You canb use something like this:

my $max_size = 512000; #For 500kb limit

$CGI::POST_MAX=$max_size;

If the file size is bigger than that, it stop the process and returns an
error message.


But, thinking about it now, it's better to know the size of the file and
don't even waste time trying to upload it if it's too big, than begin the
upload and finish it if you get to the limit.

It may be a good idea to use the -s flag as 'awarsd' said to decide if
begining the upload process, but keep CGI::POST_MAX for security reasons.

-rm-


- Original Message -
From: Mike Harrison [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 17, 2003 9:03 PM
Subject: File uploading


 Hello,

 I have a perl program that allows a user to upload a file (either .jpg or
 .gif) to the server, and returns a message if it exceeds a specified size
 (in my case 100kB).  Currently (and don't laugh - I am new to perl), I go
 through the motions of uploading the file in 1024-byte blocks (in binary
 mode), and increment a counter with each block.  If the counter exceeds
100
 (i.e. greater than 100kB), then it exits the loop, displays a warning
 message and deletes the file.

 I am sure there would have to be an easier and more efficient way of doing
 this - that is, somehow finding out how large the file is without having
to
 download it first.

 Does perl have a module that can check the size of the file?  And for that
 matter, its type (.jpg, .gif etc.)?

 Thanks in advance,
 Mike.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: File uploading

2003-07-18 Thread Ramon Chavez
Hello.

CGI.pm module can restrict the size of the file being uploaded.
You canb use something like this:

my $max_size = 512000; #For 500kb limit

$CGI::POST_MAX=$max_size;

If the file size is bigger than that, it stop the process and returns an
error message.


But, thinking about it now, it's better to know the size of the file and
don't even waste time trying to upload it if it's too big, than begin the
upload and finish it if you get to the limit.

It may be a good idea to use the -s flag as 'awarsd' said to decide if
begining the upload process, but keep CGI::POST_MAX for security reasons.

-rm-


- Original Message -
From: Mike Harrison [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 17, 2003 9:03 PM
Subject: File uploading


 Hello,

 I have a perl program that allows a user to upload a file (either .jpg or
 .gif) to the server, and returns a message if it exceeds a specified size
 (in my case 100kB).  Currently (and don't laugh - I am new to perl), I go
 through the motions of uploading the file in 1024-byte blocks (in binary
 mode), and increment a counter with each block.  If the counter exceeds
100
 (i.e. greater than 100kB), then it exits the loop, displays a warning
 message and deletes the file.

 I am sure there would have to be an easier and more efficient way of doing
 this - that is, somehow finding out how large the file is without having
to
 download it first.

 Does perl have a module that can check the size of the file?  And for that
 matter, its type (.jpg, .gif etc.)?

 Thanks in advance,
 Mike.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Short silly question

2003-07-18 Thread Gabor Urban
Hi,


could someone give me a quick info whar __END__ and __DATA__ lines are
good for?

Gabaux

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Short silly question

2003-07-18 Thread Rob Dixon
Gabor Urban wrote:
 Hi,


 could someone give me a quick info whar __END__ and __DATA__ lines
 are good for?


Short silly answer:

__END__ing the program and starting the __DATA__ that you can
read from the implicit DATA filehandle.

Rob





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to call / push an elem to a hash of array ?

2003-07-18 Thread LI NGOK LAM
my (%LIST, @other_list);

@other_list = ( Unknown Length Data Elems );

foreach my $col (@lists)
{
for (@other_list)
{  
if ( exist $LIST{$col}[0] ) { Do_smth_2 }  # But ERROR either

What should I write here ? So can push vars to $LIST{$col}
}
}


Thanks in advise


Re: Simple process controll question

2003-07-18 Thread Ming Deng
Ramprasad wrote:

else
Instead in your main program call
do foo.pl args...
And in foo.pl set some scope defined variable like

#foo.pl
$dbh=connect()
unless($dbh){
  $GLOBAL::ERRORSTR=Couldnot connect to database $@;
   exit 1
}
And in the main program you can check

if($GLOBAL::ERRORSTR) {
  # Hmm something went wrong
...
}

But personally I consider this as dirty work though it works. Let me 
know If you get a better way

Ram
I don't understand how can perl pass variables across processes. Sort of 
 magic?



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: custom return value from entire script

2003-07-18 Thread Paul Archer
 Anyone know if it's possible for the return/exit value of a script, in the
 event of success, to be something other than 0?

The 'exit' command should work just like it does in the shell: 'exit 9;' for
example, *should* give you an exit status of 9 (although I couldn't get it
to work for me a minute ago...).

 I want to call, from a shell script, a perl script that determines a certain
 record ID from a database.  When the ID has been obtained, the script would
 exit, and the calling shell script would receive the returned value.

Why muck around with exit statuses? Just have the perl script print the
value you want, then in your shell script you can do something like:
myID=`perl_script_to_return_ids`
Or just do it all in Perl. 8-)


 The 'return' command doesn't allow this - I've thought of setting an env
 variable - not sure how to export it from perl so the environment sees it.
 Would like to get plan A to work first though..

Impossible. You can't run a subcommand and have it set a variable for the
calling shell. If Peter Parker gets bit by a radioactive spider and gains
spidey-powers, he could pass those powers to his kids--but never his
parents.

Paul



-
Welcome to downtown Coolsville--population: us.
-

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: fast match count of char in string

2003-07-18 Thread Paul Archer
Here's a quick way:
perl -e '$var=abdaatela; print ((scalar grep /a/,(split /(.)/,$var)),\n);'

grep returns the number of matches in a scalar context, and the split breaks
the string up into separate elements. The parens in the split return the
item split on (otherwise it would throw away each character it encountered).

Paul

PS. Wow, it almost looks like I know what I'm talking 'bout, don't it? 8-)


Yesterday, Juerg Oehler wrote:

 hi,

 how do efficent count char 'a' in string abdaatela ?

 i guess there are better solutions than:

 $tmpstr =~ s/[^a]//g ;
 $cnt = length ($tmpstr) ;
 print (found $cnt a's $tmpstr\n);

 thanx
 george






My parents just came back from a planet where the dominant lifeform
had no bilateral symmetry, and all I got was this stupid F-Shirt.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: fast match count of char in string

2003-07-18 Thread Steve Grazzini
On Fri, Jul 18, 2003 at 01:15:15PM -0500, Paul Archer wrote:
 Here's a quick way:
 perl -e '$var=abdaatela; print ((scalar grep /a/,(split /(.)/,$var)),\n);'
 
 grep returns the number of matches in a scalar context, and the split breaks
 the string up into separate elements. The parens in the split return the
 item split on (otherwise it would throw away each character it encountered).

Okay, but split // is the usual idiom:

  perl -le 'print $n = grep /a/, split //, abdaatela'

And /./g is a bit shorter.

  perl -le 'print $n = grep /a/, /./g for abdaatela'

And of course, you could just match a in the first place.

  perl -le 'print $n = () = /a/g for abdaatela'

And tr/// is how you ought to count characters.

  perl -le 'print tr/a// for abdaatela'

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to call / push an elem to a hash of array ?

2003-07-18 Thread Zeus Odin
What are you trying to do? If you could include a brief example, it
would be nice.

Li Ngok Lam wrote:
 my (%LIST, @other_list);
 
 @other_list = ( Unknown Length Data Elems );
 
 foreach my $col (@lists)
 {
 for (@other_list)
 {  
 if ( exist $LIST{$col}[0] ) { Do_smth_2 }  # But ERROR either
 
 What should I write here ? So can push vars to $LIST{$col}
 }
 }
 
 
 Thanks in advise
 




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help

2003-07-18 Thread Jostein Berntsen
On 17.07.03,14:51, Keith Olmstead wrote:
 Hello,
 
 Been searching though this list for awhile now, and now I am needing some help.  I 
 am not asking for someone to do my code for me,  I am trying to learn perl and the 
 only way for me to do that is to dive staight into it.
 
 My problem is with the theory of the script that I am trying to write.  I am needing 
 something to backup logs for me from a central log server.  They layout of these 
 files are as follows.
 
 /host/ip/year/month/day/log1, log2, etc
 
 Every file and dir under dir1 is created dynamically by the logging program, 
 syslog-ng.
 
 What I am wanting to do is create a script that will tar and gzip the day dirs at 
 the end of the day and remove the dir after it has been backed up.  After the month 
 is finished, I would like the same done for it.
 
 Currently there are 20ish host dirs, one of each server that is logging to this box. 
  There will be more and when they get pointed to this server, the ip dir will be 
 created for that host and each dir under that will also be created for the 
 corresponding date.  The logs need to be kept for 2-3 months, and then deleted.
 
 I am needing help thinking this script out, maybe get ideas of how to set it up.  
 From reading using File::Find, might be useful.  
 
 I was thinking about writing a script that runs in cron each night that tars and gzp 
 the log dirs.  Currently I have a script that is getting a list of the dir, but I 
 don't really know  where to go from there.  I need to get it to dive into the dir to 
 the day lvl and archive the previous days logs.
 
 Here are 2 scripts that I have been playing with.  I don't even know if I am going 
 in the right direction.
 
 #!/usr/bin/perl
 use strict;
 use warnings;
  
 my $dir = '/opt/log/hosts/';
  
 opendir(DIR, $dir) or die Cannot open Directory;
  
 # read the dir contents into a list, and grep out the . and .. dir entries
 my @entries = grep (!/^\.\.?$/ , readdir (DIR));
 closedir(DIR);
 foreach (@entries)
 {
   print $_\n;
 }
 
 and
 
 #!/usr/bin/perl
  
 use File::Find;
 use strict;
 use warnings;
 my $startdir = $ARGV[0];
 my @dirlist;
 find(
 sub {
 return if -d and /^\.\.?$/;
 push @dirlist, $_ if -d;
 }, $startdir);
  
 #my $file_list = join 'BR', @dirlist;
 my $file_list = @dirlist;
 print $file_list;
 
 Like I said before, I am not asking for someone to do my work just some guidiance in 
 the right direction.
 
 TIA,
 
 Keith Olmstead
 

Hi,

As often is the case with Perl it's a good thing to be inspired by 
others good work. Check this:

http://www.dienhart.com/software/PERL_Scripts/documentation/daboobak.shtml#

- Jostein

 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-- 
Jostein Berntsen [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Regex extraction skipping lines

2003-07-18 Thread Andrew Thomas
Anyone have any ideas about this - is there a common mistake I might be 
making here?

I am using a simple regex to extract a few pieces of every line of a 2000+ 
line text file then spitting it back into a second text file. I can't figure 
out why but the output file always includes every other line from the input 
file. Any thoughts?

Thanks

-Andy

_
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Regex extraction skipping lines

2003-07-18 Thread Rob Dixon
Andrew Thomas wrote:
 Anyone have any ideas about this - is there a common mistake I
 might be making here?

 I am using a simple regex to extract a few pieces of every line of
 a 2000+ line text file then spitting it back into a second text
 file. I can't figure out why but the output file always includes
 every other line from the input file. Any thoughts?

This is my thought:

  You're using /\n/ in your regex? Don't.

Beyond that, you need to tell us a whole lot more. Try starting
with you early school subjects and qualifications, how you related
to your tutor and so on. After that we need to know the people
with major influence in your life, your age and sexual orientation.
Oh, and your program and input format.

Rob







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Regex extraction skipping lines

2003-07-18 Thread Mark Anderson
 Anyone have any ideas about this - is there a common mistake I might be
 making here?

 I am using a simple regex to extract a few pieces of every line of a 2000+
 line text file then spitting it back into a second text file. I can't
figure
 out why but the output file always includes every other line from the
input
 file. Any thoughts?

Generally it help if you show us a snippet of your code.

I'm guessing that you're opening the file for read, let's call it FILE and
doing a while (FILE) loop.  Now, I'd guess your error is that you are
using FILE again somewhere within the loop, but without more information,
and ideally some actual code, it's very difficult to debug.

/\/\ark


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to call / push an elem to a hash of array ?

2003-07-18 Thread John W. Krahn
Li Ngok Lam wrote:
 
 my (%LIST, @other_list);
 
 @other_list = ( Unknown Length Data Elems );
 
 foreach my $col (@lists)
 {
 for (@other_list)
 {
 if ( exist $LIST{$col}[0] ) { Do_smth_2 }  # But ERROR either

If you want to test if the array has any elements you can do this:

  if ( @{$LIST{$col}} ) { Do_smth_2 }  # But ERROR either


 What should I write here ? So can push vars to $LIST{$col}

  push @{$LIST{$col}}, 'something';

 }
 }


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: chomp'ing EOL

2003-07-18 Thread Wiggins d'Anconia
Jamie Risk wrote:
I've no control over the EOL of text files that I'm processing; is there a
conveniant method using chomp() and the INPUT_RECORD_SEPERATOR ($/) to
handle DOS/UNIX/MAC generated text files automatically?
Handle them how?

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


php mod perl 5.8 apache2 question

2003-07-18 Thread Motherofperls
Hi all,

I have downloaded and installed perl with apache and php

Here are the readme file folders for each part of the packaged file 
Perl-5.8-win32-bin-0.1.exe

openssl-0.9.6h
php-4.23
mod_perl-2.0
httpd-2.0.43
AP804_source

I have apache running ok and perl,  but I can't get the hello world file for 
php to display Hello World

htmlbody
?php
$myvar = Hello World;
echo $myvar;
?
/body/html

I've uncommented these lines in my Apache2 httpd.conf file
# Uncomment the following for php
LoadFile C:/Apache2/bin/php4ts.dll
LoadModule php4_module modules/php4apache2.dll
AddType application/x-httpd-php .php

Also the Paths to Perl and Apache are in my autoexec.bat file.
The .dll files for php are in the apache2/bin folder.

What else should I check for?  









Re: Simple process controll question

2003-07-18 Thread Ramprasad A Padmanabhan
On Fri, 2003-07-18 at 22:34, Ming Deng wrote:

 Ramprasad wrote:
 
  else
  Instead in your main program call
  do foo.pl args...
  
  And in foo.pl set some scope defined variable like
  
  #foo.pl
  $dbh=connect()
  unless($dbh){
$GLOBAL::ERRORSTR=Couldnot connect to database $@;
 exit 1
  }
  
  
  And in the main program you can check
  
  if($GLOBAL::ERRORSTR) {
# Hmm something went wrong
  ...
  
  }
  
  
  But personally I consider this as dirty work though it works. Let me 
  know If you get a better way
  
  Ram
 
 I don't understand how can perl pass variables across processes. Sort of 
   magic?
 
 

Did you try it. If it works perl is a wizard else I am just wasting my
time
I think it is just that when you do a 'do foo.pl' No new perl instance
is forked. It is just that the perl interpreter instance that was
running your main code now interprets the foo.pl. 
Since it shares the same 'process environment'  I think maintaining any
variable does not require any harry potter skills
 


Ram




NETCORE SOLUTIONS *** Ph: +91 22 5662 8000 Fax: +91 22 5662 8134

MailServ: Email, IM, Proxy, Firewall, Anti-Virus, LDAP
Fleximail: Mail Storage, Management and Relaying
http://netcore.co.in

Emergic Freedom: Linux-based Thin Client-Thick Server Computing
http://www.emergic.com

BlogStreet: Top Blogs, Neighborhoods, Search and Utilities
http://www.blogstreet.com

Rajesh Jain's Weblog on Technology: http://www.emergic.org