Installing and Using Perl Modules

2004-03-25 Thread urvashi mishra

Hi,

 

I am looking forward to learn how to use Perl Modules... Can some one tell me..

1) How to Install CPAm modules?

and

2) how to use them?

 

Waiting for a quick reply

 



-
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.

Learning how to map a drive in Perl

2004-03-25 Thread neill . taylor
I am looking at how I could connect to share and map a local drive in a
perl script. I have cut and pasted the code from the man page from Lanman
to understand what is happening.

When I run the code below I get the following error

Undefined subroutine &main::USE_IPC called at map.pl line 5.

Am I missing something ?

Cheers

Neill


#!/usr/bin/perl
use strict;
use warnings;
# use win32::Lanman;
if(!Win32::Lanman::NetUseAdd({remote => "server\\ipc\$",
  password => "pass",
  username => "user",
  domain => "NT",
  asg_type => &USE_IPC}))
{
 print "Sorry, something went wrong; error: ";
# get the error code
print Win32::Lanman::GetLastError();
exit 1;
}

 #connects drive h: to \\testserver\testshare.

 if(!Win32::Lanman::NetUseAdd({remote => "testserver\\testshare",
  local => "h:",
  asg_type => &USE_DISKDEV}))
 {
print "Sorry, something went wrong; error: ";
# get the error code
print Win32::Lanman::GetLastError();
exit 1;
 }



Undefined subroutine &main::USE_IPC called at map.pl line 5.








IMPORTANT NOTICE  This email (including any attachments) is meant only for the 
intended recipient. It may also contain confidential and privileged information.  If 
you are not the intended recipient, any reliance on, use, disclosure, distribution or 
copying of this email or attachments is strictly prohibited. Please notify the sender 
immediately by email if you have received this message by mistake and delete the email 
and all attachments. 

Any views or opinions in this email are solely those of the author and do not 
necessarily represent those of Trinity Mirror PLC or its associated group companies 
(hereinafter referred to as "TM Group"). TM Group accept no liability for the content 
of this email, or for the consequences of any actions taken on the basis of the 
information provided, unless that information is subsequently confirmed in writing. 
Although every reasonable effort is made to keep its network free from viruses, TM 
Group accept no liability for any virus transmitted by this email or any attachments 
and the recipient should use up-to-date virus checking software. Email to or from this 
address may be subject to interception or monitoring for operational reasons or for 
lawful business practices. 

Trinity Mirror PLC is the parent  company of the Trinity Mirror group of companies and 
is registered in England No 82548, with its address at One Canada Square, Canary 
Wharf, London E14 5AP. 


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




Question about cgi forms (slightly OT)

2004-03-25 Thread mike
I am developing a cgi/DBI app which is nearly finished

I have this one question

The scenario

I have a cgi generated form on a web-page, it consists of several
records defined by a DB lookup.

When I do Search in the web-browser, is there any way to get it to
search the values in the fileds of the form?

Currently all the values show up, but they dont seem to appear to be in
scope for searching

thanks for any tips (and apologies for vaguely OT)

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




Re: Confused

2004-03-25 Thread mike
On Wed, 2004-03-24 at 14:19, James Edward Gray II wrote:
> On Mar 24, 2004, at 7:59 AM, WC -Sx- Jones wrote:
> 
> > while() {
> > chomp; s/^\s+//; s/\s+$//; next unless length;
> 
> There's probably not much reason to chomp() and s/\s+$//, since the 
> later handles both.
> 
> James
> 

Thanks for all assistance

This worked 
s/\s+$/;

One question will this only take out blank lines?
eg: if I have this line
anytext tabe space newline
will the non-printing characters be removed and the text be added to the
beginning of the next line?

thanks

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




Re: Learning how to map a drive in Perl

2004-03-25 Thread Randy W. Sims
[EMAIL PROTECTED] wrote:
I am looking at how I could connect to share and map a local drive in a
perl script. I have cut and pasted the code from the man page from Lanman
to understand what is happening.
When I run the code below I get the following error

Undefined subroutine &main::USE_IPC called at map.pl line 5.

Am I missing something ?

Cheers

Neill

#!/usr/bin/perl
use strict;
use warnings;
# use win32::Lanman;
if(!Win32::Lanman::NetUseAdd({remote => "server\\ipc\$",
  password => "pass",
  username => "user",
  domain => "NT",
  asg_type => &USE_IPC}))

The problem is perl interprets the above marked code as: assign the 
value returned from a call to the subroutine USE_IPC() to the key 
asg_type. I'm not familiar with the Lanman module, but I'm guessing that 
is supposed to be a constant. You probably need to either fully qualify 
the constant (eg Win32::Lanman::USE_IPC) or import the constant into the 
current namespace (eg use Win32::Lanman (USE_IPC)).


{
 print "Sorry, something went wrong; error: ";
# get the error code
print Win32::Lanman::GetLastError();
exit 1;
}
 #connects drive h: to \\testserver\testshare.

 if(!Win32::Lanman::NetUseAdd({remote => "testserver\\testshare",
  local => "h:",
  asg_type => &USE_DISKDEV}))
 {
print "Sorry, something went wrong; error: ";
# get the error code
print Win32::Lanman::GetLastError();
exit 1;
 }


Undefined subroutine &main::USE_IPC called at map.pl line 5.


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



Re: Installing and Using Perl Modules

2004-03-25 Thread Randy W. Sims
urvashi mishra wrote:
Hi,

 

I am looking forward to learn how to use Perl Modules... Can some one tell me..

1) How to Install CPAm modules?

and

2) how to use them?

 

