uploading files

2001-06-30 Thread Carmen Marincu


Hi -

I know that you can upload files in CGI.
But I was wondering if it is possible to upload all the files contained
in a given directory.
Does anyone know or did that ?

Thanks -
Carmen




Re: How is this doing what I want it too?

2001-06-30 Thread Me

[note: for some reason, your perl script came through
(at least on my email client) as an attachment. if you
can stop that happening, that would be nice.]

-

 for ($i=0; $b[$i] != undef; $i++)

!= is a numeric comparison.

Line 1544 of list is:

#stopped at 867

and in perl's book, that isn't a number.


 for ( $i = 0; !!$b[$i] ; $i++)

! alone, is a generic 'not'. It is neither a numeric nor
a string operator.

!! is redundant. It means 'not not'. You can just leave it out:

for ($i=0; $b[$i]; $i++)

In general:

1. If you just want an obvious is this thing set?, just
say things like:

if ($foo)

2. Don't do comparisons with undef. If you really need
to test the definedness of something (not something
you really need to do much as a beginner), say
something like:

if (defined $foo)




Re: How is this doing what I want it too?

2001-06-30 Thread M.W. Koskamp



 for ($i=0; $b[$i] != undef; $i++)
 {
 print STDOUT $b[$i];
 }

 and that seem logical but I was getting complaints such as..
 Argument #stopped at 867\n isn't numeric in ne at ./page57_1.pl line
 9, FILEIN chunk 1544.

 anyhow hope you can enlighten me as to all this hullaballooo ;-)

The operator != is meant for numeric values.
The operator ne is meant for non numeric values.
If you want to check for both try this:

for ($i=0; defined $b[$i]; $i++)
 {
 print STDOUT $b[$i];
}

It will just check if $b[$i] has a defined value, regardless of it being
numeric or non-numeric.
I would suggest to use the defined function rather then using an not-equals
operator with the value undef.
But be warned: An empty string counts as a defined value:

my $a;
print defined $a;
$a = '';
print defined $a;

Maarten.




RegExp

2001-06-30 Thread Morgan

Hi

Can someone help me out with a simple question?

I need to match some parts if a document. and store it in variables so
I can send the matching string into more than one new file.

RegExp



while () {
$pub =~ if (/pub/i .. /\/pub/i )   # or is it better with an
array or hash?
}
open (DOC, $newfile or die$!;
print DOC $pub;
close (DOC) or die $!;

open (FILE, $new or die $!;
print FILE $pub;
close (FILE);
--

I can't get it to work.
Am I on the trail or have I just lost it :)








Re: How is this doing what I want it too?

2001-06-30 Thread Abdulaziz Ghuloum

You seem to be doing everything correctly except for the for loop as you've
thought.  You have:

for($i=0; !!$b[$i]; $i++){
   print STDOUT $b[$i];
}

What you need instead is to say:
for($i=0; $i  @b; $i++){
   print $b[$i];
}

Remember, @b is evaluated in scalar context (@b = number of elements in array
b).  Remember also that perl arrays are not null-terminated lists where the
last element is undef.  

Also, print prints to STDOUT by default, so, no need to mention that.  

Of course there is more than one way to do what you want to do, but I was just
correcting the way *you* wanted to do it :-)

Aziz,,,



On Fri, 29 Jun 2001 22:19:06 -0600, Toni Janz said:

 I am just learning perl and have been doing some of the exercises in the
  llama book.
  
  I was doing page exercise one from page 57 and I was pulling out my hair
  as to why it was not working and then I did something experimental and
  got it to work. But to be honest I have no idea why it works.
  
  I will attatch it to this email so that mayhap you can explain why it
  does what it does.
  
  Note: the think that I added was the double bang '!!' 
  I was previously using things like:
  
  for ($i=0; $b[$i] != undef; $i++)
  {
  print STDOUT $b[$i];
  }
  
  and that seem logical but I was getting complaints such as..
  Argument #stopped at 867\n isn't numeric in ne at ./page57_1.pl line
  9, FILEIN chunk 1544.
  
  anyhow hope you can enlighten me as to all this hullaballooo ;-)




Re: RegExp

