Processing files in a directory

2008-11-10 Thread satyak...@gmail.com
Hi Everyone,

I have around 2000 files in a directory. During processing of these
files, a temp* will be created for each file and its removed after
processing that file. If the processing is unsuccessful, temp* file
still exists. Can u plz help me to write a script to automate this
process using Perl ie., when a temp* file is found (which stays for
abt 10 secs max), I hv to move that temp* file to some other folder.

Thanks in advance,
Satish


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Processing files in a directory

2008-11-10 Thread Susheel Koushik
use the PERL system command. Its a wrapper for system call on your host OS.

ex: system(mv $filename $new_location/$filename);

susheel

On Mon, Nov 10, 2008 at 4:39 PM, Susheel Koushik [EMAIL PROTECTED] wrote:

 use the PERL system command. Its a wrapper for system call on your host OS.

 ex: system(rm *.tmp);

 susheel

   On Mon, Nov 10, 2008 at 3:32 AM, [EMAIL PROTECTED] 
 [EMAIL PROTECTED] wrote:

 Hi Everyone,

 I have around 2000 files in a directory. During processing of these
 files, a temp* will be created for each file and its removed after
 processing that file. If the processing is unsuccessful, temp* file
 still exists. Can u plz help me to write a script to automate this
 process using Perl ie., when a temp* file is found (which stays for
 abt 10 secs max), I hv to move that temp* file to some other folder.

 Thanks in advance,
 Satish


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/





 --
 Susheel Koushik M
 Graduate Student
 Ira A Fulton School of Engineering
 Arizona State University




-- 
Susheel Koushik M
Graduate Student
Ira A Fulton School of Engineering
Arizona State University


Re: Processing files in a directory

2008-11-10 Thread Susheel Koushik
use the PERL system command. Its a wrapper for system call on your host OS.

ex: system(rm *.tmp);

susheel

On Mon, Nov 10, 2008 at 3:32 AM, [EMAIL PROTECTED] [EMAIL PROTECTED]wrote:

 Hi Everyone,

 I have around 2000 files in a directory. During processing of these
 files, a temp* will be created for each file and its removed after
 processing that file. If the processing is unsuccessful, temp* file
 still exists. Can u plz help me to write a script to automate this
 process using Perl ie., when a temp* file is found (which stays for
 abt 10 secs max), I hv to move that temp* file to some other folder.

 Thanks in advance,
 Satish


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/





-- 
Susheel Koushik M
Graduate Student
Ira A Fulton School of Engineering
Arizona State University


RE: email validation

2008-11-10 Thread Bob McConnell
From: Dermot
 2008/11/10 Rob Coops [EMAIL PROTECTED]:
 On Mon, Nov 10, 2008 at 11:55 AM, Anusha Krishna chand 
 [EMAIL PROTECTED] wrote:

 Hi All,
  How to validate an email id using perl regular expression
.

 ...

 As for how to actually do that... there are a lot of different ways
and
 looking at the RFC822 there are very complex email address
posibilities that
 even many of the major commercial mail servers out there will not
accept
 because they are so extremely rare that it is easier not to bother
with them
 then to try and figure out a way to match them.
 A full fletched way to match all possible types of email addresses
does as
 far as I am aware not even exist.

 In any case having a look on cpan http://search.cpan.org/ might
help
 though I think you might be better helped havign a look at the email
 procject http://emailproject.perl.org/
 
 I was sure that there was an FAQ about this that basically said you
 can't just for the reasons that Rob has said. Email addresses of all
 kinds can be valid
 
 [EMAIL PROTECTED] is a valid email address according
 to RFC822 but in practise will probably be undelivered.
 
 Formbuilder and HTML::FormFu have email validation pattern.

Linux Journal has an article about email validation with RE in PHP. It
talks about some of the corner and boundary cases in excruciating
detail. It also lists test cases. Perhaps it could be ported to Perl
without too much difficulty.

  http://www.linuxjournal.com/article/9585

