Printing data into a file every time some presses ENTERHELP!!

2002-02-18 Thread Bruce Ambraal

Hi 

Could someone help?

the following code is not working.

open(INPUT_FILE,+fixed.dat) || die Could not open filename;
while (STDIN) {
print INPUT_FILE bruce\n;
}
close(INPUT_FILE);


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




RE: regrex question

2002-02-18 Thread mark crowe (JIC)

Or try:
$key =~ s/(\w+)/\u$1/g
Note, no need for the \w\w+ character class (in fact that doesn't work
right) and remember the 'g' modifier, to do all words, not just the first. 

Cheers

Mark C

 -Original Message-
 From: fliptop [mailto:[EMAIL PROTECTED]]
 Sent: 16 February 2002 14:07
 To: David Gilden
 Cc: [EMAIL PROTECTED]
 Subject: Re: regrex question
 
 
 David Gilden wrote:
 
  
  $key =Departure date;
  
  $key =~ s/([\w\w+])/\u$1/;
  
  
  --- Desired result:
  
  Departure Date
  
  What is wrong the above regrex?
 
 
 it's probably easier to use the ucfirst() function:
 
 my $key =Departure date;
 my @result = map { ucfirst } split /\s+/, $key;
 print join  , @result, \n;
 
 this prints
 
 Departure Date
 
 

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




Fwd: Printing data into a file every time some pressesENTERHELP!!

2002-02-18 Thread Bruce Ambraal

Hi 

Where's every one?

Or maybe our my server's down.

Help!

Cheers

---BeginMessage---

Hi 

Could someone help?

the following code is not working.

open(INPUT_FILE,+fixed.dat) || die Could not open filename;
while (STDIN) {
print INPUT_FILE bruce\n;
}
close(INPUT_FILE);


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



---End Message---

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


-default for filefield

2002-02-18 Thread Octavian Rasnita

Hi all,

I tried to specify the default value for a file field in a form, and I see
that in Internet Explorer it doesn't appear.

The code was:
print $screen-filefield(-name='file',
-default='c:\My Documents\test.txt',
..
the other parameters);

Do you know what's wrong?
Thanks.


Teddy,
My dear email address is [EMAIL PROTECTED]



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


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




HTML page seperator or page breaks?

2002-02-18 Thread Carolyn Bentley

Hi,

I need to be able to create a web page that has page breaks in it. I
need users to be able to print out multiple copies of invoices and
address
labels. I will have a CGI form that asks the user how many invoices and
how many address labels they need. Then I need to output some html,
which
can just be printed from the browser with each address label and invoice

on a seperate page.

I think there might be a way to do this with tables. However I cannot
find any documentation about it.

Is there anything you might suggest trying?

Thanks,
Carolyn


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




CGI page to provide image links (true beginner)

2002-02-18 Thread Stout, Joel R

I wanted a web page that was super easy to maintain (lazy person that I am).
I basically wanted to drop new images in the 'images' folder and have them
accessible, sorted with newest images at the top of the table.  What I came
up with works but I had various questions about how to improve the coding
and how to improve on the web page appearance (I've worked with css files
before but not with CGI).  Also I cut and paste some of the code from
perlmonks and if anyone could give me a step by step description of what it
actually does - that would be cool.  Here goes:

*   When I say print start_html($title), that includes the body tag
correct?  How do I add the background image.  Below I did it by adding
another line but I guess my real question is - What is the syntax when
adding parameter values when using the shortcut notation?  This may also
answer the 'What's the syntax for adding a css link?' question.   
*   I see many different 'styles' of CGI coding, is the one displayed
below outdated, sufficient or recommended?  I've seen many sites with CGI
examples and everyone seems to do it different.  Obviously, I don't use the
shortcut notation (correct term?) entirely, as the table coding proved
tricky for me.  
*   See the 'map' code below.  Can you explain it step by step?  I know
what it does (sort an array by date) but not really how it does it.  
*   I'm using lstat ~and~ stat, is there a way to get the file
information in one step?

#!/usr/bin/perl -w
use CGI qw(:standard);
my $title  = My Image Webpage;
my $subtitle = Pictures;
my $dir = ../images/;
my $cols = 6;

#HTML--
print header, start_html($title), h1($title);
print body background = ../grey_dots.gif;
print br;
print _HEADER_;
table border=1 cellpadding=2
tr
  thClick on the file name:/th
  thDate added:/th
  th colspan=4br//th
/tr
_HEADER_

#Open directory---
opendir(DIR,$dir) or die error:cannot open $dir: $!;
my @files = readdir(DIR);
closedir(DIR);

#Sort files--
@files = map $_-[0],
 reverse sort { $a-[1] = $b-[1] }
 map { /^\./ ? () : [ $_, (lstat $_)[9] ] }
 @files;

my $a = 0;
my $b = 1;

#Print rows--
print tr;
foreach (@files){
  if (/(^.*)\.jpg$/i) {
my $desc = $1;
if ($a == $cols/2) {
  print /trtr;
  $a = 0;
}
my $currImage = $dir$_;
print td($b.) ,a({-href=$currImage},$desc));
my @fileInfo = stat($currImage);
my $fileDate = localtime($fileInfo[9]);
print td($fileDate);
$a++;
$b++;
  }
}
print /tr/table;
print _PERL_;
br/
a href=http://use.perl.org;
img src=http://use.perl.org/images/topics/useperl.gif; width=100
height=26 alt=All the Perl that's Practical to Extract and Report
/a
_PERL_
print end_html;

I know I should get the Metzler book, it's just that I only use CGI at home.
At work I'm stuck in ASP land.

Joel

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




removing white space revisited

2002-02-18 Thread David Gilden

Hi,

My goal is to  clean up the fields submitted from a form and then be able to use them 
in other places.

Does the following modify the value of param('name') -- if I have a form element named 
'name' --
permanently (like when you have an array)


foreach my $key (param()){

$val = param($key),
$value =~ s/^\s+//;
$value =~ s/\s+$//;
$key =~ s/\d$//;


print $key: $val\n\n;

}


later in the script 

print param('email')  # will this have been cleaned regrex in the up the loop above?


Do I have to assign my 'cleaned' data to a hash?

Thanks!

Dave

**
*   Cora Connection Your West African Music Source   *  
*   http://www.coraconnection.com/   *  
*   Resources, Recordings, Instruments  More!   *
**

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




Re: removing white space revisited

2002-02-18 Thread David Gilden

That is kool, but I am using CGI.pm like we all should be :)