Waiting for a quick reply
What OS are you using? If it's a Windows variant, you will do best using 
ppm to install modules. Otherwise, you can use CPAN.pm (included with 
the perl distribution) or CPANPLUS (you'll have to install from CPAN).

To use ppm just type 'ppm' from a commandline.

To use CPAN.pm, type 'perl -MCPAN -eshell'

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



Re: Installing and Using Perl Modules

2004-03-25 Thread Hacksaw
using cpan:

invoke cpan, either by running 

perl -MCPAN -e shell;

or, if it's set up, just

cpan

You will get a prompt.

If you are trying to find a particular module, but you aren't sure of the 
whole name, you can search for it as so:

cpan>  i /someModuleName/

It will look it up, and spit out all the matches.

If you see what you want, you may install it by running

cpan>  install ModuleName

for instance, to install spamassassin:

cpan> install Mail::SpamAssassin

This will download, make, test, and install the package, including any 
dependencies. That last bit is important. You will be asked if you want to 
install the extra modules. Say yes if you want it to work correctly, unless 
you are doing something tricky. At this point, you shouldn't be doing anything 
tricky, so just say yes.

--

Using a cpan module is just like any other module:

use ModuleName;

Everything that happens will depend on the module.

You should go right now and read:

perldoc cpan
perldoc perlmod

I suggest you also take a look at 

perldoc Getopt

It's an easy to understand module, and useful for command line programs.

-- 
Sharp tools prevent accidents, and foster intent.
http://www.hacksaw.org -- http://www.privatecircus.com -- KB1FVD



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




Re: references

2004-03-25 Thread Joe Mecklin
On Wed, 2004-03-24 at 15:08, Wiggins d Anconia wrote:
> > i know this should be a simple step or two that i'm missing, and i
> > haven't been able to figure it out from reading yet...
> > 
> > i have the following code:
> > 
> > $sth = $mysql_dbh->prepare("select subroutine_pointer from
> > $database.equipment_manufacturer where
> > manufacturer=\"$remedy_eqpt_mfgr\"");
> > $sth->execute();
> > $subroutine_pointer = $sth->fetchrow_array();
> > no strict "refs";
> > &$subroutine_pointer() unless $subroutine_pointer eq "";
> > use strict "refs";
> > 
> > this pulls a phrase from the database that matches a subroutine name
> > that i want to call based on certain other criteria, then displays that
> > sub's output to a web page.  this works fine as is but i want to learn
> > how to restructure this so i don't have to use "no strict" and "use
> > strict" around the call.  all suggestions welcome *s*
> > 
> 
> One way, I won't guarantee the best, would be to store a mapping of
> subroutine references into a hash, where the hash key replaces the
> subroutine name, then you would index into the hash using the value from
> the db to access the reference of the sub to call.
> 
> %subs = ( 'db_value1' => sub { print "Called sub 1"; },
>   'db_value2' => sub { print "Called sub 2"; }, );
> 
> $subs{$subroutine_pointer}->();
> 
> Where $subroutine_pointer is the string 'db_value1', etc.
> 
> http://danconia.org

thanks for the ideas.  i played with them some but couldn't get anything
to work.  right now time is an issue so i'll just leave things as they
are but will come back to these ideas when i have more time.  i
appreciate the quick responses.  thanks again.

joe



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




Re: sort function?

2004-03-25 Thread Flemming Greve Skovengaard
Use this:

__BEGIN__
use strict;
use warnings;
die "No file name supplied.\n" unless @ARGV;
my $oldest_name = shift @ARGV;
my $oldest_age = -C $oldest_name;
foreach (@ARGV) {
my $age = -C;

($oldest_name, $oldest_age) = ($_, $age) if ($age > $oldest_age);
}
printf "The oldest file is '%s', and it is %.1f days old.\n",
$oldest_name, $oldest_age;
__END__
This is a modified version of the solution to exercise 11-3 in Learning Perl
(which I assume you are reading). The unmodified version uses '-M' not '-C'.
Radhika Sambamurti wrote:
Hi,
I have written a small script that is supposed to tell me the oldest file in my 
directory (as per ctime). I have read the various times the various files were 
created, into an array called times. I have then sorted this array - @sorted_times.
when i do ls -l i get the following:
wxrwxr-x  1 radhika  wheel  1028 Mar 24 11:57 chapter11_1.pl
-rwxrwxr-x  1 radhika  wheel   387 Mar 24 12:37 chapter11_2.pl
-rwxrwxr-x  1 radhika  wheel   551 Mar 24 21:25 chapter11_3.pl
-rwxrwxr-x  1 radhika  wheel   281 Mar 15 16:28 file_basename.pl
-rw-rw-r--  1 radhika  wheel   236 Mar 21 11:46 filereader.pl
-rw-rw-r--  1 radhika  wheel   115 Mar 24 12:04 new.txt
-rw-rw-r--  1 radhika  wheel   115 Mar 24 12:00 rad.txt
-rwxrwxr-x  1 radhika  wheel   648 Mar 15 15:40 rm_file_30days.pl
-rwxrwxr-x  1 radhika  wheel   554 Mar 15 16:37 rmoldshares.pl
and when I execute the program I get the following:

radhika$ ./chapter11_3.pl *
Mon Mar 15 15:55:58 2004
Mon Mar 15 16:28:50 2004
Mon Mar 15 16:37:46 2004
Sun Mar 21 11:46:36 2004
Wed Mar 24 11:57:21 2004
Wed Mar 24 12:00:15 2004
Wed Mar 24 12:04:01 2004
Wed Mar 24 12:37:10 2004
Wed Mar 24 21:26:56 2004
my question is - where did the very first line from my output come from? ie Mon Mar 15 
15:55:58.
As you can see, ls -l does not show any file created at that time. Even . and .. are 
not the above time.
Is it using sort(@array), that sorts it in some manner that I do not understand?
Thanks,
Radhika
--
I've pasted the code for the script below.

#! /usr/bin/perl -w
use strict;
use diagnostics;
my $create_time;
my $i=0;
my @times;
my @sorted_times;
my $file;
foreach $file (@ARGV) {
my($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, 
$blksize, $blocks) = stat($file);
$create_time = localtime($ctime);
$times[$i] = $create_time;
$i++;
}
@sorted_times = sort(@times);
my $this_time;
foreach $this_time (@sorted_times) {
my($day, $mon, $dt, $tm, $yr) = split /\s+/,$this_time;
my ($hr, $mn, $sec) = split /:/, $tm;
print "$this_time\n";
}


--
Flemming Greve Skovengaard   Be it the Devil or be it him
a.k.a Greven, TuxPower   You can count on just one thing
<[EMAIL PROTECTED]>  When the time is up, you'll know
4168.08 BogoMIPS Not just one power runs the show
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Question about cgi forms (slightly OT)

2004-03-25 Thread WC -Sx- Jones
mike wrote:

When I do Search in the web-browser, is there any way to get it to
search the values in the fileds of the form?
Currently all the values show up, but they dont seem to appear to be in
scope for searching


Show some code -- likely your logic is wrong -- if using CGI module
then capture all params in a single arrary, or hash, then walk
thru the data.
If you normalize the CGI input to a sane value (IE, make string zero 
numeric 0 and undefined input as empty strings) you can control
the order they are placed into the array then you can use array
index to make sure you are looking at the right array to CGI
input values.

HTH

--
_Sx_ http://youve-reached-the.endoftheinternet.org/ _
perldoc -qa.a | perl -lpe '($_)=m("(.*)")' | grep Martian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Confused

2004-03-25 Thread WC -Sx- Jones
mike wrote:

This worked 
s/\s+$/;

One question will this only take out blank lines?
eg: if I have this line
anytext tabe space newline
will the non-printing characters be removed and the text be added to the
beginning of the next line?
This will only remove whitespace from the END of a line.

If you slurp the file in a one BIG line ... well, you
accomplished very little.  Removing s,\n,,; forces the whole
thing to become one text block.
My while statement in the other post forced line by line processing...

If you are still having trouble processing the file; maybe
this trick will slow it down to a reasonable speed:
http://backpan.cpan.org/authors/id/T/TO/TOMC/scripts/slowcat.gz

:)

--
_Sx_ http://youve-reached-the.endoftheinternet.org/ _
perldoc -qa.a | perl -lpe '($_)=m("(.*)")' | grep Martian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: sort function?

2004-03-25 Thread Bob Showalter
Radhika Sambamurti wrote:
> Hi,
> I have written a small script that is supposed to tell me the oldest
> file in my directory (as per ctime). I have read the various times
> the various files were created, into an array called times. I have
> then sorted this array - @sorted_times. when i do ls -l i get the
> following:   
> 

[snip]

ls is showing you mtime, not ctime. You should be using mtime. ctime is
inode change time, NOT "create" time. Unix does not have a "create" time.

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




sorting multi dimensional array

2004-03-25 Thread N, Guruguhan \(GEAE, Foreign National, EACOE\)
Hi All,
  I have an array that is build like this
foreach $i ( 0 .. @array1) {
foreach $j ( 0 .. @array2) {
$array3[$i][$j] = $array2[$j];
}
} 
The array3 has "m" rows and "n" columns of data.

This code is written by some one else and I am trying to get the statistics for each 
of the column data stored in array3. Before getting the statistics, I wanted to sort 
each column data of the array3 in ascending order. Can some one tell me how do I this? 
 

Thanks
Regards
Guruguhan
EACoE, India.
* - *91-80-5031516
* - *901-1516 ( Dial Com)


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




Re: Question about cgi forms (slightly OT)

2004-03-25 Thread mike
On Thu, 2004-03-25 at 13:18, WC -Sx- Jones wrote:
> mike wrote:
> 
> > When I do Search in the web-browser, is there any way to get it to
> > search the values in the fileds of the form?
> > 
> > Currently all the values show up, but they dont seem to appear to be in
> > scope for searching
> 
> 
> Show some code -- likely your logic is wrong -- if using CGI module
> then capture all params in a single arrary, or hash, then walk
> thru the data.
> 
> If you normalize the CGI input to a sane value (IE, make string zero 
> numeric 0 and undefined input as empty strings) you can control
> the order they are placed into the array then you can use array
> index to make sure you are looking at the right array to CGI
> input values.
> 
> HTH
> 

dont think I was clear enough

this creates the form