Bob McConnell

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




algorithm permute

2008-11-10 Thread Sharan Basappa
Hi,

After working fine with Algorithm::Permute module for weeks now,
suddenly I seem to be getting errors.

The particular error is:
$ perl StTrAuto.pl
Can't locate Algorithm/Permute.pm in @INC (@INC contains:
/u/sharan/local/perl/perm_install/lib/perl5/site_perl .) at
StTrAuto.pl line 4.
BEGIN failed--compilation aborted at StTrAuto.pl line 4.

First few lines of code which I thought are causing the issue:
  1 #!/usr/bin/perl
  2 use warnings;
  3 use lib /u/sharan/local/perl/perm_install/lib/perl5/site_perl;
  4 use Algorithm::Permute;

The interesting thing is that I have an example code elsewhere and
that works fine.
Again, the first few lines of code from example:

#!/usr/bin/perl
use warnings;
use lib
/u/sharan/local/perl/perm_install/lib/perl5/site_perl;
use Algorithm::Permute;

my @array = (1..4);
Algorithm::Permute::permute { print @array\n } @array;
[EMAIL PROTECTED] = Algorithm::Permute::permute (@array);

Any clues

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




insert keyword

2008-11-10 Thread Sharan Basappa
Hi,

I have a string that has value delimited by space
e.g. 1 2 10 8 etc.

I need to add a keyword wherever there is a space.
I wrote a small code to try this out:

$str = one two three;
$str =~ s/\s/x /g;

In this case, I am trying to insert x where there is a space. one two
three should
become one x two x three.
But the above example results in:
nex twox three (chops off leading o char)

The interesting this is that this happens only in debug mode.
The regular output is: onex twox three

Regards

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




hash slice??

2008-11-10 Thread Travis Thornhill
Is there such a thing?
 
I'm trying to take a HoH and make a reference to a sub-part of the hash.
 
This doesn't work:
 
my %sub_hash = $main_hash{'sub_hash'};
 
I get the following error:
Reference found where even-sized list expected at ./my_buggy_program line 30.
 
Any quick tips on how to reference and assign this sub-hash?
 
Thanks,
- Travis


  

Re: hash slice??

2008-11-10 Thread Chas. Owens
On Mon, Nov 10, 2008 at 09:52, Travis Thornhill
[EMAIL PROTECTED] wrote:
 Is there such a thing?

 I'm trying to take a HoH and make a reference to a sub-part of the hash.

 This doesn't work:

 my %sub_hash = $main_hash{'sub_hash'};

 I get the following error:
 Reference found where even-sized list expected at ./my_buggy_program line 30.

 Any quick tips on how to reference and assign this sub-hash?
snip

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my %name_to_num = (
one   = 1,
two   = 2,
three = 3,
four  = 4,
five  = 5,
six   = 6
);

#get keys whose values are odd
my @keys = grep { $name_to_num{$_} % 2 } keys %name_to_num;

#make a hash of the odd keys and values with a hash slice
my %odd_name_to_num;
@[EMAIL PROTECTED] = @[EMAIL PROTECTED];

print Dumper \%name_to_num, \%odd_name_to_num;


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: hash slice??

2008-11-10 Thread Rob Coops
On Mon, Nov 10, 2008 at 3:52 PM, Travis Thornhill [EMAIL PROTECTED]
 wrote:

 Is there such a thing?

 I'm trying to take a HoH and make a reference to a sub-part of the hash.

 This doesn't work:

 my %sub_hash = $main_hash{'sub_hash'};

 I get the following error:
 Reference found where even-sized list expected at ./my_buggy_program line
 30.

 Any quick tips on how to reference and assign this sub-hash?

 Thanks,
 - Travis





Hi Travis,

The problem you are facing is that $main_hash{'sub_hash'} does not return a
hash at all but a reference. Which is exactly what perl is telling you. You
can simply tell perl that it should dereference the reference to a hash, you
could do that like this:

#!/usr/bin/perl

use warnings;
use strict;
use Data::Dumper;

my %hash = ( 1 = 'one',
 2 = 'two',
 3 = { 3.1 = 'three point one',
3.2 = 'three point two' },
 4 = 'four' );
my %hash_slice = %{$hash{3}};
print Dumper %hash_slice;
Reagrds,

Rob


Re: email validation

2008-11-10 Thread Dermot
2008/11/10 Rob Coops [EMAIL PROTECTED]:
 On Mon, Nov 10, 2008 at 11:55 AM, Anusha Krishna chand 
 [EMAIL PROTECTED] wrote:

 Hi All,
  How to validate an email id using perl regular expression .

...

 As for how to actually do that... there are a lot of different ways and
 looking at the RFC822 there are very complex email address posibilities that
 even many of the major commercial mail servers out there will not accept
 because they are so extremely rare that it is easier not to bother with them
 then to try and figure out a way to match them.
 A full fletched way to match all possible types of email addresses does as
 far as I am aware not even exist.

 In any case having a look on cpan http://search.cpan.org/ might help
 though I think you might be better helped havign a look at the email
 procject http://emailproject.perl.org/

I was sure that there was an FAQ about this that basically said you
can't just for the reasons that Rob has said. Email addresses of all
kinds can be valid

[EMAIL PROTECTED] is a valid email address according
to RFC822 but in practise will probably be undelivered.

Formbuilder and HTML::FormFu have email validation pattern.

Perhaps the better solution is to get the user to confirm the email
address in a 2nd field.

Dp.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: String concatination.

2008-11-10 Thread Taylor, Andrew (ASPIRE)
Try:

print abc${string}zyx\n;

or

print abc.$string.zyx\n;

