Re: Appending array from HoA elements into one single array

2004-08-24 Thread John W. Krahn
Jenda Krynicky wrote:
From: "John W. Krahn" <[EMAIL PROTECTED]>
Edward WIJAYA wrote:
Is there any efficient way to append
each of this HoA's array into one
single array, e.g:
@name = ("fred", "barney", "george", "jane", "elroy");
my @name = map @$_, @HoA{ keys %HoA };
Why not 

my @name = map @$_, values %HoA;
? :-)
Why not indeed!
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: how to print pdf files to particular printer like LASER in windows

2004-08-24 Thread Jenda Krynicky
From: "R.MURUGAVEL" <[EMAIL PROTECTED]>
> I am new to this group, I have one problem that is how
> to print pdf files to the particular printer installed
> our system/network systems.
> 
> If any one helps me a very great help for me urgent
> Pl?

This print the file on command line:

print /d:"\\czfiles\HP4200 PCL" c:\boot.ini

So just call something like this by system() or `` and it should 
work.

Or try this:

open OUT, '>czfiles\HP4200 PCL'
binmode OUT;
print OUT $the_data;
close OUT;

If neither of these works correctly try to run the Acrobat Reader and 
instruct it to print the document:

"C:\Program Files\Adobe\Acrobat 6.0\Reader\AcroRd32.exe" /p /h 
"http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Appending array from HoA elements into one single array

2004-08-24 Thread Jenda Krynicky
From: "John W. Krahn" <[EMAIL PROTECTED]>
> Edward WIJAYA wrote:
> > Hi,
> 
> Hello,
> 
> > Suppose I have this Hash of array:
> > 
> > %HoA = {
> 
> If you had warnings enabled then that would have produced a warning. 
> It should be either:
> 
> %HoA = ( ... );
> 
> Or:
> 
> $HoA = { ... };
> 
> 
> >A => ["fred", "barney"],
> >B => ["george", "jane", "elroy"],
> > };
> > 
> > Is there any efficient way to append
> > each of this HoA's array into one
> > single array, e.g:
> > 
> > @name = ("fred", "barney", "george", "jane", "elroy");
> 
> my @name = map @$_, @HoA{ keys %HoA };

Why not 

my @name = map @$_, values %HoA;

? :-)

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Split and extract a sub-string

2004-08-24 Thread Gunnar Hjalmarsson
Rajesh Dorairajan wrote:
I've to extract a CN (Common Name) from an LDAP DN. The LDAP DN is
as shown below:
isuer=CN=Name,OU=People,OU=com
I just need to extract the Name from the above string. Right now
I've
my @tmpList = split ( /=CN=/, $_ );
$issuer = $tmpList[1];
But this returns the whole string "Name,OU=People,OU=com"
You'd better use a regex without the split() function:
my ($issuer) = /CN=([^,]+)/;
Suggested reading:
http://www.perldoc.com/perl5.8.4/pod/perlrequick.html
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Split and extract a sub-string

2004-08-24 Thread Rajesh Dorairajan
Hello All,

I've to extract a CN (Common Name) from an LDAP DN. The LDAP DN is as shown
below:

isuer=CN=Name,OU=People,OU=com

I just need to extract the Name from the above string. Right now I've

my @tmpList = split ( /=CN=/, $_ );
$issuer = $tmpList[1];

But this returns the whole string "Name,OU=People,OU=com"

I just need the "Name" from this. Is there anyway to do this? I cannot split
by "," because the "Name" could be anywhere in the string. Is there a better
way of doing the split?

Thanks in Advance,
 
--Rajesh 


Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Chris Devers
On Tue, 24 Aug 2004, Errin Larsen wrote:
Perhaps:
   $scalar =~ s/^(a|an|the)\s*\b//i;
would work better.
<>
Is this capturing into $1 the a|an|the (yes) and the rest of the title 
into $2 (no?).
There is only one pair of parentheses, so only $1 is captured.
I still think it's prudent to capture everything else as $2, and then 
substitute such that the article captured in $1 is now the suffix:

$scalar =~ s/^(a|an|the)\s*\b(.*)/$2, $1/i;
Which turns "A Hard Day's Night" into "Hard Day's Night, A". If you ever 
need the original string back -- the person who started this thread was 
trying to get this info into a MySQL database in such a way that it 
would sort by the first significant word and not the article that 
precedes it -- then you can reverse the change with something like:

   $scalar =~ s/(.*), \b(a|an|the)$/$2 $1/i;
and "Hard Day's Night, A" should once again be "A Hard Day's Night".
After doing so, will it reverse the two ( i.e. 
s/^(a|an|the)\s+(.*)\b/$2, $1/i )?
Your version should; the one above won't.
Also, what is the "\b"?
Word boundary.
it seems that the trailing "i" is for ignoring case; is that correct?
Yes.
Just need some help with RE!!
`perldoc perlre`
Or the wonderful -- really! -- book, _Mastering Regular Expressions_.

--
Chris Devers  [EMAIL PROTECTED]
http://devers.homeip.net:8080/blog/
np: 'Colt 45'
 by
 from 'Television Theme Songs'
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread John W. Krahn
Bob Showalter wrote:
Jose Alves de Castro wrote:
On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
I need to pull out articles "a", "an", and "the" from the beginning
of title strings so that they sort properly in MySQL.  What is the
best way to accomplish that if I have a single $scalar with the
whole title in it? 
I would go with substitutions:
$scalar =~ s/^(?:a|an|the)//i;
Two problems:
1. This doesn't remove just the whole words; it removes parts of words as
well. i.e. "Analyzing Widgets" would become "alyzing Widgets"
Actually it would become "nalyzing Widgets" because 'a' is the first 
alternative.  :-)

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Errin Larsen
Hey,

