Re: Checking Form data

2002-07-31 Thread Greg Matheson

On Tue, 30 Jul 2002, Kipp, James wrote:

 What is the best way to validate form data. I have a form which the user
 enters dates like '08/01/2002'. What is the best way to make sure this
 format is entered. Should i use javascript here or regex?

I heard about and started using Data::FormValidator. It returns a
hash, I think of fields which were valid, an array of fields that
were missing, and some other things, like invalid fields and
unknown fields.

The problem is, I don't know what to do with the information. I
just enter $valid{$field} in the form wihout checking whether it
exists, or is defined, or is true.

-- 
Greg MathesonIf you're not making any mistakes,
Chinmin College  you must be making some mistake.
 
Taiwan Penpals Archive URL: http://netcity.hinet.net/kurage

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




Multiple Selects to Perl Script

2002-07-31 Thread Margaret

Hi

I am having a most frustrating problem. I created a from with multiple
selects using a perl script and passed the multiple selections to an array
ie.

@array1 = $q-param('type').

The array only contains the first selection and none of the others. How do I
fix this? I have read a lot of documentation and it is supposed to work.
What am I doing wrong?

Regards
Margaret


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




RE: Multiple Selects to Perl Script

2002-07-31 Thread Kipp, James

are you sure all the values are associated with the name 'type' ?


 -Original Message-
 From: Margaret [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 9:27 AM
 To: [EMAIL PROTECTED]
 Subject: Multiple Selects to Perl Script
 
 
 Hi
 
 I am having a most frustrating problem. I created a from with multiple
 selects using a perl script and passed the multiple 
 selections to an array
 ie.
 
 @array1 = $q-param('type').
 
 The array only contains the first selection and none of the 
 others. How do I
 fix this? I have read a lot of documentation and it is 
 supposed to work.
 What am I doing wrong?
 
 Regards
 Margaret
 
 
 -- 
 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: Post to a second CGI script

2002-07-31 Thread perl-dvd

Jim,
My recommendation is to write a session file on your server and pass the session 
id around with
the browser variables.  Now whether you use cookies, get or post to pass the session 
id, you don't
have to be passing the actual username.  If you don't want to have the user see the 
session id, put
it in a cookie, and check to see if the cookie was created, if not, then send it via a 
form with
post.  If you want to be really sneaky about it, get your session id, then encrypt the 
id before
giving it to the individual, so if they modify it, the decrypted version of what they 
pass back will
not only not match theirs, but it cant match any one else's session id because it 
likely will not
translate into a valid session id format.

Good Luck,
David


- Original Message -
From: Jim Lundeen [EMAIL PROTECTED]
To: begin begin [EMAIL PROTECTED]
Sent: Monday, July 29, 2002 6:06 PM
Subject: Post to a second CGI script


Hello All,

I have 2 scripts.  One accepts 3 values LOGIN_USERNAME, LOGIN_PASSWORD
and ACTION from an HTML form.  That script looks in a user table in
MySQL to verify the user.  If valid, it passes them to MENU.CGI with
LOGIN_USERNAME and a unique session number (USN).

Here's the question:  How to I post the LOGIN_USERNAME and USN to the
MENU.CGI script?  I don't want the user carrying the info around in
the Location bar as ?USN=1234LOGIN_USERNAME=somebody -- I want it
to be part of the user's Perl process if you know what I mean, so that
if they hit RELOAD the values are still with them.  Too, I don't want
someone trying to modify the info if it were in the Location bar, so
it needs to be a part of the post.

Any advice would be much appreciated!

Thanks!

Jim



--
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: Help with the code please

2002-07-31 Thread zentara

On Tue, 30 Jul 2002 08:18:27 -0700, [EMAIL PROTECTED] (Soheil Shaghaghi)
wrote:

Can anyone please help me?

It is really hard to tell what you want to do from the
information you sent. Your cgi-script dosn't print out
any html, nor does it print a location to go to. What do you
want?

Post the whole working script, or else we can't even guess.




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




Re: Checking Form data

2002-07-31 Thread Connie Chan

  What is the best way to validate form data. 

That would be a very very big topic here...
I can't show the method, but can share some steps.

 Client Side 
1. Check missing fields (Check it if js enabled)
2. Check pattern (js also do regex, but not powerful as Perl)

 Server Side 
3. Pick up data ( you may have to deal with GET and POST )
## Do 1 and 2 here if client side disabled js.
4. Check referer / session id /cookies / whatever
(Aim to check where the form sign from)
5. Check yours own expectation on fields perference.

That's all about on my point of view.

  I have a form which the user
  enters dates like '08/01/2002'. What is the best way to make sure this
  format is entered. Should i use javascript here or regex?

None of them, you should create a select/opt menu.
Then you even no need to check it, so you can put you focus
to avoid 31/02/2002 etc.

Rgds,
Connie




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




Why is not the window printed?

2002-07-31 Thread Octavian Rasnita

Hi all,

I've made a script for uploading a file, and it uploads the file but it has
a problem.

I want to print another page that prints File uploading... while the file
is uploading.

Unfortunately I can't do that.
After pressing the upload button, the page remains the same. It only appears
Opening Page... in the task bar.

Only after the file is uploaded it prints the result page, even a part of
that page is printed before opening and printing the file.

Do you have any idea why?

Thank you.

Here is the script:

#!/usr/bin/perl -WT

=author Teddy;
Script made by Octavian Rasnita [EMAIL PROTECTED]
=cut

use lib /var/www/teddy/lib;

use strict;
use CGI;

my $q = new CGI;

#The max size of the uploaded file:
$CGI::POST_MAX = 1024 * 1024 * 30;
my $maxfile = $CGI::POST_MAX;

#The folder with the uploaded files:
my $outfolder = /var/www/teddy/html/up;

my $hostroot = $ENV{'HTTP_HOST'};
#The web address of the folder with uploaded files:
my $web_folder = http://$hostroot/up;;

#The max size of the directory with uploaded files
my $maxfolder = 1024 * 1024 * 100;

#Max number of retries to rename (incrementing) the file:
my $maxtries = 20;

#Should this script announce  by mail about this upload?
my $sendmail = 1;

#The email address used for announcing this upload:
my $email_address = '[EMAIL PROTECTED]';

#The sender address of this message:
my $email_from = '[EMAIL PROTECTED]';

#The address of the SMTP mail server:
my $server = '127.0.0.1';

#The Hello address:
my $hello = localhost;

#The path to the sendmail program:
my $mailprog = /usr/sbin/sendmail;

#The subject of the message:
my $email_subject = 'New file uploaded!';

### End editing ###

my $screen = $q - param ('screen');
my $script = $ENV{'SCRIPT_NAME'};
my $name = $q - param ('name');
my $email = $q - param ('email');
my $comments = $q - param ('comments');
my $filename;
my $allpath;
my $filesize;
my $host;
### Start code ###

my $dirsize = dir_size($outfolder);
my $content_length = $ENV{'CONTENT_LENGTH'};
if (! $content_length) {
$content_length = 0;
}
my $filled_space = $dirsize + $content_length;

if ($content_length  $maxfile) {
#If the size of the file is bigger than the max size of a file that is
allowed:
my $freespace = $maxfile;
$freespace = int(($freespace / 1048576) *10)/10;

print Content-type: text/html\n\n;
print eof;
html lang=enheadtitleFile too big!/title/head
The folder is full and there is not enough space for a file bigger than
$freespace MB.br
br
If you want to upload a bigger file, please
a href=mailto:$email_address;ask me how to do it./a
/body/html
eof

exit;
#End if:
}

if ($filled_space  $maxfolder) {
#If the size of the file + size of folder  is bigger than the max allowed
size of folder:
my $freespace = $maxfolder - $dirsize;
$freespace = int(($freespace / 1048576) *10)/10;

print Content-type: text/html\n\n;
print eof;
html lang=enheadtitleFile too big!/title/head
The folder is full and there is not enough space for a file bigger than
$freespace MB.br
br
If you want to upload a bigger file, please
a href=mailto:$email_address;ask me how to do it./a
/body/html
eof

exit;
}

if (! $screen) {
print_form;
}
elsif($screen eq 1) {
get_host;
upload;
if ($sendmail eq 1) {
send_mail;
}
}

sub print_form {
print Content-type: text/html\n\n;

my $freespace = $maxfolder - $dirsize;
if ($freespace  $maxfile) {
#Daca e loc mai mult decat marimea maxima a unui fisier permis:
$freespace = $maxfile;
$freespace = int(($freespace / 1048576) *10)/10;
}
else {
#Daca e loc mai putin decat marimea unui fisier:
$freespace = int(($freespace / 1048576) *10)/10;
}

print eof;
html lang=enheadtitleUpload a file!/title/headbody
Please make sure the file you want to upload is not bigger than $freespace
MB.br
If it is, it won't be saved on the server. It will be lost.br
If you want to upload a bigger file than this limit, please a
href=mailto:$email_address;ask me how to do it./a
brbr
You don't need to fill all the fields. You need just to type the correct
path to a file you want to upload.
br
You can leave all the other fields blank if you want, but I would recommend
filling them.
brbr
If you are using a screen reader, and if it can't read the Browse button,
you have to activate the forms mode, then press tab, then space bar.br
This will open the Browse for file windowbr
form method=post enctype=multipart/form-data action=$script
input type=hidden value=1 name=screen
File name:input type=file name=file size=70
Your name: input type=text name=name size=30br
Your email: input type=text name=email size=40br
Comments: textarea name=comments rows=4 cols=70/textarea
br
input type=submit value=Upload file
/form
/body/html
eof
#end sub print_form:
}

sub upload {
my ($filen, $ext);

#Print the start of the page:
$| = 1;
print eof;
Content-type: text/html

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
html lang=en head titleUploading the file.../title
link rel=stylesheet href=/teddy.css type=text/css

Re: Checking Form data

2002-07-31 Thread John Griffiths

Although Perl/CPAN makes some good form handling modules available I think that the 
more client side data checking you can do the better. For date input I'd go with 
javascript, and
I'd use an input calendar to control the data. See, for example, a prototype I'm 
working on at http://www.southwindssailing.com/pressgang/ which uses a nice 
javascript/DHTML input
calendar by Lea Smart (www.totallysmartit.com).

Kipp, James wrote:

 What is the best way to validate form data. I have a form which the user
 enters dates like '08/01/2002'. What is the best way to make sure this
 format is entered. Should i use javascript here or regex?

--
Dr. John  Griffiths  \( ~ )7  The Teahouse of Experience
MAILTO:[EMAIL PROTECTED] http://www.frontier.net/~grifftoe/
O, call back yesterday. Richard II, act 3, sc. 2.






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




RE: Checking Form data

2002-07-31 Thread Kipp, James

Thanks for the reference. but as ealier mentioned , java script can be
filtered out or shut off at the browser. i went ahead and made a validation
routine in the CGI itself with regex and other tests.

 -Original Message-
 From: John Griffiths [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 1:20 PM
 To: Kipp, James
 Cc: '[EMAIL PROTECTED]'
 Subject: Re: Checking Form data
 
 
 Although Perl/CPAN makes some good form handling modules 
 available I think that the more client side data checking you 
 can do the better. For date input I'd go with javascript, and
 I'd use an input calendar to control the data. See, for 
 example, a prototype I'm working on at 
 http://www.southwindssailing.com/pressgang/ which uses a nice 
 javascript/DHTML input
 calendar by Lea Smart (www.totallysmartit.com).
 


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




flock(); with strict subs

2002-07-31 Thread Kyle Babich

How do I flock(); with strict subs in effect?

Thanks,
--
Kyle

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




RE: Undefined subroutine main::param called

2002-07-31 Thread Kyle Babich

Thanks, my mistake.  I orginally had the qw:/standard at the top but I
changed it so anything using CGI.pm needed a $CGIquery but I forgot to
add that before the param(con);

On Wed, 31 Jul 2002 13:48:45 -0700, Soheil Shaghaghi
[EMAIL PROTECTED] said:
 Sorry, I am pretty new to Perl myself, but you might want to try
 something
 like this:
 
 $q = new CGI;
 my $con = $q-param('con');
 
 Soheil
 
 
 
 -Original Message-
 From: Kyle Babich [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 1:37 PM
 To: beginners-cgi
 Subject: Undefined subroutine main::param called
 
 
 This is what shows in my error log:
 Undefined subroutine main::param called at
 /home/sites/kmb/www/public_html/njindenial/index.pl line 10.
 
 This is like 10:
 my $con = param( con );
 
 What should I change?  I'm not quite sure what I should do.
 (I have attached the entire script if you think it is actually
 something else causing that problem.)
 
 Thank you again,
 --
 Kyle
 
 
 

--
Kyle

--
Kyle

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




Re: It was a success, but only in Windows, not Unix.

2002-07-31 Thread Wiggins d'Anconia

This is coming from left field, and the gurus should chime in, and I 
have been reading up about IPC last couple of days so this is on the 
brain, but would setting up a signal handler (don't know what signal it 
would be receiving, obviously this would need to be determined) help?  I 
would think that the END would be called, but if the script is receiving 
a signal then maybe in this case an END is never reached???

Random thoughts after a long day

http://danconia.org

Octavian Rasnita wrote:
 Hi all,
 
 After fighting a lot with a bigger script, I could make it work under
 Windows 2000, but it can't work under Red Hat 7.2 unfortunately.
 
 It is that script for downloading a file then delete it from the server.
 
 If the file finish downloading, it is deleted from the server using Windows
 and Linux.
 If the user starts downloading, or only opens the window that asks if they
 want to save or open the file, then cancel the download, the file is not
 deleted from the server under Linux.
 It is deleted from Windows however.
 
 I use Apache 2.0.3.6 in Windows, and Apache 1.32 in Linux.
 
 I've tried again that simple script version, and it works the same. I've
 attached it here below if you would like to take a look.
 
 I've tried putting the unlink $file line in an END { ... } but this block
 it is not executed if the download is cancelled.
 
 Do you have any idea if I have any solution to make it work?
 
 Thank you very much!
 Here is the script:
 
 #!/usr/bin/perl
 
 $| = 1;
 
 my $filename = $ENV{'QUERY_STRING'};
 my $docroot = $ENV{'DOCUMENT_ROOT'};
 my $file = $docroot/shopping/$filename;
 
 print eof;
 Content-type: application/zip
 Content-Disposition: attachment; filename=$filename
 
 eof
 
 open (FH, $file);
 binmode(FH);
 binmode(STDOUT);
 
 until (eof FH) {
 read (FH, my $buf, 1);
 print $buf;
 }
 close FH;
 
 END {
 unlink $file;
 }
 
 
 Teddy Center: http://teddy.fcc.ro/
 Mail: [EMAIL PROTECTED]
 
 
 



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




Re: Checking Form data

2002-07-31 Thread fliptop

Kipp, James wrote:

 What is the best way to validate form data. I have a form which the user
 enters dates like '08/01/2002'. What is the best way to make sure this
 format is entered. Should i use javascript here or regex?


i had some free time, so i decided to finish up some thoughts i have 
regarding validating form data.  i've developed a simple module to 
perform basic validation and shown how to implement it.  it's all 
available here:

http://www.peacecomputers.com/form_checker/

please send any errata or general comments directly to me, not the list.

many thanks to Eric Moore ([EMAIL PROTECTED]) for his help and 
patience during development.

please note that this module doesn't really answer the question posed by 
the original poster, namely 'how do i validate a date?'  imho, i'd do 
that like this (for slash-delimited dates only):

use strict;
use Date::Calc qw(check_date);

my @date = qw( 08/02/2002
7/3/2003
13/3/2006
09/33/2002
al/df/ioji
09/14/66
);

for my $date (@date) {
   my ($month, $day, $year) = split /, $date;

   if (check_date($year,$month,$day)) { print $date is kosher\n; }
   else { print $date is uncool\n; }
}

OUTPUT

08/02/2002 is kosher
7/3/2003 is kosher
13/3/2006 is uncool
09/33/2002 is uncool
Argument ioji isn't numeric in subroutine entry at try1.pl line 17.
Argument al isn't numeric in subroutine entry at try1.pl line 17.
Argument df isn't numeric in subroutine entry at try1.pl line 17.
al/df/ioji is uncool
09/14/66 is kosher


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




Fw: Multiple Selects to Perl Script

2002-07-31 Thread Margaret


 Hi

 My html looks like this :

 form name='form1' method='POST' action='/cgi-bin/form.pl'
 .
 .
 select multiple name='type' size=5
 optionone
 optiontwo
 optionthree
 etc
 /select
 .
 .
 /form

 Does this look right?

 Thanks
 Margaret

 - Original Message -
 From: Kipp, James [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, July 31, 2002 3:36 PM
 Subject: RE: Multiple Selects to Perl Script


  are you sure all the values are associated with the name 'type' ?
 
 
   -Original Message-
   From: Margaret [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, July 31, 2002 9:27 AM
   To: [EMAIL PROTECTED]
   Subject: Multiple Selects to Perl Script
  
  
   Hi
  
   I am having a most frustrating problem. I created a from with multiple
   selects using a perl script and passed the multiple
   selections to an array
   ie.
  
   @array1 = $q-param('type').
  
   The array only contains the first selection and none of the
   others. How do I
   fix this? I have read a lot of documentation and it is
   supposed to work.
   What am I doing wrong?
  
   Regards
   Margaret
  
  
   --
   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]




One stupid question

2002-07-31 Thread Brian Bratcher

Ok, I have developed a few cgi scripts. Some are located at: 
http://www.addapage.net/cgi-scripts/index.html
I have developed on an as we learn type of situation. Now I must ask;

what is the difference between:

my $number = 200;
and
$number = 200;
?

Im sorry to be stupid in this manner, but I see it all the time in other scripts. I 
don't undersand

Thanks in advance
Brian



RE: One stupid question

2002-07-31 Thread Christian Andreassen

Try: perldoc perlfaq7

-ca

-Original Message-
From: Brian Bratcher [mailto:[EMAIL PROTECTED]]
Sent: 30. juli 2002 20:27
To: [EMAIL PROTECTED]
Subject: One stupid question


Ok, I have developed a few cgi scripts. Some are located at:
http://www.addapage.net/cgi-scripts/index.html
I have developed on an as we learn type of situation. Now I must ask;

what is the difference between:

my $number = 200;
and
$number = 200;
?

Im sorry to be stupid in this manner, but I see it all the time in other
scripts. I don't undersand

Thanks in advance
Brian


**
This e-mail and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to which they 
are addressed. If you have received this e-mail in error please notify
the system manager at [EMAIL PROTECTED]
**


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




Re: One stupid question

2002-07-31 Thread Felix Geerinckx

on Tue, 30 Jul 2002 18:27:18 GMT, [EMAIL PROTECTED] (Brian
Bratcher) wrote: 

 what is the difference between:
 
 my $number = 200;
 and
 $number = 200;
 ?

You should read e.g. M-J Dominus' article 'Coping with Scoping' at

http://perl.plover.com/FAQs/Namespaces.html

-- 
felix

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




Removing files------help

2002-07-31 Thread Brian Bratcher

Ok, I have created a package that takes orders and creates temporary files. Upon 
completing the order, the temp files are deleted. If the user does not complete the 
order and leaves the web site, the files remain as clutter. 

How can I tell if a user has left the site and act upon it?
If a user only gets half way through the order process and decides he/she is ready to 
go-to another site; How can I tell the system to erase their left-over files?

Once again, Thanks in advance
Brian Bratcher
[EMAIL PROTECTED]




Re: Sort table with dynamic order of fields

2002-07-31 Thread Connie Chan

Thanks in advise =)

In case, my source is not an Excel spread sheet, but a Hash Of Array.
So is that mean if I want to use this function, then I have to convert 
my HOA to Spreadsheet, then use the method below to sorting about ? Or 
anything I can do more direct ? Or anything can let me directly convert 
a HOA to CVS ? I would apperciate for any further hints. Thanks !!!

Rgds,
Connie


 
 Here's a thought:  You can convert the Excel spreadsheet to a .csv file and
 then use DBD::CSV to sort the fields.  You should be able to do this using
 Win32::OLE as long as you run it on a system with Excel installed.  The
 macro code fro saving the file to a .csv is:
 
 ActiveWorkbook.SaveAs Filename:=C:\My Documents\Book1.csv, FileFormat:
 =xlCSV, CreateBackup:=False
 
 I believe the documentation on Win32::OLE can get you started, and I know
 that there is information out there on how to convert a VB script to a Perl
 script using Win32::OLE.  You'll need to change the '.'s to '-'s, etc.
 



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




Perl Array Question

2002-07-31 Thread Theuerkorn Johannes

Hi there, i have (a probably simple) Question on Arrays:

I want to get some Data out of my SQL Databas. I try using the same Query not only 
once and put the collected data in diffrent Arrays.


for (my $i=0;$i= $count_SNR_LOG_data;$i++){
print $i\n;
my $sth_RACT_LOG = $dbh-prepare (select KEY_SNR,DRAWING_RE,RCODE_ID from 
RACT_LOG where KEY_SNR='$KEY_SNR_SNR_LOG[$i]';);

$sth_RACT_LOG-execute ||
 die Kann Abfrage sth_RACT_LOG nicht ausfuehren: $DBI::errstr\n;

while (my @RACT_LOG_data=$sth_RACT_LOG-fetchrow_array){

$count_RACT_LOG_data++;
push our @KEY_SNR_RACT_LOG[$i], $RACT_LOG_data[0];
push our @DRAWING_RE_RACT_LOG[$i], $RACT_LOG_data[1];
push our @RCODE_ID_RACT_LOG[$i], $RACT_LOG_data[2];
}

Thats how I try to get data out of my Arrays...

for (my $i=0;$i=$count_SNR_LOG_DATA,$i++){
for (my $u=0;$u=$count_RACT_LOG_data;$u++){
print $KEY_SNR_RACT_LOG[$i][$u]\n;
print $DRAWING_RE_RACT_LOG[$i][$u]\n;
print $RCODE_ID_RACT_LOG[$i][$u]\n;
}
}

But this isnt working at all.

Any suggestions are welcome..

Greetings Joe

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




Re: Removing files------help

2002-07-31 Thread Nigel Peck

You could use sessions, base the file names on the session numbers, and
keep a list of open session (i.e. not completed) and the time they were
last accessed, you could have a job run every half hour to remove
session files not used for a certain time period.

Or there's probably a better way, but that's one suggestion.

HTH
Nigel

 Brian Bratcher [EMAIL PROTECTED] 07/30/02 08:57pm 
Ok, I have created a package that takes orders and creates temporary
files. Upon completing the order, the temp files are deleted. If the
user does not complete the order and leaves the web site, the files
remain as clutter. 

How can I tell if a user has left the site and act upon it?
If a user only gets half way through the order process and decides
he/she is ready to go-to another site; How can I tell the system to
erase their left-over files?

Once again, Thanks in advance
Brian Bratcher
[EMAIL PROTECTED] 



ITM Business Solutions
Unit 4
Nine Trees Trading Estate
Morthen Road
Rotherham
S66 9JG

Reception
Tel: 01709 703288
Fax: 01709 701549

Help Desk
Tel:01709 530424
Fax: 01709 702159

CONFIDENTIALITY NOTICE: This message is intended only for the use of
the individual or entity to which it is addressed, and may contain
information that is privileged, confidential and exempt from disclosure
under applicable law.



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




RE: Sort table with dynamic order of fields

2002-07-31 Thread Timothy Johnson


If you decided to go the HOA to CSV route, then you could create the CSV
like this:

###

open(OUTFILE,temp.csv);
foreach(keys %hash){
  foreach my $elem(@{$hash{$_}}){
print OUTFILE \$elem\,;
  }
  print OUTFILE \n;
}
close OUTFILE;



That should create a CSV file with each field in quotes, just in case one of
your array elements has a comma in it.

I think there might also be some convoluted sort() syntax you could use, but
I can't test it here.

-Original Message-
From: Connie Chan
To: Timothy Johnson; [EMAIL PROTECTED]
Sent: 7/30/02 11:43 PM
Subject: Re: Sort table with dynamic order of fields

Thanks in advise =)

In case, my source is not an Excel spread sheet, but a Hash Of Array.
So is that mean if I want to use this function, then I have to convert 
my HOA to Spreadsheet, then use the method below to sorting about ? Or 
anything I can do more direct ? Or anything can let me directly convert 
a HOA to CVS ? I would apperciate for any further hints. Thanks !!!

Rgds,
Connie


 
 Here's a thought:  You can convert the Excel spreadsheet to a .csv
file and
 then use DBD::CSV to sort the fields.  You should be able to do this
using
 Win32::OLE as long as you run it on a system with Excel installed.
The
 macro code fro saving the file to a .csv is:
 
 ActiveWorkbook.SaveAs Filename:=C:\My Documents\Book1.csv,
FileFormat:
 =xlCSV, CreateBackup:=False
 
 I believe the documentation on Win32::OLE can get you started, and I
know
 that there is information out there on how to convert a VB script to a
Perl
 script using Win32::OLE.  You'll need to change the '.'s to '-'s,
etc.
 


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




Re: Problem with Net::Ping

2002-07-31 Thread Sudarshan Raghavan

On Tue, 30 Jul 2002, drieux wrote:

 I was somewhat surprised that the ping(tcp) method 'failed'
 on an unvarnished linux box...

You are right, I got confused between the stream echo server and the tcp 
one. The tcp echo requests do get replied to without having to start any 
extra service. Sorry!!


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




RE: chr help

2002-07-31 Thread Beau E. Cox

Hi -

I built a tiny .doc file with MS Word 2000 containing the text:

hello - world

Word did change the dash to a long dash on the screen.

Next, I opened the .doc file in binary mode (I my case, using the
C++ built-in editor) and found that line:

48 65 6C 6C 6F 20 96 20  77 6F 72 6C 64 0D 0D 0D
-or-
h  e  l  l  o -- w  o  r  l  d

So the long dash is hex 96 or chr (150)

Aloha = Beau.

-Original Message-
From: Gabby Dizon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 30, 2002 8:23 PM
To: [EMAIL PROTECTED]
Subject: chr help


Hi,

I have a subroutine that finds commonly found Unicode characters that
Microsoft Word uses (such as smart quotes) and converts them to plain
ASCII text. However, there is one character whose chr() value I can't seem
to find - the MS Word long dash, which automatically replaces the normal
(short dash) when you press Enter. Does anyone know or can point me to a
location where I can find the chr() value of this character? All replies are
greatly appreciated.

Gabby Dizon
Web Developer
INQ7 Interactive, Inc.
http://www.inq7.net
http://you.inq7.net


--
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: Fw: Help, I suppose.

2002-07-31 Thread Felix Geerinckx

on Tue, 30 Jul 2002 16:45:26 GMT, [EMAIL PROTECTED] (Tómas
guðmundsson) wrote: 

 But what do I do to make it more than just the phone number so if
 I ask of Fred it shows his number, address, e-mail, and such ?

 my %phone_book = qw(
 Fred [EMAIL PROTECTED] 0123 fred'sstreet 34
  );
 I know perl always search for the key and then returns the value
 but how do I make the value more than one word?

Use a hash of hashes:

my %phonebook = (
Fred = { EMAIL   = '[EMAIL PROTECTED]',
  NUMBER  = '0123',
  ADDRESS = 'fred\'sstreet 34', },
);

which you can access with
  
$phonebook{Fred}-{EMAIL} #etc

-- 
felix

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




Re: Removing files------help

2002-07-31 Thread Jenda Krynicky

 Ok, I have created a package that takes orders and creates temporary
 files. Upon completing the order, the temp files are deleted. If the
 user does not complete the order and leaves the web site, the files
 remain as clutter. 
 
 How can I tell if a user has left the site and act upon it?
 If a user only gets half way through the order process and decides
 he/she is ready to go-to another site; How can I tell the system to
 erase their left-over files?

No you can't tell the user left to another site. 

You could try playing with JavaScript onUnLoad handlers, change the 
external links so that they go through a script that does something 
and redirects to the actual address, but I would not recommend that. 
You will miss some and you will delete others that you do not want to 
(imagine they open the external link into a new window, or that they 
create a new window, your page gets loaded into that second window 
and when the user moves someplace else you delete the file ... while 
he still has the first window open).

The best you can do is to run a background job from time to time and 
delete the files that were not modified for some time.

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: Sort table with dynamic order of fields

2002-07-31 Thread Jenda Krynicky

From: Connie Chan [EMAIL PROTECTED]

 Thanks in advise =)
 
 In case, my source is not an Excel spread sheet, but a Hash Of Array.
 So is that mean if I want to use this function, then I have to convert
 my HOA to Spreadsheet, then use the method below to sorting about ? Or
 anything I can do more direct ? Or anything can let me directly
 convert a HOA to CVS ? I would apperciate for any further hints.
 Thanks !!!

Are you sure it's a HashOfArrays and not an ArrayOfHashes?

#HAO

$data{$key} = ['Jenda', 'Krynicky', '[EMAIL PROTECTED]', ...]

# AOH
$data[$i] = {fname = 'Jenda', lname = 'Krynicky', email = 
'[EMAIL PROTECTED]', ...}

Keep in mind that hash is not ordered!


If you want to sort the AOH using a field you can do it like this:

@sorted_data = sort {$a-{$key} cmp $b-{$key}} @data;
#ascending
or
@sorted_data = sort {$b-{$key} cmp $a-{$key}} @data;
#descending

where $key is the name of the field you want to use.
If you want to sort using several fields you can do it like this:

@sorted_data 
= sort {$a-{$key1} cmp $b-{$key1} or $a-{$key2} cmp $b-{$key2}}
@data;

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: Sort table with dynamic order of fields

2002-07-31 Thread Connie Chan

 Are you sure it's a HashOfArrays and not an ArrayOfHashes?

 #HAO
 
 $data{$key} = ['Jenda', 'Krynicky', '[EMAIL PROTECTED]', ...]
 
 # AOH
 $data[$i] = {fname = 'Jenda', lname = 'Krynicky', email = 
 '[EMAIL PROTECTED]', ...}
 

What I have now is something like this :
@ID = qw (Foo Bar Blaz Bob);
@Country = qw (UK US HK HK);
@Gender = qw (F M M F);

%table{ID} = (ID = \@ID, Country = \@Country, Gender = \@Gender);
So I got $table{ID}[1] as 'Bar, and I think this is HOA.

Note : The above array is always same in dimension, and
the reading way is Foo's location is in UK and gender is F.
This is fixed, so I can't modify anything on it.

But what I going to do is like this :
my %newTable = SortTable ( TABLE = \%table, Seq = Gender=A, Country=D, ID=A);
my %newTable = SortTable ( TABLE = \%table, Seq = ID=A, Gender=A, Country=A);
# where =A =D is in terms of acending and decending order.

That would really complex if have to write one, so I am looking if there is an existed
module for this.

 Keep in mind that hash is not ordered!

As illustrated, the order is always dynamic by different Seq, 
so that's not important here.

 If you want to sort the AOH using a field you can do it like this:
 
 @sorted_data = sort {$a-{$key} cmp $b-{$key}} @data;
 #ascending

but how about HOA ?

 where $key is the name of the field you want to use.
 If you want to sort using several fields you can do it like this:
 
 @sorted_data 
 = sort {$a-{$key1} cmp $b-{$key1} or $a-{$key2} cmp $b-{$key2}}
 @data;

Poor me :-
I don't really understand the meaning of  or $a-{$key2} com $b-{$key2}}  here...
Would any hints given here ?

Rgds,
Connie


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




Re: Sort table with dynamic order of fields

2002-07-31 Thread Jenda Krynicky

From: Connie Chan [EMAIL PROTECTED]

  Are you sure it's a HashOfArrays and not an ArrayOfHashes?
 
  #HAO
  
  $data{$key} = ['Jenda', 'Krynicky', '[EMAIL PROTECTED]', ...]
  
  # AOH
  $data[$i] = {fname = 'Jenda', lname = 'Krynicky', email = 
  '[EMAIL PROTECTED]', ...}
  
 
 What I have now is something like this :
 @ID = qw (Foo Bar Blaz Bob);
 @Country = qw (UK US HK HK);
 @Gender = qw (F M M F);
 
 %table{ID} = (ID = \@ID, Country = \@Country, Gender = \@Gender);
 So I got $table{ID}[1] as 'Bar, and I think this is HOA.
 
 Note : The above array is always same in dimension, and
 the reading way is Foo's location is in UK and gender is F.
 This is fixed, so I can't modify anything on it.

Yes you are right, this is HoA. Whoever designed this datastructure 
should be hunted down and shot though (exagerating a little).
 
 But what I going to do is like this :
 my %newTable = SortTable ( TABLE = \%table, Seq = Gender=A,
 Country=D, ID=A); my %newTable = SortTable ( TABLE = \%table, Seq =
 ID=A, Gender=A, Country=A); # where =A =D is in terms of acending
 and decending order.
 
 That would really complex if have to write one, so I am looking if
 there is an existed module for this.

No I do not think there is anything done that you could use as such.

Here is a function that sorts the structure using one key. I'll leave 
the rest to you:

sub SortHoAbyFiels {
my ($HoAref, $key) = @_;
my @indices = (0 .. $#{$HoAref-{$key}});
# create an array containing numbers from 0 to
# the maximum index of the arrays in %HoA
@indices = sort {$HoAref-{$key}-[$a] cmp $HoAref-{$key}-[$b]}
@indices;
# order it by the elements of $HoA{$key}
# instead of sorting the @{$HoA{$key}} array directly
# we only sort indices into that array
# we have to sort the other arrays in %HoA as well

return {
ID = [@{$HoAref-{ID}}{@indices}],
Country = [@{$HoAref-{Country}}{@indices}],
Gender = [@{$HoAref-{Gender}}{@indices}],
}
# return a new HoA containing arrays in the order 
# specified by @indices
}

$newHoAref = SortHoAbyFiels \%HoA, 'Country';

Try to step through the code and see what's happening there.

There is also an artice Far More than you ever wanted to know about 
sorting somewhere on the net that should give you more info.

  Keep in mind that hash is not ordered!
 
 As illustrated, the order is always dynamic by different Seq, 
 so that's not important here.
 
  If you want to sort the AOH using a field you can do it like this:
  
  @sorted_data = sort {$a-{$key} cmp $b-{$key}} @data;
  #ascending
 
 but how about HOA ?
 
  where $key is the name of the field you want to use.
  If you want to sort using several fields you can do it like this:
  
  @sorted_data 
  = sort {$a-{$key1} cmp $b-{$key1} or $a-{$key2}
  cmp $b-{$key2}}
  @data;
 
 Poor me :-
 I don't really understand the meaning of  or $a-{$key2} com
 $b-{$key2}}  here... Would any hints given here ?

The cmp operator returns -1 if the first argument is smaller than the 
second, 1 if its greater and 0 if its the same. So the

$a-{$key1} cmp $b-{$key1} or $a-{$key2} cmp $b-{$key2}

means

$a is smaller than $b 
IF 
$a-{$key1}  $b-{$key1}
or $a-{$key1} = $b-{$key1} and $a-{$key2}  $b-{$key2}
$a is greater than $b 
IF
$a-{$key1}  $b-{$key1}
or $a-{$key1} = $b-{$key1} and $a-{$key2}  $b-{$key2}
$a is the same as $b (in this ordering)
IF
$a-{$key1} = $b-{$key1} and $a-{$key2} = $b-{$key2}

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]




Editor

2002-07-31 Thread Scott Barnett

Hi,

I am new to Perl just over a month now. I have tried other  programming languages and 
they just seem to hard to understand. I have found Perl to be a lot easier to 
understand, and that brings me to my question. What is a good Perl Editor for writing 
scripts? I am currently using Crimson Editor.

Thanks 

Scott Barnett
Home Care Medical - Technical Support Specialist
1-800-369-6939
1-262-786-9870 ext.214
E-Mail [EMAIL PROTECTED]



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




AW: Editor

2002-07-31 Thread Angerstein

I really love nedit.

 -Ursprüngliche Nachricht-
 Von: Scott Barnett [mailto:[EMAIL PROTECTED]]
 Gesendet am: Mittwoch, 31. Juli 2002 15:44
 An: [EMAIL PROTECTED]
 Betreff: Editor

 Hi,

 I am new to Perl just over a month now. I have tried other
 programming languages and they just seem to hard to understand. I
 have found Perl to be a lot easier to understand, and that brings
 me to my question. What is a good Perl Editor for writing
 scripts? I am currently using Crimson Editor.

 Thanks

 Scott Barnett
 Home Care Medical - Technical Support Specialist
 1-800-369-6939
 1-262-786-9870 ext.214
 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: Editor

2002-07-31 Thread Nikola Janceski

nedit.org -- the best there is (in my book)

 -Original Message-
 From: Angerstein [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 9:55 AM
 To: Scott Barnett; [EMAIL PROTECTED]
 Subject: AW: Editor
 
 
 I really love nedit.
 
  -Ursprüngliche Nachricht-
  Von: Scott Barnett [mailto:[EMAIL PROTECTED]]
  Gesendet am: Mittwoch, 31. Juli 2002 15:44
  An: [EMAIL PROTECTED]
  Betreff: Editor
 
  Hi,
 
  I am new to Perl just over a month now. I have tried other
  programming languages and they just seem to hard to understand. I
  have found Perl to be a lot easier to understand, and that brings
  me to my question. What is a good Perl Editor for writing
  scripts? I am currently using Crimson Editor.
 
  Thanks
 
  Scott Barnett
  Home Care Medical - Technical Support Specialist
  1-800-369-6939
  1-262-786-9870 ext.214
  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]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Re: Editor

2002-07-31 Thread Connie Chan

Me too !! This editor is the greatest I found on Win OS.
But have you download the Syntax pack for Perl ? Go ahead
if no.

Anyway, the other choice for me is Note Tab Lite. But seems
very unstable if I am using Chinese ( Perhaps that do not
have any infect on you ).

But if you are doing a global text replacement, I would
suggest using CuteHtml. The replacement speed and quality is
the fastest and flexiable( Up to paragraphs ).

Rgds,
Connie


- Original Message -
From: Scott Barnett [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 31, 2002 9:43 PM
Subject: Editor


Hi,

I am new to Perl just over a month now. I have tried other  programming languages and 
they just seem to hard to
understand. I have found Perl to be a lot easier to understand, and that brings me to 
my question. What is a good Perl
Editor for writing scripts? I am currently using Crimson Editor.

Thanks

Scott Barnett
Home Care Medical - Technical Support Specialist
1-800-369-6939
1-262-786-9870 ext.214
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: Editor

2002-07-31 Thread Nikola Janceski

perhaps you haven't dl-ed the latest version of nedit.
It's up to 5.3 now, and has come along way from version 4.2.

 -Original Message-
 From: Connie Chan [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 9:57 AM
 To: Scott Barnett; [EMAIL PROTECTED]
 Subject: Re: Editor
 
 
 Me too !! This editor is the greatest I found on Win OS.
 But have you download the Syntax pack for Perl ? Go ahead
 if no.
 
 Anyway, the other choice for me is Note Tab Lite. But seems
 very unstable if I am using Chinese ( Perhaps that do not
 have any infect on you ).
 
 But if you are doing a global text replacement, I would
 suggest using CuteHtml. The replacement speed and quality is
 the fastest and flexiable( Up to paragraphs ).
 
 Rgds,
 Connie
 
 
 - Original Message -
 From: Scott Barnett [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, July 31, 2002 9:43 PM
 Subject: Editor
 
 
 Hi,
 
 I am new to Perl just over a month now. I have tried other  
 programming languages and they just seem to hard to
 understand. I have found Perl to be a lot easier to 
 understand, and that brings me to my question. What is a good Perl
 Editor for writing scripts? I am currently using Crimson Editor.
 
 Thanks
 
 Scott Barnett
 Home Care Medical - Technical Support Specialist
 1-800-369-6939
 1-262-786-9870 ext.214
 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]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Re: Editor

2002-07-31 Thread Kay Bieri

On Wed, 31 Jul 2002, Connie Chan wrote:


 I am new to Perl just over a month now. I have tried other  programming languages 
and they just seem to hard to
 understand. I have found Perl to be a lot easier to understand, and that brings me 
to my question. What is a good Perl
 Editor for writing scripts? I am currently using Crimson Editor.

 Thanks



Is anybody using GNU Emacs to write perl programs? Is its perl-mode good
enough to compete with nedit and alike? I've been using Emacs for almost
anything (including C++, Latex, Perl ...) and hardly ever tried another
editor.

Greetings
Kay


Kay Bieri
Sidlerstr. 5, 3012 Bern
Switzerland
email: [EMAIL PROTECTED]  phone: +41 (031) 631 8682



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




Re: Sort table with dynamic order of fields

2002-07-31 Thread Felix Geerinckx

on Wed, 31 Jul 2002 12:56:17 GMT, [EMAIL PROTECTED] (Connie Chan)
wrote: 

 What I have now is something like this :
 @ID = qw (Foo Bar Blaz Bob);
 @Country = qw (UK US HK HK);
 @Gender = qw (F M M F);

Using parallel arrays to store related data is not a good idea imho.
I would use an (anonymous) array of hashes here:

my $persons = [ { ID = 'Foo', COUNTRY = 'UK', GENDER = 'F' },
{ ID = 'Bar', COUNTRY = 'US', GENDER = 'M' },
{ ID = 'Bla', COUNTRY = 'HK', GENDER = 'M' },
{ ID = 'Bob', COUNTRY = 'HK', GENDER = 'F' }
  ];

(I don't believe Bob is female though :-)


 %table{ID} = (ID = \@ID, Country = \@Country, Gender =
 \@Gender); So I got $table{ID}[1] as 'Bar, and I think this is
 HOA. 

Did you mean %table = (...) here instead of %table{ID} = (...), which 
is a syntax error.

 Note : The above array is always same in dimension, and
 the reading way is Foo's location is in UK and gender is F.

But this is not an array, it is a hash.

 This is fixed, so I can't modify anything on it.

That's a pity, because it really is error-prone.

 But what I going to do is like this :
 my %newTable = SortTable ( TABLE = \%table, Seq = Gender=A,
 Country=D, ID=A); 
 my %newTable = SortTable ( TABLE = \%table,
 Seq = ID=A, Gender=A, Country=A); # where =A =D is in terms of
 acending and decending order. 

If I understand you correctly, you want to create a new hash, where 
the elements in the individual arrays are sorted by your criteria.
 
 That would really complex if have to write one, so I am looking if
 there is an existed module for this.

Using your datastructure, this would indeed be rather complicated.
If you could use the datastructure I proposed at the beginning of 
this post, you could write

sub sortit {
my $array = shift;
my $code = 'sub sortfun { ';
my $first = 1;

while (@_) {
my $s = shift;
my $d = shift;  
$code .= ' || ' unless $first;
$first = 0;
$code .= $d eq 'A' ?
 \$a-{$s} cmp \$b-{$s} :
 \$b-{$s} cmp \$a-{$s} ;
  }
   $code .= '}';
   undef sortfun;
   eval $code;
   my @result = sort sortfun @$array;
   return \@result;
}

which builds a sortfunction on the fly per your criteria.
It could then be called as follows:

my $sorted_persons = sortit($persons,  
COUNTRY = 'A', 
GENDER  = 'D', 
ID  = 'A'); 

-- 
felix

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




empty anonomous hash

2002-07-31 Thread Nikola Janceski

I have a data structure that I want to initialized with an empty anon. hash.

I know for arrays I can do:
$DATA{$key1}{$key2} = [];

but what if I want it to be a hash?

Nikola Janceski

God is subtle, but he is not malicious.
-- Albert Einstein (1879-1955) 




The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Editor

2002-07-31 Thread Nikola Janceski

Yes. The regexs in nedit look more like perl regexs.
Also it has customizable keyboard shortcuts, and a nice graphical interface
if you don't like keystroking.

 -Original Message-
 From: Kay Bieri [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 10:06 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Editor
 
 
 Is anybody using GNU Emacs to write perl programs? Is its 
 perl-mode good
 enough to compete with nedit and alike? I've been using Emacs 
 for almost
 anything (including C++, Latex, Perl ...) and hardly ever 
 tried another
 editor.
 
 Greetings
 Kay
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Re: Sort table with dynamic order of fields

2002-07-31 Thread Jenda Krynicky

From: Felix Geerinckx [EMAIL PROTECTED]
 Using your datastructure, this would indeed be rather complicated. If
 you could use the datastructure I proposed at the beginning of this
 post, you could write

I don't think it's wise to overwrite a function definition over an 
over again. Create an unnamed function:
 
 sub sortit {
 my $array = shift;
 my $code = 'sub sortfun { ';

 my $code = 'sub { ';

 my $first = 1;
 
 while (@_) {
 my $s = shift;
 my $d = shift;
 $code .= ' || ' unless $first;
 $first = 0;
 $code .= $d eq 'A' ?
  \$a-{$s} cmp \$b-{$s} :
  \$b-{$s} cmp \$a-{$s} ;
}
$code .= '}';
undef sortfun;
eval $code;
my @result = sort sortfun @$array;

The last three lines become:

my $sortfun = eval $code;
my @result = sort $sortfun @$array;

return \@result;
 }

This may be combined with the code I posted. So then you get what you 
are after.

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]




creating MS Access tables via Perl

2002-07-31 Thread Johnson, Shaunn

Howdy:

Just got an odd call today.  A client (who works on 
a Microsoft platform) wants to have a MS Access
table created for him on a monthly basis from 
my warehouse.

The warehouse is a PostgreSQL database on a RedHat
Linux platform.

My question: Is there something in Perl that will
allow me to created an MS Access table from my
data from PostgreSQL?

I know ... everyday is a new adventure ...

Some of the outstanding problems is that MS Access
has a size limit ... and I may have to do some SQL
before creating the table (shouldn't be too much
of a problem, though).

Anyhow ...

Thanks!

-X



Perl IDE's v. Perl Editors was Re: Editor

2002-07-31 Thread drieux


On Wednesday, July 31, 2002, at 06:43 , Scott Barnett wrote:
[..]
  What is a good Perl Editor for writing scripts?

The Correct Answer is:

The one on the machine where you do your editing.
That simplifies the process for you.

I am partial to doing my development with bbedit 6.5.2
but also use 'vi' on machines where it is the only
installed 'fancy' editor.

Unfortunately these do not have some of the crucial
features that are required in a full Perl IDE - which
is what I believe you are really asking about.

Many editors now come with various forms of 'colour'
for providing 'syntax mark up' - that will provide
'visual clues' to when one has injected a 'typo' into
a script. This helps IF you know the 'colour schema'
for how perl syntax SHOULD look like to begin with. It
will of course help you along the way to learn basic
perl syntax as you use this 'memory aid'.

Amongst the features I find useful in the bbedit version
are such basic requirements as:

a) the ability to call up the 'perl docs' for
functions and modules -

a1) select the thing you wonder about, and click
the view reference option.

a2) when constructing POD in a script/code/module
one can also run the 'view POD' option to see
how the pod would lay out

b) the ability to invoke the perl debugger

c) the ability to run code in either a 'terminal' window
or as a 'stand alone' 