Cheers
Andy
-Original Message-
From: Sureshkumar M (HCL Financial Services)
[mailto:[EMAIL PROTECTED] 
Sent: 10 November 2008 15:34
To: beginners@perl.org
Subject: String concatination.


Hi all,
I have a string like below.
$string=ABCD;

While printing , I have to include some extra strings in prefix and
suffix of the stringlike below...

abcABCDxyz
how do I do this.? 

actually I tried like below..
print abc$sting\xyz;
But It's not coming as like I expected(abcABCDxyz)

Capgemini is a trading name used by the Capgemini Group of companies which 
includes Capgemini UK plc, a company registered in England and Wales (number 
943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB.
This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. If you are not the intended recipient, you are not authorized 
to read, print, retain, copy, disseminate, distribute, or use this message or 
any part thereof. If you receive this message in error, please notify the 
sender immediately and delete all copies of this message.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Using perl in a Bash-script to extract IP-addresses?

2008-11-10 Thread Stewart Anderson
 
 JC Janos wrote:
  Hi,
 
 Hello,
 
  I have a file containing IP addresses  ranges, their negations, and
  comments.  E.g.,
 
  1.1.1.1  # comment A
  2.2.2.2/29   # comment B
  !3.3.3.3 # comment C
  !4.4.4.4/28  # comment D
 
  I need to extract those IPs  ranges, rearrange them into a
  comma-separated list, e.g.,
 
  1.1.1.1,2.2.2/29,!3.3.3.3,!4.4.4.4/28
 
  I've read that Perl (which I don't know yet at all) is best for
Text
  processing like this.
 
  The thing is that I need to do this from within a Bash script, and
  assign the comma-separated list to a  variable in that Bash script.
 
 $ echo $TEST
 
 $ cat yourfile.txt
  1.1.1.1  # comment A
  2.2.2.2/29   # comment B
  !3.3.3.3 # comment C
  !4.4.4.4/28  # comment D
 $ TEST=$(perl -lp0777e'$_=join,,/!?[\d.]+(?:\/\d+)?/g'
yourfile.txt);
 echo $TEST
 1.1.1.1,2.2.2.2/29,!3.3.3.3,!4.4.4.4/28
 
Here  is an example of the same thing in shell speak just do whatever
you want with.  The  ipaddy  in the loop  to purduce the  string you
require.


cat ipin.txt |while read inline 
do ipaddy=`echo $inline |awk '{print $1 } '` 
echo $ipaddy 
done



put this in ipin.txt
1.1.1.1  # comment A
2.2.2.2/29   # comment B
!3.3.3.3 # comment C
!4.4.4.4/28  # comment D

Information in this email including any attachments may be privileged, 
confidential and is intended exclusively for the addressee. The views expressed 
may not be official policy, but the personal views of the originator. If you 
have received it in error, please notify the sender by return e-mail and delete 
it from your system. You should not reproduce, distribute, store, retransmit, 
use or disclose its contents to anyone. Please note we reserve the right to 
monitor all e-mail communication through our internal and external networks. 
SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and 
are used under licence. British Sky Broadcasting Limited (Registration No. 
2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home 
Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited 
(Registration No. 2340150) are direct or indirect subsidiaries of British Sky 
Broadcasting Group plc (Registration No. 2247735). All of the companies 
mentioned in this paragraph are incorporated in England and Wales and share the 
same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: String concatination.

2008-11-10 Thread Rodrick Brown
my $string = Hello;
$string .=  World;

print Hello  . $string, \n;

On Mon, Nov 10, 2008 at 10:34 AM, Sureshkumar M (HCL Financial Services) 
[EMAIL PROTECTED] wrote:


 Hi all,



I have a string like below.



 $string=ABCD;



 While printing , I have to include some extra strings in prefix and
 suffix of the stringlike below...





 abcABCDxyz



 how do I do this.?



 actually I tried like below..



 print abc$sting\xyz;



 But It's not coming as like I expected(abcABCDxyz)



 Pls some one help me on this.







 DISCLAIMER:

 ---
 The contents of this e-mail and any attachment(s) are confidential and
 intended for the named recipient(s) only.
 It shall not attach any liability on the originator or HCL or its
 affiliates. Any views or opinions presented in
 this email are solely those of the author and may not necessarily reflect
 the opinions of HCL or its affiliates.
 Any form of reproduction, dissemination, copying, disclosure, modification,
 distribution and / or publication of
 this message without the prior written consent of the author of this e-mail
 is strictly prohibited. If you have
 received this email in error please delete it and notify the sender
 immediately. Before opening any mail and
 attachments please check them for viruses and defect.

 ---




-- 
[ Rodrick R. Brown ]
http://www.rodrickbrown.com http://www.linkedin.com/in/rodrickbrown


Re: Using perl in a Bash-script to extract IP-addresses?

2008-11-10 Thread John W. Krahn

Stewart Anderson wrote:

JC Janos wrote:


I have a file containing IP addresses  ranges, their negations, and
comments.  E.g.,

1.1.1.1  # comment A
2.2.2.2/29   # comment B
!3.3.3.3 # comment C
!4.4.4.4/28  # comment D

I need to extract those IPs  ranges, rearrange them into a
comma-separated list, e.g.,

1.1.1.1,2.2.2/29,!3.3.3.3,!4.4.4.4/28

I've read that Perl (which I don't know yet at all) is best for

Text

processing like this.

The thing is that I need to do this from within a Bash script, and
assign the comma-separated list to a  variable in that Bash script.


Here  is an example of the same thing in shell speak just do whatever
you want with.  The  ipaddy  in the loop  to purduce the  string you
require.


cat ipin.txt |while read inline 
		do ipaddy=`echo $inline |awk '{print $1 } '` 
		echo $ipaddy 
	done


Why not just:

ipaddy=`awk '{ print $1 }' ipin.txt`


But that still doesn't get you a comma-separated list.



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




String concatination.

2008-11-10 Thread Sureshkumar M (HCL Financial Services)

Hi all,

 

I have a string like below.

 

$string=ABCD;

 

While printing , I have to include some extra strings in prefix and
suffix of the stringlike below...

 

 

abcABCDxyz

 

how do I do this.? 

 

actually I tried like below..

 

print abc$sting\xyz;

 

But It's not coming as like I expected(abcABCDxyz)

 

Pls some one help me on this.

 

 



DISCLAIMER:
---
The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only. 
It shall not attach any liability on the originator or HCL or its affiliates. 
Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the 
opinions of HCL or its affiliates. 
Any form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is 
strictly prohibited. If you have 
received this email in error please delete it and notify the sender 
immediately. Before opening any mail and 
attachments please check them for viruses and defect.
---

RE: String concatination.

2008-11-10 Thread Mr. Shawn H. Corey
On Mon, 2008-11-10 at 15:52 +, Taylor, Andrew (ASPIRE) wrote:
 Try:
 
 print abc${string}zyx\n;
 
 or
 
 print abc.$string.zyx\n;
 

Also:

printf abc%sxyz\n, $string;


-- 
Just my 0.0002 million dollars worth,
  Shawn

The map is not the territory,
the dossier is not the person,
the model is not reality,
and the universe is indifferent to your beliefs.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Using perl in a Bash-script to extract IP-addresses?

2008-11-10 Thread Stewart Anderson

 From: John W. Krahn [mailto:[EMAIL PROTECTED]
 Sent: 10 November 2008 11:26
 To: Perl Beginners
 Subject: Re: Using perl in a Bash-script to extract IP-addresses?
 
 Stewart Anderson wrote:
  JC Janos wrote:
 
  I have a file containing IP addresses  ranges, their negations,
and
  comments.  E.g.,
 
1.1.1.1  # comment A
2.2.2.2/29   # comment B
!3.3.3.3 # comment C
!4.4.4.4/28  # comment D
 
  I need to extract those IPs  ranges, rearrange them into a
  comma-separated list, e.g.,
 
1.1.1.1,2.2.2/29,!3.3.3.3,!4.4.4.4/28
 
  I've read that Perl (which I don't know yet at all) is best for
  Text
  processing like this.
 
  The thing is that I need to do this from within a Bash script, and
  assign the comma-separated list to a  variable in that Bash
script.
 
  Here  is an example of the same thing in shell speak just do
whatever
  you want with.  The  ipaddy  in the loop  to purduce the  string you
  require.
 
 
  cat ipin.txt |while read inline
  do ipaddy=`echo $inline |awk '{print $1 } '`
  echo $ipaddy
  done
 
 Why not just:
 
 ipaddy=`awk '{ print $1 }' ipin.txt`
 
 
 But that still doesn't get you a comma-separated list.
 
 
 

Never said it did,  I did suggest to build  the  string in the loop  
  Here  is an example of the same thing in shell speak just do
whatever
  you want with.  The  ipaddy  in the loop  to purduce the  string you
  require.
 
:)