Ok, looking through this ... I'm confused.  

<< SNIP >>

> >
> > Perhaps:
> >
> >$scalar =~ s/^(a|an|the)\s*\b//i;
> >
> > would work better.

<>

Is this capturing into $1 the a|an|the (yes) and the rest of the title
into $2 (no?).  After doing so, will it reverse the two ( i.e.
s/^(a|an|the)\s+(.*)\b/$2, $1/i )?  Also, what is the "\b"?  it seems
that the trailing "i" is for ignoring case; is that correct?

Just need some help with RE!!

thanks,

--Errin

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




Re: Between times

2004-08-24 Thread John W. Krahn
rmck wrote:
Hello,
Hello,
I have a script that I want to print only if between 08:00 and 17:00. Would I match
> every hour then print?? Any cleaner way to do this would be great. Thanks
Cleaner?  Yes, use appropriate whitespace and indentation and remove redundant 
code.  :-)


my($sec,$min,$hour,$mday,$mon);
($sec,$min,$hour,$mday,$mon)=localtime;
$timestamp=sprintf("%3s %02d %02d:%02d:%02d",$Month[$mon],$mday,$hour,$min,$sec);
 
my $pidstring="pid(".$$."),";
 
while(){
  $line = $_;
  if($line=~/OK/){
open( OKLIST,">>/var/log/log.ok");
print OKLIST $timestamp,":",$pidstring,$line;
close(OKLIST);
  }else{

if ( $hour =~ /^(08:|09:|10:|11:|12:|13:|14:|15:|16:|17:)/){
open( ERRLIST,">>/var/log/err.ok");
print ERRLIST $timestamp,":",$pidstring,$line;
close(ERRLIST);
chomp($line);
 }
  }
}
exit;
Something like:
my ( $sec, $min, $hour, $mday, $mon ) = localtime;
my $timestamp = sprintf '%3s %02d %02d:%02d:%02d', $Month[ $mon ], $mday, 
$hour, $min, $sec;
my $hour = sprintf '%d%02d', $hour, $min;
my $pidstring = "pid($$),";

open my $LOG, '>>', '/var/log/log.ok' or die "Cannot open log: $!";
open my $ERR, '>>', '/var/log/err.ok' or die "Cannot open err: $!";
while (  ) {
my $line = "$timestamp:$pidstring$_";
if ( /OK/ ) {
print $LOG $line;
}
elsif ( $hour >= 800 and $hour <= 1700 ) {
print $ERR $line;
}
}
exit 0;
__END__

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: is possible start some actions with Perl without Cron?

2004-08-24 Thread Errin Larsen
Hi,

Can you help me understand the below a little better.