2001-06-30 Thread Abdulaziz Ghuloum

Hello,
Where did you come up with 
$pub =~ if (/pub/i .. /\/pub/i ) 
I guess you want to get the sting between the pub /pub tags, but that's not
how it's done.
You can do 
push @pub, m#pub(.*?)/pub#g; #it's better with an array
but that would break if you have the pub and /pub on separate lines. 
Basically, you cannot parse an XML file with one regexp.  Take a look at the
XML::Parser module or friends.

Hope this helps.


On Sat, 30 Jun 2001 13:05:15 +0200, Morgan said:
 Hi
  
  Can someone help me out with a simple question?
  I need to match some parts if a document. and store it in variables so
  I can send the matching string into more than one new file.
  RegExp
  
  while () {
  $pub =~ if (/pub/i .. /\/pub/i )   # or is it better with an
  array or hash?
  }
  open (DOC, $newfile or die$!;
  print DOC $pub;
  close (DOC) or die $!;
  
  open (FILE, $new or die $!;
  print FILE $pub;
  close (FILE);
  --
  
  I can't get it to work.
  Am I on the trail or have I just lost it :)






Re: RegExp

2001-06-30 Thread Jeff 'japhy' Pinyan

On Jun 30, Morgan said:

I need to match some parts if a document. and store it in variables so
I can send the matching string into more than one new file.

while () {
$pub =~ if (/pub/i .. /\/pub/i )
}

I think what you want to do here is:

  while () {
print if m!pub!i .. m!/pub!i;
  }

(Print to the proper filehandle, of course.)  This means print the line
if it is in between a line holding pub and a line holding /pub.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: How is this doing what I want it too?

2001-06-30 Thread Randal L. Schwartz

 Abdulaziz == Abdulaziz Ghuloum [EMAIL PROTECTED] writes:

Abdulaziz What you need instead is to say:
Abdulaziz for($i=0; $i  @b; $i++){
Abdulazizprint $b[$i];
Abdulaziz }

Or even simpler:

foreach (@b) {
print $_;
}

Or as we'd write it:

print @b;

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: How is this doing what I want it too?

2001-06-30 Thread Brett W. McCoy

On Fri, 29 Jun 2001, Toni Janz wrote:

 I will attatch it to this email so that mayhap you can explain why it
 does what it does.

Please don't send attachments to the list, just include your code int eh
body of the message.  A lot of attachments don't come with the proper MIME
header and can't be directly opened in many browsers (especially
text-based ones like Pine or Mutt).

 Note: the think that I added was the double bang '!!'
 I was previously using things like:

 for ($i=0; $b[$i] != undef; $i++)

Here's your problem -- you can't compare something to nothing.  != is only
used for comparing inequality for numbers.  ne is used for strings.  But
in this case, neither will work.  undef is not the same as NULL.  What you
want to do is check to see if the element is defined:

for($i = 0; defined($b[$i]); $i++) {

However, since we are using Perl and not C, we can make this even tidier:

foreach (@b) {  print }

-- Brett
   http://www.chapelperilous.net/btfwk/

May a hundred thousand midgets invade your home singing cheesy lounge-lizard
versions of songs from The Wizard of Oz.




RE: How is this doing what I want it too?

2001-06-30 Thread Steve Howard

And (Since there are so many ways to do things in Perl) if you absolutely
needed the index of the array as you were printing (like if something else
was being done inside the loop besides a simple loop) you can still do it
simpler than the C like loop you are using by doing a:

foreach (0..scalar(@b)-1) {

print index $_ in the array is $b[$_]\n;
}

or shorten the whole loop to one line with by doing this:

print Index $_ of the array is $b[$_]\n  foreach (0..scalar(@b)-1);


I can't class myself as an expert (but I'm working on it) but that kind of
flexibility is what I love about Perl. :-)

Steve H.



-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 30, 2001 9:56 AM
To: Toni Janz
Cc: [EMAIL PROTECTED]
Subject: Re: How is this doing what I want it too?


On Fri, 29 Jun 2001, Toni Janz wrote:

 I will attatch it to this email so that mayhap you can explain why it
 does what it does.