d) Ability to Create and Utilize 'stationery' for code templates
as well as 'glossaries' of 'hot-key' sequences for basic things
one would normally have to type one's self.

Things that I have yet to find in any decent 'perl editor'
with ambitions to being a fully integraded development environment:

1. perl document searches that include all modules everywhere
that will do a full search for the appropriate module one
should have been using from the CPAN based upon some simple
Regular Expression and/or Domain Specific Language Expansion
style language that can resolve what the true intent would have been
for the functionality one is seeking.

2. UML graphical presentation to Perl Code - such a suite would
allow one to play with pictographs and various forms of hierogliphics
to graphically represent the conceptual frame work that are then
translated into an appropriate suite of Perl Modules and supporting
scripts and code.

3. Apocalypse Now Redux - the directors cut, that will identify
which portions of your current Perl5 coding style/habit/tendencies
will become redundent and/or deprecated in Perl6, and no longer
needed in Perl7.

4. The Correct Upgrader - this portion is the rational extension of
the query mechanisms used in 1 above, based upon the resilience
of section 3, as clarified by 2, that will

4a) download and install while you type, the correct
CPAN modules - correcting and replacing any
deprecated code that you had previously typed

4b) if no such module currently exists, will send out the
call for votes to form
4b1 - the correct UseNet news group
4b2 - the correct email group
4b3 - the correct bridge between SMTP and NNTP
4b4 - institutionalize such other alternative
messaging mechanisms as 
required.