As I understand what's going on, the Process (let's say PID=100)
spawns a child with the fork() function (let's say PID=200).  This
(200) is assigned to $pid in the parent, and zero (0) is assigned to
$pid in the child.  So, what does "my $pid=fork()" resolve to in each
case?  I'll assume that it resolves to the PID that fork returns.  So,
in the parent, the statement resolves to 200 and the unless statement
doesn't resolve.  In the child, the statement resolves to 0 and the
unless statement DOES resolve.  So, the parent prints a message to
STDOUT and quits, while the child keeps on running (in the little
do/while loop) doing that stuff that's in there :)  Ok ... so, um, why
go through all this?  Why not just write your do/while block and just
execute it in the background on the command line?  is fork() doing
something else that helps a daemon that I'm not aware of?

--Errin

On Sat, 21 Aug 2004 09:53:23 -0400, Adam Rosi-Kessel
<[EMAIL PROTECTED]> wrote:

<>

> 
> Here's the skeleton of it:
> 
> 
> unless (my $pid = fork()) {
>   do {
>  &SendEmailToUsers;
>  sleep 3 * 24 * 60 * 60;
>   } while (1);
> }
> 
> print "Starting email daemon...\n";
> -
> 
> That's all.  This will run indefinitely, and every three days run the
> subroutine SendEmailToUsers.  You obviously need to add a lot more to

<>

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




Re: Appending array from HoA elements into one single array

2004-08-24 Thread John W. Krahn
Edward WIJAYA wrote:
Hi,
Hello,
Suppose I have this Hash of array:
%HoA = {
If you had warnings enabled then that would have produced a warning.  It 
should be either:

%HoA = ( ... );
Or:
$HoA = { ... };

   A => ["fred", "barney"],
   B => ["george", "jane", "elroy"],
};
Is there any efficient way to append
each of this HoA's array into one
single array, e.g:
@name = ("fred", "barney", "george", "jane", "elroy");
my @name = map @$_, @HoA{ keys %HoA };
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: searching a whole array without using a loop

2004-08-24 Thread John W. Krahn
Darren Birkett wrote:
OK, to be more specific, I'm using Net::Telnet:Cisco.  When logged onto 
a device I'm using the "show version" command, and storing the output in 
an array.  Each element of the array will therefore contain lots of 
rubbish.  I just want to match certain keyword(s) to determine device 
type.  I guess a for loop is the closest I'm going to get.  I just 
thought there would be a specific function for this.
So then I wonder - which is more efficient.  My earlier "join" example, 
or a for loop?
Ok, perhaps you need something like this:
my @output = grep /keyword1|keyword2/, $session->cmd('show version');
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



filehandle errors

2004-08-24 Thread DBSMITH
All, 

never mind about responding to the past email, I got it !  My syntax was :


foreach (split /\n/, $EDM_nonactive_tapelist )  {
#print OUT "$_\n" unless substr($_, 0, 5) eq 
'*Orig';
 
if ( /\((E\d+)/ ) {
local $, = "\t";
print OUT "$1\n" unless substr($_, 0, 5) 
eq '*Orig';
}
}
 
close (OUT);

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams


- Forwarded by Derek Smith/Staff/OhioHealth on 08/24/2004 03:56 PM 
-


Derek Smith
08/24/2004 12:42 PM

 
To: [EMAIL PROTECTED]
cc: 
Subject:filehandle errors

All, 

I am a little confused on how some of my code is compiling.  This maybe a 
little long but basically my goal is:

EDM Vault Tape List for client edm01 
08/24/04 11:31

E01265 
E00869 
E00258 
E00706 
E00702 


and I am attaining this, but not through the main program rather through a 
separate .pl file that has one subroutine.  I had been trying to get the 
above this in one full swoop, but kept getting read/write IO errors 
stating FILEHANDLE only opened for writing so I changed the file to 
+) outside of the foreach statement as highlighted in 
main instead of having this separate pl file produce the above results for 
me. 



sub LVIMAGE_FE {

open (OUT, ">$lvimgFEtapes") || die "could not open file:$!";
my $lvimgFE_nonactive_tapelist = `ebreport media -template 
$FEsched`;
select( (select(OUT), $|=1 ) [0] );

foreach (split /\n/, $lvimgFE_nonactive_tapelist )  {
print OUT "$_\n" unless substr($_, 0, 5) eq 
'*Orig';
}
close (OUT);
}


 while () {
 
if ( /\((E\d+)/ ) {
local $, = "\t";
print OUT "$1 \n"; 
}
}

close (OUT);

&LVIMAGE_FE;

derek



filehandle errors

2004-08-24 Thread DBSMITH
All, 

I am a little confused on how some of my code is compiling.  This maybe a 
little long but basically my goal is:

EDM Vault Tape List for client edm01 
08/24/04 11:31

E01265 
E00869 
E00258 
E00706 
E00702 


and I am attaining this, but not through the main program rather through a 
separate .pl file that has one subroutine.  I had been trying to get the 
above this in one full swoop, but kept getting read/write IO errors 
stating FILEHANDLE only opened for writing so I changed the file to 
+) outside of the foreach statement as highlighted in 
main instead of having this separate pl file produce the above results for 
me. 



sub LVIMAGE_FE {

open (OUT, ">$lvimgFEtapes") || die "could not open file:$!";
my $lvimgFE_nonactive_tapelist = `ebreport media -template 
$FEsched`;
select( (select(OUT), $|=1 ) [0] );

foreach (split /\n/, $lvimgFE_nonactive_tapelist )  {
print OUT "$_\n" unless substr($_, 0, 5) eq 
'*Orig';
}
close (OUT);
}


 while () {
 
if ( /\((E\d+)/ ) {
local $, = "\t";
print OUT "$1 \n"; 
}
}

close (OUT);

&LVIMAGE_FE;

derek


Re: searching a whole array without using a loop

2004-08-24 Thread Gunnar Hjalmarsson
James Edward Gray II wrote:
Gunnar Hjalmarsson wrote:
if ( grep /my string/, @myarray ) {
some code
}
Ordinarily, I wouldn't even mention this, but since the
conversation is about what is fastest...
The OP was not about what is fastest at all. It was about whether
there is "a better way" than first joining the elements, without any
definition of "better".
The above is pretty much the textbook perfect example of an
inefficient use of grep().  The reason is that we just want to know
if @myarray contains ANY /my strings/, but grep() fetches them ALL.
If the list contains 10,000 entries, and the first is a /my
string/, that's 9,999 lookups we didn't need.
I didn't claim that grep() provides a fast solution. But it does
provide a solution with a minimum of Perl code.
As regards efficiency, we were informed that the array contains the
output from some "show version" command, so it should be safe to
assume that we are not talking about a huge number of elements...
I would simply substitute List::Utils' first() in the above
example, to "fix" this.
Though again, it probably isn't "broken" at all.  (See my speed
rant in previous message.)
Yeah, I read it, and you did object to you own arguments, didn't you? ;-)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Jose Alves de Castro
On Tue, 2004-08-24 at 16:19, Bob Showalter wrote:
> Jose Alves de Castro wrote:
> > On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
> > > I need to pull out articles "a", "an", and "the" from the beginning
> > > of title strings so that they sort properly in MySQL.  What is the
> > > best way to accomplish that if I have a single $scalar with the
> > > whole title in it? 
> > 
> > I would go with substitutions:
> > 
> > $scalar =~ s/^(?:a|an|the)//i;
> 
> Two problems:
> 
> 1. This doesn't remove just the whole words; it removes parts of words as
> well. i.e. "Analyzing Widgets" would become "alyzing Widgets"
> 
> 2. It doesn't remove whitespace after the word, so "The Widget Primer"
> becomes " Widget Primer", which won't sort with the w's, due to the leading
> blank.
> 
> Perhaps:
> 
>$scalar =~ s/^(a|an|the)\s*\b//i;
> 
> would work better.

You're absolutely right. I think this is a sign that I need to go out,
eat and drink something, breath some fresh air, etc.

-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


RE: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Bob Showalter
Jose Alves de Castro wrote:
> On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
> > I need to pull out articles "a", "an", and "the" from the beginning
> > of title strings so that they sort properly in MySQL.  What is the
> > best way to accomplish that if I have a single $scalar with the
> > whole title in it? 
> 
> I would go with substitutions:
> 
> $scalar =~ s/^(?:a|an|the)//i;

Two problems:

1. This doesn't remove just the whole words; it removes parts of words as
well. i.e. "Analyzing Widgets" would become "alyzing Widgets"

2. It doesn't remove whitespace after the word, so "The Widget Primer"
becomes " Widget Primer", which won't sort with the w's, due to the leading
blank.

Perhaps:

   $scalar =~ s/^(a|an|the)\s*\b//i;

would work better.

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




Perl, Unicode, and Hashes

2004-08-24 Thread Alex Lawson
hello,

I am writing a flash card program with PERL, and I have two problems:

 

How do I read from a file in the format:

 

[][][] \t pronunciation

[][][] \t pronunciation

 

the [][][] basically represents any number of Unicode characters [in my case, 
Chinese], and the pronunciation is in regular test.

 

and secondly, how do I ensure that Unicode will work on this program:

 

open(INPUT,"<","c:\\software\\alexcode\\AlexData.txt")

or die"Could not open input file for reading\n";

$count = 0;

my @prehasha = ();

while ()

{

 chomp;

 my ($values1, $values2) = split(/\t/,$_);

 $prehasha[$count++] = $values1;

 $prehasha[$count++] = $values2;

  print "$values1 and $values2\n";

}#above this Mike wrote

print "after while statement @prehasha \n";

#now we have an array where the first element is the char and the seco

+nd element is the pinyin etc.

@char = ();

@pinyin = ();

while (@prehasha != 0) 

{

$a = shift @prehasha;

$b = shift @prehasha;

push (@char, $a);

push (@pinyin, $b); #the array has officially been split!

 }

print "@char  : @pinyin\n";

keys %charpinyin = @char;

 

#values %charpinyin = @pinyin;#Mike approved 8:44 PM

$elnum = ($char)/2;

#now is where we assign random numbers to each pair in the hash!

$randomarray{$elnum-1} = ();

foreach (@randomarray) {

push (@random, int( rand($elnum-1) )-1)

}

#keys %randhash = 1..$elnum-1;

#values %randomhash = @randomarray;

#now we have two hashes, %charpinyin, and %randomarray, what I will do

+ now is sort the randomhash hash based on the random number, and use 

+the key [0..elnum-1] to determine which pair to spit off on the scree

+n!  clever, eh?

#the following few lines is ONLY a test#

while (($key, $value) = each(%charpinyin)) {

print "$key \t $value \n";

}



-
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.

Re: security on a html page with perl.

2004-08-24 Thread Chris Devers
On Tue, 24 Aug 2004, Jose Alves de Castro wrote:
One thing that could be done was to have the page with the form 
generate the hidden field in a way that only the script could validate 
it...
But that's exactly the problem I'm talking about -- what would that 
solve? The machinery to do that well would be complicated & bug-prone, 
and for what? It doesn't seem to solve any real problem.

If you really want to keep out robots, try doing the randomly generated, 
distorted text images that some web sites are using these days. Note 
that I'm not actually sure how to implement one of these things in Perl, 
but I'm sure it can be done, and it's the only anti-robots solution I've 
seen that seems to make any sense at all -- it's not *that* complicated, 
it is easy to understand, and it should be highly effective.

But that said, it's still much more complicated than just validating the 
form data and accepting that with some degree of faith. For most things, 
I could live with that just fine; if you really need to be sure and you 
really need to keep people on a fixed path, then think about bringing in 
a more complex solution to the problem, but don't do that if you don't 
need to.

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



Re: searching a whole array without using a loop

2004-08-24 Thread James Edward Gray II
On Aug 24, 2004, at 9:14 AM, Gunnar Hjalmarsson wrote:
Isn't grep() "specific" enough?
Initially you said:
$line = join(' ',@myarray);
if ($line =~ /my string/) {
some code
}
The equivalent using grep() would be:
if ( grep /my string/, @myarray ) {
some code
}
Ordinarily, I wouldn't even mention this, but since the conversation is 
about what is fastest...

The above is pretty much the textbook perfect example of an inefficient 
use of grep().  The reason is that we just want to know if @myarray 
contains ANY /my strings/, but grep() fetches them ALL.  If the list 
contains 10,000 entries, and the first is a /my string/, that's 9,999 
lookups we didn't need.

I would simply substitute List::Utils' first() in the above example, to 
"fix" this.

Though again, it probably isn't "broken" at all.  (See my speed rant in 
previous message.)

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