On Monday, February 18, 2002 at 2:01 PM, [EMAIL PROTECTED] (John M) wrote:

 David,
 
 foreach $key (keys(%in))
{ $in{$key} =~ s/^\s+//;  $in{$key} =~ s/\s+$//; }
 
 That's all you have to do.
 
 -jdm
 
 (%in is generated under cgi-lib.pl)

So back to my question do need to assign param() to hash?

Thx,

Dave


From an earlier post:
This is great for 'Upper-casing' just the first letter of a string!

#!/usr/bin/perl -w

my $key =today's Departure date;
$key =~ s/([\w'-]+)/\u$1/g;

print  $key;





 
 From: David Gilden [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: removing white space revisited
 Date: Mon, 18 Feb 2002 13:48:46 -0500
 
 Hi,
 
 My goal is to  clean up the fields submitted from a form and then be able 
 to use them in other places.
 
 Does the following modify the value of param('name') -- if I have a form 
 element named 'name' --
 permanently (like when you have an array)
 
 
 foreach my $key (param()){
 
 $val = param($key),
 $value =~ s/^\s+//;
 $value =~ s/\s+$//;
 $key =~ s/\d$//;
 
 
 print $key: $val\n\n;
 
  }
 
 
 later in the script
 
 print param('email')  # will this have been cleaned regrex in the up the 
 loop above?
 
 
 Do I have to assign my 'cleaned' data to a hash?
 
 Thanks!
 
 Dave
 
 **
 *   Cora Connection Your West African Music Source   *
 *   http://www.coraconnection.com/   *
 *   Resources, Recordings, Instruments  More!   *
 **
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 _
 MSN Photos is the easiest way to share and print your photos: 
 http://photos.msn.com/support/worldwide.aspx

**
*   Cora Connection Your West African Music Source   *  
*   http://www.coraconnection.com/   *  
*   Resources, Recordings, Instruments  More!   *
**

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




Re: HTML page seperator or page breaks?

2002-02-18 Thread Briac Pilpré

On Mon, 18 Feb 2002 at 16:44 GMT, Carolyn Bentley wrote:
 I need to be able to create a web page that has page breaks in it.
  snip
 I think there might be a way to do this with tables. However I cannot
 find any documentation about it.
 
 Is there anything you might suggest trying?

 Although this is more a HTML/CSS question, you may want to look at the
 following CSS2 properties:

 page
 page-break-before
 page-break-inside
 page-break-after
 
 (although they are not supported by every
 browsers - Opera5/6 and IE5.5/6, and maybe Mozilla)
 
 Documentation and examples can be found in the CSS2 specifications:
 http://www.w3.org/TR/CSS2/page.html

-- 
briac
  dynamic .sig on strike, we apologize for the inconvenience 


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




Re: removing white space revisited

2002-02-18 Thread Briac Pilpré

On Mon, 18 Feb 2002 at 18:48 GMT, David Gilden wrote:
 Hi,
 
 My goal is to clean up the fields submitted from a form and then be
 able to use them in other places.
 
 Do I have to assign my 'cleaned' data to a hash?

 You can try it by yourself:

#!/usr/bin/perl -w
use strict;
use CGI qw(:cgi);

foreach my $key ( param() ) {
my $value = param($key);# Fetch the parameter value
$value =~ s/^\s*|\d*\s*$//g;# Strip whitespaces and trailing digits
param( $key, $value );  # Reassigning the value in the parameter
}

# We verify the parameters to see if the values were changed
foreach ( param() ) {
print $_ = ', param($_), '\n;
}

__END__


-- 
briac
  dynamic .sig on strike, we apologize for the inconvenience 


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




Re: removing white space revisited

2002-02-18 Thread John M

David,

cgi-lib.pl and CGI.pm do the same things, for all intents and purposes.  
I've not bothered to use CGI.pm, in part because of its overly cumbersome 
style and kludges.
But that's my preference.  There are very few 'shoulds' in perl and far 
fewer 'musts.'  CGI.pm over cgi-lib.pl is neither of those.  :o

So, for giggles, here's the problem solved in CGI.pm

#!/usr/bin/perl

use CGI;
$q = new CGI;
$q-header;
%params = $q-Vars;
foreach $key (keys(%params))
{ $params{$key} = s/^\s+//; $params{$key} =~ s/\s+$//; }

#
# whatever else
#

  And, equally for giggles, here's the same thing in cgi-lib.pl:

#!/usr/bin/perl

require 'cgi-lib.pl';
ReadParse;
print PrintHeader;
foreach $key (keys(%in))
{ $in{$key} = s/^\s+//; $in{$key} =~ s/\s+$//; }

#
# whatever else
#


   One involves less typing.  It's also clearer in the eye of the beholder.

-jdm

From: David Gilden [EMAIL PROTECTED]
To: John M [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: removing white space revisited
Date: Mon, 18 Feb 2002 14:13:34 -0500

That is kool, but I am using CGI.pm like we all should be :)

On Monday, February 18, 2002 at 2:01 PM, [EMAIL PROTECTED] (John 
M) wrote:

  David,
 
  foreach $key (keys(%in))
 { $in{$key} =~ s/^\s+//;  $in{$key} =~ s/\s+$//; }
 
  That's all you have to do.
 
  -jdm
 
  (%in is generated under cgi-lib.pl)

So back to my question do need to assign param() to hash?

Thx,

Dave


 From an earlier post:
This is great for 'Upper-casing' just the first letter of a string!

#!/usr/bin/perl -w

my $key =today's Departure date;
$key =~ s/([\w'-]+)/\u$1/g;

print  $key;





 
  From: David Gilden [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: removing white space revisited
  Date: Mon, 18 Feb 2002 13:48:46 -0500
  
  Hi,
  
  My goal is to  clean up the fields submitted from a form and then be 
able
  to use them in other places.
  
  Does the following modify the value of param('name') -- if I have a 
form
  element named 'name' --
  permanently (like when you have an array)
  
  
  foreach my $key (param()){
  
  $val = param($key),
  $value =~ s/^\s+//;
  $value =~ s/\s+$//;
  $key =~ s/\d$//;
  
  
  print $key: $val\n\n;
  
   }
  
  
  later in the script
  
  print param('email')  # will this have been cleaned regrex in the up 
the
  loop above?
  
  
  Do I have to assign my 'cleaned' data to a hash?
  
  Thanks!
  
  Dave
  
  **
  *   Cora Connection Your West African Music Source   *
  *   http://www.coraconnection.com/   *
  *   Resources, Recordings, Instruments  More!   *
  **
  
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
 
 
  _
  MSN Photos is the easiest way to share and print your photos:
  http://photos.msn.com/support/worldwide.aspx

**
*   Cora Connection Your West African Music Source   *
*   http://www.coraconnection.com/   *
*   Resources, Recordings, Instruments  More!   *
**


_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


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




Uploading a file

2002-02-18 Thread Octavian Rasnita

Hi all,

I want to make a simple script for uploading a file.
Please tell me if there is a function, or give me some tips what should I
do to upload a file which is typed in a file field.

Thank you.
Teddy,
My dear email address is [EMAIL PROTECTED]



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


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




Setting cookies

2002-02-18 Thread Octavian Rasnita

Hi all,

I just made a script which set cookies, and it works fine.
But I tried to disable the cookies from my machine and if I open that page
which set cookies, they are still set and read, even they are disabled.

Do you have any idea why?
Can't I disable the cookie  for a local HTML document?
Or, is the Perl script I did so powerfull that it doesn't care about my
settings?

Thank you for some light.

Teddy,
My dear email address is [EMAIL PROTECTED]



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


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




Q:How to get whole packet whithout loosing headers

2002-02-18 Thread shilpa deshpande

I want to use serial communication on Windows
platform. I want to write a watcher job (like
trace/ltrace system calls) which will obeserve
communication between 2 hosts.I am getting only data
and loosing packet header information. I want this
header information for further processing.
 
Can anybody help me?

Thanx,
Shilpa

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




Re: DB_File and auto sorting DB's

2002-02-18 Thread Jenda Krynicky

From:   zentara [EMAIL PROTECTED]
 I'm starting to look at perl db's, and I ran across 
 something, but I'm not sure what it's about.
 I have questions.
 
 In the below code, if I comment out use DB_File;
 I get an unsorted printout, and only 2 files are
 created, dbmdatabase.dir  and dbmdatabase.pag.
 Everything seems fine.
 
 If I leave use DB_File in, I get back a sorted
 printout, and 3 files are produced, the above mentioned
 2, and plain dbmdatabase.
 
 So,  is it acceptable to use db without use DB_File;
 or if I do use it, can I always count on the automatic
 sorting?  The docs seem to say that hashes will come back
 unsorted without a sort routine.
 
 
 #
 #!/usr/bin/perl
 use warnings;
 use strict;
 use DB_File;
 
 my (%Z,$i,$j);
 dbmopen(%Z,dbmdatabase,0644) 
|| die cannot open DBM dbmdatabase: $!; 

The dbmopen/dbmclose functions are kind of obsolete. It's generaly 
better to use the tie() interface.

Anyway in your case the use DB_File statement replaced the 
builtin DBM implementation by Berkeley DB implemented (OK, 
interfaced) via the DB_File module. I'm not sure what exactly are 
the properties of the builtin DBM code, but I bet Berkeley will be 
better. But you will want to use

tie %hash,  'DB_File', $filename, $flags, $mode, $DB_HASH ;

instead of dbmopen() since that will allow you more control over the 
options.

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: Crop string to x characters

2002-02-18 Thread Jenda Krynicky

From:   Gary Hawkins [EMAIL PROTECTED]

 How do I truncate a string to a particular number of characters?
 
 This is expensive:
 
 $shortdescription =~
 s/(...
 .  ).*/$1/;
 
 Gary

If you insisted on using regexps you could use

$shortdescription =~ s/^.{50}.*$/$1/;

But it would be quicker to use substr()

$shortdescription = substr $shortdescription, 0, 50;

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: Getting the proper info from an INI file...

2002-02-18 Thread Jenda Krynicky

From:   Chris [EMAIL PROTECTED]
 Unfortunatly, any time I ty to PPM anything from CPAN, I get an
 error... :(

You don't PPM from CPAN. You PPM from ActiveState or 
someone else's PPM repository.

What do you get when you run

PPM install Config-IniFiles

?

Jenda


=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: need help to output to screen and file simultaneously

2002-02-18 Thread Jenda Krynicky

From:   jimf [EMAIL PROTECTED]

 This little script is one of my first attempts with perl, it works ok
 but I would also like to capture the output to file. Help appreciated.

You might like Ron Wantock's Local::TeeOutput.pm
( http://Jenda.Krynicky.cz/perl/TeeOutput.pm , save as 
/lib/Local/TeeOutput.pm)

This allows you to print into several handles at once:

open (LOG, logfile.txt);
openTee (*STDOUT, *STDOUT, *LOG);
print This goes both to STDOUT and the logfile.txt\n;
# assuming of course you did not select() some 
# other filehandle

Jenda


=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: Regular exps on files

2002-02-18 Thread John W. Krahn

Tetsuo wrote:
 
 Hey all - I am trying to learn perl and I know that key to this is a deep
 understanding of regular expressions. I attempted to write a little tool
 that would allow me to test out regular expressions on multiple files (I'm
 thinking an email archive search tool at this point).
 
 In the first incarnation I would test against each line of a file and then
 rewrote it so that I can test against all the contents of a file (basically
 one big string variable).  It works but can anyone tell me what the best way
 to report where in the file the match occurs?  Also, is there a quicker way
 of getting the contents of a file in a string rather than my loop?
 
 Here is the code:
 
 #finding regular expressions in perl
 
 print Enter a regular expression to use \n;
 my $regexp = STDIN;
 chomp $regexp;
 print Your regular expression is $regexp \n;
 my $s=;
 while(defined($foo = c:/davidcode/perlbeast/*.secret)){ #or whatever file
 path you want...
 $foo =~ s#.*/##;
 open(TEST,$foo) || die cannot open file;
 while(defined($line = TEST)){
 $s = $s . $line;
 }
 if($s =~ /$regexp/){
 print match \n;
 }
 
 close(TEST) || die cannot close file;
 }


Here is one way to do it:

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

print 'Enter a regular expression to use: ';
chomp( my $regexp = STDIN );
print Your regular expression is $regexp \n;

@ARGV = glob 'c:/davidcode/perlbeast/*.secret';

while (  ) {
print Found in file: $ARGV  on line: $.\n$_\n if /$regexp/;
close ARGV if eof;
}

__END__


John
-- 
use Perl;
program
fulfillment

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




Re: STDOUT STDERR

2002-02-18 Thread Jenda Krynicky

From:   Angus Laycock [EMAIL PROTECTED]
 I want to print messages from a script to either STDOUT or STDERR
 depending on a value of a variable. I want to control where I send the
 print statements to. Can I do something like this or are there other
 ways to control the target I send my message to. I'm hoping there are
 lots of other ways.
 
 if ($out) { $whereitsggoing = STDERR } else { $whereitsggoing = STDOUT
 }
 
 print $whereitsgoing My message\n;

Either

if ($out) { 
*STDSOME = STDERR 
} else { 
*STDSOME = STDOUT
}

print STDSOME My message\n;

or

use FileHandle;

my $FH;
if ($out) { 
$FH = \*STDERR 
} else { 
$FH = \*STDOUT
}

print $FH My message\n;

or

if ($out) { 
open STDSOME, 'STDERR';
} else { 
open STDSOME, 'STDOUT';
}

print STDSOME My message\n;

or

use FileHandle;

my $FH;
if ($out) { 
open $FH, 'STDERR';
} else { 
open $FH, 'STDOUT';
}

print $FH My message\n;

In the first two solutions when you change where the 
STDOUT/STDERR goes, the STDSOME (or $FH) will change as 
well, in the last two it'll remain unaffected.

HTH, Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: Regular exps on files

2002-02-18 Thread zentara

On Sun, 17 Feb 2002 19:02:36 -0800, [EMAIL PROTECTED] (Tetsuo) wrote:

one big string variable).  It works but can anyone tell me what the best way
to report where in the file the match occurs?  Also, is there a quicker way
of getting the contents of a file in a string rather than my loop?

The variable $.  gives you the line number.  So
print 'match at ',$.,\n;

You are using nested while loops to iterate
thru a file, this isn't necessary. Also you don't need to
open a file just to loop thru it.
Try something like:

my $file  = 'c:/davidcode/perlbeast/*.secret';
while ($file){
print $file: $.  :$_\n  if  /$regexp/;
}


Here is the code:

#finding regular expressions in perl

print Enter a regular expression to use \n;
my $regexp = STDIN;
chomp $regexp;
print Your regular expression is $regexp \n;
my $s=;
while(defined($foo = c:/davidcode/perlbeast/*.secret)){ #or whatever file
path you want...
$foo =~ s#.*/##;
open(TEST,$foo) || die cannot open file;
while(defined($line = TEST)){
$s = $s . $line;
}
if($s =~ /$regexp/){
print match \n;
}

close(TEST) || die cannot close file;
}



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




Re:Regexp help

2002-02-18 Thread Jorge Goncalvez

Hi, I need some help to have a regexp which could replace : by - in this code:

my $cmd=arp -s $ipadress $_Globals{MAC_ADDRESS};

system($cmd);
 actually
$_Globals{MAC_ADDRESS} is formatted like this :XX:XX:XX:XX:XX:XX and i wanted to 
put it like this: XX-XX-XX-XX-XX-XX
How can i do this thanks a regexp 
thanks for your precious help.


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




RE: Dates in file or directory names ?

2002-02-18 Thread Dave Cross

On Sat, 02 Feb 2002 17:11:12 +, Timothy Johnson wrote:
 
 -Original Message-
  From: Dave Cross
  To: [EMAIL PROTECTED]
  Sent: 2/2/02 1:01 AM
  Subject: Re: Dates in file or directory names ?
  
  On Thu, 31 Jan 2002 21:20:16 +, Mark Richmond wrote:
  
  Ok, so I'm confused
  What I want to do is create a directory where the name is the current
  date say mkdir(2002131)
  What Can't figure out is how to build the date string. I'm sure I'm
  just missing something.
  Any thoughts.
  
  [can you please try to configure your mail client not to use HTML]
  
  You probably need the strftime function from the POSIX module.
  
  my $date = strftime('%Y%m%d', localtime);

 Or you can just use localtime();
 
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); 
 my $date = ($year + 1900).($mon + 1).$mday;
 
 mkdir($date);

Well perhaps. But that breaks when either $mon or $mday have only one
digit. At which point you'll need to wheel out something like sprintf -
so you may as well use strftime anyway :)

Dave...

-- 

  Drugs are just bad m'kay

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




Printing data into a file every time some presses ENTERHELP!!

2002-02-18 Thread Bruce Ambraal

Hi 

Could someone help?

the following code is not working.

open(INPUT_FILE,+fixed.dat) || die Could not open filename;
while (STDIN) {
print INPUT_FILE bruce\n;
}
close(INPUT_FILE);


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




RE: Printing data into a file every time some presses ENTER HEL P!!

2002-02-18 Thread Yacketta, Ronald

maybe you need to flush your output? if I am correct nothing is printing
because it is not flushing

add this to the top of the script

$|=1;


again, not sure if this is the right solution etc..

 -Original Message-
 From: Bruce Ambraal [mailto:[EMAIL PROTECTED]]
 Sent: Monday, February 18, 2002 09:18
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Printing data into a file every time some presses ENTER
 HELP!!
 
 
 Hi 
 
 Could someone help?
 
 the following code is not working.
 
 open(INPUT_FILE,+fixed.dat) || die Could not open filename;
 while (STDIN) {
 print INPUT_FILE bruce\n;
 }
 close(INPUT_FILE);
 
 
 -- 
 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]




Fwd: Printing data into a file every time some pressesENTERHELP!!

2002-02-18 Thread Bruce Ambraal

Hi 

Where's every one?

Or maybe our my server's down.

Help!

Cheers

---BeginMessage---

Hi 

Could someone help?

the following code is not working.

open(INPUT_FILE,+fixed.dat) || die Could not open filename;
while (STDIN) {
print INPUT_FILE bruce\n;
}
close(INPUT_FILE);


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



---End Message---

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


Re: Getting the proper info from an INI file...

2002-02-18 Thread Chris

Jenda Krynicky wrote:
 From: Chris [EMAIL PROTECTED]
 
Unfortunatly, any time I ty to PPM anything from CPAN, I get an
error... :(

 
 You don't PPM from CPAN. You PPM from ActiveState or 
 someone else's PPM repository.
 
 What do you get when you run
 
   PPM install Config-IniFiles
 
 ?
 
 Jenda
 
 
 === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
 There is a reason for living. There must be. I've seen it somewhere.
 It's just that in the mess on my table ... and in my brain.
 I can't find it.
   --- me
 

Hmm... Wonder why
PPM install Config::IniFiles failed, but this worked?!?!?!?!


Probably a bad case of FFS (Fat Finger Syndrome)...

:)

I've been told I have that disease REAL bad! ;)

Thanks,

Got it and it is working GREAT


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




Re: Getting the proper info from an INI file...

2002-02-18 Thread Jenda Krynicky

From:   Chris [EMAIL PROTECTED]
Subject:Re: Getting the proper info from an INI file...

 Jenda Krynicky wrote:
  What do you get when you run
  
  PPM install Config-IniFiles
  
  ?
 
 Hmm... Wonder why
 PPM install Config::IniFiles failed, but this worked?!?!?!?!

I see. You have to put a dash in place of the double colon in the 
names of modules to be installed with PPM.

IMHO PPM should be able to take both though.

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




sorting an array

2002-02-18 Thread Yacketta, Ronald

Folks,

I have an array which contains data as such

psych|Sun Feb 17  2002|0:35:59|1523882|HLHack|UG-CS Central-Hell's Kitchen
uenlon|Sun Feb 17  2002|3:31:17|127244|HLHack|UG-CS Central-Hell's Kitchen
uenlon|Sun Feb 17  2002|3:31:19|127244|HLHack|UG-CS Central-Hell's Kitchen
juihung|Sun Feb 17  2002|7:4:56|1149357|HLHack|UG-CS Central-Hell's Kitchen
juihung|Sun Feb 17  2002|7:4:57|1149357|HLHack|UG-CS Central-Hell's Kitchen
S02|Sun Feb 17  2002|7:13:18|831398|HLHack|UG-CS Central-Hell's Kitchen
S02|Sun Feb 17  2002|7:13:20|831398|HLHack|UG-CS Central-Hell's Kitchen

and would like to sort it by the second and third field (the date IE Sun
Feb 17  2002 7:13:20)
I have tried several different methods including the use of Date::Manip
etc..
no matter what I do the date is not sorted in descending order
(http://www.sampier.com/busted.php)

Regards,


Ronald J. Yacketta
Principal Consultant
Ciber, INC
345 Woodcliff Dr.
Fairport, NY 14450
---
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. 

Any review, retransmission, dissemination or other use of, or taking of 
any action in reliance upon, this information by persons or entities other 
than the intended recipient is prohibited. 

If you received this in error, please contact the sender and delete the 
material from any computer.
-- 


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




Re: Getting the proper info from an INI file...

2002-02-18 Thread Chris

Jenda Krynicky wrote:
 From: Chris [EMAIL PROTECTED]
 Subject:  Re: Getting the proper info from an INI file...
 
 
Jenda Krynicky wrote:

What do you get when you run

 PPM install Config-IniFiles

?

Hmm... Wonder why
PPM install Config::IniFiles failed, but this worked?!?!?!?!

 
 I see. You have to put a dash in place of the double colon in the 
 names of modules to be installed with PPM.
 
 IMHO PPM should be able to take both though.
 
 Jenda
 
 === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
 There is a reason for living. There must be. I've seen it somewhere.
 It's just that in the mess on my table ... and in my brain.
 I can't find it.
   --- me
 

Agreed!  :)

Again, Thank you!


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




Size of Array

2002-02-18 Thread Agustin Rivera

Thank-you to everyone who answered my last question.  As usually I am very
grateful for this group and the people in it.

Quick one.. is there a way to evaluate the size of an array?  Right now I'm
writing the arrays to a file and then doing an ls -l to compare sizes. The
array is of type $array[0][0] and not $array[0] (if anyone has the proper
terminology on this, I'd appreciate it).

Thanks,
Agustin Rivera
Webmaster, Pollstar.com
http://www.pollstar.com





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




Re: sorting an array

2002-02-18 Thread Frank

On Mon, Feb 18, 2002 at 11:03:33AM -0500, Yacketta, wrote:
 Folks,
 
 I have an array which contains data as such
 
 psych|Sun Feb 17  2002|0:35:59|1523882|HLHack|UG-CS Central-Hell's Kitchen
 uenlon|Sun Feb 17  2002|3:31:17|127244|HLHack|UG-CS Central-Hell's Kitchen
 uenlon|Sun Feb 17  2002|3:31:19|127244|HLHack|UG-CS Central-Hell's Kitchen
 juihung|Sun Feb 17  2002|7:4:56|1149357|HLHack|UG-CS Central-Hell's Kitchen
 juihung|Sun Feb 17  2002|7:4:57|1149357|HLHack|UG-CS Central-Hell's Kitchen
 S02|Sun Feb 17  2002|7:13:18|831398|HLHack|UG-CS Central-Hell's Kitchen
 S02|Sun Feb 17  2002|7:13:20|831398|HLHack|UG-CS Central-Hell's Kitchen
 
 and would like to sort it by the second and third field (the date IE Sun
 Feb 17  2002 7:13:20)
 I have tried several different methods including the use of Date::Manip
 etc..
 no matter what I do the date is not sorted in descending order
 (http://www.sampier.com/busted.php)
---end quoted text---

how-about splitting the fields and converting to an epoch time? 
you'll need Time::Local

$epochtime=timelocal($sec,$min,$hours,$mday,$mon,$year);

for the rest use split or a nice regex ;)
-- 
 Frank Booth - Consultant
Parasol Solutions Limited.
(www.parasolsolutions.com)

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




Re: Size of Array

2002-02-18 Thread Frank

On Mon, Feb 18, 2002 at 09:17:50AM -0800, Agustin wrote:
 Quick one.. is there a way to evaluate the size of an array?  Right now I'm
 writing the arrays to a file and then doing an ls -l to compare sizes. The
 array is of type $array[0][0] and not $array[0] (if anyone has the proper
 terminology on this, I'd appreciate it).

try scalar(@array)
or scalar(@{$array[0]})

perldoc perldata
perldoc perllol


-- 
 Frank Booth - Consultant
Parasol Solutions Limited.
(www.parasolsolutions.com)

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




RE: Size of Array

2002-02-18 Thread John Edwards

The terminology you are looking for is multidimensional array. I.e you have
an array wherin each element is an array (actually a reference to an
anonymous array IIRC), not a scalar.

You can find the size of the array by asking for it in a scalar context, not
a list context.

For example

my @array = qw(one two three four);
my $arraysize = @array;

print Array is $arraysize elements in length;

for a multidiemensional array

my @array = ([one, two, three], [four, five, six, seven]);

my $arraysize = @{$array[0]};
#   Here you are dereferencing the array referenced by $array[0]
into an anonymous array which is the enclosing @{}, then taking the scalar
value of it which gives you the number of elements in the second level of
the array

print First sub array size is $arraysize elements\n;

my $arraysize = @{$array[1]};

print Second sub array size is $arraysize elements\n;

HTH

John

-Original Message-
From: Agustin Rivera [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2002 17:18
To: [EMAIL PROTECTED]
Subject: Size of Array


Thank-you to everyone who answered my last question.  As usually I am very
grateful for this group and the people in it.

Quick one.. is there a way to evaluate the size of an array?  Right now I'm
writing the arrays to a file and then doing an ls -l to compare sizes. The
array is of type $array[0][0] and not $array[0] (if anyone has the proper
terminology on this, I'd appreciate it).

Thanks,
Agustin Rivera
Webmaster, Pollstar.com
http://www.pollstar.com





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


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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




Help.... Regex Guru Required

2002-02-18 Thread insomniak

Hi All,
Please please please can someone save me from further headaches.
Bascially the regex will match the header (lines with hashes) to the
/VirtualHost
giving me what I need into %virtual_host.

However if there is a blank line as shown for server 1
the regex wont match.
Can any regex gurus help me with this

Oh and please feel free to point out any cockups ive made :)

Kind regards
Mark.

The code
~
sub open_httpd {
open(FH, . @_[0]) or die print Cannot read @_[0];
local $/ = '';
while (FH) {
while (/^([#]{50}\n## [Ss]erver
+?([0-9]+).*^(VirtualHost(.*)(.*)^\/VirtualHost)\n$)$/smg) {
if (!exists $virtual_host{$2}){
$virtual_host{$2}=$1;
   }else {
   warn Duplicate Virtual Host ID $2 found at $.\n;
   }
 }
}
}

Sample Data


##
## Server 1
##
##  WWW.SOMEHOST.COM  ##
##  Date 06/10/2001 By MEK
##
##
##
##
VirtualHost xxx.xxx.xxx.xxx
ServerAdmin [EMAIL PROTECTED]
DocumentRoot /serv/apache/somepath
ServerName www.somehost.net
DirectoryIndex index.html index.htm INDEX.HTML INDEX.HTM index.shtml
FancyIndexing on
AccessFileName .htaccess
DefaultType text/plain
ScriptAlias /cgi-bin /serv/apache/somepath/cgi-bin

ErrorLog /serv/apache/somepath/logs/error_log
TransferLog /serv/apache/somepath/logs/transfer_log
/VirtualHost



##
## Server 2
##
##  WWW.SOMEHOST2.COM  ##
##  Date 06/10/2001 By MEK
##
##
##
##
VirtualHost xxx.xxx.xxx.xxx
ServerAdmin [EMAIL PROTECTED]
DocumentRoot /serv/apache/somepath2
ServerName www.somehost2.net
DirectoryIndex index.html index.htm INDEX.HTML INDEX.HTM index.shtml
FancyIndexing on
AccessFileName .htaccess
DefaultType text/plain
ScriptAlias /cgi-bin /serv/apache/somepath2/cgi-bin

ErrorLog /serv/apache/somepath2/logs/error_log
TransferLog /serv/apache/somepath2/logs/transfer_log
/VirtualHost

##
## Server 3
##
##  WWW.SOMEHOST3.COM  ##
##  Date 06/10/2001 By MEK
##
##
##
##
VirtualHost xxx.xxx.xxx.xxx
ServerAdmin [EMAIL PROTECTED]
DocumentRoot /serv/apache/somepath3
ServerName www.somehost3.net
DirectoryIndex index.html index.htm INDEX.HTML INDEX.HTM index.shtml
FancyIndexing on
AccessFileName .htaccess
DefaultType text/plain
ScriptAlias /cgi-bin /serv/apache/somepath3/cgi-bin

ErrorLog /serv/apache/somepath3/logs/error_log
TransferLog /serv/apache/somepath3/logs/transfer_log
/VirtualHost


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




[ANN] Mail::Sender 0.7.12

2002-02-18 Thread Jenda Krynicky

Uploaded to http://Jenda.Krynicky.cz
Available via PPM from http://Jenda.Krynicky.cz/perl/
Uploaded to and soon to be available from CPAN

New:
debuging
accepts multiline responses (the old qmail bug is fixed at last)
miscelaneous fixes

Enjoy, Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




RE: sorting an array

2002-02-18 Thread Yacketta, Ronald

the sort routine

sortby () {
  ($name, $date, $time, $wonid, $cheat, $server) = split(/\|/, $a);
   ($wday,$month,$mday,$year) = split(/\s+/, $date);
   ($hour,$min,$secs) = split(/:/, $time);
   $TIME = timelocal($secs,$min,$hour,$mday,$mon,$year);

   ($name2, $date2, $time2, $wonid2, $cheat2, $server2) = split(/\|/, $b);
   ($wday2,$month2,$mday2,$year2) = split(/\s+/, $date2);
   ($hour2,$min2,$secs2) = split(/:/, $time2);
   $TIME2 = timelocal($secs,$min,$hour,$mday2,$mon2,$year2);

   $diff =Date_Cmp($TIME,$TIME2);
##
##
##
if ( $table_sort eq adate ) {
if ( $diff  0 ) {
return $TIME;
} else {
return $TIME2;
}
} elsif ( $table_sort eq ddate ) {
if ( $diff  0 ) {
return $TIME = $TIME2;
} else {
return $TIME2 = $TIME;
}
}



}


sort the array
foreach $line (sort sortby @cheaters) 


-Ron


 -Original Message-
 From: Frank [mailto:[EMAIL PROTECTED]]
 Sent: Monday, February 18, 2002 12:43
 To: Yacketta, Ronald
 Subject: Re: sorting an array
 
 
 On Mon, Feb 18, 2002 at 12:30:11PM -0500, Yacketta, wrote:
  I am currently doign a split to get the date and time
  then a timelocal to get epoch. after that is what goes south.
  everything I try no matter how I do it it is always sorted 
 as I shown :(
 ---end quoted text---
 
 Ok, my advice post the code and the data in one well written mail ;)
 
 -- 
  Frank Booth - Consultant
 Parasol Solutions Limited.
 (www.parasolsolutions.com)
 

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




RE: sorting an array

2002-02-18 Thread Wagner-David

Here is a shot using map. I moved the data around(basically in backwards so 
would know if sorted). Ran with warnings under as build 623:


my %DayOfWeek = ( 'jan', 1, 'feb', 2, 'mar', 3, 'apr', 4, 'may', 5, 'jun', 6,
  'jul', 7, 'aug', 8, 'sep', 9, 'oct',10, 'nov',11, 'dec',12);

my @MyData = ();
while ( DATA ) {
   chomp;
   push(@MyData, $_);;
 }
   
foreach my $MyKey (sort { $a-[3] = $b-[3] || $DayOfWeek{lc($a-[1])} = 
$DayOfWeek{lc($b-[1])} ||
  $a-[2] = $b-[2] || $a-[4] = $b-[4] || $a-[5] = 
$b-[5] || 
  $a-[6] = $b-[6] } map{ [ 
$_,/^[a-z0-9]+\|\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{4})\|(\d{1,2}):(\d{1,2}):(\d{1,2})/i 
]} @MyData) {
   
   printf %-s\n, $MyKey-[0];
 }

__DATA__
S02|Sun Feb 17  2002|7:13:18|831398|HLHack|UG-CS Central-Hell's Kitchen
S02|Sun Feb 17  2002|7:13:20|831398|HLHack|UG-CS Central-Hell's Kitchen
juihung|Sun Feb 17  2002|7:4:56|1149357|HLHack|UG-CS Central-Hell's Kitchen
juihung|Sun Feb 17  2002|7:4:57|1149357|HLHack|UG-CS Central-Hell's Kitchen
uenlon|Sun Feb 17  2002|3:31:17|127244|HLHack|UG-CS Central-Hell's Kitchen
uenlon|Sun Feb 17  2002|3:31:19|127244|HLHack|UG-CS Central-Hell's Kitchen
psych|Sun Feb 17  2002|0:35:59|1523882|HLHack|UG-CS Central-Hell's Kitchen


Output:

psych|Sun Feb 17  2002|0:35:59|1523882|HLHack|UG-CS Central-Hell's Kitchen
uenlon|Sun Feb 17  2002|3:31:17|127244|HLHack|UG-CS Central-Hell's Kitchen
uenlon|Sun Feb 17  2002|3:31:19|127244|HLHack|UG-CS Central-Hell's Kitchen
juihung|Sun Feb 17  2002|7:4:56|1149357|HLHack|UG-CS Central-Hell's Kitchen
juihung|Sun Feb 17  2002|7:4:57|1149357|HLHack|UG-CS Central-Hell's Kitchen
S02|Sun Feb 17  2002|7:13:18|831398|HLHack|UG-CS Central-Hell's Kitchen
S02|Sun Feb 17  2002|7:13:20|831398|HLHack|UG-CS Central-Hell's Kitchen

__END__

Wags ;)
-Original Message-
From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 08:04
To: Beginners (E-mail)
Subject: sorting an array


Folks,

I have an array which contains data as such

psych|Sun Feb 17  2002|0:35:59|1523882|HLHack|UG-CS Central-Hell's Kitchen
uenlon|Sun Feb 17  2002|3:31:17|127244|HLHack|UG-CS Central-Hell's Kitchen
uenlon|Sun Feb 17  2002|3:31:19|127244|HLHack|UG-CS Central-Hell's Kitchen
juihung|Sun Feb 17  2002|7:4:56|1149357|HLHack|UG-CS Central-Hell's Kitchen
juihung|Sun Feb 17  2002|7:4:57|1149357|HLHack|UG-CS Central-Hell's Kitchen
S02|Sun Feb 17  2002|7:13:18|831398|HLHack|UG-CS Central-Hell's Kitchen
S02|Sun Feb 17  2002|7:13:20|831398|HLHack|UG-CS Central-Hell's Kitchen

and would like to sort it by the second and third field (the date IE Sun
Feb 17  2002 7:13:20)
I have tried several different methods including the use of Date::Manip
etc..
no matter what I do the date is not sorted in descending order
(http://www.sampier.com/busted.php)

Regards,


Ronald J. Yacketta
Principal Consultant
Ciber, INC
345 Woodcliff Dr.
Fairport, NY 14450
---
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. 

Any review, retransmission, dissemination or other use of, or taking of 
any action in reliance upon, this information by persons or entities other 
than the intended recipient is prohibited. 

If you received this in error, please contact the sender and delete the 
material from any computer.
-- 


-- 
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]




DBM Problems.

2002-02-18 Thread Balint, Jess

Hello all. I have incorporated a DBM file into one of my programs. The
problem I am having is that I cannot store  as a key in a DBM file. (if
so, it's not working here!) Anyways, here is a sample output from diff on 2
sets of program output. The first is where DBM is used, and the second is
where an in-memory hash is used. The second field of each line is the
frequency of the occurance of the first field. The fourth field is the
cumulative frequency. Everything adds up,  but the DBM version is missing
the 76 which had a key of . Is there any way to get around this besides
recoding the value? The only differences in the programs is the use of DBM.
I have also included a diff output on the 2 perl scripts at the very bottom.
TIA. --Jess

Diff output on 2 outputs of the program:

1,12c1,13
 0|257707|51.5414|257707|51.54|
 1|133131|26.6262|390838|78.17|
 10|3|0.0006|390841|78.17|
 11|1|0.0002|390842|78.17|
 2|64050|12.8100|454892|90.98|
 3|29061|5.8122|483953|96.79|
 4|11163|2.2326|495116|99.02|
 5|3559|0.7118|498675|99.74|
 6|961|0.1922|499636|99.93|
 7|218|0.0436|499854|99.97|
 8|62|0.0124|499916|99.98|
 9|8|0.0016|499924|99.98|
---
 |76|0.0152|76|0.02|
 0|257707|51.5414|257783|51.56|
 1|133131|26.6262|390914|78.18|
 10|3|0.0006|390917|78.18|
 11|1|0.0002|390918|78.18|
 2|64050|12.8100|454968|90.99|
 3|29061|5.8122|484029|96.81|
 4|11163|2.2326|495192|99.04|
 5|3559|0.7118|498751|99.75|
 6|961|0.1922|499712|99.94|
 7|218|0.0436|499930|99.99|
 8|62|0.0124|42|100.00|
 9|8|0.0016|50|100.00|

Diff from 2 perl scripts: This illustrates the only difference is the use of
the DBM file. Everything else is the same.

5a6
 use DB_File;
82a84,85
 dbmopen( %freqidx, /tmp/$$.db, 0666 ) or die( Can't open temporary file
(/tmp/$$.db): $!\n );
 
115a119,122
 dbmclose( %freqidx ) or die( Can't close temporary file (/tmp/$$.db):
$!\n );
 
 unlink( /tmp/$$.db ) or die( Can't delete temporary file (/tmp/$$.db):
$!\n );


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




OLE DB

2002-02-18 Thread mb

Hello all,
I have seached for learning OLE DB syntax for accessing database,and all 
informations converge to this statement for 
join use but it does not work.

 require connexion.pl;
my $Statement = SELECT F_FAMILLE.FA_Intitule, F_ARTICLE.AR_UniteVen, 
F_ARTICLE.AR_SuiviStock, F_FAMILLE.FA_CatProduit FROM F_ARTICLE INNER JOIN F_FAMILLE 
ON StrComp(F_ARTICLE.FA_CodeFamile,F_FAMILLE.FA_CodeFamille,0) == 0 WHERE AR_Ref like 
'$codeB' AND AR_Design like '$inti';

if(! ($RS = $Conn-Execute($Statement)))
{
 print Win32::OLE-LastError() ;
 exit;
}

OLE exception from Microsoft OLE DB Provider for ODBC Drivers: [Simba][Simba ODBC 
Driver]Syntax Error. Win32::OLE(0.1502) error 0x80040e14 in METHOD/PROPERTYGET 
Execute

What it the problem  can some one help me, thanks.
asma



Re: Regexp help

2002-02-18 Thread Johannes Franken

On Mon, Feb 18, 2002 at 01:30:01PM +0100, Jorge Goncalvez wrote:
 Hi, I need some help to have a regexp which could replace : by - in this code:

my $mac=$_Globals{MAC_ADDRESS};
$mac=~s/:/-/g; # Here's the RE you were asking for
my $cmd=arp -s $ipadress $mac;
system($cmd);

on a unix system, man perlre is your friend...

-- 
Johannes Franken
 
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/

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




RE: Regexp help

2002-02-18 Thread Balint, Jess

On Mon, Feb 18, 2002 at 01:30:01PM +0100, Jorge Goncalvez wrote:
 Hi, I need some help to have a regexp which could replace : by - in this
code:

   my $mac=$_Globals{MAC_ADDRESS};

$mac=~s/://; # You will need to add this to remove the leading colon

   $mac=~s/:/-/g; # Here's the RE you were asking for
   my $cmd=arp -s $ipadress $mac;
   system($cmd);

on a unix system, man perlre is your friend...

-- 
Johannes Franken
 
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/

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




ignore spaces in files

2002-02-18 Thread Susan Aurand

I have been writing Perl code for (1) week as of  today. Thanks to the
beginner user e:mail, and thank you to John Edwards, and
[EMAIL PROTECTED], and other input I have learned from this page. I have
put togther the following. It works well, and is doing what I want it to
do. Except, 1 little problem remains. Please read the below, and I would
appreciate any advice.
I have tried trim and chomp with no results.
Thank You Susan. (P.S. - I am not a student - I work in the ITC
department.)

This routine opens 15 different school files, for this example, I have
shorten it to 1 school. It creates a data file
call STNAME.DAT. This file contains, last name, first name, student #,
and school #. I then open STNAME, look for
duplicates using ( first 5 char's of last name+1 char of first name).
Look in arrary does it exist. if yes, add a counter to name.
I then store this in a result file, called result.dat. What my question
is, how do I strip out the spaces on the last name if the last
name is not 5 char. long. example: ASHE J  123456  396.

Example:  open(FILE396,396.TXT) or die $!;  # open file for input
SCHOOLS INDIV. FILE
 print OUT
substr($_,12,5),substr($_,30,1),substr($_,3,9),
,substr($_,0,3),\n
  while FILE396;
 close(FILE396);

# CREATE result file, look for duplicates add counter on name, rebuild
string

 my %names;

 open(I,STNAMES.DAT) or diename: $!\n; # open student consolidated
names
 open(O,results.dat) or dieresults: $!\n;  # result file open
output

   foreach $line(I)
 {
  my $name=substr($line,0,6);
  my $workingname=$name;
  my $counter=1;

while(exists($names{$workingname}))
  {
 $workingname=$name.$counter;
 $counter++;
  }

 $names{$workingname}=$workingname;
 print O $workingname,substr($line,7,13),\n; # add back
Student #
   # School #
  }

# The file below is results.dat  (if last name is less than 5 chars. it
fille in spaces. I want the spaces gone)

LINDSD   5 314

LINDS1   13065 314

LINDS2 225   396

LINDS3   11125 378

LOCK S   90174 314

LOKE  J   14013 314

LONDOS   13009 314






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




Re: ignore spaces in files

2002-02-18 Thread Agustin Rivera

If I think I am understanding you right, try

$name=~ s/\s+^//g;

Means any white space (\s+) before the end of name (^), remove (blank in
between the //'s)

Agustin Rivera
Webmaster, Pollstar.com
http://www.pollstar.com



- Original Message -
From: Susan Aurand [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, February 18, 2002 1:29 PM
Subject: ignore spaces in files


 I have been writing Perl code for (1) week as of  today. Thanks to the
 beginner user e:mail, and thank you to John Edwards, and
 [EMAIL PROTECTED], and other input I have learned from this page. I have
 put togther the following. It works well, and is doing what I want it to
 do. Except, 1 little problem remains. Please read the below, and I would
 appreciate any advice.
 I have tried trim and chomp with no results.
 Thank You Susan. (P.S. - I am not a student - I work in the ITC
 department.)

 This routine opens 15 different school files, for this example, I have
 shorten it to 1 school. It creates a data file
 call STNAME.DAT. This file contains, last name, first name, student #,
 and school #. I then open STNAME, look for
 duplicates using ( first 5 char's of last name+1 char of first name).
 Look in arrary does it exist. if yes, add a counter to name.
 I then store this in a result file, called result.dat. What my question
 is, how do I strip out the spaces on the last name if the last
 name is not 5 char. long. example: ASHE J  123456  396.

 Example:  open(FILE396,396.TXT) or die $!;  # open file for input
 SCHOOLS INDIV. FILE
  print OUT
 substr($_,12,5),substr($_,30,1),substr($_,3,9),
 ,substr($_,0,3),\n
   while FILE396;
  close(FILE396);

 # CREATE result file, look for duplicates add counter on name, rebuild
 string

  my %names;

  open(I,STNAMES.DAT) or diename: $!\n; # open student consolidated
 names
  open(O,results.dat) or dieresults: $!\n;  # result file open
 output

foreach $line(I)
  {
   my $name=substr($line,0,6);
   my $workingname=$name;
   my $counter=1;

 while(exists($names{$workingname}))
   {
  $workingname=$name.$counter;
  $counter++;
   }

  $names{$workingname}=$workingname;
  print O $workingname,substr($line,7,13),\n; # add back
 Student #
# School #
   }

 # The file below is results.dat  (if last name is less than 5 chars. it
 fille in spaces. I want the spaces gone)

 LINDSD   5 314

 LINDS1   13065 314

 LINDS2 225   396

 LINDS3   11125 378

 LOCK S   90174 314

 LOKE  J   14013 314

 LONDOS   13009 314






 --
 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: ignore spaces in files

2002-02-18 Thread Balint, Jess

That doesn't work. You need a ($) to indicate the end. THe circumflex means
the beginning of the line. That should read:

$name =~ s/\s+$//;

Also, you don't need the (g)lobal flag because it is only at the end of the
text.

-Jess

-Original Message-
From: Agustin Rivera [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 3:52 PM
To: [EMAIL PROTECTED]
Subject: Re: ignore spaces in files


If I think I am understanding you right, try

$name=~ s/\s+^//g;

Means any white space (\s+) before the end of name (^), remove (blank in
between the //'s)

Agustin Rivera
Webmaster, Pollstar.com
http://www.pollstar.com



- Original Message -
From: Susan Aurand [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, February 18, 2002 1:29 PM
Subject: ignore spaces in files


 I have been writing Perl code for (1) week as of  today. Thanks to the
 beginner user e:mail, and thank you to John Edwards, and
 [EMAIL PROTECTED], and other input I have learned from this page. I have
 put togther the following. It works well, and is doing what I want it to
 do. Except, 1 little problem remains. Please read the below, and I would
 appreciate any advice.
 I have tried trim and chomp with no results.
 Thank You Susan. (P.S. - I am not a student - I work in the ITC
 department.)

 This routine opens 15 different school files, for this example, I have
 shorten it to 1 school. It creates a data file
 call STNAME.DAT. This file contains, last name, first name, student #,
 and school #. I then open STNAME, look for
 duplicates using ( first 5 char's of last name+1 char of first name).
 Look in arrary does it exist. if yes, add a counter to name.
 I then store this in a result file, called result.dat. What my question
 is, how do I strip out the spaces on the last name if the last
 name is not 5 char. long. example: ASHE J  123456  396.

 Example:  open(FILE396,396.TXT) or die $!;  # open file for input
 SCHOOLS INDIV. FILE
  print OUT
 substr($_,12,5),substr($_,30,1),substr($_,3,9),
 ,substr($_,0,3),\n
   while FILE396;
  close(FILE396);

 # CREATE result file, look for duplicates add counter on name, rebuild
 string

  my %names;

  open(I,STNAMES.DAT) or diename: $!\n; # open student consolidated
 names
  open(O,results.dat) or dieresults: $!\n;  # result file open
 output

foreach $line(I)
  {
   my $name=substr($line,0,6);
   my $workingname=$name;
   my $counter=1;

 while(exists($names{$workingname}))
   {
  $workingname=$name.$counter;
  $counter++;
   }

  $names{$workingname}=$workingname;
  print O $workingname,substr($line,7,13),\n; # add back
 Student #
# School #
   }

 # The file below is results.dat  (if last name is less than 5 chars. it
 fille in spaces. I want the spaces gone)

 LINDSD   5 314

 LINDS1   13065 314

 LINDS2 225   396

 LINDS3   11125 378

 LOCK S   90174 314

 LOKE  J   14013 314

 LONDOS   13009 314






 --
 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]

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




Re: OLE DB

2002-02-18 Thread Andrea Holstein

In article 000f01c1b8b8$61d7a420$f389933e@w3w6d9 wrote Mb [EMAIL PROTECTED]:

 Hello all,
 I have seached for learning OLE DB syntax for accessing database,and all 
informations converge
 to this statement for join use but it does not work.

I regret, that's not an SQL list.


  require connexion.pl;
 my $Statement = SELECT F_FAMILLE.FA_Intitule, F_ARTICLE.AR_UniteVen, 
F_ARTICLE.AR_SuiviStock,
 F_FAMILLE.FA_CatProduit FROM F_ARTICLE INNER JOIN F_FAMILLE ON
 StrComp(F_ARTICLE.FA_CodeFamile,F_FAMILLE.FA_CodeFamille,0) == 0 WHERE AR_Ref 
like '$codeB'
   ^   ^^
However, it seems,   an 'l' is missed or too much

 AND AR_Design like '$inti';
 
 if(! ($RS = $Conn-Execute($Statement)))
 {
  print Win32::OLE-LastError() ;
  exit;
 }
 
 OLE exception from Microsoft OLE DB Provider for ODBC Drivers: [Simba][Simba ODBC 
Driver]Syntax
 Error. Win32::OLE(0.1502) error 0x80040e14 in METHOD/PROPERTYGET Execute

You should also check the content of $inti and $codeB.
It's an SQL syntax error, nut a perl syntax error.

 
 What it the problem  can some one help me, thanks. asma

Greetings,
Andrea

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




Re: Printing data into a file every time some presses ENTER

2002-02-18 Thread Andrea Holstein

In article [EMAIL PROTECTED] wrote Bruce Ambraal [EMAIL PROTECTED]:

 Hi
 
 Could someone help?
 
 the following code is not working.

What's wrong ?
What's the error message ?
 
 open(INPUT_FILE,+fixed.dat) || die Could not open filename;

In this snippet INPUT_FILE is a file where you write output to. 
Don't call an output file INPUT_FILE!

 while (STDIN) {
 print INPUT_FILE bruce\n;

It should write as many lines as read by STDIN
bruce.

E.g. if your STDIN consists of 4 lines, your output is: 
bruce
bruce
bruce
bruce

Is it what you really want ?

 }
 close(INPUT_FILE);

Best Wishes,
Andrea

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




Re: Regexp help

2002-02-18 Thread John W. Krahn

Jorge Goncalvez wrote:
 
 Hi, I need some help to have a regexp which could replace : by - in this code:
 
 my $cmd=arp -s $ipadress $_Globals{MAC_ADDRESS};
 
 system($cmd);
  actually
 $_Globals{MAC_ADDRESS} is formatted like this :XX:XX:XX:XX:XX:XX and i wanted to
 put it like this: XX-XX-XX-XX-XX-XX
 How can i do this thanks a regexp
 thanks for your precious help.

You don't really need a regular expression.

$cmd =~ tr/:/-/;


John
-- 
use Perl;
program
fulfillment

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




Re: Help.... Regex Guru Required

2002-02-18 Thread John W. Krahn

Insomniak wrote:
 
 Hi All,

Hello,

 Please please please can someone save me from further headaches.
 Bascially the regex will match the header (lines with hashes) to the
 /VirtualHost
 giving me what I need into %virtual_host.
 
 However if there is a blank line as shown for server 1
 the regex wont match.
 Can any regex gurus help me with this
 
 Oh and please feel free to point out any cockups ive made :)
 
 The code
 ~
 sub open_httpd {
 open(FH, . @_[0]) or die print Cannot read @_[0];
 local $/ = '';
 while (FH) {
 while (/^([#]{50}\n## [Ss]erver 
+?([0-9]+).*^(VirtualHost(.*)(.*)^\/VirtualHost)\n$)$/smg) {
   ||  |   ||  | |  || 
  |
   |+- $2 -+   |+$4+ +$5+| 
  |
   |   + $3 -+ 
  |
   +--- $1 
--+

It isn't clear what you are trying to match and why you are using 5 backreferences.

while ( /^(#{50}\n## [Ss]erver +?([0-9]+).*?^VirtualHost.*?.*?^\/VirtualHost)$/smg 
) {


 if (!exists $virtual_host{$2}){
 $virtual_host{$2}=$1;
}else {
warn Duplicate Virtual Host ID $2 found at $.\n;
}
  }
 }
 }
 
 Sample Data
 
 [snip]




John
-- 
use Perl;
program
fulfillment

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




Re: ignore spaces in files

2002-02-18 Thread John W. Krahn

Susan Aurand wrote:
 
 I have been writing Perl code for (1) week as of  today. Thanks to the
 beginner user e:mail, and thank you to John Edwards, and
 [EMAIL PROTECTED], and other input I have learned from this page. I have
 put togther the following. It works well, and is doing what I want it to
 do. Except, 1 little problem remains. Please read the below, and I would
 appreciate any advice.
 I have tried trim and chomp with no results.
 Thank You Susan. (P.S. - I am not a student - I work in the ITC
 department.)
 
 This routine opens 15 different school files, for this example, I have
 shorten it to 1 school. It creates a data file
 call STNAME.DAT. This file contains, last name, first name, student #,
 and school #. I then open STNAME, look for
 duplicates using ( first 5 char's of last name+1 char of first name).
 Look in arrary does it exist. if yes, add a counter to name.
 I then store this in a result file, called result.dat. What my question
 is, how do I strip out the spaces on the last name if the last
 name is not 5 char. long. example: ASHE J  123456  396.
 
 Example:  open(FILE396,396.TXT) or die $!;  # open file for input
 SCHOOLS INDIV. FILE
  print OUT
 substr($_,12,5),substr($_,30,1),substr($_,3,9),
 ,substr($_,0,3),\n
   while FILE396;

print OUT (unpack 'a3 a9 A5 x13 a1', $_)[2,3,1,0], \n while FILE396;


  close(FILE396);
 
 # CREATE result file, look for duplicates add counter on name, rebuild
 string
 
 [snip]
 
 # The file below is results.dat  (if last name is less than 5 chars. it
 fille in spaces. I want the spaces gone)
 
 [snip]


John
-- 
use Perl;
program
fulfillment

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




Perl Regular Expressions

2002-02-18 Thread Kittler, Karl

Hi all,
 
I've been writing in Perl for quite some time now, however regular
expressions have eluded me. I'm not completely sure why, but they have.
Now that I need them I figure I better get some assistance soon.
 
I'm trying to extract the linked text out of an html string. I thought
that matching text between  and /a would be the best way to do
this. I came up with the following line of code:
 
$line2 = string to be parsed.
 
 ($linkname) = ($line2 =~ m/[:alpha:]*\/a[]/gi); #extract the linked
text.
 
However when I do this, the value of $linkname is always /a. I
think this means it does see a linkname in the string, but doesn't
collect what I want.
I've tried several variations on the above, changing [:alpha:] to \w
adding in \s* changing the case of those character definitions.
Thinking my resource could be wrong.
 
I've also tried several things which return errors.
 
I'm also trying to figure out how to collect both the URL and the link
name in one line of code. From what I've read, it looks like it can be
done.
 
The initial goal is to create a list, including the link name, of every
URL on my site.
 
Thanks,
Karl Kittler
 



Re: Perl Regular Expressions

2002-02-18 Thread Briac Pilpré

On Mon, 18 Feb 2002 at 22:44 GMT, Karl Kittler wrote:
 I'm also trying to figure out how to collect both the URL and the link
 name in one line of code. From what I've read, it looks like it can be
 done.

 Forget regexes, use a proper HTML parser.
 TokeParser is nice for this task 

#!/usr/bin/perl -w
use strict;
use HTML::TokeParser;

my $p = HTML::TokeParser-new(\*DATA) or die Cannot read DATA: $!;

my %links;

while ( my $token = $p-get_tag('a') ){
my $url = $token-[1]{href};
my $text = $p-get_trimmed_text(/a);
$links{$url} = $text;
}

while ( my ($url, $text) = each %links ){
print $url = $text\n;
}

__DATA__
html
headtitleTest TokeParser/title
/head
body
a
  href=hello.htmlHello World!/a
 pSome text a href=goodbye.htmlGoodbye cruel world/a /p
a style=font-size:18pt href='foo.html'Foo!/ap
 /body
/html
__END__
-- 
briac
  dynamic .sig on strike, we apologize for the inconvenience 


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




Re: Passing an array from a 2-D array

2002-02-18 Thread Michael Fowler

On Sat, Feb 16, 2002 at 11:20:42AM -0500, Ian P. Thomas wrote:
   If I read this correctly, I takes the first array from 
 unchecked_dfa_states and passes it out, but not before dereferencing 
 it.  I needed something that could take the first array as a whole 
 object and pass it to checked_dfa_states, another array of arrays.  
 After pouring through my Perl books, I think what I needed to do was to 
 give each stored array in unchecked_dfa_states a scalar reference.  
 This way I could pass the reference to the whole array.  Does that 
 sound right?   

It sounds like you have a fundamental misunderstanding about
multi-dimensional arrays in Perl.  A multi-dimensional array in Perl is just
an array of array references; these references are scalar values, and can be
passed around as single entities.

So the code:

@checked_dfa_states = @{ shift(@unchecked_dfa_states) };

Removes the first element from @unchecked_dfa_states, dereferences it, then
assignes it to @checked_dfa_states.  So, given:

@checked_dfa_states = ();
@unchecked_dfa_states = (
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
);

After the code I showed runs you'd have:

@checked_dfa_states = (1, 2, 3);
@unchecked_dfa_states = (
[4, 5, 6],
[7, 8, 9],
);

If, instead, you wanted, as I suspect from your question, the result:

@checked_dfa_states = (
[1, 2, 3],
);

@unchecked_dfa_states = (
[4, 5, 6],
[7, 8, 9],
);

Then don't dereference the shift; in other words, use:

@checked_dfa_states = shift(@unchecked_dfa_states);


Does that answer your question?


   The alternative that I used was keeping two arrays. One just 
 held information about  the size of the arrays in unchecked_dfa_states. 
  I called it  unchecked_dfa_states_sizes.  I did a for loop using a 
 value from the unchecked_dfa_states_sizes array as the ceiling  to put 
 each element into a temporary array.  I then pushed this temporary 
 array onto checked_dfa_states.  The reason I was able to do this is 
 because I kept the two arrays, 
 
 unchecked_dfa_states 
 unchecked_dfa_states_sizes  

 in sync.  That meant that every subscript for 
 unchecked_dfa_states_sizes matched a corresponding subscript for an 
 array in unchecked_dfa_states.  A reference to an array, and a separate 
 reference to its size.

Just to be clear, your two arrays would look something like this:

@unchecked_dfa_states = (
[1, 2, 3],
[4, 5, 6, 7],
[8, 9],
);

@unchecked_dfa_states_sizes = (
3,
4,
2,
);

where the size of $unchecked_dfa_states[$n] is in
$unchecked_dfa_states_sizes[$n].

This is unnecessary in Perl.  @{$unchecked_dfa_states[$n]} in scalar context
would yield the size of $unchecked_dfa_states[$n].


Instead of iterating over elements, like you describe, it's a fairly simple
matter to copy a dimension from @unchecked_dfa_states to
@checked_dfa_states:

$checked_dfa_states[$n] = [ @{$unchecked_dfa_states[$n]} ]

This is much like the altered shift operation I showed you:

@checked_dfa_states = shift(@unchecked_dfa_states);]

Except that it's not destructive of either @checked_dfa_states or
@unchecked_dfa_states.


 
 I believe you want: 
 
 push( 
 @unchecked_dfa_states, 
 dfa_state_creation($unchecked_dfa_states[0], 
 $symbol) 
 ); 
  
   I can't remember exactly, but I believe when I tried to do it 
 this way, it passed an actual numeric value, the memory address to the 
 array referenced by $unchecked_dfa_states[0].  As above, I stored the 
 array referenced by $unchecked_dfa_states[0] into a temporary array and 
 passed that in like this 

The first argument to dfa_state_creation() call would be a reference.  In
numeric context this is a very large number.  However, this reference can be
dereferenced and used as if you were dealing directly with
$unchecked_dfa_states[0], because you actually are.

 
   This worked.  Thanks for the help.  I think I need to spend 
 some more time with the animal books and reading this list.  I ended up 
 having some problems using global variables later in the program.  Next 
 time I'll cut and paste the code. :) 

Yes, reviewing the books is a very good idea.  You should also read perldoc
perlreftut and perldoc perlol.  The first is a tutorial on references, the
second documents how to use lists of lists, or multi-dimensional arrays.

There's also perldoc perlref and perldoc perldsc, describing references and
data structures, respectively.


Also, keep in mind that when multi-dimensional arrays are talked about in
Perl they're not quite the same thing as in other languages.  Some languages
are fixed in their dimensions: for instance, in C you can have a 3x2 array,
or 3x3x3, etc.  With Perl each of the elements of an array can be any
length: a prime example is from above:

@unchecked_dfa_states = (
[1, 2, 

Re: Regular exps on files

2002-02-18 Thread Michael Fowler

On Mon, Feb 18, 2002 at 07:20:50AM -0500, zentara wrote:
 You are using nested while loops to iterate
 thru a file, this isn't necessary. Also you don't need to
 open a file just to loop thru it.

Yes, you do.  At some level, you have to open the file if you want to
read its contents.


 my $file  = 'c:/davidcode/perlbeast/*.secret';
 while ($file){
 print $file: $.  :$_\n  if  /$regexp/;
 }

This code doesn't actually work.  Did you test it?  Perl won't automatically
open a file using the file read operator like that.  The  operator is the
only one that's special in that respect.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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




Re: Perl Regular Expressions

2002-02-18 Thread Jeff 'japhy' Pinyan

On Feb 18, Kittler, Karl said:

I've been writing in Perl for quite some time now, however regular
expressions have eluded me. I'm not completely sure why, but they have.
Now that I need them I figure I better get some assistance soon.

Perhaps http://japhy.perlmonk.org/book/ will help.

 ($linkname) = ($line2 =~ m/[:alpha:]*\/a[]/gi); #extract the linked
text.

I think you mean [[:alpha:]].  [...] denotes a character class, and
[:alpha:] denotes the POSIX set alpha INSIDE that character class.  Just
using [:alpha:] in a regex is the same as [:alph].

But you should be using a full-blown HTML parser instead.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for Regular Expressions in Perl published by Manning, in 2002 **
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Web Address for Archives

2002-02-18 Thread terri harrison



Is there a web address to search archived messages for this list?

Thanks
Terri

_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


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




Re: Web Address for Archives

2002-02-18 Thread Chris Ball

 terri == terri harrison [EMAIL PROTECTED] writes:

terri Is there a web address to search archived messages for this
terri list?

Certainly is.  It's at:
http:[EMAIL PROTECTED]/

If your browser is anything like mine, this might need to be re-encoded:
http://archive.develooper.com/beginners%40perl.org/

Hope this helps,

- Chris.
-- 
$a=printf.net; Chris Ball | chris@void.$a | www.$a | finger: chris@$a
 In the beginning there was nothing, which exploded.


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




Possible outcomes

2002-02-18 Thread Daniel Falkenberg

Hey all,

I have some code (below) that will strip data from a HTML page and go
ahead and display information that I need.  The proble I am facing is
that the data has 4 possible out comes derived from user input.  

Basically I would like to start on 2 possible out comes.  If the user is
to have the page return 2 headers named number and coverage I can
display the results of both outcomes.  I.e 1: The user can get DSL 2:
The user can't get DSL. 

Now, if the user can't get DSL then the page will return only 2 headers
(number and coverage) while if the user can get DSL the page will return
3 headers (number coverage and location).  For some reason I can't get
my code to display both results.  I have tried if and or statements but
that still won't work.

$html_string = $tree-as_HTML;

  @headers = qw/number coverage/; # Tried this but doesn't work or
@headers = qw/number coverage location/ ;
  $te = new HTML::TableExtract( headers = [@headers] );
  $te-parse($html_string);
  # Examine all matching tables
  foreach $ts ($te-table_states) {
#print Table (, join(',', $ts-coords), ):\n;
foreach $row ($ts-rows) {
 $mRow = @$row;
 $mRow =~ s/.*\//g;
 #$mRow =~ s/[^.\d\s]//g;
 my @webValues = split/\s+/, $mRow;
 print join(' ', $mRow), \n;
 }
  }
  undef @headers;

Does any one have any ideas?

Kind regards,

Dan

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




10 Digits, no more no less

2002-02-18 Thread Daniel Falkenberg

Hey all,

Just wondering if Perl is able to could how many digits there is in a
variable.  Basically I want a user to be only able to enter 10 digits no
more no less.  Is there a way perl can count this variable and with a
little if/else statment I can display the result.

Kind regards,

Dan

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




Re: 10 Digits, no more no less

2002-02-18 Thread Randal L. Schwartz

 Daniel == Daniel Falkenberg [EMAIL PROTECTED] writes:

Daniel Hey all,
Daniel Just wondering if Perl is able to could how many digits there is in a
Daniel variable.  Basically I want a user to be only able to enter 10 digits no
Daniel more no less.  Is there a way perl can count this variable and with a
Daniel little if/else statment I can display the result.

Daniel Kind regards,

if ($input =~ /\A\d{10}\z/) { print input contains exactly ten digits!\n }

-- 
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!

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




Re: 10 Digits, no more no less

2002-02-18 Thread Jeff 'japhy' Pinyan

On Feb 19, Daniel Falkenberg said:

Just wondering if Perl is able to could how many digits there is in a
variable.  Basically I want a user to be only able to enter 10 digits no
more no less.  Is there a way perl can count this variable and with a
little if/else statment I can display the result.

Well, Randal's answer is to make sure a variable consists ONLY of 10
digits -- if that's what you needed, ok.

If you want code that sees how many digits there are in a string, you can
use tr///:

  $digit_count = $str =~ tr/0-9//;

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for Regular Expressions in Perl published by Manning, in 2002 **
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Re: 10 Digits, no more no less

2002-02-18 Thread Rodney Clang

If you're wanting to limit the user's input, that would be dependant on the 
interface of choice (HTML? TK? Curses? )


-r

On Monday 18 February 2002 06:49 pm, you wrote:
 On Feb 19, Daniel Falkenberg said:
 Just wondering if Perl is able to could how many digits there is in a
 variable.  Basically I want a user to be only able to enter 10 digits no
 more no less.  Is there a way perl can count this variable and with a
 little if/else statment I can display the result.

 Well, Randal's answer is to make sure a variable consists ONLY of 10
 digits -- if that's what you needed, ok.

 If you want code that sees how many digits there are in a string, you can
 use tr///:

   $digit_count = $str =~ tr/0-9//;

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




Perl and apache

2002-02-18 Thread Matthew Harrison

I am a newbie to perl and linux and i am having trouble with my apache server 
and cgi scripts.

I know that there is nothing wrong with the scripts so I wonder if anyone 
else has come across this.

when i try to execute a cgi script i get an HTTP 500 error and my error log 
says something like:

[Tue Feb 19 02:23:39 2002] [error] (2)No such file or directory: exec of 
/var/www/cgi-bin/admin.cgi failed

What is this (2)no such file or directory error talking about? i know there 
is nothing wrong with my directory or file structure. it always happens if i 
try with a downloaded apache from apache.org but not always with the redhat 
7.2 distro version (unless i change the file root, and no, it doesn't start 
working if i change it back).

has anyone else ever had to solve this before.

Cheers

-- 
Matthew Harrison
Internet/Network Services Adminstrator
Genestate
www.peanutbuttercheesecake.co.uk

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