4c) Establish and Co-ordinate a working group both at the
CPAN, as well as within the IETF, to establish a
standards track for this solution space.

4d) Interoperate with the dissident factions to create a
religious war over this solution space.

5. The Endless Coffee Pot - this portion of any reasonable Perl
IDE will make sure that the 'stimulant based' fluid system is
current with the requirements for neural enhancers.

6. Enhanced Management Interface Mechanisms - that will summarise
all that one has done to date with regards to

6a) open defects against the project
6b) the timeline and budget of the project
6c) shifts in the corporate policies with regards to
the allocation of stock options as they influence
the market position of the company and coder assets

6d) as required, master meaningless marketting expressions
promulgated in the corporate email disinformation campaign
  

store message in a variable and use sendmail

2002-07-31 Thread loan tran


I store a messages(4 pages in text) in a variabe and
use sendmail to send it. The mail messages get chopped
of but I'm not sure why.
Can you suggest a better way to send a content of a
text file using sendmail. Thanks in advance.

Below is part of my script:

foreach $eachowner(@ownerlist){
  $sql_ownwhat = qq(select sybaseServer, dbName
from DatabaseOwner where email_test = $eachowner);
 
sybase_connect(FCCDEV01W,'aigdb',$sql_ownwhat);
while($ownwhatdata = $sth-fetchrow_hashref){
  `cat
$reportdir/$ownwhatdata-{sybaseServer}..$ownwhatdata-{dbName}.users
 $reportdir/$eachowner.txt`;
}#end while
 $sth-finish;
 $mail_message = `cat $reportdir/$eachowner.txt`;
 sendownermail($eachowner,$mail_message);
}#end foreach