Re: searching a whole array without using a loop

2004-08-24 Thread James Edward Gray II
On Aug 24, 2004, at 7:48 AM, Darren Birkett wrote:
OK, to be more specific, I'm using Net::Telnet:Cisco.  When logged onto
a device I'm using the "show version" command, and storing the output 
in
an array.  Each element of the array will therefore contain lots of
rubbish.  I just want to match certain keyword(s) to determine device
type.
That sounds like a Regular Expression, naturally.
I guess a for loop is the closest I'm going to get.  I just  thought 
there would be a specific function for this.
If you need only to find the first occurrence, John's suggestion is 
perfect.  You could also use:

use List::Util qw/first/;
if (first { /test/ } @list) {
# ...
}
If you need all entries that match grep() is the right choice, in my 
opinion.

So then I wonder - which is more efficient.  My earlier "join" example,
or a for loop?
Does it matter?  Will you have 10 million or more entries in this list? 
 Do you need the answer in microseconds?  Will the results be used in 
the guidance system of a nuclear missile?

Silly questions, I know, but often so is worrying about performance.  
With reasonable data on modern hardware, both will likely be faster 
than you blink.  That's generally good enough, don't you think?  My 
rule for optimization is, "Speed it up when it gets too slow".

Let me ask you a question:  Which method is easier for you to 
understand?  The answer to that is a much more noble pursuit, I think.