Information in this email including any attachments may be privileged, 
confidential and is intended exclusively for the addressee. The views expressed 
may not be official policy, but the personal views of the originator. If you 
have received it in error, please notify the sender by return e-mail and delete 
it from your system. You should not reproduce, distribute, store, retransmit, 
use or disclose its contents to anyone. Please note we reserve the right to 
monitor all e-mail communication through our internal and external networks. 
SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and 
are used under licence. British Sky Broadcasting Limited (Registration No. 
2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home 
Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited 
(Registration No. 2340150) are direct or indirect subsidiaries of British Sky 
Broadcasting Group plc (Registration No. 2247735). All of the companies 
mentioned in this paragraph are incorporated in England and Wales and share the 
same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: email validation

2008-11-10 Thread Rob Coops
On Mon, Nov 10, 2008 at 11:55 AM, Anusha Krishna chand 
[EMAIL PROTECTED] wrote:

 Hi All,
  How to validate an email id using perl regular expression .



First of all it would be nice to see what you tried so far with out that it
seems like you are simply using thsi mailing list as a way to cut corners
during a school/work assignment rather then actually being intrested in the
way the sollution works, or even being willing to bother givving it some
thought your self.

As for how to actually do that... there are a lot of different ways and
looking at the RFC822 there are very complex email address posibilities that
even many of the major commercial mail servers out there will not accept
because they are so extremely rare that it is easier not to bother with them
then to try and figure out a way to match them.
A full fletched way to match all possible types of email addresses does as
far as I am aware not even exist.

In any case having a look on cpan http://search.cpan.org/ might help
though I think you might be better helped havign a look at the email
procject http://emailproject.perl.org/

Regards,

Rob


Re: String concatination.

2008-11-10 Thread Mr. Shawn H. Corey
On Mon, 2008-11-10 at 21:04 +0530, Sureshkumar M (HCL Financial
Services) wrote:
 print abc$sting\xyz;

print abc${string}xyz;


-- 
Just my 0.0002 million dollars worth,
  Shawn

The map is not the territory,
the dossier is not the person,
the model is not reality,
and the universe is indifferent to your beliefs.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




email validation

2008-11-10 Thread Anusha Krishna chand
Hi All,
  How to validate an email id using perl regular expression .


Re: hash slice??

2008-11-10 Thread John W. Krahn

Travis Thornhill wrote:

Is there such a thing?


Yes there is.


I'm trying to take a HoH and make a reference to a sub-part of the hash.

This doesn't work:

my %sub_hash = $main_hash{'sub_hash'};

I get the following error:
Reference found where even-sized list expected at ./my_buggy_program line 30.

Any quick tips on how to reference and assign this sub-hash?


my %sub_hash;

@sub_hash{ 'sub_hash' } = @main_hash{ 'sub_hash' };


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.-- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: algorithm permute

2008-11-10 Thread Paul Lalli
On Nov 10, 9:15 am, [EMAIL PROTECTED] (Sharan Basappa) wrote:
 Hi,

 After working fine with Algorithm::Permute module for weeks now,
 suddenly I seem to be getting errors.

 The particular error is:
 $ perl StTrAuto.pl
 Can't locate Algorithm/Permute.pm in @INC (@INC contains:
 /u/sharan/local/perl/perm_install/lib/perl5/site_perl .) at
 StTrAuto.pl line 4.
 BEGIN failed--compilation aborted at StTrAuto.pl line 4.

 First few lines of code which I thought are causing the issue:
       1 #!/usr/bin/perl
       2 use warnings;
       3 use lib /u/sharan/local/perl/perm_install/lib/perl5/site_perl;
       4 use Algorithm::Permute;

 The interesting thing is that I have an example code elsewhere and
 that works fine.
 Again, the first few lines of code from example:

 #!/usr/bin/perl
 use warnings;
 use lib
 /u/sharan/local/perl/perm_install/lib/perl5/site_perl;
 use Algorithm::Permute;

 my @array = (1..4);
 Algorithm::Permute::permute { print @array\n } @array;
 [EMAIL PROTECTED] = Algorithm::Permute::permute (@array);

 Any clues