sub sendownermail{
my $to= $_[0];
my $mail_message = $_[1];
open(SENDMAIL, |/usr/lib/sendmail -oi -t) or die
Cannot fork for send mail: $! \n;
print SENDMAILEOF;
From: [EMAIL PROTECTED]
To: $to\@test.com ; ltran\@test.com
Subject: Testing 


$mail_message 
EOF
close(SENDMAIL) or warn sendmail dinnot close
nicely;
}# end sendownermail

__
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

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




RE: Perl IDE's v. Perl Editors was Re: Editor

2002-07-31 Thread Nikola Janceski

Yep even the best of syntax highlighting patterns still can't handle some of
those FUNKY regexs I use in my perl program.

 -Original Message-
 From: drieux [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 10:46 AM
 To: begin begin
 Subject: Perl IDE's v. Perl Editors was Re: Editor
 
[snip]
 
 Many editors now come with various forms of 'colour'
 for providing 'syntax mark up' - that will provide
 'visual clues' to when one has injected a 'typo' into
 a script. This helps IF you know the 'colour schema'
 for how perl syntax SHOULD look like to begin with. It
 will of course help you along the way to learn basic
 perl syntax as you use this 'memory aid'.
 
[snip]



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Editor

2002-07-31 Thread Robert Smith

I've been using EditPlus for awhile now on Win32 platform...

http://www.editplus.com/

The $$ I paid for it a couple years ago (it's $30 now) seems to have
been worth it, although after looking at the Crimson Editor website, it
looks quite similar and is free...a good price. I've also tried the
Komodo 1.2 IDE, but went away frustrated with its slow performance...$15
for the non-commercial license, I opine, was not well spent.
~Robert

-Original Message-
From: Scott Barnett [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, July 31, 2002 6:44 AM
To: [EMAIL PROTECTED]
Subject: Editor

Hi,

I am new to Perl just over a month now. I have tried other  programming
languages and they just seem to hard to understand. I have found Perl to
be a lot easier to understand, and that brings me to my question. What
is a good Perl Editor for writing scripts? I am currently using Crimson
Editor.

Thanks 

Scott Barnett
Home Care Medical - Technical Support Specialist
1-800-369-6939
1-262-786-9870 ext.214
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: chr help

2002-07-31 Thread zentara

On Wed, 31 Jul 2002 18:17:46 +0800, [EMAIL PROTECTED] (Connie Chan)
wrote:
 Does anyone know or can point me to a
 location where I can find the chr() value of this character? All replies are
 greatly appreciated.

my @chars = split //, $line; # $line is your string.
foreach my $char(@chars) { print sprintf%1x, ord($char) ; print   }
# Hope this help.

Hi, this dosn't match up the ascii character with the hex code, making
it very hard to read the output. Here is an improved version, which
prints out the hex characters vertically, directly beneath each
character. Add this to your utilities directory.
#ascii-hex-print
###
#!/usr/bin/perl -wnl012
# Prints the contents of a file a line at a time
# followed by the ASCII value of each character in vertical columns.
# Useful for debugging.
# If no filename is specified then input is read from the keyboard.
# Version 1.00 Ian Howlett [EMAIL PROTECTED] 6 July 2001
# Version 1.10 James Yolkowski [EMAIL PROTECTED] 8 July 2001

print;  
@hexvals = map {sprintf %02X, ord $_} split //;  
for $a (0, 1) {print map {substr $_, $a, 1} @hexvals}
#



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




regex capturing

2002-07-31 Thread Nikola Janceski

$\ = \n;
$date = 20020731;
print join /, ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; # this works
print join /, ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # this doesn't

__END__

why did the second pattern not capture the second occurance of \d{2} ?
Is this the correct action? or should it capture the second one in the
second example?
Is there a way to capture like so (like second example as I expected it to
work)?


Nikola Janceski

If you enjoy what you do, you'll never work another day in your life.
-- Confucius 




The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Re: Perl IDE's v. Perl Editors was Re: Editor

2002-07-31 Thread drieux


On Wednesday, July 31, 2002, at 08:04 , Nikola Janceski wrote:

 Yep even the best of syntax highlighting patterns still can't handle some 
 of
 those FUNKY regexs I use in my perl program.

don't EVEN get me started...

{ too late drieux  }

hum. parenting code, is like parenting children,
not for the feint of heart, and mostly done wrong



ciao
drieux

---


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




Re: regex capturing

2002-07-31 Thread Tanton Gibbs

To capture the second occurance you have to surround the {2} with parens.

print join /, ($date =~ /(\d{4})(\d{2}{2})/)[1,2,0]

Tanton
- Original Message -
From: Nikola Janceski [EMAIL PROTECTED]
To: Beginners (E-mail) [EMAIL PROTECTED]
Sent: Wednesday, July 31, 2002 11:27 AM
Subject: regex capturing


 $\ = \n;
 $date = 20020731;
 print join /, ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; # this works
 print join /, ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # this doesn't

 __END__

 why did the second pattern not capture the second occurance of \d{2} ?
 Is this the correct action? or should it capture the second one in the
 second example?
 Is there a way to capture like so (like second example as I expected it to
 work)?


 Nikola Janceski

 If you enjoy what you do, you'll never work another day in your life.
 -- Confucius


 --
--
 
 The views and opinions expressed in this email message are the sender's
 own, and do not necessarily represent the views and opinions of Summit
 Systems Inc.


 --
 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: regex capturing

2002-07-31 Thread Nikola Janceski

Nested quantifiers before HERE mark in regex m/(\d{4})(\d{2}{  HERE 2})/
at line.
when i do that, so that's not the answer.
print join /, ($date =~ /(\d{4})(\d{2}{2})/)[1,2,0];

 -Original Message-
 From: Tanton Gibbs [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 11:55 AM
 To: Nikola Janceski; Beginners (E-mail)
 Subject: Re: regex capturing
 
 
 To capture the second occurance you have to surround the {2} 
 with parens.
 
 print join /, ($date =~ /(\d{4})(\d{2}{2})/)[1,2,0]
 
 Tanton
 - Original Message -
 From: Nikola Janceski [EMAIL PROTECTED]
 To: Beginners (E-mail) [EMAIL PROTECTED]
 Sent: Wednesday, July 31, 2002 11:27 AM
 Subject: regex capturing
 
 
  $\ = \n;
  $date = 20020731;
  print join /, ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; 
 # this works
  print join /, ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # 
 this doesn't
 
  __END__
 
  why did the second pattern not capture the second occurance 
 of \d{2} ?
  Is this the correct action? or should it capture the second 
 one in the
  second example?
  Is there a way to capture like so (like second example as I 
 expected it to
  work)?
 
 
  Nikola Janceski
 
  If you enjoy what you do, you'll never work another day in 
 your life.
  -- Confucius
 
 
  
 --
 
 --
  
  The views and opinions expressed in this email message are 
 the sender's
  own, and do not necessarily represent the views and 
 opinions of Summit
  Systems Inc.
 
 
  --
  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]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Editor

2002-07-31 Thread nkuipers

Well, I am working on linux, and I started with pico but now I use vi and am 
quite happy with it; fast movement, versatile copy-paste, colored syntax 
toggling...it does the job.  I'll have to give nedit a look though if there 
are any linux offerings...people seem to be raving about it.

regards,
nathanael


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




Re: How to replace a literal with a variable

2002-07-31 Thread Larry Steinberg

Timothy,

Yes, thanks!

Timothy Johnson [EMAIL PROTECTED] wrote in message
C0FD5BECE2F0C84EAA97D7300A500D50046DC99B@SMILEY">news:C0FD5BECE2F0C84EAA97D7300A500D50046DC99B@SMILEY...

 Do you mean something like this?

 
 open(LOG,log.txt);
 my %errs = ();
 while(LOG){
   chomp $_;
   my($details,$err) = split(/\|/,$_);
   $err =~ s/^\s+//;
   $errs{$err}++ if $err;
 }

 print Total for each error:\n;
 print -\n\n;

 foreach(sort keys %errs){
   print $_.$errs{$_}\n;
 }

 

 That will split each line on a pipe, then remove whitespaces at the
 beginning of the variable, then store it as a hash key.

 -Original Message-
 From: Larry Steinberg [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, July 30, 2002 10:17 AM
 To: [EMAIL PROTECTED]
 Subject: Re: How to replace a literal with a variable


 Here is what I need. I hope this explains it better.

 I have a script which creates a report for No Listings Found errors. I'd
 like to adapt it to create a report for any ERR  code condition in the
 log. The errors and values are below. TIA!

 Error | Value

 city not in state | TSE

 ZIP not in state | ZSE

 ZIP not in city | ZTE

 can't find address in distance search | BAD

 not enough address info in distance search | DBK

 keyword but no category or name | KEY

 more than one address in distance search | MUL

 network problem | NET

 no such category | CAT

 no such category and no such city | NCC

 no such category and city not in state | NCG

 no such city | CIT

 no listings found | NLF

 no listings found and no such phone number | NSP

 no fields, state only, or no state | NST

 no such state | NSS

 no such ZIP | ZIP

 only one phone field | PHN

 too many listings | TML

 search timeout | TIM

 no state and no ZIP | MSZ

 no coverage | MCV

 search failure | MSF

 failure to connect to server | MSV

 unknown error (oops page) | UNK

 no results found | NRF

 Nkuipers [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I'm probably not understanding what exactly you needbut...as I see
it,
  $err holds whatever error message that you captured with a regex.  So if
 you
  want to make a variable with the same name as the literal, dereference a
  variable with the name held in $err and the new var will autovivify:
 
  ($err) = ( $line =~ / ERR (\w+) /i );
  my $$err;
 
  I think.
 



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




Create HTML form within a perl function.

2002-07-31 Thread Lance Prais

I am not sure if I am going to ask this question correctly therefore, please
ask as many questions as you need to understand.

My situation is a follows:   I have a perl script that extracts data from a
list then processes this information and outputs is to HTML.  I am working
off someone else code and understand enough of it to be dangerous.

Therefore, with the code below I can do some tweaking.

This code outputs the following for example:
FileSize Image
Description

I need to do this:
Title Item a
Description item b  item c
  Item d
Item e  item f
  Item g

I am just not to clear on how I need to modify the code to get the above
output.  If someone could help me out or point to a place on the web that
talks about this it would be greatly appreciated.

The code I am using is:

# Create education list table
sub docTableList {
my %args = (
BGCOLOR_FLAG = '',
FILESIZE = '',
FILENAME = '',
TITLE = '',
DESC = '',
EXAM = '',
POINTS = '',
DELIVERY = '',
@_,
);
$bgcolor_flag = $args{BGCOLOR_FLAG};
$filesize = $args{FILESIZE};
$filename = $args{FILENAME};
$summary  = this is a summary of the item;
$title = $args{TITLE};
$desc = $args{DESC};
$exam = $args{EXAM};
$points = $args{POINTS};
$delivery = $args{DELIVERY};


$display_result = ;
$display_result = $display_result . $doc_list_table_product . \n;
$display_result = $display_result . $doc_list_tr_product . \n;
if ($bgcolor_flag == 0) {
$display_result = $display_result . $doc_list_title_td_one_product .
$doc_list_title_font_product;
} else {
$display_result = $display_result . $doc_list_title_td_two_product .
$doc_list_title_font_product;
}
$display_result = $display_result  . $desc . \\/font\\\/td\ . \n;
$display_result = $display_result . \a href=\ . $filename . \\ .
$title . \\/a\\\/font\\\/td\ . \n;
if ($bgcolor_flag == 0) {
$display_result = $display_result . $doc_list_size_td_one_product . 
\n;
} else {
$display_result = $display_result . $doc_list_size_td_two_product . 
\n;
}
$display_result = $display_result . $doc_list_size_div_product .
$doc_list_size_font_product;
$display_result = $display_result . $filesize . \\/font\\\/div\;
$display_result = $display_result . \\/td\ . \n;
if ($bgcolor_flag == 0) {
$bgcolor_flag = 1;
$display_result = $display_result . $doc_list_image_td_one_product . 
\n;
} else {
$bgcolor_flag = 0;
$display_result = $display_result . $doc_list_image_td_two_product . 
\n;
}
$display_result = $display_result . $doc_list_image_div_product . \n;
$icon_image = fileImage(FILENAME = $filename);
$display_result = $display_result . \img src=\..\/..\/..\/..\/images\/
.. $icon_image . \ width=\16\ height=\16/div\;
$display_result = $display_result . \\/td\ . \n;
$display_result = $display_result . \\/tr\ . \n;

return  $display_result;
}


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




RE: regex capturing

2002-07-31 Thread Bob Showalter

 -Original Message-
 From: Nikola Janceski [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 11:27 AM
 To: Beginners (E-mail)
 Subject: regex capturing
 
 
 $\ = \n;
 $date = 20020731;
 print join /, ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; # 
 this works
 print join /, ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # this doesn't
 
 __END__
 
 why did the second pattern not capture the second occurance of \d{2} ?

But it does capture the second occurrence (the 31). It doesn't capture
the first (the 07).

In the absence of /g, it would seem that since there are only two
sets of parens in the second regex, only two values can be captured.
The {2} quanitifier would simply cause $2 to be reused.

 Is this the correct action? or should it capture the second one in the
 second example?
 Is there a way to capture like so (like second example as I 
 expected it to
 work)?

I would think /g would have to be used somehow, but I do not know
how.

Of course, the simple:

   /(\d{2})/g

works, returning '20', '02', '07', '31'.

But that's not what you're after.

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




Re: Perl IDE's v. Perl Editors was Re: Editor

2002-07-31 Thread Paul Tremblay

I'm surprised that more posters didn't advocate vim as *the* editor.
I think it is linux world that did a survey and found that 80 percent of
the users picked vim as their favorite editor. 

I originally started using vim, then switched to nedit, and now have
switched back to vim. Nedit if very nice, but I had problems with
keyboard commands. About half the time when I would press keys like
cntrl z to undo a command, I would get a ^ack or something like that
on the screen.

I can see why vim is the most popular linux editor. It is extremelly
powerful. It has all sorts of options for automatic inenting, as well as
a feature called folding, which I still have to learn how to use; it
bascially hides lines on your screen. So if you were working between
your main program and a subroutine 1000 lines below, you could hide
those thousand lines. Of course, vim as full highlighting capabilities.
Vim offers so many options that I doubt I could learn them all.

The drawback to vim is that it is a bit hard to learn at first. It is
keyboard driven, which goes against how most people learn to operate
a computer, with a mouse. Of course, there is full graphical interface
version of vim, which I use, called gvim. Once you get over the initial
difficulty of learning vim (which should only take a few days?), then it
can be easier to use, depending on your preferences.

Vim is also one hundred percent free--as is Nedit. I wouldn't pay for an
editor, with all the excellent free choices out there.

But nedit is also a good choice as an editor. It is very intuitive and also
powerful.

Paul

-- 


*Paul Tremblay *
*[EMAIL PROTECTED]*


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




RE: regex capturing

2002-07-31 Thread Nikola Janceski

Correct actually. It just didn't dawn on me that $2 was being reused but
that is unlike perl to do that.
I would have thought that it would know that I wanted 2 captures. So is this
just a new issue that hasn't come up before? or is it something seen just
nothing done about it?

I am using the first example anyway because I need it working now, but I was
curious to learn if this is a problem/bug or if this was the intended
result. Perldocs didn't have much about this kind of situation, so I don't
know what the intended result would be.

 -Original Message-
 From: Bob Showalter [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 12:21 PM
 To: 'Nikola Janceski'; Beginners (E-mail)
 Subject: RE: regex capturing
 
 
 But it does capture the second occurrence (the 31). It doesn't capture
 the first (the 07).
 
 In the absence of /g, it would seem that since there are only two
 sets of parens in the second regex, only two values can be captured.
 The {2} quanitifier would simply cause $2 to be reused.
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Regex Problem

2002-07-31 Thread John Francis

woah...

why is $bar = \${foo} - ? something is weird there...

also the problem was with your substitution op

$bar =~ s/\$\{\(\w+)\}/\$${1}/g;

- John

On Mon, 29 Jul 2002, Balint, Jess wrote:

 Thanks. Here is what I am trying to accomplish:
 
 $foo = something;
 $bar = \${foo};
 $bar =~ s/\$\{\(\w+)\}/$$1/g;
 print $bar;
 
 OUTPUT:
 
 something
 
 I am getting an error:
 
 Can't use string (something) as a SCALAR ref while strict refs in use at
 .. . .
 Thanks.
 
 Jess
 
 -Original Message-
 From: John Francis
 To: Balint, Jess
 Cc: '[EMAIL PROTECTED]'
 Sent: 7/28/02 10:14 PM
 Subject: Re: Regex Problem
 
 Jess,
  Try:
   s/\$\{(\w+)\}/\$${1}/g;
 
  if i understood your problem correctly =)
   - John
 
 On Sun, 28 Jul 2002, Balint, Jess wrote:
 
  Hello all. I am getting an error with the following reg-exp:
  
  s/\$\{(\w+)\}/$$1/g;
  
  I am not sure exactly how to do this type of thing. Is there any way
 to get
  around the error or must I turn off 'strict refs' for this line??
 Thanks
  alot.
  
  Jess
  
  -- 
  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: Perl IDE's v. Perl Editors was Re: Editor

2002-07-31 Thread Nikola Janceski

see inline comments

 -Original Message-
 From: Paul Tremblay [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 12:24 PM
 To: begin begin
 Subject: Re: Perl IDE's v. Perl Editors was Re: Editor
 
 
 I'm surprised that more posters didn't advocate vim as *the* editor.
 I think it is linux world that did a survey and found that 80 
 percent of
 the users picked vim as their favorite editor. 
 
 I originally started using vim, then switched to nedit, and now have
 switched back to vim. Nedit if very nice, but I had problems with
 keyboard commands. About half the time when I would press keys like
 cntrl z to undo a command, I would get a ^ack or 
 something like that
 on the screen.

that's been fixed on the new release.

 
 I can see why vim is the most popular linux editor. It is extremelly
 powerful. It has all sorts of options for automatic inenting, 
 as well as
 a feature called folding, which I still have to learn how to use; it
 bascially hides lines on your screen. So if you were working between
 your main program and a subroutine 1000 lines below, you could hide
 those thousand lines. Of course, vim as full highlighting 
 capabilities.
 Vim offers so many options that I doubt I could learn them all.

nedit too, and the help docs are much better now, vim docs weren't that
great.
IMHO.

 
 The drawback to vim is that it is a bit hard to learn at first. It is
 keyboard driven, which goes against how most people learn to operate
 a computer, with a mouse. Of course, there is full graphical interface
Ack, love the keyboard, hate the mouse.

 version of vim, which I use, called gvim. Once you get over 
 the initial
 difficulty of learning vim (which should only take a few 
 days?), then it
 can be easier to use, depending on your preferences.
 
 Vim is also one hundred percent free--as is Nedit. I wouldn't 
 pay for an
 editor, with all the excellent free choices out there.
 
Agreed.

 But nedit is also a good choice as an editor. It is very 
 intuitive and also
 powerful.

And easy to learn.




The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Fw: ?Perl Editors - Re: Editor

2002-07-31 Thread Krackedpress \(Default\)

 {Yep even the best of syntax highlighting patterns still can't handle some
  of those FUNKY regexs I use in my perl program.}

 Was that to scare us newcomers to Perl

 I have been programming on/off since late 1978
 and now I an just starting to program for the WEB

 Perl, PHP, mySQL, etc.

 I have seen good editors, and bad ones.
 I have written editors for RPG II and other specific languages
 that are very hard to work with in normal text-style editors

 I have not seen any ONE editor that works for even most
 type of text-based programming documents I and other I know have done.

 I currently use more than 5 different editor,
 depending upon what I am editing and what I want to do.
 But, I use only one most of the time.

 As a long time programmer
 and one with Dyslexia to boot{two strikes against me},
 I say find one you like and use it,
 until it becomes second nature to you.

 If you have need to use other editors for SPECIFIC
 needs that the one you work with cannot do
 find one that can handle those needs, and use it
 for those needs only.

 The best writing is done when you do not have to worry
 about the tools you are using to write with.

 As I said, I use many editors, and I am always looking to see
 if there are better ones. I currently use an older version of
 NoteTab as my main editor.  Sometimes the newer a product gets,
 the harder it is to use.

 I still find some of my old DOS programs work easier and faster
 then that of their Windows counterparts.

 I read one comment about Crimson Editor - it can fit on a floppy
 I can remember when that was a given - fit on a floppy.
 I now have that editor and it looks promising.
 We will see after using it for a while.

 I am sorry for this long statement - and it is my first reply here.
 But us old time programmers, even though new to web-programming
 may have in-sites with over 20 years of programming.
 I have forgotten more languages than I want to remember.
 And I have been told that the older generation could not
 understand this new world of the NET.
 I had to write the routines to allowed me to do things the younger
 generation take for granted today.  My generation invented the
 stuff  we build on today.  Just because I am over 40 does not
 mean I cannot do what a 20 year old can. I have lost many a job
 just because of age prejudice.

 But it is time that he newer programmers look back to the ones
 that have been doing it for most of their lives, ask how to program.
 It is language independent - I should know.  It is just syntax differences
 not the How-To.

 This argument about which editor is the best is just the tip.
 We must have the best of everything.
 Buy a computer for $4,000 this year and then
 scrap it next year for the newest and greatest.

 I use and own equipment from a 486 to some of the newest technology,
 nut I an typing this from a computer that I have had since the AMD-266
 days.  It is currently upgraded to a 500 MHz computer, but it still
 is my favorite one to work with.

 Remember - find one you like and stick with it
 unless you find one that is much better, not just the newest thing.

 If you keep needing to learn new hardware and software to
 do the same job that you can do with your current equipment,
 why take the time.  For me time is money.  Spend you time
 where it counts.  Not to keep up with the Jones.

 Timothy Lungstrom
 owner of Kracked Press Production
 [EMAIL PROTECTED]

 **

 - Original Message -
 From: drieux [EMAIL PROTECTED]
 To: begin begin [EMAIL PROTECTED]
 Sent: Wednesday, July 31, 2002 11:30 AM
 Subject: Re: Perl IDE's v. Perl Editors was Re: Editor


 
  On Wednesday, July 31, 2002, at 08:04 , Nikola Janceski wrote:
 
   Yep even the best of syntax highlighting patterns still can't handle
 some
   of
   those FUNKY regexs I use in my perl program.
 
  don't EVEN get me started...
 
  { too late drieux  }
 
  hum. parenting code, is like parenting children,
  not for the feint of heart, and mostly done wrong
 
 
 
  ciao
  drieux
 
  ---
 
 
  --
  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: ?Perl Editors - Re: Editor

2002-07-31 Thread drieux


On Wednesday, July 31, 2002, at 09:22 , perl wrote:
[..]
 Was that to scare us newcomers to Perl

I can't speak for anyone else, but 'scare' is too
strong a word for my intentions - unless by that
we mean oblige folks to remember that 'coding'
is about 'putting the stuff between the curley braces'
and that 'text editors' and 'IDE' types of solutions
can help solve some of that...

[..]


 I have seen good editors, and bad ones.
[..]
 I have not seen any ONE editor that works for even most
 type of text-based programming documents I and other I know have done.

 I currently use more than 5 different editor,
 depending upon what I am editing and what I want to do.
 But, I use only one most of the time.

Good Point Here

While many of us can 'multitask' to various levels,
few of us have mastered the ability to edit multiple
files on multiple systems concurrently.

{ although I still have my 'doubts' about some of the
emacs users I know.

cf:
http://www.wetware.com/drieux/OldWorld/screeds/LiNox.html

since it is not clear to me that all of those
linux/emac/perl types are limited to the standard
number of fingers and hands }

[..]
 I say find one you like and use it,
 until it becomes second nature to you.

way correct. The problem for most beginners as
they start mastering both a new programming language
as well as multiple editors is that their fingers
tend to 'reflex' what would work well in the other editor

[..]
 I currently use an older version of
 NoteTab as my main editor.  Sometimes the newer a product gets,
 the harder it is to use.
[..]

As some of my friends complain about perl v. emacs,

at least emacs still has an editor built into it

But then again, few folks want to solve

the tower of hanoi problem

in 'vi macroes' - when it is easier to solve in emacs macros

 I read one comment about Crimson Editor - it can fit on a floppy
 I can remember when that was a given - fit on a floppy.

[..]
 I have forgotten more languages than I want to remember.

One of the on going problems in the field, and a core reason
for adopting 'perl' as one of the 'default' group that one
will hold onto - as it will most likely be trundling on into
Perl8,Perl9. Or until we find a cure for software development.

 And I have been told that the older generation could not
 understand this new world of the NET.
[..]

And some of can point to documentation that various 'hot software
houses' were at one time opposed to tcp/ip and that it was
merely a 'passing fad' and/or 'militarist' - since it was
derived from DARPA projects  As opposed to their current
posturing about being 'fully internet hip'.

A part of the problem also remains the 'inter-generational struggle'
that it appears to 'management types' to be cheaper to hire a bunch
of 'kids' fresh out of college, and 'mold them correctly' - than
to hire the more expensive senior programmers - who understand
the simple maxim:

it IS the coder,
not the text editor

 But it is time that he newer programmers look back to the ones
 that have been doing it for most of their lives, ask how to program.
 It is language independent - I should know.  It is just syntax differences
 not the How-To.

BOING

yes and no

That one understands the standard

Header
Payload

approach, will help explain why we wandered first into the
bifurcation of HTTP and HTML - and now the later has extended
along into XHTML - because X is a cool letter to use - and
that this helps provide a way to 'standardize' the model for

TAG -::- VALUE

pairing system as a prelude to 'abstracting' that into XML
as the X coolness adding to the notion of 'mark up language'.

hence why so many of us are awaiting the True

Xperl

with a Real X in perl - rather than simply having the
implicit extensibility of writing modules rather
than the hassle of compiling libraries.

 This argument about which editor is the best is just the tip.

on this we also agree


[..]

 I use and own equipment from a 486 to some of the newest technology,
 nut I an typing this from a computer that I have had since the AMD-266
 days.

I think that many here, if push came to shove, can haul
our our 8-bit architectures.

[..]
 If you keep needing to learn new hardware and software to
 do the same job that you can do with your current equipment,
 why take the time.

Good Challenge!!!

[..]
  Spend you time where it counts.  Not to keep up with the Jones.


Good Maxim!!!


 Timothy Lungstrom
 owner of Kracked Press Production
 [EMAIL PROTECTED]


ciao
drieux

http://www.wetware.com/drieux/pbl/

--

This space left intentionally blank.


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




RE: best tutorial for regex

2002-07-31 Thread McCormick, Rob E

Also, try:  perldoc perlretut 

http://www.perldoc.com/perl5.6.1/pod/perlretut.html

spoken by one who has miles to go w/regex


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




Re: Sort table with dynamic order of fields [Part 1]

2002-07-31 Thread Connie Chan

 Using parallel arrays to store related data is not a good idea imho.

I wanna ask for long... so what is IMHO and RTFM ??


 I would use an (anonymous) array of hashes here:
 
 my $persons = [ { ID = 'Foo', COUNTRY = 'UK', GENDER = 'F' },
 { ID = 'Bar', COUNTRY = 'US', GENDER = 'M' },
 { ID = 'Bla', COUNTRY = 'HK', GENDER = 'M' },
 { ID = 'Bob', COUNTRY = 'HK', GENDER = 'F' }
   ];

Actually, the arrays are picked up from 'files' with their names.
like : open fh,... while... read... push @this_arr, $_ ... close(fh)
So to forms arrays... I think I know how to take care of this.

But is there any quick way to transform HOA to AOH ? I suggest this :

sub HoA2AoH
{ my %hash = @_; my @ret = ();
 my @keys = keys(%hash);

 for my $round (0..$#{$hash{$keys[0]}}) 
## Thanx 2 those folks teach me $#{$...} again ##

 { my %tempHash = ();
   for my $KEY(keys(%hash)) 
  { $tempHash{$KEY} = $hash{$KEY}[$round] }
   push @ret, \%tempHash;
 }
  return @ret
}

Any comment ? Any faster ways ?


Rgds,
Connie


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




RE: Sort table with dynamic order of fields [Part 1]

2002-07-31 Thread Timothy Johnson


IMHO = In My Humble Opinion

RTFM = Read The Freaking Manual

TMAMYEHTU = Too Many Acronyms Make Your Emails Hard To Understand

-Original Message-
From: Connie Chan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 10:28 AM
To: [EMAIL PROTECTED]; Felix Geerinckx
Subject: Re: Sort table with dynamic order of fields [Part 1]


 Using parallel arrays to store related data is not a good idea imho.

I wanna ask for long... so what is IMHO and RTFM ??


 I would use an (anonymous) array of hashes here:
 
 my $persons = [ { ID = 'Foo', COUNTRY = 'UK', GENDER = 'F' },
 { ID = 'Bar', COUNTRY = 'US', GENDER = 'M' },
 { ID = 'Bla', COUNTRY = 'HK', GENDER = 'M' },
 { ID = 'Bob', COUNTRY = 'HK', GENDER = 'F' }
   ];

Actually, the arrays are picked up from 'files' with their names.
like : open fh,... while... read... push @this_arr, $_ ... close(fh)
So to forms arrays... I think I know how to take care of this.

But is there any quick way to transform HOA to AOH ? I suggest this :

sub HoA2AoH
{ my %hash = @_; my @ret = ();
 my @keys = keys(%hash);

 for my $round (0..$#{$hash{$keys[0]}}) 
## Thanx 2 those folks teach me $#{$...} again ##

 { my %tempHash = ();
   for my $KEY(keys(%hash)) 
  { $tempHash{$KEY} = $hash{$KEY}[$round] }
   push @ret, \%tempHash;
 }
  return @ret
}

Any comment ? Any faster ways ?


Rgds,
Connie


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




more regex woes...

2002-07-31 Thread Joe Sprankle

Hi all,
I am brand new to perl, and programming at that. I'm learning alot from
Robert's Perl Tutorial and I was hoping someone culd possibly clear up the
following from the tutorial:

$_='My email address is [EMAIL PROTECTED].';
print Match 1 worked :$1: if /(*)/i;

$_='My email address is [EMAIL PROTECTED].';
print Match 2 worked :$1: if /(*)/i;

$_='My email address is [EMAIL PROTECTED].';
print Match 3 worked :$1: if /(*)/i;

Match 1 is true. It doesn't return anything, but it is true
because there are 0  at the very
start of the string.
Match 2 works. After the 0  at the start of the string, there is 1  so the
regex can match that too.
Match 3 works. After the failing on the first  , it jumps to the second.
After that, there are plenty more to match right up until the required
ending.
I've been doing fine so far but I just can't seem to completly grasp this
part.

thanx, joe




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




RE: more regex woes...

2002-07-31 Thread Mark Anderson

Looks to me like you understand it better than I did.  I don't understand
your question.

/\/\ark

-Original Message-
From: Joe Sprankle [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 10:44 AM
To: [EMAIL PROTECTED]
Subject: more regex woes...


Hi all,
I am brand new to perl, and programming at that. I'm learning alot from
Robert's Perl Tutorial and I was hoping someone culd possibly clear up the
following from the tutorial:

$_='My email address is [EMAIL PROTECTED].';
print Match 1 worked :$1: if /(*)/i;

$_='My email address is [EMAIL PROTECTED].';
print Match 2 worked :$1: if /(*)/i;

$_='My email address is [EMAIL PROTECTED].';
print Match 3 worked :$1: if /(*)/i;

Match 1 is true. It doesn't return anything, but it is true
because there are 0  at the very
start of the string.
Match 2 works. After the 0  at the start of the string, there is 1  so the
regex can match that too.
Match 3 works. After the failing on the first  , it jumps to the second.
After that, there are plenty more to match right up until the required
ending.
I've been doing fine so far but I just can't seem to completly grasp this
part.

thanx, joe




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




hash guts

2002-07-31 Thread nkuipers

Hello everyone,

I want to count hash keys.  I originally tried

my $count = scalar %hash;

which when printed gave the string 411/1024.  I looked this up in 
perldoc perldata and sort of understand the significance of this result in 
terms of buckets.

So I tried this in a driver where I varied the size of the test hash:

my $count = scalar (keys %hash);
print $count\n;

and it seemed to work.  I just want to make sure that this is in fact a true 
result that applies to hashes of any size, and not some crazy perl-guts 
coincidence.

I skimmed the llama, camel, and cookbook, but I guess what I am wanting to do 
is so basic it doesn't need [readily apparent] mention.

thanks,

nathanael


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




writing/reading records with Data::Dumper

2002-07-31 Thread todd shifflett

I am having trouble re-reading a record after I write it.

This is my situation (I'll try and be as concise as possible):


I have an object ($profile) with methods, variables, and variables of 
other objects.
For example:
  $profile = MY_PROFILE-new();
  $profile-{NAME} = theName;
  $profile-{ARRAY} = [MY_OBJECT-new(), MY_OBJECT-new(), ...];
  $profile-myFunction();   # calls a method of MY_PRIOFILE


I then use Data::Dumper to write out a file with a header and an array 
of profiles:
  $Data::Dumper::Purity = 1;
  $Data::Dumper::Indent = 0;
  my $header = {DATE = ${year}\.${month}\.${day}};
  open RECORD, $fileName;
  print RECORD Data::Dumper-Dump([$header], [*header]);
  close RECORD;
  foreach my $profile (@profileArray) {
 $profile-myFunction();
 open RECORD, $fileName;
 print RECORD Data::Dumper-Dump([\$profile], ['*profile']);
 close RECORD;
  }

when I read the file I can regenerate the header:

 open RECORDFILE, , $inFile;
 my @elements = split(;,RECORDFILE);
 close RECORDFILE;
 my $element = shift(@elements);
 eval $element;
 $header = \%header;

however I cannot recreate the MY_PROFILE object with:

  foreach $element (@elements) {
   my $profile = MY_PROFILE-new();
 eval $element;
 push(@profileArray,$profile);
  }

is there anyone that can help?  Am I being at all clear?


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




Re: hash guts

2002-07-31 Thread Paul Johnson

On Wed, Jul 31, 2002 at 11:50:47AM -0700, nkuipers wrote:

 Hello everyone,
 
 I want to count hash keys.  I originally tried
 
 my $count = scalar %hash;
 
 which when printed gave the string 411/1024.  I looked this up in 
 perldoc perldata and sort of understand the significance of this result in 
 terms of buckets.
 
 So I tried this in a driver where I varied the size of the test hash:
 
 my $count = scalar (keys %hash);
 print $count\n;
 
 and it seemed to work.  I just want to make sure that this is in fact a true 
 result that applies to hashes of any size, and not some crazy perl-guts 
 coincidence.

Yes, this is guaranteed to work.  You don't even need to explicitly
mention scalar.

 I skimmed the llama, camel, and cookbook, but I guess what I am wanting to do 
 is so basic it doesn't need [readily apparent] mention.

perldoc -f keys

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




Re: regex capturing

2002-07-31 Thread Janek Schleicher

Nikola Janceski wrote at Wed, 31 Jul 2002 17:27:22 +0200:

 $\ = \n;
 $date = 20020731;
 print join /, ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; # this works
 print join /, ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # this doesn't
 
 __END__
 
 why did the second pattern not capture the second occurance of \d{2} ?
 Is this the correct action? or should it capture the second one in the
 second example?

The second pattern matches only these 12 days in a year:

Jan 01
Feb 02
Mar 03
Apr 04
May 05
Jun 06
Jul 07
Aug 08
Sep 09
Oct 10
Nov 11
Dec 12


Cheerio,
Janek


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




Re: store message in a variable and use sendmail

2002-07-31 Thread Janek Schleicher

Loan Tran wrote at Wed, 31 Jul 2002 16:59:50 +0200:

 
 I store a messages(4 pages in text) in a variabe and
 use sendmail to send it. The mail messages get chopped
 of but I'm not sure why.
 Can you suggest a better way to send a content of a
 text file using sendmail. Thanks in advance.
 
 Below is part of my script:
  
 ...

 sub sendownermail{
 my $to= $_[0];
 my $mail_message = $_[1];
 open(SENDMAIL, |/usr/lib/sendmail -oi -t) or die
 Cannot fork for send mail: $! \n;
 print SENDMAILEOF;
^
A miss a blank.
print SENDMAIL EOF;

 From: [EMAIL PROTECTED]
   ^
It's not protected.

 To: $to\@test.com ; ltran\@test.com

The standard way would be
To: $to\@test.com, ltran\@test.com

 Subject: Testing 
 
 

That should not be a reason to fail,
but why two empty lines ?
One is enough :-)

 $mail_message 
 EOF
 close(SENDMAIL) or warn sendmail dinnot close
 nicely;
 }# end sendownermail


Best Wishes,
Janek


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




RE: Sort table with dynamic order of fields [Part 1]

2002-07-31 Thread Felix Geerinckx

on Wed, 31 Jul 2002 17:47:09 GMT, Timothy Johnson wrote:

 IMHO = In My Humble Opinion
 
 RTFM = Read The Freaking Manual
 
 TMAMYEHTU = Too Many Acronyms Make Your Emails Hard To Understand

Strange, I didn't find that last one at

http://www.apc.net/ia/scrmaim.htm

-- 
felix

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




Re: Perl Array Question

2002-07-31 Thread Robin Norwood

First, something more specific than 'this isn't working at all', will
help in diagnosing the problem...but here are some comments which may
help:


Theuerkorn Johannes [EMAIL PROTECTED] writes:

 Hi there, i have (a probably simple) Question on Arrays:
 
 I want to get some Data out of my SQL Databas. I try using the same Query not only 
once and put the collected data in diffrent Arrays.
 
 
 for (my $i=0;$i= $count_SNR_LOG_data;$i++){
   print $i\n;
   my $sth_RACT_LOG = $dbh-prepare (select KEY_SNR,DRAWING_RE,RCODE_ID from 
RACT_LOG where KEY_SNR='$KEY_SNR_SNR_LOG[$i]';);

First, the $dbh-prepare statement should go before the 'for', like
so:

'
my $sth_RACT_LOG = $dbh-prepare('select KEY_SNR, DRAWING_RE, RCODE_ID
from RACT_LOG where KEY_SNR = ?');

for (my $i = 0; $i = $count_SNR_LOG_data; $i++) {
  print $i\n;
'

I've also used a placeholder value (the '?') - this takes care of
quoting, and, with a good database module, will speed the queries
significantly.  Search `perldoc DBI` for info.

Also, if you are looping through all of the elements in the
'@KEY_SNR_SNR_LOG' array, and assuming they are unique, it would be
better to use foreach:

'
foreach my $elem (@KEY_SNR_SNR_LOG) {
'

This way '$elem' gets the value of each element in the array.

#--back to your code - 

   $sth_RACT_LOG-execute ||
die Kann Abfrage sth_RACT_LOG nicht ausfuehren: $DBI::errstr\n;

call execute with the value to replace the ? with - if you are using a
foreach loop as above, that would be '$elem', if you stick with the
for loop, it would be:

'
$sth_RACT_LOG-execute($KEY_SNR_SNR_LOG[$i]) || die something
german-sounding;
'
 
   while (my @RACT_LOG_data=$sth_RACT_LOG-fetchrow_array){
   
   $count_RACT_LOG_data++;
   push our @KEY_SNR_RACT_LOG[$i], $RACT_LOG_data[0];
   push our @DRAWING_RE_RACT_LOG[$i], $RACT_LOG_data[1];
   push our @RCODE_ID_RACT_LOG[$i], $RACT_LOG_data[2];
 }

There are a few problems with this:  

First, I would give each value it's own variable - an array just
confusing things here:

'
while (my ($key_snr, $drawing_re, $rcode_id) = $sth-fethrow_array) {
'

Second, I don't see why 'our' is necessary - and if it is, I think the
proper usage would be to call 'our @KEY_SNR_RACT_LOG' (etc) before the
while loop.  I've never really had a use for 'our', so perhaps someone
else could shed more light on the situation.

Third, assuming you were to switch to a 'foreach' (and still assuming
all the element in '@KEY_SNR_SNR_LOG' are unique), use hashes:

'
my %key_log;  
my %drawing_log;
my %rcode_log; #somewhere above these loops

# ...

push @{$key_log{$elem}}, $key_snr;
push @{$drawing_log{$elem}}, $drawing_re;
push @{$rcode_log{$elem}}, $rcode_id;
'

This says, basically: 'The value of the %key_log hash for key '$elem'
is an array reference.  Push '$key_snr' onto the end of that
array.'

Later, you would call the elements of the arrays like so: 'print
$key_log{$elem}-[0]', or the whole array like 'my @foo =
@{$key_log{$elem}}'.

If you feel you must use arrays, what you probably mean to do is this:
'
push @{$KEY_SNR_RACT_LOG[$i]}, $RACT_LOG_data[0];
'

Which says 'The value of element $i of array '@KEY_SNR_SNR_LOG' is an
array reference, push $RACT_LOG_data[0] onto the end of that array.

What you have up there is a slice.  Read the Camel book for more
information about them.  For now, just use one of the methods I
suggest above.

Fourth, the variable '$count_RACT_LOG_data' is almost certainly
useless for you, and definately useless for what you use it for
below.  You are counting the total number of times the query returned
data - over all of the '$sth-executes'.

 Thats how I try to get data out of my Arrays...
 
 for (my $i=0;$i=$count_SNR_LOG_DATA,$i++){
   for (my $u=0;$u=$count_RACT_LOG_data;$u++){
   print $KEY_SNR_RACT_LOG[$i][$u]\n;
   print $DRAWING_RE_RACT_LOG[$i][$u]\n;
   print $RCODE_ID_RACT_LOG[$i][$u]\n;
   }
 }

As I said above, part of the problem is that '$count_RACT_LOG_data'
contains the total number of times $sth-fetchrow returned
data...which goes way out of bounds for each individual array.

Re-written with hashes, as recommended in #3 above:

'
foreach my $elem (@KEY_SNR_SNR_LOG) {

  for (my $u = 0; $u  @{$key_log{$elem}}; $u++) {
print $key_log{$elem}-[$u] . \n;
print $drawing_log{$elem}-[$u] . \n;
print $rcode_log{$elem}-[$u] . \n;
  }
}
'

I've done some not-so-nice things here, and would probably rewrite the
output part entirely, depending on how I needed to access the data,
but this way is pretty much identical to your way, with hashes.  The
key for this part is not to use '$count_RACT_log' - use either the
number of elements in the aray '$u  @KEY_SNR_RACT_LOG', or the index
of the last element in the array '$u = $#KEY_SNR_RACT_LOG' in the
inner for loop.  The second method is much more correct, actually.

There are better ways to do 

RE: more regex woes...

2002-07-31 Thread Bob Showalter

 -Original Message-
 From: Joe Sprankle [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 1:44 PM
 To: [EMAIL PROTECTED]
 Subject: more regex woes...
 
 
 Hi all,
 I am brand new to perl, and programming at that. I'm learning 
 alot from
 Robert's Perl Tutorial and I was hoping someone culd possibly 
 clear up the
 following from the tutorial:

What is Robert's Perl Tutorial?

 
 $_='My email address is [EMAIL PROTECTED].';
 print Match 1 worked :$1: if /(*)/i;
 
 $_='My email address is [EMAIL PROTECTED].';
 print Match 2 worked :$1: if /(*)/i;
 
 $_='My email address is [EMAIL PROTECTED].';
 print Match 3 worked :$1: if /(*)/i;
 
 Match 1 is true. It doesn't return anything, but it is true
 because there are 0  at the very
 start of the string.
 Match 2 works. After the 0  at the start of the string, 
 there is 1  so the
 regex can match that too.
 Match 3 works. After the failing on the first  , it jumps to 
 the second.
 After that, there are plenty more to match right up until the required
 ending.
 I've been doing fine so far but I just can't seem to 
 completly grasp this
 part.

What don't you understand? Why they capture what they do?
They all capture the leftmost, longest substring matching the
pattern.

An regex like /*/ will *always* match at the beginning of the
string, since '*' means zero or more of the preceding item.
So this regex will only capture 's if they appear at the beginning
of the string. Perhaps that's what Robert is trying to illustrate.

The regex /*/ won't necessarily match at the beginning, because
the zero or more 's must be followed by one  char.

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




RE: regex capturing

2002-07-31 Thread Bob Showalter

 -Original Message-
 From: Janek Schleicher [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 31, 2002 2:14 PM
 To: [EMAIL PROTECTED]
 Subject: Re: regex capturing
 
 
 Nikola Janceski wrote at Wed, 31 Jul 2002 17:27:22 +0200:
 
  $\ = \n;
  $date = 20020731;
  print join /, ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; 
 # this works
  print join /, ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # 
 this doesn't
  
  __END__
  
  why did the second pattern not capture the second occurance 
 of \d{2} ?
  Is this the correct action? or should it capture the second 
 one in the
  second example?
 
 The second pattern matches only these 12 days in a year:
 
 Jan 01
 Feb 02
 Mar 03
 Apr 04
 May 05
 Jun 06
 Jul 07
 Aug 08
 Sep 09
 Oct 10
 Nov 11
 Dec 12

Huh?

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




Re: ?Perl Editors - Re: Editor

2002-07-31 Thread Jenda Krynicky

  I read one comment about Crimson Editor - it can fit on a floppy I
  can remember when that was a given - fit on a floppy.

SciTE can too (unpacked!) : http://www.scintilla.org/SciTE.html
Though if you wanted macros you'd have to install FilerX : 
http://llt.chez.tiscali.fr/
which is another floppy. But packed they'd both fit on one ;-)

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]




regex error: runaway multi-line !! string starting on line...

2002-07-31 Thread McCormick, Rob E

I appreciate the suggestions from Mike, Michael and John around my log
parsing questions.

When attempting to match 'or' conditions using the the m!! and x pattern
match operators, would this construct be correct?

In other words, does this m// attempt :

# match lines begining with #, or lines that contain 'CommmunityID=399', or
lines that contain these paths

 if (
m/^#|CommunityID\=399|\/developersupport\/testfiles|\/remotegadgets\/marks\/
gadget/ ) {
  print NEWLOG;

equate to this m!!x attempt:

21  while ( my $line =  LOG ) {
22  while ( m!
23  ^#   # match lines that start with
'#'
24  CommunityID=399  # or lines that
contain
25  /developersupport/testfiles
26  /remotegadgets/marks/gadget/
27  !x)  
28  print NEWLOG;
29  }

When running with strict and use diagnostics, I get this error.

syntax error at line 28, near )  
print
  (Might be a runaway multi-line !! string starting on line 22)
Execution aborted due to compilation errors (#1)

(F) The final summary message when a Perl compilation fails.

Uncaught exception from user code

Rob






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




RE: regex capturing

2002-07-31 Thread Janek Schleicher

Bob Showalter wrote at Wed, 31 Jul 2002 21:34:02 +0200:

  $\ = \n;
  $date = 20020731;
  print join /, ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; 
 # this works
  print join /, ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # 
 this doesn't
  
 The second pattern matches only these 12 days in a year:
 .
 
 Huh?

Oops, forget what I wrote.
I just read too quick and so I read it as something
like (\d{4})(\d{2})\1


Bye,
Janek

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




qr/$stuff/

2002-07-31 Thread Nikola Janceski

I want to make sure that I am using this correctly for efficiency.

I want to use $stuff as a regex but I want to store it in a data structure.
so when I do use it in a regex will it be more efficient than just saying
/$stuff/?

I cannot use the /o option because $stuff changes with each OUTER iteration.

ex:

foreach my $stuff (@stuffs){

$INFO{key1}{regex} = qr/$stuff/;

## do stuff using $INFO{key1}{regex} several times as so:
foreach my $test (@tests){ ## yeah I know I could store @tests as qr
regexs but this is an example
print somthing if $test =~ $INFO{key1}{regex};
}

}


thx for feedback

Nikola Janceski

Not until we dare to regard ourselves as a nation, not until we respect
ourselves, can we gain the esteem of others, or rather only then will it
come of its own accord.
-- Albert Einstein (1879-1955) 




The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Re: more regex woes...

2002-07-31 Thread John W. Krahn

Joe Sprankle wrote:
 
 Hi all,

Hello,

 I am brand new to perl, and programming at that. I'm learning alot from
 Robert's Perl Tutorial and I was hoping someone culd possibly clear up the
 following from the tutorial:
 
 $_='My email address is [EMAIL PROTECTED].';
 print Match 1 worked :$1: if /(*)/i;

This regular expression matches zero or more consecutive '' characters
case-insensitively and stores the match in the $1 variable.  Since the
'' character doesn't have an upper or lower case version the /i option
is not doing anything useful.  Since zero '' characters will always
match, the regular expression is always true and the statement will
always print.


 $_='My email address is [EMAIL PROTECTED].';
 print Match 2 worked :$1: if /(*)/i;

Same as above.


 $_='My email address is [EMAIL PROTECTED].';
 print Match 3 worked :$1: if /(*)/i;

This regular expression matches zero or more consecutive '' characters
followed by one '' character case-insensitively and stores the match in
the $1 variable.  Since neither the '' or '' character have an upper
or lower case version the /i option is not doing anything useful.  Since
'' must match for the regular expression to be true and the '*' is
greedy this will match the longest string of '' followed by a '' at
the end of your string.



John
-- 
use Perl;
program
fulfillment

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




RE: more regex woes...

2002-07-31 Thread Joe Sprankle

What is Robert's Perl Tutorial?
A good perl tutorial that I heard of on this list after lurking for awhile.
I believe the link is http://www.sthomas.net/roberts-perl-tutorial.htm


What don't you understand? Why they capture what they do?
They all capture the leftmost, longest substring matching the
pattern.

An regex like /*/ will *always* match at the beginning of the
string, since '*' means zero or more of the preceding item.
So this regex will only capture 's if they appear at the beginning
of the string. Perhaps that's what Robert is trying to illustrate.

The regex /*/ won't necessarily match at the beginning, because
the zero or more 's must be followed by one  char.

I got it now, thanks for the reply.
joe



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




Re: writing/reading records with Data::Dumper

2002-07-31 Thread todd shifflett

For those who are interested...

This seems to work but I don't know why:
foreach $element (@elements) {
   my $profile = MY_PROFILE-new();
 $profile = eval(eval(Dumper($element)));
 push(@profileArray,$profile);
  }



On Wednesday, July 31, 2002, at 11:51 AM, todd shifflett wrote:

 I am having trouble re-reading a record after I write it.

 This is my situation (I'll try and be as concise as possible):


 I have an object ($profile) with methods, variables, and variables of 
 other objects.
 For example:
  $profile = MY_PROFILE-new();
  $profile-{NAME} = theName;
  $profile-{ARRAY} = [MY_OBJECT-new(), MY_OBJECT-new(), ...];
  $profile-myFunction();   # calls a method of MY_PRIOFILE


 I then use Data::Dumper to write out a file with a header and an array 
 of profiles:
  $Data::Dumper::Purity = 1;
  $Data::Dumper::Indent = 0;
  my $header = {DATE = ${year}\.${month}\.${day}};
  open RECORD, $fileName;
  print RECORD Data::Dumper-Dump([$header], [*header]);
  close RECORD;
  foreach my $profile (@profileArray) {
 $profile-myFunction();
 open RECORD, $fileName;
 print RECORD Data::Dumper-Dump([\$profile], ['*profile']);
 close RECORD;
  }

 when I read the file I can regenerate the header:

 open RECORDFILE, , $inFile;
 my @elements = split(;,RECORDFILE);
 close RECORDFILE;
 my $element = shift(@elements);
 eval $element;
 $header = \%header;

 however I cannot recreate the MY_PROFILE object with:

  foreach $element (@elements) {
  my $profile = MY_PROFILE-new();
 eval $element;
 push(@profileArray,$profile);
  }

 is there anyone that can help?  Am I being at all clear?


 -- 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: regex error: runaway multi-line !! string starting on line...

2002-07-31 Thread nkuipers

equate to this m!!x attempt:

21  while ( my $line =  LOG ) {
22  while ( m!
23  ^#   # match lines that start with
'#'
24  CommunityID=399  # or lines that
contain
25  /developersupport/testfiles
26  /remotegadgets/marks/gadget/
27  !x)
28  print NEWLOG;
29  }


you have a nested while loop without its own set of {} for starters.


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




how to use socketpair to run another program

2002-07-31 Thread Ken

I've looked at Programming Perl and the Perl Cookbook, but I'm just too dense 
to figure out how to do this.
I have an external program (not in perl, and not written by me). I want to 
send a string to it, have it do it's thing, then return the output to my perl 
program. Then, depending on the results, I might need to run the external 
program again with a different string.
I'm close with the following:
open BL, |-, bl -d /usr/local/share/bl  #open program with parameters
or die cant open bl fork: $!;
local $SIG{PIPE} = sub { die bl pipe broke}; 
print BL stuff\n\n;   #send this to the program bl
close BL or die bad close $!;

This sends the output to the screen, STDOUT. So I think my next step is to 
use a socketpair so I can gather the ouput and use it.
But I can't figure out how to set this up. 

Using the example in the Perl Cookbook (p. 575), here's the line that stumps 
me.
socketpair (CHILD, PARENT, AF_UNIX, SOCK_STREAM, PF_UNSPEC)

this is what I tried, along with other variations (no laughing please)
socketpair (CHILD |- bl -d /usr/local/share/bl, PARENT, AF_UNIX, 
SOCK_STREAM, PF_UNSPEC)

Any help is appreciated
Ken

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




Re: qr/$stuff/

2002-07-31 Thread Jenda Krynicky

From: Nikola Janceski [EMAIL PROTECTED]

 I want to make sure that I am using this correctly for efficiency.
 
 I want to use $stuff as a regex but I want to store it in a data
 structure. so when I do use it in a regex will it be more efficient
 than just saying /$stuff/?

Yes. You do use it correctly.

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: Syntax Culture

2002-07-31 Thread Wiggins d'Anconia

Sorry this is so delayed, but I have to exploit the chance to be anal 
:-)...

In two of the responses the language of creating a value was used, 
which is also dangerous in a *philosophical* way (I use the term 
extremely lightly), in such that an expression could also *create* NO 
value (aka undef, or NULL) in which case it is an expression that is 
creating (for lack of a better english word) a response (though I am 
sure this isn't precise enough either), even though that response has no 
value, is undefined or NULL.

Though I will give kudos for the one example given earlier:  Also, a 
regular expression is an expression that fits a range of definitions, 
but still in it's own polymorphic way is a 'value' and can be tested 
against other values to see if it is the 'same as' or not.

And possibly this is why we call it a new language, or its *own* 
language, rather than pseudo-enlish-code or something, right drieux?? ;-)

http://danconia.org




Cody Art Supply LLC wrote:
 Hi,
 
 I'm pretty new to perl, but I think this may help:
 
 I believe a good 'rule of thumb' test can be can that 'whole area that I think may 
be an expression' be used as having some type of value?
 
 The reason '$x = $y + 2' is an expression is because you can legally (although 
almost never done on purpose) use that as a value, say in 'if ($x = $y + 2) {}'.  The 
resulting value that is returned by that expression is the value of $x.  (Most of the 
time when you see that in an 'if' statement, the coder meant to use the '==' 
comparison instead of the '=' assignment.)
 
 In your question you asked 'for (my $x = 0; $x = 100; $x++){}' being an expression.
 
 It contains three expressions, 'my $x = 0', '$x = 100', and '$x++' but the whole 
block isn't one itself.  Only the middle one is used as an expression by the 
interpreter, because it's value is observed at the beginning of every iteration in 
the loop to see if it is equal to 'true'.  The first expression is only used to 
initialize the start of the loop, and the last expression is used to create a change, 
to ensure the loop's condition will vary and eventually test false and exit.
 Because of that, although they pass the 'expressions' test, you'd probably call them 
'assignment operations' because that is their primary use, which better describes 
their use within that context.  Still, in that case they are both assignments and 
expressions.
 
 As for 'for (0..100){}', it is a shortcut loop that hides the expressions by 
declaring them implicitly... I think.  It's not an expression itself.
 
 Also, a regular expression is an expression that fits a range of definitions, but 
still in it's own polymorphic way is a 'value' and can be tested against other values 
to see if it is the 'same as' or not.  Unlike most expressions, regular expressions 
can't be reduced to an actual 'literal' value, in the way (5+4) is reduced to a 
literal 9.
 
 Often, if you are confused if something is an expression or not, you may be looking 
at a block of code that contains expressions inside of it, but is not one itself.  
 
 Hope this helps!
 
 -Original Message-
 From: Connie Chan [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, July 27, 2002 7:15 AM
 To: Jenda Krynicky; begin begin
 Subject: Re: Syntax Culture
 
 
 
 
These are all expressions:
1
1 + 2
$x * 2
foo(1,2,3) + 49
(1,2) x 2
$x == $y
$x  5
$x  1  $x  5
but even this is an expression:
$x = $y + 2

Basicaly expression is something that creates a value that you can 
assign to a variable, pass to a function or use as a condition.

This means that
$x = $y + 2
IS an expression, but 
$x = $y + 2;
IS NOT! It's a statement.

 
 
 With this, I'll have a question again =)
 how about : for (my $x = 0; $x = 100; $x++){} ?
 In every loop, $x return the value to the middle, 
 and the middle design to roll another loop or not.
 It is doing something similar to if then else, but
 it also returning vals and condition signals... 
 So what is this ? And when I write as 
 for (0..100){} there is quite no difference, still 
 an invisible $x, as $_... so...sorry, dunno how to ask.. =)
 
 Rgds,
 Connie
 
 
 
 



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




Need to extract just the mac id

2002-07-31 Thread Tucker, Ernie

I have a file with the following data in it. What I am trying to do is just
grab the mac id. Is there a good way to do this in perl. I tried to grep on
just 00 but that gave me more info than what I need. Thanks for any help.


0008.0e39.ad80
Account: 10391-x
Name:glusick, dave
Status:  scheduled
Install Date:2002-06-03
Address: 850 xx, 
 sun prarie, wi 53590
Phone:   (608) xxx-
Headend: athome
Node:
==
0004.bdca.04a0
Account: 10391-x
Name:NUNN, ROBBIE
Status:  scheduled
Install Date:2002-06-03
Address: 1106 N x, 
 SUN PRAIRIE, WI 53590
Phone:   (608) xxx-
Headend: athome
Node:


Ernest P. Tucker II
 Network Technician
 Madison Management Area
 Charter Communications



 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 all
computers. 





RE: Need to extract just the mac id

2002-07-31 Thread Timothy Johnson

 

How about something like this?

$_ =~ /([0-9A-F]{4}\.[0-9A-F]{4}\.[0-9A-F]{4}\.[0-9A-F]{4})/i
$mac = $1;

#matches four sets of 4 characters between 0 and 9 or A and F separated by
periods

-Original Message-
From: Tucker, Ernie
To: [EMAIL PROTECTED]
Sent: 7/31/02 9:26 PM
Subject: Need to extract just the mac id

I have a file with the following data in it. What I am trying to do is
just
grab the mac id. Is there a good way to do this in perl. I tried to grep
on
just 00 but that gave me more info than what I need. Thanks for any
help.


0008.0e39.ad80
Account: 10391-x
Name:glusick, dave
Status:  scheduled
Install Date:2002-06-03
Address: 850 xx, 
 sun prarie, wi 53590
Phone:   (608) xxx-
Headend: athome
Node:
==
0004.bdca.04a0
Account: 10391-x
Name:NUNN, ROBBIE
Status:  scheduled
Install Date:2002-06-03
Address: 1106 N x, 
 SUN PRAIRIE, WI 53590
Phone:   (608) xxx-
Headend: athome
Node:


Ernest P. Tucker II
 Network Technician
 Madison Management Area
 Charter Communications



 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
all
computers. 



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