To me, join() is for strings and we're dealing with a list.  Because of 
that, I would use list tools:  for, grep(), first(), etc.  That doesn't 
make me right though.  That's just what makes sense to me, so that's 
what I would use.

Hope that helps.
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: security on a html page with perl.

2004-08-24 Thread Jose Alves de Castro
On Tue, 2004-08-24 at 15:36, Chris Devers wrote:
> On Tue, 24 Aug 2004, Jose Alves de Castro wrote:
> 
> > On Tue, 2004-08-24 at 15:22, Chris Devers wrote:
> >
> >> The obvious way I can think of to do this is to make the download page a
> >> script that checks to see that:
> >>
> >>* mandatory form fields are defined as input for the download script
> >>* the referring page is your original form (this one is probably less
> >>  important than the previous criteria, if you think about it)
> >>
> >> If these are not verified, send the user back to the form with a note
> >> saying that fields X, Y, and Z still need to be filled out.
> >
> > This gave me an idea... one could have a hidden field in that form :-)
> 
> But this doesn't really change much: anyone trying to get around the 
> entry form, for whatever reason, isn't going to have to work very hard 
> to have the insight that they should look at the html source to see if 
> there are any hidden fields.

No, it doesn't change much. I guess I misread the original email. I was
thinking that, this way, sending a mail with a link directly to the
script wouldn't be enough to download the file. The user had to start
from some page. But thinking better about it, you're right, there's no
need for a hidden field, as there are already other fields that can be
validated...


One thing that could be done was to have the page with the form generate
the hidden field in a way that only the script could validate it...


-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Jose Alves de Castro
On Tue, 2004-08-24 at 15:39, Chris Devers wrote:
> On Tue, 24 Aug 2004, Jose Alves de Castro wrote:
> 
> > On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
> >> I need to pull out articles "a", "an", and "the" from the beginning of
> >> title strings so that they sort properly in MySQL.  What is the best way
> >> to accomplish that if I have a single $scalar with the whole title in it?
> >
> > I would go with substitutions:
> >
> > $scalar =~ s/^(?:a|an|the)//i;
> 
> Why not save the data for later by moving the article to the end?
> 
>  $scalar =~ s/^(?:a|an|the)\s+(.*)/$2, $1/i;
> 
> That way, "A Tale of Two Cities" should become "Tale of Two Cities, A", 
> and if you have to reconstitute the original title later, you haven't 
> thrown anything away...

I second this :-)

> -- 
> Chris Devers
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Chris Devers
On Tue, 24 Aug 2004, Jose Alves de Castro wrote:
On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
I need to pull out articles "a", "an", and "the" from the beginning of
title strings so that they sort properly in MySQL.  What is the best way
to accomplish that if I have a single $scalar with the whole title in it?
I would go with substitutions:
$scalar =~ s/^(?:a|an|the)//i;
Why not save the data for later by moving the article to the end?
$scalar =~ s/^(?:a|an|the)\s+(.*)/$2, $1/i;
That way, "A Tale of Two Cities" should become "Tale of Two Cities, A", 
and if you have to reconstitute the original title later, you haven't 
thrown anything away...


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



Re: security on a html page with perl.

2004-08-24 Thread Chris Devers
On Tue, 24 Aug 2004, Jose Alves de Castro wrote:
On Tue, 2004-08-24 at 15:22, Chris Devers wrote:
The obvious way I can think of to do this is to make the download page a
script that checks to see that:
   * mandatory form fields are defined as input for the download script
   * the referring page is your original form (this one is probably less
 important than the previous criteria, if you think about it)
If these are not verified, send the user back to the form with a note
saying that fields X, Y, and Z still need to be filled out.
This gave me an idea... one could have a hidden field in that form :-)
But this doesn't really change much: anyone trying to get around the 
entry form, for whatever reason, isn't going to have to work very hard 
to have the insight that they should look at the html source to see if 
there are any hidden fields.

Unless the hidden fields are in some way functional -- e.g. they 
identify the file that is going to be downloaded -- don't bother. They 
just make the script more complicated without gaining very much.

The real goal here should be to verify that the necessary input data has 
been provided and is valid before delivering the download. Throwing in 
some kind of garbage hidden field just to make this harder is only 
really going to make more work for you.

Really, the input form and the response page are so inter-tangled that 
it would make a lot of sense to make one script out of it. If all of the 
mandatory fields are defined, then respond by streaming the download 
back to the user; if anything is missing, respond with the form, with 
missing fields highlighted (in the case that some but not all of the 
fields are present) or no fields highlighted (in the case that someone 
is visiting the form for the first time, and has submitted no data).


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



Re: Between times

2004-08-24 Thread Gunnar Hjalmarsson
Rmck wrote:
I have a script that I want to print only if between 08:00 and
17:00. Would I match every hour then print?? Any cleaner way to do
this would be great. Thanks
my($sec,$min,$hour,$mday,$mon);
($sec,$min,$hour,$mday,$mon)=localtime;
You can declare and assign the variables in the same expression:
my ($sec,$min,$hour,$mday,$mon) = localtime;