Please don't send attachments to the list, just include your code int eh
body of the message.  A lot of attachments don't come with the proper MIME
header and can't be directly opened in many browsers (especially
text-based ones like Pine or Mutt).

 Note: the think that I added was the double bang '!!'
 I was previously using things like:

 for ($i=0; $b[$i] != undef; $i++)

Here's your problem -- you can't compare something to nothing.  != is only
used for comparing inequality for numbers.  ne is used for strings.  But
in this case, neither will work.  undef is not the same as NULL.  What you
want to do is check to see if the element is defined:

for($i = 0; defined($b[$i]); $i++) {

However, since we are using Perl and not C, we can make this even tidier:

foreach (@b) {  print }

-- Brett
   http://www.chapelperilous.net/btfwk/

May a hundred thousand midgets invade your home singing cheesy lounge-lizard
versions of songs from The Wizard of Oz.




RE: How is this doing what I want it too?

2001-06-30 Thread Brett W. McCoy

On Sat, 30 Jun 2001, Steve Howard wrote:

 And (Since there are so many ways to do things in Perl) if you absolutely
 needed the index of the array as you were printing (like if something else
 was being done inside the loop besides a simple loop) you can still do it
 simpler than the C like loop you are using by doing a:

 foreach (0..scalar(@b)-1) {

Don't even need to be that verbose, since an array used here would be in a
scalar context anyway -- the scalar function is superfluous here.  But you
can also use $#b, which gives the index of th last element:

foreach (0..$#b) {

-- Brett
   http://www.chapelperilous.net/btfwk/

Senate, n.:
A body of elderly gentlemen charged with high duties and misdemeanors.
-- Ambrose Bierce




Artistic License 2.0

2001-06-30 Thread Adam Theo


Hello, Adam Theo here;

i was wondering if the artistic license version 2.0 that i think is 
going to be used for Perl6 is finished? can it be effectively used as a 
standalone license, or should it be used in conjunction with the GPL again?

if someone could point me to a webpage or email it to me: 
[EMAIL PROTECTED], i'd be much obliged, thank you. also feel free 
to comment on it.
--
   /\   Theoretic Solutions (www.Theoretic.com):
  //\\'Activism, Software, and Internet Services'
//--\\ Personal Homepage (www.Theoretic.com/adamtheo/):
   ][ 'Personal history, analysis, and favorites'
   ][   Birthright Online (www.Birthright.net):
  'Keeping the best role-playing game alive'
Email  Jabber:   Other:
-Professional: [EMAIL PROTECTED]  -AIM: AdamTheo2000
-General: [EMAIL PROTECTED]   -ICQ: 3617307
-Personal: [EMAIL PROTECTED]  -Phone: (850)8936047




MYSql (fwd)

2001-06-30 Thread Ryan Gralinski


I can't find a module to open and read/write to a mySql database, can
someone help me out?

Ryan





RE: MYSql (fwd)

2001-06-30 Thread Steve Howard

You need DBI
and
DBD::MySQL

They should be avaliable on CPAN, or if you are using ActivePerl or PPM they
can be installed with just:

ppm install DBI
ppm install DBD::MYSQL

That should be all you need to interact with MySQL.

Steve Howard

-Original Message-
From: Ryan Gralinski [mailto:[EMAIL PROTECTED]]
Sent: Sunday, July 01, 2001 2:20 AM
To: [EMAIL PROTECTED]
Subject: MYSql (fwd)



I can't find a module to open and read/write to a mySql database, can
someone help me out?

Ryan




Re[7]: Best practice for config file use?

2001-06-30 Thread Tim Musson

Hey Grant,

Thursday, June 28, 2001, 5:34:26 PM, my MUA believes you used
Internet Mail Service (5.5.2653.19) to write:

GM You might like to check out XML::Simple it was designed for
GM exactly this problem.

GM If you put your config data in a file called foo.xml:

GM   config
GM usrfoo/usr
GM pwdbar/pwd
GM hostbleh.com/host
GM   /config

I think I will try this.  Thanks for the tip.  Will have to talk to
the 'users' and see if the XML format is ok - *I* like it, but g...

-- 
[EMAIL PROTECTED]
Using The Bat! (http://www.ritlabs.com/the_bat/) eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
5 days a week my body is a temple.  The other two, it's an amusement park.




Re[2]: ENV $HOME

2001-06-30 Thread Tim Musson

Hey Michael,

Wednesday, June 27, 2001, 3:17:32 AM, my MUA believes you used
(X-Mailer not set) to write:

MF On Wed, Jun 27, 2001 at 02:37:55AM -0400, Adam Theo wrote:
 i am looking for a way my perl program can automatically get the
 home directory of the user.

 linux, windows, mac, etc? also, what does ENV do for windows and
 mac users, since those are not typically milti-user OSes? and
 finally, while i have found the ENV, does anyone know of a better
 way to do this? thank you for your time.

MF I know Windows has environmental variables, and Perl can get to
MF them. I'm not sure if $ENV{HOME} will have a sane value, or any
MF value at all.

My Win32 machine has no HOME var (typical), it has
HOMEDRIVE=C:
HOMEPATH=\
Not what you are looking for I believe.

MF There is no real concept of a home directory anyways, unless you
MF count the primary hard drive, aka C.

If you are running in a Domain or Active Directory environment,
the admins could have set up a home dir on a network server, but I
don't think it will be set in the $ENV{HOME} variable... If
interested, I can check when at work monday. Let me know.

MF I can't help you with Mac

Same here...

-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
Why get even, when you can get odd?




Tk::After Error

2001-06-30 Thread Adam Theo


Hello, Adam Theo here;

i have built a Tk program to act as a alarm clock. it was a while ago 
that i created it, and was pretty sure it was working, but now that i go 
back to it, it is giving this error when i press the button to stop the 
alarm:

Tk::Error: Can't locate object method IsWidget via package Tk::After 
(perhaps you forgot to load Tk::After?) at 
/usr/local/lib/perl5/site_perl/5.6.1/i586-linux/Tk.pm line 173.
  [\main::beep_stop]
  Tk callback for .frame4.button
  Tk::__ANON__ at /usr/local/lib/perl5/site_perl/5.6.1/i586-linux/Tk.pm 
line 228
  Tk::Button::butUp at 
/usr/local/lib/perl5/site_perl/5.6.1/i586-linux/Tk/Button.pm line 111
  (command bound to event)

here is the relevant code from the program. this is certainly not all 
the code, though:

### set off the beep alarm
# recieve the alarm number to work with.
# start the Tk alarm.
# set the number's status as 'down' in the hash.
# save hash,
# sending '-1' to save only what is in hash now.
sub beep_alarm {
 my($number) = @_;
 my($status);
 print(Starting alarm $number.\n);
 $beep_repeat = $main_w-repeat($interval, sub {$f2-bell});
 print(Bringing alarm $number status down.\n);
 $config-{alarm}-[$number]-{status}-[0] = 'Down';
 alarm_refresh('-1');
}

 ### stop alarm
 $f5-Button(
 -text = 'Stop',
 -command = \beep_stop
 )-pack(-expand = '1', -fill = 'x');

### stop the beep alarm
# stop the universal beep alarm,
# but only if it is running.
sub beep_stop {
 $beep_repeat-cancel() if Tk::Exists($beep_repeat);
}

any ideas pop out to anyone? thanks in advance.
--
   /\   Theoretic Solutions (www.Theoretic.com):
  //\\'Activism, Software, and Internet Services'
//--\\ Personal Homepage (www.Theoretic.com/adamtheo/):
   ][ 'Personal history, analysis, and favorites'
   ][   Birthright Online (www.Birthright.net):
  'Keeping the best role-playing game alive'
Email  Jabber:   Other:
-Professional: [EMAIL PROTECTED]  -AIM: AdamTheo2000
-General: [EMAIL PROTECTED]   -ICQ: 3617307
-Personal: [EMAIL PROTECTED]  -Phone: (850)8936047




Simple split() question

2001-06-30 Thread Sanjeeb Basak

Hi,

I want to perform a simple split operation, but can't get the regular expr
working. Can anybody help me on this?

my $line from a file read is:
xyz abc 12sd pqr stz dfg (delimited by blank char).

I'm doing
my ($par1, $par2, $par3, $par4, $par5) = split(/ /, $line);

and I'm getting
$par4 = pqr
$par5 = stz, which I don't want.

I want $par4 = pqr stz,  $par5 = dfg

Thanks in advance.
-Basak



_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




Simple split() Regexp question

2001-06-30 Thread Sanjeeb Basak

Hi,

I want to perform a simple split operation, but can't get the regular expr
working. Can anybody help me on this?

my $line from a file read is:
xyz abc 12sd pqr stz dfg (delimited by blank char).

I'm doing
my ($par1, $par2, $par3, $par4, $par5) = split(/ /, $line);

and I'm getting
$par4 = pqr
$par5 = stz, which I don't want.

I want $par4 = pqr stz,  $par5 = dfg

Thanks in advance.
-Basak




_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




Re: Simple split() question

2001-06-30 Thread Jeff 'japhy' Pinyan

On Jun 30, Sanjeeb Basak said:

I want to perform a simple split operation, but can't get the regular expr
working. Can anybody help me on this?

my $line from a file read is:
xyz abc 12sd pqr stz dfg (delimited by blank char).

I'm doing
my ($par1, $par2, $par3, $par4, $par5) = split(/ /, $line);

Using split() isn't good enough here.  You'll need to use a more involving
regex:

  my @pieces;
  push @pieces, $1 while
$line =~ /\G\s*([^]*)/gc or
$line =~ /\G\s*(\S+)/gc;

That code matches either quoted strings, or groups of non-whitespace, and
puts them, one-at-a-time, into @pieces.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: Simple split() question

2001-06-30 Thread Eric Beaudoin

At 01:40 2001.07.01, Jeff 'japhy' Pinyan wrote:
On Jun 30, Sanjeeb Basak said:

I want to perform a simple split operation, but can't get the regular expr
working. Can anybody help me on this?

my $line from a file read is:
xyz abc 12sd pqr stz dfg (delimited by blank char).

I'm doing
my ($par1, $par2, $par3, $par4, $par5) = split(/ /, $line);

Using split() isn't good enough here.  You'll need to use a more involving
regex:

  my @pieces;
  push @pieces, $1 while
$line =~ /\G\s*([^]*)/gc or
$line =~ /\G\s*(\S+)/gc;

That code matches either quoted strings, or groups of non-whitespace, and
puts them, one-at-a-time, into @pieces.

The module Text::ParseWords might do exactly want you want. The functions in it allow 
you to split line with quote in them.

With the line 

one two three four

parse_line('\s', 0, $line) returns the list ('one', 'two', 'three four'). If you put 1 
instead of 0 for the second parameter, the quotes are kept with the result.

Even better, if you need a quote in one your entries, you can \ed it. So, the line

one two three \four

would result in the list ('one', 'two', 'three four'). 

The doc of the module is way clearer than me.

Hope it helps.



---
Éric Beaudoinmailto:[EMAIL PROTECTED]




Re: Code Review Needed!

2001-06-30 Thread dave hoover

At the suggestion of a few people I've converted the
program into text files to make things easier for
reviewers.  Here are the four files:

http://www.redsquirreldesign.com/soapbox/Soapbox.pm.txt
http://www.redsquirreldesign.com/soapbox/main.txt
http://www.redsquirreldesign.com/soapbox/soap.txt
http://www.redsquirreldesign.com/soapbox/soapbox.conf.txt

I am particularly interested in feedback about: 
  Any common newbie blunders you may find 
  Security issues 
  Specific areas where the code could be more
efficient 
  A critique on my use of object-oriented Perl 

The feedback I have received thus far has been very
helpful. It's been a learning
experience...particularly about taint checking!

Thanks,

--Dave


--- dave hoover [EMAIL PROTECTED] wrote:
 I would greatly appreciate ANY feedback anyone could
 provide. The following page will provide details and
 a
 link to download the tarball.
 
 http://www.redsquirreldesign.com/soapbox
 
 TIA
 
 
 =
 Dave Hoover
 Twice blessed is help unlooked for. --Tolkien
 http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/