print start_multipart_form (POST,'con_role_upd.pl');
print "Choose Id",textfield('id2','0');
print "";
print "";
[EMAIL PROTECTED]();
#print @value;
$row1=$dbh->prepare("SELECT
tb_contact_role.id,contact_id,type_of_contact,description,priority FROM
tb_contact_role LEFT JOIN lk_sort_of_contact ON
type_of_contact=type_code WHERE contact_id ILIKE ?");
my $idsel=$id;
$row1->bind_param(1,$idsel);
$row1->execute();
while(($id1,$contact_id1,$type_id,$type,$priority) =
$row1->fetchrow_array()) {
#print $id1,$contact_id1,$type,$priority;
print font {-style=>'background-color: #F8FC8C;color: blue'};
print "Roles for Contact";
print end_font;
print p;
print font {-style=>'background-color: white;color: blue'};
print "Role
ID",textfield(-name=>'id1'.$id1,-value=>$id1,-style=>'background-color:
#C59E65;color: white');
print "Role
ID",textfield(-name=>'type_id1'.$id1,-value=>$type_id,-style=>'background-color: 
#C59E65;color: white');
print "Type of
Contact",textfield(-name=>'type'.$id1,-value=>$type,-style=>'background-color: 
#C59E65;color: white');
print
"priority",textfield(-name=>'priority'.$id1,-value=>$priority,-style=>'background-color:
 #C59E65;color: white')};
print br;
print br;
print br;
}
print submit;
print end_form;

This results in a html page of forms which is populated, I can tab
through the fields, edit etc, but if I do a control F for instance, the
values in the fields are not found.

What I would like is for users to be able to search for a value and then
go tothat record



> -- 
> _Sx_ http://youve-reached-the.endoftheinternet.org/ _
> perldoc -qa.a | perl -lpe '($_)=m("(.*)")' | grep Martian

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




RE: Question about cgi forms (slightly OT)

2004-03-25 Thread Guay Jean-Sébastien
Hello,

> mike wrote:
> 
> > When I do Search in the web-browser, is there any way to get it to
> > search the values in the fileds of the form?
> > 
> > Currently all the values show up, but they dont seem to 
> appear to be in
> > scope for searching
> 
> 
> Show some code -- likely your logic is wrong -- if using CGI module
> then capture all params in a single arrary, or hash, then walk
> thru the data.
> 
> If you normalize the CGI input to a sane value (IE, make string zero 
> numeric 0 and undefined input as empty strings) you can control
> the order they are placed into the array then you can use array
> index to make sure you are looking at the right array to CGI
> input values.

Actually, I think the OP means that text in form fields in his CGI-generated
web page can't be searched using the _browser's_ find feature (eg. when
pressing Ctrl-F in your browser window and typing some of the text that's in
a form field, it won't be found).

If that's the question, it is indeed totally unrelated to Perl and, indeed,
even to CGI. That is the browser's behaviour. As far as I know, this is true
for all browsers. For text to be searchable by the search function in the
browser, it has to be text on the web page itself, not in form fields.

In the interest of completeness, I will suggest one way of dealing with this
(assuming your user really needs to be able to both search and modify the
text) : Provide the text on the page (say "old value"...) _and_ in a form
field that will allow modification. That way, the text can be searched, and
it has the added benefit that the user will see the old value when modifying
it. Of course, if the text really doesn't need to be modified, then just put
it on the web page, not in a form field, and that will do it.

For more info about the search feature in web browsers, I suggest either the
Mozilla documentation (or the docs for some other browser), or you may want
to find a forum on browser development to ask what the behaviour of the
search feature with form fields really is.

Hope this helps,

J-S

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




Re: Question about cgi forms (slightly OT)

2004-03-25 Thread WC -Sx- Jones
mike wrote:

This results in a html page of forms which is populated, I can tab
through the fields, edit etc, but if I do a control F for instance, the
values in the fields are not found.
What I would like is for users to be able to search for a value and then
go tothat record
I was afraid that was what you meant.  :)

It is totally OT now because what you want is to chamge / control
the client side and you can't -- unless you do what the OP
stated - explode the current/old values out beside the input
fields as plain text.
Otherwise you will need client-side JS and DCOM programming; see

http://www.mozilla.org/projects/xpcom/book/cxc/html/using_components.html#1000194

Some modification of that or maybe something from here:

http://javascript.internet.com/forms/

--
_Sx_ http://youve-reached-the.endoftheinternet.org/ _
perldoc -qa.a | perl -lpe '($_)=m("(.*)")' | grep Martian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: sorting multi dimensional array

2004-03-25 Thread Charles K. Clarkson
N, Guruguhan (GEAE, Foreign National, EACOE) <[EMAIL PROTECTED]>
wrote:
:
: I have an array that is build like this
:
: foreach $i ( 0 .. @array1) {
:   foreach $j ( 0 .. @array2) {
:   $array3[$i][$j] = $array2[$j];
:   }
: } 

Are you sure this code functions correctly? Looks like it
will add an extra column of undefined values and an extra row
each time it runs. It is equivalent to this code and results
in @array3 having one more row than @array1.

my @array3;
push @array3, [ @array2, undef ] foreach 0 .. @array1;

Find the guy who wrote the program and club him a few
times.


: The array3 has "m" rows and "n" columns of data.
: 
: This code is written by some one else and I am trying to get 
: the statistics for each of the column data stored in array3. 
: Before getting the statistics, I wanted to sort each column 
: data of the array3 in ascending order. Can some one tell me 
: how do I this?  


Do you know how to numerically sort one column? There all
the same, except that column on the end which is not numeric.

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


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




Hash Help Needed !

2004-03-25 Thread jason_normandin
Hey List.

I have run into a situation that I am unclear on.

I am making the following assignment during a loop:

push @{$response_hash{$request_id}},{time => "$time",ip_addr => "$ip_address",oids => 
"%response_values"};

Where: response_values is a simple hash containing key,value pairs and $time and 
$ip_address are simple scalar vars.

I can iterate through the %response_values hash after it is created localy using 
simple foreach my $value (keys %response_values ) syntax, but when I try to include 
that iteration when iterating the main response hash, I am not getting any values.

I am using the following syntax:

foreach my $request (sort keys %response_hash) {
print "Response to request_id $request\n";
foreach my $record(@{$response_hash{$request}}) {

print "Time : $record->{time}\n";
print "IP : $record->{ip_addr}\n";
foreach my $response ($record->{keys %response_values} )
{
print "Response to oid : $response = 
$response_values{$response}\n";
}
}

}

The other attributes of the %response_hash are printing fine, just not the contents of 
the %response_values hash.

I have also tried assigning as a referance, but that does not seem to work either:

push @{$response_hash{$request_id}},{time => "$time",ip_addr => "$ip_address",oids => 
"\%response_values"};

I get an error when trying to referance it later during the main hash iteration:

Type of arg 1 to keys must be hash (not reference constructor) at 
H:\nhsParseSnmpLog.pl line 56, near "%response_values}
"

I am pretty confused at this point and would really appreciate any help I could get.

Thanks!!
Jason


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




RE: Hash Help Needed !

2004-03-25 Thread Charles K. Clarkson
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
: 
: I have run into a situation that I am unclear on.
: 
: I am making the following assignment during a loop:
: 
: push @{$response_hash{$request_id}},{time => "$time",ip_addr 
: => "$ip_address",oids => "%response_values"};

I didn't test your code but "%response_values" is not the
same as \%response_values or %response_values. You have just
run into the problem with unnecessarily quoting variables.
(Read perlfaq4.)

You might have wanted (White space is your friend.):

push @{ $response_hash{ $request_id } }, {
time=> $time,
ip_addr => $ip_address,
oids=> \%response_values,
};



: 
: Where: response_values is a simple hash containing key,value 
: pairs and $time and $ip_address are simple scalar vars.
: 
: I can iterate through the %response_values hash after it is 
: created localy using simple foreach my $value (keys 
: %response_values ) syntax, but when I try to include that 
: iteration when iterating the main response hash, I am not 
: getting any values.
: 
: I am using the following syntax:

Add this near the top of your script. It adds a function
named Dumper to your script.

use Data::Dumper 'Dumper';

: 
: foreach my $request (sort keys %response_hash) {
:   print "Response to request_id $request\n";
:   foreach my $record(@{$response_hash{$request}}) {

Test what is in $record with the Dumper function:

print Dumper @record;
exit;

Is the result what you thought was in there?


:   
:   print "Time : $record->{time}\n";
:   print "IP : $record->{ip_addr}\n";
:   foreach my $response ($record->{keys %response_values} )
:   {
:   print "Response to oid : $response = 
: $response_values{$response}\n";
:   }
:   }
:   
: }

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



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




RE: Hash Help Needed !

2004-03-25 Thread Wiggins d Anconia
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

[snip]

> : 
> : print "Time : $record->{time}\n";
> : print "IP : $record->{ip_addr}\n";
> : foreach my $response ($record->{keys %response_values} )

In addition to what Charles already stated, once you have cleared up the
quoting problem and gotten your hash to store properly, then you will
need to access the hash reference of the key in the main hash using
'oids' .  In other words, you need to index into $record using 'oids' to
get the hash reference, then take the keys of that dereferenced hash.

foreach my $response (keys %{ $record->{'oids'} }) {

I suspect you have a scoping issue with %response_values otherwise
strict would have complained, are you declaring your variables when
first used or all at the top?  %response_values should have been a
temporary variable scoped only to your first loop which you didn't show.

http://danconia.org

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




Re: RE: Hash Help Needed !

2004-03-25 Thread jason_normandin
Got it. I missed your note on the whitespace.

Thanks everyone !!

> 
> From: "Charles K. Clarkson" <[EMAIL PROTECTED]>
> Date: 2004/03/25 Thu PM 03:35:08 GMT
> To: <[EMAIL PROTECTED]>,  <[EMAIL PROTECTED]>
> CC: <[EMAIL PROTECTED]>
> Subject: RE: Hash Help Needed !
> 
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> : 
> : I have run into a situation that I am unclear on.
> : 
> : I am making the following assignment during a loop:
> : 
> : push @{$response_hash{$request_id}},{time => "$time",ip_addr 
> : => "$ip_address",oids => "%response_values"};
> 
> I didn't test your code but "%response_values" is not the
> same as \%response_values or %response_values. You have just
> run into the problem with unnecessarily quoting variables.
> (Read perlfaq4.)
> 
> You might have wanted (White space is your friend.):
> 
> push @{ $response_hash{ $request_id } }, {
> time=> $time,
> ip_addr => $ip_address,
> oids=> \%response_values,
> };
> 
> 
> 
> : 
> : Where: response_values is a simple hash containing key,value 
> : pairs and $time and $ip_address are simple scalar vars.
> : 
> : I can iterate through the %response_values hash after it is 
> : created localy using simple foreach my $value (keys 
> : %response_values ) syntax, but when I try to include that 
> : iteration when iterating the main response hash, I am not 
> : getting any values.
> : 
> : I am using the following syntax:
> 
> Add this near the top of your script. It adds a function
> named Dumper to your script.
> 
> use Data::Dumper 'Dumper';
> 
> : 
> : foreach my $request (sort keys %response_hash) {
> : print "Response to request_id $request\n";
> : foreach my $record(@{$response_hash{$request}}) {
> 
> Test what is in $record with the Dumper function:
> 
> print Dumper @record;
> exit;
> 
> Is the result what you thought was in there?
> 
> 
> : 
> : print "Time : $record->{time}\n";
> : print "IP : $record->{ip_addr}\n";
> : foreach my $response ($record->{keys %response_values} )
> : {
> : print "Response to oid : $response = 
> : $response_values{$response}\n";
> : }
> : }
> : 
> : }
> 
> HTH,
> 
> Charles K. Clarkson
> -- 
> Mobile Homes Specialist
> 254 968-8328
> 
> 
> 
> -- 
> 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]
 




Streaming a file to a remote user

2004-03-25 Thread Price, Jason (TLR Corp)
I'm trying to figure out a way to stream a file to a remote user, and be able to 
determine that the download completed, so I can delete the file being streamed.  I may 
be missing an obvious way to do this, so I'm hoping you all can help me out.

Here's the sequence of events I'm after:

1.  User clicks URL pointing to perl script.
2.  Perl script pulls file out of LDAP, and writes it temporarily to disk.
3.  File is uudecoded on the disk.
4.  Decoded file is streamed to user, who saves the file locally.
5.  Once it is determined that the download is complete, the temp file on the web 
server is deleted.


Steps 4 and 5 are what I'm really after - the rest is relatively straight forward.  
For security reasons, we don't want the file to remain on the web server filesystem 
any longer than it has to, which is why I need to delete it after being downloaded.  
Emailing the file is not an option, also due to security reasons.

Can anyone help me out with a way to do this?

Thanks.

Jason

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




RE: Hash Help Needed !

2004-03-25 Thread Wiggins d Anconia
Please bottom post

> Hi
> 
> I am scoping the  %response_values hash at the top. I dont understand
why it
> would need to be temporary as I am referancing that hash outside of
the loop
> when I iterate through.
> 

It doesn't have to be temporary, but you overstep the help that 'strict'
would have given you in finding at least one of your problems.  By
declaring it outside of the scope necessary, it is available later on in
your block when it likely doesn't need to be.

> I changed the syntax to referance the oids rather then the hash name and I
> get the following error:
> 
> Can't use string ("%response_values") as a HASH ref while "strict refs" in
> use at H:\nhsParseSnmpLog.pl line 72,  OG> chunk 78.
>

Exactly.  That is what you want to see, because this is telling you that
you are trying to use a string as a hash reference, which should tell
you that you don't have the structure you want. In other words, this
just told you that you shouldn't have quoted %response_values to begin with.
 
> Here is what I have:
> 
> .. SNIP.. 
> use strict;
> my (%request_hash,%response_hash);
> 
> .. SNIP...
> elsif ( m/RESPONSE:/ ) {
>   my
>
($time,$timeSecs,$request_id,$ip_address,%response_values,$oid,$oid_value);
> # Set these local to each record

Which is exactly what you haven't done, aka they are local to the
enclosing 'if' block, not the foreach. If you scope them inside of the
foreach, which should be sufficient from what you have shown us, then
'strict' will also complain later about using %response_values.

>   my @lines = split/\n/;
>   foreach my $line (@lines) {
>   next if $line =~ m/REQUEST:/;
>   $timeSecs=$1 if $line =~ m/# Time (\d+)\.\d+
> seconds/;
>   $time=convertUtcToLocaltime($timeSecs);
>   $request_id=$1 if $line =~ m/\[REQUEST_ID\] (\d+)/;
>   $oid=$1 if $line =~ m/\[OBJECT_ID \] (.+)/;
>   $oid_value =$1 if $line =~ m/[\[COUNTER   \]|\[GAUGE
> \]|\[INT   \]|\[TICKS \]] (.+)/;
>   $response_values{$oid}=$oid_value;
>   }
>   push @{$response_hash{$request_id}},{time => "$time",oids =>
> "%response_values"};

Right here the values you push can go out of scope because they will
still exist referenced inside of 'response_hash'.

>   }   
> 
> .. SNIP ..
> 
> foreach my $request (sort keys %response_hash) {
>   #print "Response to request_id $request\n";
>   foreach my $record(@{$response_hash{$request}}) {
>   #print "Time : $record->{time}\n";
>   foreach my $response (keys %{ $record->{'oids'} }) {
>   #foreach my $response ($record->{keys %response_values} )
>   
>   print "Response to oid : $response =
> $record->{'oids'}{$response}\n";
>   }
>   }
>   #print "\n";
> }
> 
> I am thoroughly confused at this point :(
> 

That's fine, references are generally pretty difficult to "get" but once
you have gotten them you will have plenty of doors opened to you.  You
may want to read, if you haven't already:

perldoc perldsc
perldoc perllol
perldoc perlreftut
perldoc perlref

Come back when/if you have more questions,

http://danconia.org

[snip old posts]

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




RE: Hash Help Needed !

2004-03-25 Thread Normandin, Jason
Charles

It does not print anything even though I know the time and ip_address
objects are populated as they print correctley.

I added the following ( and use Data::Dumper 'Dumper'; to the top of the
script )

foreach my $request (sort keys %response_hash) {
#print "Response to request_id $request\n";
foreach my $record(@{$response_hash{$request}}) {
print Dumper @record;
#print "Time : $record->{time}\n";
foreach my $response ($record->{keys %response_values} )
{
#print "Response to oid : $response =
$response_values{$response}\n";
}
}

What am I missing here ?

Thanks !

-Original Message-
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 25, 2004 10:35 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Normandin, Jason
Subject: RE: Hash Help Needed !


[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
: 
: I have run into a situation that I am unclear on.
: 
: I am making the following assignment during a loop:
: 
: push @{$response_hash{$request_id}},{time => "$time",ip_addr 
: => "$ip_address",oids => "%response_values"};

I didn't test your code but "%response_values" is not the
same as \%response_values or %response_values. You have just
run into the problem with unnecessarily quoting variables.
(Read perlfaq4.)

You might have wanted (White space is your friend.):

push @{ $response_hash{ $request_id } }, {
time=> $time,
ip_addr => $ip_address,
oids=> \%response_values,
};



: 
: Where: response_values is a simple hash containing key,value 
: pairs and $time and $ip_address are simple scalar vars.
: 
: I can iterate through the %response_values hash after it is 
: created localy using simple foreach my $value (keys 
: %response_values ) syntax, but when I try to include that 
: iteration when iterating the main response hash, I am not 
: getting any values.
: 
: I am using the following syntax:

Add this near the top of your script. It adds a function
named Dumper to your script.

use Data::Dumper 'Dumper';

: 
: foreach my $request (sort keys %response_hash) {
:   print "Response to request_id $request\n";
:   foreach my $record(@{$response_hash{$request}}) {

Test what is in $record with the Dumper function:

print Dumper @record;
exit;

Is the result what you thought was in there?


:   
:   print "Time : $record->{time}\n";
:   print "IP : $record->{ip_addr}\n";
:   foreach my $response ($record->{keys %response_values} )
:   {
:   print "Response to oid : $response = 
: $response_values{$response}\n";
:   }
:   }
:   
: }

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
the latest virus scan software available for the presence of computer
viruses.
**



RE: Hash Help Needed !

2004-03-25 Thread Normandin, Jason
Hi

I am scoping the  %response_values hash at the top. I dont understand why it
would need to be temporary as I am referancing that hash outside of the loop
when I iterate through.

I changed the syntax to referance the oids rather then the hash name and I
get the following error:

Can't use string ("%response_values") as a HASH ref while "strict refs" in
use at H:\nhsParseSnmpLog.pl line 72,  chunk 78.

Here is what I have:

.. SNIP.. 
use strict;
my (%request_hash,%response_hash);

.. SNIP...
elsif ( m/RESPONSE:/ ) {
my
($time,$timeSecs,$request_id,$ip_address,%response_values,$oid,$oid_value);
# Set these local to each record
my @lines = split/\n/;
foreach my $line (@lines) {
next if $line =~ m/REQUEST:/;
$timeSecs=$1 if $line =~ m/# Time (\d+)\.\d+
seconds/;
$time=convertUtcToLocaltime($timeSecs);
$request_id=$1 if $line =~ m/\[REQUEST_ID\] (\d+)/;
$oid=$1 if $line =~ m/\[OBJECT_ID \] (.+)/;
$oid_value =$1 if $line =~ m/[\[COUNTER   \]|\[GAUGE
\]|\[INT   \]|\[TICKS \]] (.+)/;
$response_values{$oid}=$oid_value;
}
push @{$response_hash{$request_id}},{time => "$time",oids =>
"%response_values"};
}   

.. SNIP ..

foreach my $request (sort keys %response_hash) {
#print "Response to request_id $request\n";
foreach my $record(@{$response_hash{$request}}) {
#print "Time : $record->{time}\n";
foreach my $response (keys %{ $record->{'oids'} }) {
#foreach my $response ($record->{keys %response_values} )

print "Response to oid : $response =
$record->{'oids'}{$response}\n";
}
}
#print "\n";
}

I am thoroughly confused at this point :(

= Jason

-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 25, 2004 10:45 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Normandin, Jason
Subject: RE: Hash Help Needed !


> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

[snip]

> : 
> : print "Time : $record->{time}\n";
> : print "IP : $record->{ip_addr}\n";
> : foreach my $response ($record->{keys %response_values} )

In addition to what Charles already stated, once you have cleared up the
quoting problem and gotten your hash to store properly, then you will
need to access the hash reference of the key in the main hash using
'oids' .  In other words, you need to index into $record using 'oids' to
get the hash reference, then take the keys of that dereferenced hash.

foreach my $response (keys %{ $record->{'oids'} }) {

I suspect you have a scoping issue with %response_values otherwise
strict would have complained, are you declaring your variables when
first used or all at the top?  %response_values should have been a
temporary variable scoped only to your first loop which you didn't show.

http://danconia.org


**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
the latest virus scan software available for the presence of computer
viruses.
**



RE: Hash Help Needed !

2004-03-25 Thread Normandin, Jason
Charles

I was able to get the data dumper to work.

According to the output, the oids referance is referancing the hash for
response_values:

$VAR1 = {
  'oids' => '%response_values',
  'time' => '03/25/2004 03:16:39'
};
$VAR1 = {
  'oids' => '%response_values',
  'time' => '03/25/2004 03:16:39'
};
$VAR1 = {
  'oids' => '%response_values',
  'time' => '03/25/2004 03:16:39'
};
$VAR1 = {
  'oids' => '%response_values',
  'time' => '03/25/2004 03:16:39'
};

My guess is as that hash is local, that hash does not really exist.

Should it be showing the actual data rather then the hash referance ?

Ex.
$VAR1 = {
  'oids' => 'dat1=>value etc..',
  'time' => '03/25/2004 03:16:39'
};

If so, what is wrong with my assignment statement ?

push @{$response_hash{$request_id}},{time => "$time",oids =>
"%response_values"};

How can I get the oids=> to populate the oids object with the vals ?

Thanks
Jason

-Original Message-
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 25, 2004 10:35 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Normandin, Jason
Subject: RE: Hash Help Needed !


[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
: 
: I have run into a situation that I am unclear on.
: 
: I am making the following assignment during a loop:
: 
: push @{$response_hash{$request_id}},{time => "$time",ip_addr 
: => "$ip_address",oids => "%response_values"};

I didn't test your code but "%response_values" is not the
same as \%response_values or %response_values. You have just
run into the problem with unnecessarily quoting variables.
(Read perlfaq4.)

You might have wanted (White space is your friend.):

push @{ $response_hash{ $request_id } }, {
time=> $time,
ip_addr => $ip_address,
oids=> \%response_values,
};



: 
: Where: response_values is a simple hash containing key,value 
: pairs and $time and $ip_address are simple scalar vars.
: 
: I can iterate through the %response_values hash after it is 
: created localy using simple foreach my $value (keys 
: %response_values ) syntax, but when I try to include that 
: iteration when iterating the main response hash, I am not 
: getting any values.
: 
: I am using the following syntax:

Add this near the top of your script. It adds a function
named Dumper to your script.

use Data::Dumper 'Dumper';

: 
: foreach my $request (sort keys %response_hash) {
:   print "Response to request_id $request\n";
:   foreach my $record(@{$response_hash{$request}}) {

Test what is in $record with the Dumper function:

print Dumper @record;
exit;

Is the result what you thought was in there?


:   
:   print "Time : $record->{time}\n";
:   print "IP : $record->{ip_addr}\n";
:   foreach my $response ($record->{keys %response_values} )
:   {
:   print "Response to oid : $response = 
: $response_values{$response}\n";
:   }
:   }
:   
: }

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328



**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
the latest virus scan software available for the presence of computer
viruses.
**



Re: Streaming a file to a remote user

2004-03-25 Thread Paul D. Kraus
On Thursday 25 March 2004 12:02 pm, Price, Jason (TLR Corp) wrote:
> I'm trying to figure out a way to stream a file to a remote user, and be
> able to determine that the download completed, so I can delete the file
> being streamed.  I may be missing an obvious way to do this, so I'm hoping
> you all can help me out.
>
> Here's the sequence of events I'm after:
>
> 1.  User clicks URL pointing to perl script.
> 2.  Perl script pulls file out of LDAP, and writes it temporarily to disk.
> 3.  File is uudecoded on the disk.
> 4.  Decoded file is streamed to user, who saves the file locally.
> 5.  Once it is determined that the download is complete, the temp file on
> the web server is deleted.
>
>
> Steps 4 and 5 are what I'm really after - the rest is relatively straight
> forward.  For security reasons, we don't want the file to remain on the web
> server filesystem any longer than it has to, which is why I need to delete
> it after being downloaded.  Emailing the file is not an option, also due to
> security reasons.
>
> Can anyone help me out with a way to do this?

You should try posting this on the cgi list instead. You would me more likely 
to get a response.


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




RE: Hash Help Needed !

2004-03-25 Thread Guay Jean-Sébastien
Hello Jason,

> $VAR1 = {
>   'oids' => '%response_values',
>   'time' => '03/25/2004 03:16:39'
> };
...
> If so, what is wrong with my assignment statement ?
> 
> push @{$response_hash{$request_id}},{time => "$time",oids =>
> "%response_values"};

That is exactly what Charles told you in his first response. Look at the
$VAR1 at the top. Do you see that %response_values is quoted? That means
that it's a string in your data structure, not a variable that contains
data.

What you need to do is this :

push @{ $response_hash{ $request_id } }, 
{
time => $time,
oids => \%response_values,
};

In other words, do not quote variables unless you _know_ that's what you
need to do, because most of the time it isn't. Also, note that I put a
backslash before the %response_values, because values in a hash can only be
scalars. This way, you're putting a reference (which is a scalar) to
%response_values in the hash, keyed on the 'oids' key, so that you can
access it in the future.

Once you change this (and correct any errors the correction may cause),
Data::Dumper should print the correct data structure, where the value for
key 'oids' is the contents of your %response_values hash. Of course, then
you'll need to know how to access those values by using the reference. See
the perlref and perlreftut manpages (using perldoc) for more information. I
suggest you read those thoroughly, because you'll need it, considering what
you're trying to do here.

Good luck,

J-S


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




RE: Fuzzy string matching

2004-03-25 Thread McMahon, Chris
Hi Juman... 

> -Original Message-
> From: juman [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, March 24, 2004 3:31 AM
> To: [EMAIL PROTECTED]
> Subject: Fuzzy string matching
> 
> 
> I have two strings I want to compare doing some kind of fuzzy 
> matching?
> Is there some good way to that in perl or could someone help with a
> routine matching word by word and giving a percental result.
> 
> Like
> 
> String 1 : This is a ten characters long string is it not
> String 2 : This is not so long
> 
> String 1 compared to String 2 gives 40% (four words are the same)
> String 2 compared to String 1 gives 80% (four word are the same)
> 
> /juman
> 

You might try fooling around with the List::Compare module
http://search.cpan.org/~jkeenan/List-Compare-0.22/Compare.pm .  I've
been using it recently and it's pretty nifty.  It won't give you the
percentages you want, but I think it could supply the raw comparison
data, and then you could compute the percentages yourself.   
And if that's not quite right, the List::Compare page on CPAN
has references to similar modules at the bottom of the page, maybe one
of the other diff/compare modules might get you there.  
Hope that helps. 
-Chris   

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




Make a nice buffer?

2004-03-25 Thread David Busby
List,
  I want to make a buffer for my application to write log data to.  I've
created a fifo (`mkfifo /tmp/buf`)  Then I made my PERL script that
reads from /tmp/buf.  Other programs open and write to /tmp/buf but when
they close then my program that is reading from /tmp/buf stops.  I want
the script that reads and buffers (then parses and other such stuff) not
to close when the other folks are done writing to the fifo at /tmp/buf.
Ideas?  Should I just loop and re-open after every close (seems bad).

/djb


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




Playing with Unicode

2004-03-25 Thread James Edward Gray II
Why when I run this one-liner:

perl -e 'print "\x{2660}\n"'

do I see this:

Wide character in print at -e line 1.

I'm assuming that's a warning, since I still get the expected output, 
but why am I getting it, when I didn't ask for them?

Is there a better way to drop in a unicode character?

Semi-related question:  Is there a good document I could read somewhere 
on the differences for one-liners in Windows?

Thanks.

James

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



sort

2004-03-25 Thread ewalker
any modules out there that can sort things such as.. BB10, BB1100,BB11.   I want it to 
be in this order. BB10,BB11,BB1100.

Thanks

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


String differences

2004-03-25 Thread David Busby
Any differences between strings quoted with ' vs "?
I know the '' delimited strings don't get variables and other nice
things converted to values, does that make '' faster when using constant
strings than ""?

/djb


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




Re: sort

2004-03-25 Thread James Edward Gray II
On Mar 25, 2004, at 4:51 PM, [EMAIL PROTECTED] wrote:

any modules out there that can sort things such as.. BB10, 
BB1100,BB11.   I want it to be in this order. BB10,BB11,BB1100.
I'm not sure about the modules, but it's generally pretty easy to roll 
your own sort, in Perl.  See if this code gets you going:

#!/usr/bin/perl

use strict;
use warnings;
my @codes = qw(BB10 BB1100 BB11);
print "@codes\n";
my @sorted = map { join '', @$_ }
 sort { $a->[1] <=> $b->[1] }
 map { m/(\D+)(\d+)/ ? [$1, $2] : ['', $_] } @codes;
print "@sorted\n";
__END__

James

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



Re: sort

2004-03-25 Thread lists
On Thu, 25 Mar 2004 [EMAIL PROTECTED] wrote:

> any modules out there that can sort things such as.. BB10,
> BB1100,BB11.   I want it to be in this order. BB10,BB11,BB1100.

yeah, if you have 5.8 you can use mergesort from the sorts module

use strict; use warnings;   # always!
use sort '_mergesort';  # only work with perl 5.8

my $instring = "BB10,BB1100,BB11";

my @temparray = split(",",$instring);
my $outstring = join(",", sort
{ substr($a, 3, 5) cmp substr($b, 3, 5) } @temparray );

print $outstring;

__END__


-- 
Christian Bolstad - [EMAIL PROTECTED], PGP key #E7BCEB9A - http://atdt.nu/
  "I hate quotations."  -- Ralph Waldo Emerson


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




Re: sort

2004-03-25 Thread James Edward Gray II
On Mar 25, 2004, at 5:45 PM, [EMAIL PROTECTED] wrote:

On Mar 25, 2004, at 4:51 PM, [EMAIL PROTECTED] wrote:

any modules out there that can sort things such as.. BB10,
BB1100,BB11.   I want it to be in this order. BB10,BB11,BB1100.
I'm not sure about the modules, but it's generally pretty easy to roll
your own sort, in Perl.  See if this code gets you going:
#!/usr/bin/perl

use strict;
use warnings;
my @codes = qw(BB10 BB1100 BB11);
print "@codes\n";
my @sorted = map { join '', @$_ }   
 sort { $a->[1] <=> $b->[1] }
 map { m/(\D+)(\d+)/ ? [$1, $2] : ['', $_] } @codes;
print "@sorted\n";
__END__

James
James you just blew me away, can you comment some of those lines..
  Sorry, about that.  Let's take it piece by piece.

map { m/(\D+)(\d+)/ ? [$1, $2] : ['', $_] } @codes

That looks uglier than it is.  It just breaks the strings apart, into 
digit and non-digit units.  I turn each one into an array ref, with the 
first element being the letters and the second being the digits.

sort { $a->[1] <=> $b->[1] }

Is your basic numerical sort(), except I have to index into the array 
refs to hit the number.

map { join '', @$_ }

And that just puts Humpty Dumpty... er, the strings back together again.

Make more sense?

James

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



Re: sort

2004-03-25 Thread James Edward Gray II
On Mar 25, 2004, at 6:02 PM, [EMAIL PROTECTED] wrote:

James
	Yea,, now thats a ringer.. Glad you were able to look outside the 
box. :)
now my next question is that I got say 75 different string all 
starting like the previous list.
R50, AB11,BB110,BCD34...etc... Think this will sort the entire lot for 
me?  Or should I group all the ones with the same letters at the 
beginning and sort each group, then put them back togther again.
Give it a try.  It'll sort any amount, by number only.  Now if you need 
to sort by the letters too, it needs a small enhancement...

James

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



Re: sort

2004-03-25 Thread James Edward Gray II
On Mar 25, 2004, at 6:11 PM, [EMAIL PROTECTED] wrote:

James
	Hey james.. One other thing, I know its cause your a wise perl 
programmer, but how do you know on those lines not to put semi colons 
and that the data will be auto piped the next command?
map() builds up a list and returns it.  sort() sorts a list and returns 
it.  I'm just feeding the return values directly too the next function. 
 It could all be on one line.  Perl ignores whitespace, so I just made 
it a little prettier.

James

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



Re: String differences

2004-03-25 Thread WilliamGunther
In a message dated 3/25/2004 6:02:03 PM Eastern Standard Time, 
[EMAIL PROTECTED] writes:
>Any differences between strings quoted with ' vs "?
>I know the '' delimited strings don't get variables and other nice
>things converted to values, does that make '' faster when using constant
>strings than ""?

' and " are different. The Single quote is faster, to answer your question. 
Double quotes are interpolated. In simple terms, perl will break apart (or try 
to) double quote string to single quote string, hence its slowness. So 
something like:

print "You picked $number";

will be changed to

print 'You picked ' . $number;

(In this case, the fastest solution would be print 'You picked ', $number;)

All this kind of stuff is gone over in Master Perl Algorithms, which is a 
good read.


-will
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone (a Godsend)
-Perl::Tidy
-Beautifier


Re: Playing with Unicode

2004-03-25 Thread Randy W. Sims
On 3/25/2004 5:42 PM, James Edward Gray II wrote:
Why when I run this one-liner:

perl -e 'print "\x{2660}\n"'

do I see this:

Wide character in print at -e line 1.

I'm assuming that's a warning, since I still get the expected output, 
but why am I getting it, when I didn't ask for them?

Is there a better way to drop in a unicode character?

Semi-related question:  Is there a good document I could read somewhere 
on the differences for one-liners in Windows?
Hi James,

I'm not really up on unicode, but you might find something in 'perldoc 
perluniintro' & 'perldoc perlunicode'.

The only information that I know of about running perl at the 
commandline is in 'perldoc perlrun'. Although, I have a vague 
recollection of seeing an article with hints and tips for one-liners 
somewhere. Maybe a google search will find something.

Regards,
Randy.


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



noob needs help

2004-03-25 Thread Gallimore, Christopher
Being a total Perl noob I get tasked with some log parsing duties. The
project involves parsing the apache access log. What I need to be able
to do is get the "time served" data per hour per page. 

Something like: script.pl   would return all the logged
instances of that url and how long it took to serve each page for the
time requested. I was able to pull that data out using awk into a flat
file, however that's not as efficient as having Perl read thru the file
and store the data on the fly.. I just have no idea how to start.. does
anyone have any ideas on this?





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




Re: Playing with Unicode

2004-03-25 Thread david
James Edward Gray II wrote:

> Why when I run this one-liner:
> 
> perl -e 'print "\x{2660}\n"'
> 
> do I see this:
> 
> Wide character in print at -e line 1.
> 
> I'm assuming that's a warning, since I still get the expected output,
> but why am I getting it, when I didn't ask for them?
> 

different version seems to behave differently. my v5.6.0 never warn me about 
it. my v5.8.2 does emit a warning. you can turn it off by saying:

[panda]# perl -mbytes=no -e 'print "\x{2660}\n"'

there is a long discussion about what Perl should do when it encounters a 
byte sequence which is different than the current C local. should it 
upgrade to UTF-8 silently? should it warn? if the current C local is not 
UTF-8 then what? you can check the p5p list for the discussion.

david
-- 
s$s*$+/http://learn.perl.org/> 




Re: noob needs help

2004-03-25 Thread Randal L. Schwartz
> "Christopher" == Christopher Gallimore <[EMAIL PROTECTED]> writes:

Christopher> Being a total Perl noob I get tasked with some log
Christopher> parsing duties. The project involves parsing the apache
Christopher> access log. What I need to be able to do is get the "time
Christopher> served" data per hour per page.

Either get Analog (for speedy parsing with lots of options,
www.analog.cx), or roll something yourself with Apache::Log (a module
you can find in the CPAN).

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

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




Re: Hash Help Needed !

2004-03-25 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote:


> foreach my $response ($record->{keys %response_values} )

What is this?  It looks like you are trying to use a list as a hash key.  I don't 
think that is going to work.  A hash element should take a scalar as its key, not a 
list:

Greetings! C:\Documents and Settings\rjnewton>perl -w
my %hash = (first => 'one thing', second => 'another', third => 'still another')
;
foreach $try_a_key ($hash{keys %hash}) {
   print "$try_a_key\n";
}

^Z
Use of uninitialized value in concatenation (.) or string at - line 3.


 There is one, sorta quirky, way that it can work, though:

Greetings! C:\Documents and Settings\rjnewton>perl -w
my %hash = (first => 'one thing', second => 'another', 3 => 'still another');
foreach $try_a_key ($hash{keys %hash}) {
   print "$try_a_key\n";
}

^Z
still another

Of course, in the above, the foreach is superfluous, since this syntax willalway put 
one or fewer items in the list.

Is that what you were looking for--something keyed to the number of keys in a hash?  
Otherwise, you may have to go back and define your goal and steps to reach it more 
clearly.

Joseph




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




warn ?!

2004-03-25 Thread Jayakumar Rajagopal
Hi,
 In my program , $sth->execute fails since oracle tables already present. It is 
very natural. But the waring message output line 37 is different(just behaves as 
print) from same kind of message at line 57. Any suggestions please..
regards,
Jay 

regression Testing table( default : reg_test_cols) name : 
 Not able to create reg_test_cols
 discrepancy report table ( default : disc_table) name : 
 Not able to create disc_table
  at /tmp/selfextract.XX/install line 57, <> chunk 5.

26  $query=qq { create table reg_test_cols
27  ( tabname varchar2(40),
28colname varchar2(40),
29iskey   varchar2(1),
30tocomp  varchar2(1),
31primary key (tabname,colname) )
32};
33
34  $sth=$dbh->prepare($query)|| warn " $DBI::errstr \n";
35  unless ($sth->execute() )
36   {
37   warn " Not able to create reg_test_cols \n" ;
38   }
39  else
40  {
41  print " Successfully created table reg_test_cols \n";
42  }
43 
44  
45  
46  $query=qq { create table disc_table
47  ( tabname   varchar2(40),
48querycols varchar2(2000),
49cond  varchar2(2000),
50rerun varchar2(1),
51seq   number(4),
52primary key (tabname,cond,seq) )
53};
54  $sth=$dbh->prepare($query) || warn " $DBI::errstr\n ";
55  unless ($sth->execute() )
56   {
57   warn " Not able to create disc_table\n " ;
58   }

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




Show/download file from a non public folder

2004-03-25 Thread Alex A.
Hi,

I have files(.jpg, .pdf, .rtf, .xls) in the following non-public folder:

/home/alex/documents/

I need to show these files (jpg), or allow the download (.pdf, .rtf ...) from a script 
for users who already are authenticated and have a session opened in the server (this 
part is already working).

that I can do?

thanks in advance, 

Alex

Using Perl Expect.pm

2004-03-25 Thread TapasranjanMohapatra
Hi,
Can someone tell me how to handle the vt100 sequences using expect module of perl.
 I have used the same sequences while using TCL Expect. It works fine. But I don't 
understand what is the problem while I try doing the same thing using Perl Expect.
 If my TCL Expect Code goes like:-
 
 send "\x09" # hexadecimal equivalent of a tab
 expect "\x1b?2;2H"

What should be the equivalent Perl code?
I am able to send "\x09" in perl but I think it doesn't expect the correct thing. 
Perhaps the semicolon has to be escaped but even after escaping the semicolon didn't 
solve the problem.
Can someone give some help or reference link where I can learn what these values
like "\x1b?2;2H"  mean.

Thanks

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




Re: Using Perl Expect.pm

2004-03-25 Thread Andrew Gaffney
TapasranjanMohapatra wrote:
Hi,
Can someone tell me how to handle the vt100 sequences using expect module of perl.
 I have used the same sequences while using TCL Expect. It works fine. But I don't understand what is the problem while I try doing the same thing using Perl Expect.
 If my TCL Expect Code goes like:-
 
 send "\x09" # hexadecimal equivalent of a tab
 expect "\x1b?2;2H"

What should be the equivalent Perl code?
I am able to send "\x09" in perl but I think it doesn't expect the correct thing. 
Perhaps the semicolon has to be escaped but even after escaping the semicolon didn't solve the 
problem.
Can someone give some help or reference link where I can learn what these values
like "\x1b?2;2H"  mean.
Most likely, the problem is that Perl is interpreting what is in the quotes first. Try 
putting it in single quotes when you pass it to expect.

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Apache::Session question

2004-03-25 Thread Perl
My implementation of Apache::Session::MySQL dies along the way, and gives 
unclear warning. 
[error] Died at /usr/lib/perl5/site_perl/5.8.0/Apache/Session/Generate/MD5.pm 
line 40.

I decided to implement session as a module call Store::Session, so as to 
minimize recoding it in many script.






#
#  Program: 
#  Author: Babale Fongo#
#  Date: 01-03-2004			   	#
#  Description: Module for database connections.#
#  Copyright (c) Babale Fongo			#
#  Email: [EMAIL PROTECTED]			#
#  Web: http://www.domain name.com		#
# ===   #
#		#
#  <<< Technical information 		#
# 		#
# 		#
#



#
#  Beginning of the script. #
#


package Store::Session;
use vars qw(@ISA @EXPORT);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(new getId closeSession deleteObject);

use strict;
use Apache::Session::MySQL;


#
# Start a new session  
##


sub new {

my ($dbh, $session_id) = @_;
my %session;
tie %session, "Apache::Session::MySQL", $session_id,{ 

Handle => $dbh, LockHandle => $dbh

};

return;#(\%session);

}

1;



















#!/usr/bin/perl -w

#
#  Program: 	
#  Author: Babale Fongo
#  Date: 				
#  Description: 
#  Copyright (c) Babale Fongo			
#  Email: [EMAIL PROTECTED]			
#  Web: http://www.domain name.com		
# ===   
#		
#  <<< Technical information 		
# 		
# 		



use strict;
use lib qw(/data/www/perl-bin/jupiterShop/Modules);
use Store::Session;
use CGI qw(:all);
use DBConnect;
use Layout;


# Database connectivity
my $dbh = dbConnect();

# Get value of url or cookie id if any.
my $session_id = cookie("session"); #|| param("session");
my ($cookie, $session_ref);

if (defined($session_id)){

$session_ref = Store::Session->new($dbh, $session_id);
defined($session_ref) || die ("Couldn't retrieve session: Apache::Session::errstr"); 

}else {

$session_ref = Store::Session->new($dbh, undef);
defined($session_ref) || die ("Couldn't start a new session: Apache::Session::errstr");
$cookie = cookie(-name => "session",
   -value => $session_ref,
   -expires => "+3d",
   -domain => ".shop.com"
);

}




print header (-cookie => $cookie);
print header();
start_html();
   print p ("The session id is : $session_ref"); 
end_html();

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


Fwd: Apache::Session question

2004-03-25 Thread B. Fongo




My implementation of Apache::Session::MySQL dies along the way, and gives
unclear warning.
[error] Died at /usr/lib/perl5/site_perl/5.8.0/Apache/Session/Generate/MD5.pm
line 40.

I decided to implement session as a module call Store::Session, so as to
minimize recoding it in many script.

Babs

#
#  Program: 
#  Author: Babale Fongo #
#  Date: 01-03-2004 #
#  Description: Module for database connections.#
#  Copyright (c) Babale Fongo   #
#  Email: [EMAIL PROTECTED] #
#  Web: http://www.domain name.com  #
# ===   #
#   #
#  <<< Technical information    #
#   #
#   #
#



#
#  Beginning of the script. #
#


package Store::Session;
use vars qw(@ISA @EXPORT);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(new getId closeSession deleteObject);

use strict;
use Apache::Session::MySQL;


#
# Start a new session  
##


sub new {

my ($dbh, $session_id) = @_;
my %session;
tie %session, "Apache::Session::MySQL", $session_id,{ 

Handle => $dbh, LockHandle => $dbh

};

return;#(\%session);

}

1;





















shop
Description: Perl program
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: Hash Help Needed !

2004-03-25 Thread R. Joseph Newton
"Normandin, Jason" wrote:

> Hi
>
> I am scoping the  %response_values hash at the top. I dont understand why it
> would need to be temporary as I am referancing that hash outside of the loop
> when I iterate through.
>
> I changed the syntax to referance the oids rather then the hash name and I
> get the following error:
>
> Can't use string ("%response_values") as a HASH ref while "strict refs" in
> use at H:\nhsParseSnmpLog.pl line 72,  OG> chunk 78.
>
> Here is what I have:
>
> .. SNIP..
> use strict;
> my (%request_hash,%response_hash);
>
> .. SNIP...
> elsif ( m/RESPONSE:/ ) {
># my
> ($time,$timeSecs,$request_id,$ip_address,%response_values,$oid,$oid_value);

Best not to do this.  it is good that they are soped within the sub, but would
be even better if you declare them at the time they are used, or just prior to
their first use.


>
> # Set these local to each record
> my @lines = split/\n/;

my %response_values;

>
> foreach my $line (@lines) {
> next if $line =~ m/REQUEST:/;
> my $timeSecs=$1 if $line =~ m/# Time (\d+)\.\d+
> seconds/;
> my $time=convertUtcToLocaltime($timeSecs);
> my $request_id=$1 if $line =~ m/\[REQUEST_ID\] (\d+)/;
>
> my $oid=$1 if $line =~ m/\[OBJECT_ID \] (.+)/;
> my $oid_value =$1 if $line =~ m/[\[COUNTER
> \]|\[GAUGE
> \]|\[INT   \]|\[TICKS \]] (.+)/;
> $response_values{$oid}=$oid_value;
> }
> push @{$response_hash{$request_id}},{time => "$time",oids =>
> "%response_values"};
> }
>
> .. SNIP ..

Just snip?  If this is getting long enough that you need to ship, then it is
getting too long to be in one sub.

Start at the top again.  What data do you have to work with, in what form?  What
kind of information do you want out of the process in what form?  Unfortunately
%response_hash is so genral as to say nothing about the meaning of the data in
context.

I have the feeling that, if you take a fresh look at the original problem with a
view to what you have to work with, and what end result you want to achieve, we
can help you find much more straightforward means to get there.

Joseph


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




Re: Playing with Unicode

2004-03-25 Thread R. Joseph Newton
James Edward Gray II wrote:

> Why when I run this one-liner:
>
> perl -e 'print "\x{2660}\n"'
>
> do I see this:
>
> Wide character in print at -e line 1.

Makes sense.  2660 would overflow a one-byte character.

>
>
> I'm assuming that's a warning, since I still get the expected output,
> but why am I getting it, when I didn't ask for them?
>
> Is there a better way to drop in a unicode character?

I think you need to warn the compiler ahead of time that you are reading or
writig unicode.  It adapts anyway, but it's just reminding you.  You might see
if you can make sense out of
perldoc encoding
perldoc perlunicode
though they are both rather windy and circuituous.

Joseph



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




Re: Passing file name /filehandle as argument to a subroutine...

2004-03-25 Thread John W. Krahn
Urvashi Mishra wrote:
> 
> hi;

Hello,

> i am trying to take input from multiple files
> Various I/P files are specified at command line...
> 
> Can anyone tell me how to pass the file name to a
> routine that opens it for parsing 
> 
> the same function is to be called for all the I/P
> files...
> 
> Code is:
> 
> foreach my $file (@ARGV)
> {
>  #my $file= shift @ARGV;
>  #print "$file\n";
>  #
>  &pass1($file);
>  &display();
>  print " \n 8next**\n";
> }
> 
> 
> and the function to be called is
> 
> sub pass1
> {
>  my ($file)[EMAIL PROTECTED];
>  print "$file";
>  #MIBFH++;
>  open(MIBFH,$file)|| die "Error opening the  $file
> $!\n";
>  while(my $line =  )
>  {
> 
> }
> close(MIBFH);
> 
> }
> 
> Can anyone help me...!


How about something like this:

while ( <> ) {  # process files in @ARGV
if ( $. == 1 ) {
print "File name: $ARGV\n";
}

# process the contents of the file

if ( eof ) {
close ARGV;  # reset $. for next file
print " \n 8next**\n";
}
}



John
-- 
use Perl;
program
fulfillment

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




Home made mail news search tool, and folded header lines

2004-03-25 Thread Harry Putnam
I'm writing a home boy mail/news search tool and wondered if there is
a cononical way to handle folded or indented header lines.

An example would be that I wanted to run a series of regex against each
line of input (While in headers) grabing the matches into an array
for printing.

Something like:
[...] snipped getopts and other unrelated stuff
  while(){
  chomp;
  my $line = $_;
  ## @hdregs is an array of several regex for the headers
  for($ii=0;$ii<=$#hdregs;$ii++){
 if($line =~ /$hdregs[$ii]/){
## Capture the line
push @hits,$line;
 }
  } 
}
  (somewhere later... if some body regex also match
print the hits.)

I used a for loop so as to stop at each incoming line and compare it
to a number of regex in rotation, instead of using a possibly long
string of alternation operators (if ($_ =~ /regex|regex2|regex3/)  etc

But going this route means lines like `Received: ' lines that might
have folded (indented) lines containing newlines after them will get
missed.

It seems like it might take some fairly complex code to do something
like above but include slurping the indented lines on hits that have
them.   I wondered if there is some well worn way to do this?

Or is it necessary to process the entire header... making single
lines out of the indents before doing the matching?

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




Re: sort

2004-03-25 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> 
> any modules out there that can sort things such as.. BB10, BB1100,BB11.
> I want it to be in this order. BB10,BB11,BB1100.

Perl's built-in sort does that:

$ perl -le'@x = qw[BB11 BB10 BB1100]; print for @x; print; print for sort @x'
BB11
BB10
BB1100

BB10
BB11
BB1100


Unless you are not describing the problem correctly.


John
-- 
use Perl;
program
fulfillment

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