if ( $hour =~ /^(08:|09:|10:|11:|12:|13:|14:|15:|16:|17:)/){
What made you think that $hour would contain a string with a trailing
colon character?
You can simply do:
if ( $hour >= 8 and $hour < 17 ) {
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: security on a html page with perl.

2004-08-24 Thread Jose Alves de Castro
On Tue, 2004-08-24 at 15:22, Chris Devers wrote:
> On Tue, 24 Aug 2004, Joe Echavarria wrote:
> 
> >  After a user fill out a form and submit it a perl
> > script takes the user to a download page of my
> > website.  how can i prevent a user from directly
> > access the download page using the web browser.., for
> > example http://www.mydomain.com/download_page.html, i
> > only want the user to able to download the file if
> > he/she fill out and submit the form.
> >
> >  Any help on how to do that ?
> 
> Users can *always* get around such barriers, so don't get your hopes up 
> that it will be perfect.
> 
> That said, you can make it harder, but not impossible, to get to the 
> download page without filling out the form first.
> 
> The obvious way I can think of to do this is to make the download page a 
> script that checks to see that:
> 
>* mandatory form fields are defined as input for the download script
>* the referring page is your original form (this one is probably less
>  important than the previous criteria, if you think about it)
> 
> If these are not verified, send the user back to the form with a note 
> saying that fields X, Y, and Z still need to be filled out.

This gave me an idea... one could have a hidden field in that form :-)

This way, you could know if the user came from a form with that field or
not (note: "if the user came from a form with that field", not if the
user came from that form). Then you can point him to the right address
:-)

> If these are verified -- or, more to the point, if the form fields you 
> need are verified -- then that's about as good as forcing the user to 
> have visited the first page to begin with.
> 
> 
> -- 
> Chris Devers
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Tim McGeary
Jose Alves de Castro wrote:
On Tue, 2004-08-24 at 15:16, Tim McGeary wrote:
Jose Alves de Castro wrote:
On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:

I need to pull out articles "a", "an", and "the" from the beginning of 
title strings so that they sort properly in MySQL.  What is the best way 
to accomplish that if I have a single $scalar with the whole title in it?

I would go with substitutions:
$scalar =~ s/^(?:a|an|the)//i;
So that I am understanding this process, what does each part mean?  I 
assume that the ^ means beginning of the variable... is that correct? 
What about "(?:" ?

The ^ means the beginning of the string in $scalar, indeed.
As for the rest, I decided to group "a", "an" and "the" with brackets,
or otherwise the regex would have been /^a|^an|^the/
Regarding the :? , that's just so variable $1 doesn't end up with
whatever was removed, as there was no need for that.
Search for "Non-capturing groupings" under perldoc perlretut, if you
need more information
Great!  Thank you very much!  :)
Tim
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Jose Alves de Castro
On Tue, 2004-08-24 at 15:16, Tim McGeary wrote:
> Jose Alves de Castro wrote:
> > On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
> > 
> >>I need to pull out articles "a", "an", and "the" from the beginning of 
> >>title strings so that they sort properly in MySQL.  What is the best way 
> >>to accomplish that if I have a single $scalar with the whole title in it?
> > 
> > 
> > I would go with substitutions:
> > 
> > $scalar =~ s/^(?:a|an|the)//i;
> 
> So that I am understanding this process, what does each part mean?  I 
> assume that the ^ means beginning of the variable... is that correct? 
> What about "(?:" ?

The ^ means the beginning of the string in $scalar, indeed.

As for the rest, I decided to group "a", "an" and "the" with brackets,
or otherwise the regex would have been /^a|^an|^the/

Regarding the :? , that's just so variable $1 doesn't end up with
whatever was removed, as there was no need for that.

Search for "Non-capturing groupings" under perldoc perlretut, if you
need more information

> tyia,
> Tim

HTH, :-)

jac

-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


Re: security on a html page with perl.

2004-08-24 Thread Chris Devers
On Tue, 24 Aug 2004, Joe Echavarria wrote:
 After a user fill out a form and submit it a perl
script takes the user to a download page of my
website.  how can i prevent a user from directly
access the download page using the web browser.., for
example http://www.mydomain.com/download_page.html, i
only want the user to able to download the file if
he/she fill out and submit the form.
 Any help on how to do that ?
Users can *always* get around such barriers, so don't get your hopes up 
that it will be perfect.

That said, you can make it harder, but not impossible, to get to the 
download page without filling out the form first.

The obvious way I can think of to do this is to make the download page a 
script that checks to see that:

  * mandatory form fields are defined as input for the download script
  * the referring page is your original form (this one is probably less
important than the previous criteria, if you think about it)
If these are not verified, send the user back to the form with a note 
saying that fields X, Y, and Z still need to be filled out.

If these are verified -- or, more to the point, if the form fields you 
need are verified -- then that's about as good as forcing the user to 
have visited the first page to begin with.

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



Re: Between times

2004-08-24 Thread Jose Alves de Castro
On Tue, 2004-08-24 at 14:49, rmck wrote:
> Hello,

Hi

> I have a script that I want to print only if between 08:00 and 17:00. Would I match 
> every hour then print?? Any cleaner way to do this would be great. Thanks
> 
> my($sec,$min,$hour,$mday,$mon);
> ($sec,$min,$hour,$mday,$mon)=localtime;

I would change this to

my ($sec,$min,$hour,$mday,$mon) = localtime;