elsewhere is the problem.  Algorithm::Permute is not a built-in
module.  You have to install it manually via the CPAN on every machine
you want to use it.   Whatever machine you're currently using, you
haven't installed it - or at the very least, you haven't installed it
to /u/sharan/local/perl/perm_install/lib/perl5/site_perl.  Try
running
find / -name Permute.pm 2 /dev/null
to see where, if at all, the module is located on this system.

Paul Lalli


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: email validation

2008-11-10 Thread Rob Dixon
Anusha Krishna chand wrote:

 How to validate an email id using perl regular expression .

This should help you.

Rob


use strict;
use warnings;

use Regexp::Common 'Email::Address';

my $email_re = $RE{Email}{Address};

foreach (
'Anusha Krishna chand [EMAIL PROTECTED]',
'Rob Dixon [EMAIL PROTECTED]',
'beginners@perl.org') {

  print $1, \n if /($email_re)/;
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: hash slice??

2008-11-10 Thread Rob Dixon
Travis Thornhill wrote:

 Is there such a thing?
  
 I'm trying to take a HoH and make a reference to a sub-part of the hash.
  
 This doesn't work:
  
 my %sub_hash = $main_hash{'sub_hash'};
  
 I get the following error:
 Reference found where even-sized list expected at ./my_buggy_program line 30.
  
 Any quick tips on how to reference and assign this sub-hash?

There is certainly such a thing as a hash slice, but I think it is probably not
what you want here. A slice will let you extract multiple values from the hash
simultaneously, something like

  my @subhashes = @main_hash{'key1', 'key2', 'key3'};

and it doesn't look to me like that's what you're trying to achieve.

If you have a hash of hashes then $main_hash{'sub_hash'} is already a reference,
as the error message has told you, so you should write

  my $subhash_ref = $main_hash{'sub_hash'};

after which you can access the subsidiary hash with constructs like

  foreach my $key (keys %$subhash_ref) {
printf %s = %s\n, $key, $subhash_ref-{$key};
  }

HTH,

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Using perl in a Bash-script to extract IP-addresses?

2008-11-10 Thread Rob Dixon
John W. Krahn wrote:
 
 Why not just:
 
 ipaddy=`awk '{ print $1 }' ipin.txt`
 
 But that still doesn't get you a comma-separated list.

Erm, a Perl list?

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Help understanding why the RE does not totally work

2008-11-10 Thread Rob Dixon
Rob Dixon wrote:
 Jack Gates wrote:
 On Friday 26 September 2008 02:52:45 pm Rob Dixon wrote:
 Jack Gates wrote:
 On Friday 26 September 2008 01:20:29 pm Rob Dixon wrote:
 Jack Gates wrote:

 s!(|/)([^\!][A-Z0-9 ]+)!$1\L$2\E!g;
 or
 s/(|\/)([^!][A-Z0-9 ]+)/$1\L$2\E/g;

 The RE above captures and replaces all HTML tags with
 lowercase as desired except for any tag that has only one
 letter such as P, B or I

 It will get the /B, /P and /I

 It properly ignores the !DOCTYPE tag

 What is the correct way to write the above RE?

 HTML tag names can't contain spaces, so you want

 s|(/?)([A-Z][A-Z0-9]*)|$1\L$2|g;
 
 Thanks for the effort. Your RE does not work as well as what I
 have.

 HTML tags can contain spaces.
 You forgot about
 p id=something class=something

 No, I didn't. The tag name is 'p' and it has no spaces in it. The
 tag has two attributes named 'id' and 'class'. They don't have
 spaces in them either.

 If you prefer yours that doesn't work on tags with
 single-character names just because it happens to also modify the
 first attribute name then go ahead and use it.

 I'm pretty sure there is no simple way to change the case of a
 tag's name and all its attribute names while leaving the
 attribute values intact.

 I was not talking about the HTML tag name but the entire tag which 
 includes everything in it.

 And yes I have a RE that does exactly what I want with John's help.

 Rob, PLEASE STOP CCing ME. I am subscribed to the list.
 
 That's fine, I shall stop trying to help you altogether. You are very rude and
 don't want to accept correction.

I am posting this again for the consideration of the moderators.

This is the worst example of asking for help I have ever seen.

Jack:

- The resolution that you chose was crude and applicable only to your example

- You don't appear to understand what an HTML tag name is

- You asked and got very good free help. To expect to fine-tune the presentation
  of that help without paying a thing is pompous in the extreme

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/