> $timestamp=sprintf("%3s %02d %02d:%02d:%02d",$Month[$mon],$mday,$hour,$min,$sec);
>  
> my $pidstring="pid(".$$."),";
>  
> while(){
>   $line = $_;
>   if($line=~/OK/){
> open( OKLIST,">>/var/log/log.ok");
> print OKLIST $timestamp,":",$pidstring,$line;
> close(OKLIST);
>   }else{
> 
> if ( $hour =~ /^(08:|09:|10:|11:|12:|13:|14:|15:|16:|17:)/){

if ($hour > 7 and $hour < 18){

that would do the trick

> open( ERRLIST,">>/var/log/err.ok");
> print ERRLIST $timestamp,":",$pidstring,$line;
> close(ERRLIST);
> chomp($line);
>  }
>   }
> }
> exit;
> 
> 
> 
> rob
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


Re: searching a whole array without using a loop

2004-08-24 Thread Gunnar Hjalmarsson
Darren Birkett wrote:
I just want to match certain keyword(s) to determine device type.
I guess a for loop is the closest I'm going to get.  I just thought
there would be a specific function for this.
Isn't grep() "specific" enough?
Initially you said:
$line = join(' ',@myarray);
if ($line =~ /my string/) {
some code
}
The equivalent using grep() would be:
if ( grep /my string/, @myarray ) {
some code
}
So then I wonder - which is more efficient.  My earlier "join"
example, or a for loop?
To get the answer to such a question, do a benchmark with help of the
Benchmark module.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Tim McGeary
Jose Alves de Castro wrote:
On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
I need to pull out articles "a", "an", and "the" from the beginning of 
title strings so that they sort properly in MySQL.  What is the best way 
to accomplish that if I have a single $scalar with the whole title in it?

I would go with substitutions:
$scalar =~ s/^(?:a|an|the)//i;
So that I am understanding this process, what does each part mean?  I 
assume that the ^ means beginning of the variable... is that correct? 
What about "(?:" ?

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



Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Jose Alves de Castro
On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
> I need to pull out articles "a", "an", and "the" from the beginning of 
> title strings so that they sort properly in MySQL.  What is the best way 
> to accomplish that if I have a single $scalar with the whole title in it?

I would go with substitutions:

$scalar =~ s/^(?:a|an|the)//i;

> Thanks,
> Tim
> 
> -- 
> Tim McGeary
> [EMAIL PROTECTED]
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


Re: pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Jose Alves de Castro
On Tue, 2004-08-24 at 15:04, Tim McGeary wrote:
> I need to pull out articles "a", "an", and "the" from the beginning of 
> title strings so that they sort properly in MySQL.  What is the best way 
> to accomplish that if I have a single $scalar with the whole title in it?

I would go with substitutions:

$scalar =~ s/^(?:a|an|the)//i;

> Thanks,
> Tim
> 
> -- 
> Tim McGeary
> [EMAIL PROTECTED]
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


security on a html page with perl.

2004-08-24 Thread Joe Echavarria
Hi there, 

  After a user fill out a form and submit it a perl
script takes the user to a download page of my
website.  how can i prevent a user from directly
access the download page using the web browser.., for
example http://www.mydomain.com/download_page.html, i
only want the user to able to download the file if
he/she fill out and submit the form.

  Any help on how to do that ?



__
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo 

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




RE: Appending array from HoA elements into one single array

2004-08-24 Thread Charles K. Clarkson
From: Edward WIJAYA  wrote:

: Suppose I have this Hash of array:
: 
: %HoA = {
: A => ["fred", "barney"],
: B => ["george", "jane", "elroy"],
: };

I'll assume you mean a hash like this. Note
the use of parenthesis instead of braces.

my %HoA = (
A => [ qw( fred barney ) ],
B => [ qw( george jane elroy ) ],
);

 
: Is there any efficient way to append
: each of this HoA's array into one
: single array, e.g:
: 
: @name = ("fred", "barney", "george", "jane", "elroy");

use Data::Dumper 'Dumper';

my %HoA = (
A => [ qw( fred barney ) ],
B => [ qw( george jane elroy ) ],
);


#Order doesn't matter

my @names;
push @names, @$_ foreach values %HoA;
print Dumper [EMAIL PROTECTED];


#   Or if order matters

# with sort
@names = ();
push @names, @{ $HoA{ $_ } } foreach sort keys %HoA;
print Dumper [EMAIL PROTECTED];

# with hash slice
@names = ();
push @names, @$_ foreach @HoA{ qw( B A ) };
print Dumper [EMAIL PROTECTED];

__END__


HTH,

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


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




pulling out "a","an", "the" from beginning of strings

2004-08-24 Thread Tim McGeary
I need to pull out articles "a", "an", and "the" from the beginning of 
title strings so that they sort properly in MySQL.  What is the best way 
to accomplish that if I have a single $scalar with the whole title in it?

Thanks,
Tim
--
Tim McGeary
[EMAIL PROTECTED]

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



Re: searching a whole array without using a loop

2004-08-24 Thread Darren Birkett
[EMAIL PROTECTED] (John W. Krahn) wrote in
news:[EMAIL PROTECTED]: 


> 
> If all the elements are unique then use a hash.
> 
> if ( exists $hash{ 'my string' } ) {
>  # do something
>  }
> 
> 
> The most efficient way to determine if an element exists in an array
> is to use a for loop and exit early:
> 
> my $found = 0;
> for ( @array ) {
>  if ( $_ eq 'my string' ) {
>  $found = 1;
>  last;
>  }
>  }
> 
> 
> If you need to determine the number of matches you can use grep:
> 
> my $count = grep $_ eq 'my string', @array;
> 
> 
> 
> John

OK, to be more specific, I'm using Net::Telnet:Cisco.  When logged onto 
a device I'm using the "show version" command, and storing the output in 
an array.  Each element of the array will therefore contain lots of 
rubbish.  I just want to match certain keyword(s) to determine device 
type.  I guess a for loop is the closest I'm going to get.  I just 
thought there would be a specific function for this.
So then I wonder - which is more efficient.  My earlier "join" example, 
or a for loop?

Thanks for all the input
Darren


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




Between times

2004-08-24 Thread rmck
Hello,

I have a script that I want to print only if between 08:00 and 17:00. Would I match 
every hour then print?? Any cleaner way to do this would be great. Thanks

my($sec,$min,$hour,$mday,$mon);
($sec,$min,$hour,$mday,$mon)=localtime;
$timestamp=sprintf("%3s %02d %02d:%02d:%02d",$Month[$mon],$mday,$hour,$min,$sec);
 
my $pidstring="pid(".$$."),";
 
while(){
  $line = $_;
  if($line=~/OK/){
open( OKLIST,">>/var/log/log.ok");
print OKLIST $timestamp,":",$pidstring,$line;
close(OKLIST);
  }else{

if ( $hour =~ /^(08:|09:|10:|11:|12:|13:|14:|15:|16:|17:)/){
open( ERRLIST,">>/var/log/err.ok");
print ERRLIST $timestamp,":",$pidstring,$line;
close(ERRLIST);
chomp($line);
 }
  }
}
exit;



rob


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




Appending array from HoA elements into one single array

2004-08-24 Thread Edward WIJAYA
Hi,
Suppose I have this Hash of array:
%HoA = {
   A => ["fred", "barney"],
   B => ["george", "jane", "elroy"],
};
Is there any efficient way to append
each of this HoA's array into one
single array, e.g:
@name = ("fred", "barney", "george", "jane", "elroy");
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: how to print pdf files to particular printer like LASER in windows

2004-08-24 Thread Chris Devers
On Tue, 24 Aug 2004, R.MURUGAVEL wrote:
Good morning All!
I am new to this group, I have one problem that is how
to print pdf files to the particular printer installed
our system/network systems.
If any one helps me a very great help for me urgent
Pl?
Does this have something to do with Perl programming?
You may have come to the wrong place, but it's hard to tell.
It sounds like you need to talk to your sysadmins to find out how to 
print to particular printers. Once you know the command to use, you 
should be able to wrap it in a system command in a Perl script.

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



how to print pdf files to particular printer like LASER in windows

2004-08-24 Thread R.MURUGAVEL
Hi,

Good morning All!

I am new to this group, I have one problem that is how
to print pdf files to the particular printer installed
our system/network systems.

If any one helps me a very great help for me urgent
Pl?

Regards

Murugavel R



__
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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




Re: seek help!!

2004-08-24 Thread Chris Devers
On Tue, 24 Aug 2004, Puppala, Satheesh Kumar (Satheesh)** CTR ** wrote:
Can anybody help me to convert XML document into MS-DOC file in 
Solaris enviornment using perl.
This isn't a free script writing service.
Please share with the list what you have tried so far, as well as what 
the XML data you're starting with is like and what format (do you mean 
Word Documents?) you're trying to end up with.

Demonstrate that you've tried to solve this on your own and people on 
mailing lists will be more willing to lend you a hand.

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



Re: PERL and Mobile Devices.

2004-08-24 Thread Jose Alves de Castro
I know this is old stuff, but it might be interesting to some of you

On Fri, 2004-08-13 at 14:33, James Edward Gray II wrote:
> On Aug 10, 2004, at 3:35 PM, JupiterHost.Net wrote:
> 
> > I remember hearing some cell phones had perl and maybe PDA's???
> 
> Really?  I would be very interested to know what cell phone that is...

The Nokia 6600, apparently

http://www.mobilewhack.com/programming/perl/perl_on_nokia_at_foo.html


> Perl has a pretty big overhead compared to what mobile devices offer.  
> I've seen ports for Windows CE and the Sharp Zaurus, but I wasn't aware 
> of any others.
> 
> James
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


Re: Regex problems

2004-08-24 Thread John W. Krahn
me wrote:
Hello all,
Hello,
I have been beating my head against the wall for a
while trying to extract some data.
Here is the following data:

===
Data 1: data1
Data 2: data2
Data 3: data3
Data 4: data4
Data 5:
data5 data5 data5 data5 
data5 data5 data5 data5 
data5 data5 data5 data5 



My goal is to put all data after each colon into a
variable.
I don't have any problem with Data 1 through Data 4. 
My problem is when I get to Data 5:, I can't figure
out how to put the data into a variable.
I can think of three ways to do it.
Method one:
my @data;
while (  ) {
if ( /:\s*(.*)/ ) {
push @data, $1;
}
else {
$data[ -1 ] .= $_;
}
}
Method two:
my @data;
$/ = ':';
while (  ) {
s/.*://;
s/^\s+//;
s/\s+$//;
next unless length;
push @data, $_;
}
Method three:
local $/;
my @data = map /^[^:]*:\s*([^:]+)$/gm, ;

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: seek help!!

2004-08-24 Thread Gunnar Hjalmarsson
Satheesh Kumar ** CTR ** Puppala wrote:
Can anybody help me to convert XML document into MS-DOC file in
Solaris enviornment using perl.
http://search.cpan.org/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



seek help!!

2004-08-24 Thread Puppala, Satheesh Kumar (Satheesh)** CTR **
Hai all,

Can anybody help me to convert XML document into MS-DOC file in Solaris
enviornment using perl.

your inputs help me in agreat way

thanks in advance

satish

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




Re: Recording Ping responses in perl part 2

2004-08-24 Thread Ben Crane
Prasanna Kothari,

Excellent, I've seen the mistake I made with my
program now thanx to yours! Cheers.

One more thing, Is there any module that allows you to
log network errors whilst the program is pinging??

Thanx
Ben



___
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

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