Re: Send both parts of a multipart email

2008-08-25 Thread Jeff Pang
Outlook has great features to be combined with MS's Exchange.
Outlook Express is just an email client, which even can't support IMAP protocal.
I once worked on email systems, had dozens of accounts set up in my OE,:)

--
Jeff Pang
- using one of my 1000+ email accts




> Message du 26/08/08 07:26
> De : "Rob Dixon" 
> A : "Perl Beginners" 
> Copie à : "Dr.Ruud" 
> Objet : Re: Send both parts of a multipart email
>
> 
> Dr.Ruud wrote:
> > Rob Dixon schreef:
> > 
> >> - Outlook is many years old, and even the email client on Vista is
> >> better.
> > 
> > I guess you are mixing up Outlook and Outlook Express there. 
> 



 Créez votre adresse électronique [EMAIL PROTECTED] 
 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.


Re: Send both parts of a multipart email

2008-08-25 Thread Rob Dixon
Dr.Ruud wrote:
> Rob Dixon schreef:
> 
>> - Outlook is many years old, and even the email client on Vista is
>>   better.
> 
> I guess you are mixing up Outlook and Outlook Express there. 

No I understand the difference. Outlook first came out in 1997 and has been
tweaked almost annually ever since. I think the latest version was a couple of
years ago, but it suffers from classic Microsoft over-burdening with exotic
facilities and lack of flexibility. I still prefer the email client that comes
with Vista.

Rob

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




RE: How to compress an exe file?

2008-08-25 Thread sanket vaidya


Hi Raymond,
Thanx a lot for suggestion.

-Original Message-
From: Raymond Wan [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 25, 2008 11:21 AM
To: sanket vaidya
Cc: beginners@perl.org
Subject: Re: How to compress an exe file?


Hi Sanket,

sanket vaidya wrote:
> I have made an exe using PAR::Packer. Now I want to reduce the
> size of exe. Can anyone suggest me how to do that?
>   


Using Perl?  Perl aside, executables are generally not 
compressible...or, to be precise, not compressible by much.  While you 
might save a couple of percents, it probably won't give you much savings. 

Give gzip, bzip2, etc. a try (or their equivalent on Windows/Mac) and if 
they work, see if there is a Perl library that does it.  There is one 
for gzip, but I have a feeling that gzip will make the file 
larger...just a guess.  Better to try it on the command-line before you 
use time to make it work in Perl.

Ray



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


http://www.patni.com
World-Wide Partnerships. World-Class Solutions. 
_ 

This e-mail message may contain proprietary, confidential or legally privileged 
information for the sole use of the person or entity to whom this message was 
originally addressed. Any review, e-transmission dissemination or other use of 
or taking of any action in reliance upon this information by persons or 
entities other than the intended recipient is prohibited. If you have received 
this e-mail in error kindly delete this e-mail from your records. If it appears 
that this mail has been forwarded to you without proper authority, please 
notify us immediately at [EMAIL PROTECTED] and delete this mail.
_

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




Re: Send both parts of a multipart email

2008-08-25 Thread Dr.Ruud
Rob Dixon schreef:

> - Outlook is many years old, and even the email client on Vista is
>   better.

I guess you are mixing up Outlook and Outlook Express there. 

-- 
Affijn, Ruud

"Gewoon is een tijger."

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




Re: Decrementing Characters

2008-08-25 Thread Jenda Krynicky
From: "Jeff Westman" <[EMAIL PROTECTED]>
> Simple question here.  I need to decrement a character "counter".
> Incementing works fine, but not decrementing.
> 
> I have:
> 
>  #!/bin/perl
> use warnings;
> $var = 'm';
> 
> print "var was $var\n";
> $var++;
> print "var was $var\n";
> --$var;
> print "var is $var\n";
> 
> 
> And I get:
> 
> 0: rc-hp18:/home/dnxjjw5/dev
> $ x2.pl
> var was m
> var was n
> var is -1
> 
> I expected to see "var is m" in the last line.

++ is magical enough, -- is not. But if it's a single character you 
can use ord() and chr().

$var = chr(ord($var)-1)

not as nice, I agree.

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]
http://learn.perl.org/




Decrementing Characters

2008-08-25 Thread Jeff Westman
Hi,

Simple question here.  I need to decrement a character "counter".
Incementing works fine, but not decrementing.

I have:

 #!/bin/perl
use warnings;
$var = 'm';

print "var was $var\n";
$var++;
print "var was $var\n";
--$var;
print "var is $var\n";


And I get:

0: rc-hp18:/home/dnxjjw5/dev
$ x2.pl
var was m
var was n
var is -1

I expected to see "var is m" in the last line.

I know this is trivial, but I can't seem to see it.



Thanks in advance!!


Jeff


Re: Send both parts of a multipart email

2008-08-25 Thread Rob Dixon
David Allender wrote:
> 
> Thanks all, I think I have came up with a conclusion.
>
> I think I would just send the HTML as an attachment, but is there a way for
> me to do it in the cgi without having to put a ?
>
> Also, I dont believe I can use a module, so that would be sort of a 
> hindrance.
>
> Well if that doesn't work, can someone please try explaining me the 
> HTML tag?
>
> The email client we use is outlook, so it will only be able to display one
> type of content type in the email.
>
> So, I just hope the  tags will work or possibly attaching an email
> through the cgi without the html (input typ=file) form.

So what was the conclusion?!

- What has your question to do with CGI?

- I would be very surprised if you have to write entirely in native and built-in
  Perl. I couldn't send an email at all under those circumstances without a lot
  of work

- The behaviour of the  tag is very loosely defined. RFC 1866 says this

> The  element represents a character cell block of text and is
> suitable for text that has been formatted for a monospaced font.

  In general it simply preserves whitespace, and is rendered in a monospaced
  font

- Outlook is many years old, and even the email client on Vista is better. If
  you have any control over what people use then choose something better

-  tags may work. I don't think you've told us what you want to do, apart
  from sending the same data in both text and HTML in a single mail

Rob

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




Perl and "vi" (not "vim") , ctags like feature in Perl !

2008-08-25 Thread Amit Saxena
Hi all,


   - I am using Perl 5.8.4 and "vi" (not "vim") on Solaris 9.


While developing my Perl programs, I have to open two sessions one for my
"vi" session and another where I run my perl programs. Moreover, in some
scenarios, I have to open a sqlplus session to access Oracle 10g. Shifting
between the sessions is tough sometimes.

Is there a possibility where I can customize "vi" for some shortcuts for at
least running Perl programs or accessing sqlplus session ?



   - Is there a ctags like facility for Perl as well ?


Thanks & Regards,
Amit Saxena


Re: "use constant" as hash key

2008-08-25 Thread Xavier Mas
El Monday 25 August 2008 14:30:14 Moon, John va escriure:
> > How can I use a "constant" as a hash key?
> >
> > $ perl -e 'use constant CAT=>A;
> >
> >> $hash{CAT} = q{Bobby};
> >> $hash{"CAT"} = q{Muffy};
> >> $hash{'CAT'} = q{Fluffy};
> >> $hash{qq{CAT}} = q{Tuffy};
> >> print "$_ = $hash{$_}\n" foreach (keys %hash);'
> >
> > CAT = Tuffy
> > $
> >
> > Want...
> >
> > A=Bobby
>
> See the "Not-so-symbolic references" section of the perlref.pod man page
>
> for some hints:
>
> perldoc perlref
>
>
>
> 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
>
>
> [>>] Thank you...
>
> >>perl -we 'use constant CAT=>a; $hash{+CAT} = q{Bobby}; print "$_ =
>
> $hash{$_}\n" foreach (keys %hash);'
>
> jwm

key must be always unique.

-- 
Xavier Mas


__ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com


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




Re: code to fetch, configure, and build two library packages - can it be better?

2008-08-25 Thread yitzle
On Sun, Aug 24, 2008 at 9:29 AM, Ed <[EMAIL PROTECTED]> wrote:
> On Aug 21, 8:32 am, [EMAIL PROTECTED] (Yitzle) wrote:
>> On Wed, Aug 20, 2008 at 7:37 AM, Ed <[EMAIL PROTECTED]> wrote:
>> I might be way off here, but wouldn't it make sense to use the CPAN
>> package to do package installation?
>
> Good idea, but I need this to run on a bunch of different machines.
> They all have standard perl, but not any CPAN modules...
>
> Thanks anyway,
>
> Ed

CPAN is a core module, so any Perl installation (after a certain
version) would have CPAN packages.
See http://perldoc.perl.org/index-modules-C.html

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




Re: Send both parts of a multipart email

2008-08-25 Thread David Allender
On Aug 23, 12:53 am, [EMAIL PROTECTED] (Dr.Ruud) wrote:
> David Allender schreef:
>
> > I was wondering if i can send both parts of a multipart email.
> > Basically what im trying to do is,
>
> > send an email to a person with text/enriched text at the top of the
> > email, and text/html at the bottom of the email.  The reason being is
> > so:  Its a cgi that handles a form, and i need it to be text/enriched
> > above because i want to keep the formatting of what the user inputs in
> > the form, while keeping the ability to make the words bold, etc.  and
> > i need the email part because i am basically appending an html file to
> > the bottom.
> > The client needs to see both of them in the email.
>
> Is it OK for the second part, the html part, to appear as an attachment?
> If not, then I would use one part, only HTML (use  to preserve the
> formatting).
>
> See alsohttp://en.wikipedia.org/wiki/MIME
>
> Some mail clients will show all the parts together, and some wont.
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."

Thanks all, I think I have came up with a conclusion.  I think I would
just send the HTML as an attachment, but is there a way for me to do
it in the cgi without having to put a ?  Also, I
dont believe I can use a module, so that would be sort of a
hindrance.  Well if that doesn't work, can someone please try
explaining me the  HTML tag?  The email client we use is outlook,
so it will only be able to display one type of content type in the
email.  So, I just hope the  tags will work or possibly attaching
an email through the cgi without the html (input typ=file) form.


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




Re: What wrong with this code

2008-08-25 Thread John W. Krahn

Anirban Adhikary wrote:


On Mon, Aug 25, 2008 at 5:34 PM, John W. Krahn <[EMAIL PROTECTED]> wrote:


The usual way to do what you want is to use a hash:

use strict;
use warnings;

print "Enter the Absolutepath of the file\t";
chomp( my $filename =  );

open my $FH, '<', $filename or die "Cannot open '$filename' $!";

my %seen;
while ( <$FH> ) {
   unless ( $seen{ $_ }++ ) {
   print;
   }
   }

__END__


Thanks a lot John . I have a little question can u please dexcribe in detail
what this line is doing actually
 unless ( $seen{ $_ }++ )


$_ contains the current line from the file.  ++ is the postfix 
auto-increment operator.  The hash %seen contains the line from the file 
as the key and the number of times the line was "seen" as the value. 
The value of $seen{$_} is tested to see if it is true or false and after 
it is tested the value is incremented so if a line is not already in the 
hash the value will be false (undef) and that line will be printed.




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: "use constant" as hash key

2008-08-25 Thread Moon, John
> How can I use a "constant" as a hash key?
> 
> $ perl -e 'use constant CAT=>A;
>> $hash{CAT} = q{Bobby};
>> $hash{"CAT"} = q{Muffy};
>> $hash{'CAT'} = q{Fluffy};
>> $hash{qq{CAT}} = q{Tuffy};
>> print "$_ = $hash{$_}\n" foreach (keys %hash);'
> CAT = Tuffy
> $
> 
> Want...
> 
> A=Bobby

See the "Not-so-symbolic references" section of the perlref.pod man page

for some hints:

perldoc perlref



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


[>>] Thank you... 

>>perl -we 'use constant CAT=>a; $hash{+CAT} = q{Bobby}; print "$_ =
$hash{$_}\n" foreach (keys %hash);'

jwm

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




Re: code to fetch, configure, and build two library packages - can it be better?

2008-08-25 Thread Ed
On Aug 21, 8:32 am, [EMAIL PROTECTED] (Yitzle) wrote:
> On Wed, Aug 20, 2008 at 7:37 AM, Ed <[EMAIL PROTECTED]> wrote:
> > Howdy all!
>
> > As part of a test script, I have to make sure my test machine (i.e.
> > the machine that is running the script) has libraries zlib and hdf5. I
> > do that with this code. Is there a better way?
>
> [snip]
>
> > Any comments appreciated!
>
> > Thanks,
>
> > Ed
>
> I might be way off here, but wouldn't it make sense to use the CPAN
> package to do package installation?

Good idea, but I need this to run on a bunch of different machines.
They all have standard perl, but not any CPAN modules...

Thanks anyway,

Ed


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




Re: What wrong with this code

2008-08-25 Thread Anirban Adhikary
Thanks a lot John . I have a little question can u please dexcribe in detail
what this line is doing actually
 unless ( $seen{ $_ }++ )

Thanks & regards in advance
Anirban Adhikary

On Mon, Aug 25, 2008 at 5:34 PM, John W. Krahn <[EMAIL PROTECTED]> wrote:

> Anirban Adhikary wrote:
>
>> Dear List
>> I have write the The following code to check a file and print only
>> distinct
>> lines to a new file and skips the duplicate lines. My source file is as
>> follows
>>
>> hello how are you?
>> hello how are you?
>> What language did you want to use?
>> What language did you want to use?
>> I am here
>> You are there
>> this is my first perl script
>> What language did you want to use?
>>
>>
>> ###
>> my code is as follows
>>
>>
>> #use strict;
>> #use warnings;
>>
>> print "Enter the Absolutepath of the file\t";
>> my $input=;
>> chomp($input);
>>
>> dup($input);
>>
>> sub dup
>> {
>>  my $filename=shift;
>>  my $count=0;
>>  my @arr;
>>  my $el;
>>  my $element;
>>  open(FH,"$filename");
>>  while()
>>{
>>  chomp($_);
>>  $element = $_;
>>  if($count ==0)
>>   {
>> push(@arr,$element);
>> $count+=1;
>> print "Count is $count\n";
>>   }
>>  else
>>   {
>> foreach $el(@arr)
>>  {
>>my $len=$#arr;
>>chomp($el);
>>   # print "$element\n";
>>#print "The length of arr is $len\n";
>>if($el ==  $element)
>> {
>>   print "\t##Inside If##\t\n";
>>   print $element."\n";
>>   next;
>>   #push(@arr,$_);
>> }
>>
>>elsif($el != $element)
>> {
>>   push(@arr,$element);
>>   print "\tInside Elseif\n";
>>   #next;
>> }
>>  }
>>   }
>>  }
>>
>> ###
>> The problems I am facing are
>>
>> 1) The code is not getting entered into elsif block
>>
>> 2) I am comparing between 2 strings but if I use "eq" or "ne"  for
>> comparison I am getting some horrible output so I am using numeric
>> comparison.
>>
>> 3)If I am giving print the $element variable outside foreach loop it is
>> getting printed but Inside foreach loop it is not showing anything.
>>
>> Can anybody Please suggest me where I am making the mistake?
>>
>
> The usual way to do what you want is to use a hash:
>
> use strict;
> use warnings;
>
> print "Enter the Absolutepath of the file\t";
> chomp( my $filename =  );
>
> open my $FH, '<', $filename or die "Cannot open '$filename' $!";
>
> my %seen;
> while ( <$FH> ) {
>unless ( $seen{ $_ }++ ) {
>print;
>}
>}
>
> __END__
>
>
>
>
> 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/
>
>
>


XPUSHs

2008-08-25 Thread Patrick Dupre

Hello,

I need to make a XPUSHs of a referene on an array, but XPUSHs takes only
scalar, so it looks like that I need convert my AV* into a scalar
with a newSV, but I do not know exactly.
Can I have some help ?

Regards

--
---
==
 Patrick DUPRÉ  |   |
 Department of Chemistry|   |Phone: (44)-(0)-1904-434384
 The University of York |   |Fax:   (44)-(0)-1904-432516
 Heslington |   |
 York YO10 5DD  United Kingdom  |   |email: [EMAIL PROTECTED]
==
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Re: What wrong with this code

2008-08-25 Thread John W. Krahn

Anirban Adhikary wrote:

Dear List
I have write the The following code to check a file and print only distinct
lines to a new file and skips the duplicate lines. My source file is as
follows

hello how are you?
hello how are you?
What language did you want to use?
What language did you want to use?
I am here
You are there
this is my first perl script
What language did you want to use?

###
my code is as follows


#use strict;
#use warnings;

print "Enter the Absolutepath of the file\t";
my $input=;
chomp($input);

dup($input);

sub dup
{
  my $filename=shift;
  my $count=0;
  my @arr;
  my $el;
  my $element;
  open(FH,"$filename");
  while()
{
  chomp($_);
  $element = $_;
  if($count ==0)
   {
 push(@arr,$element);
 $count+=1;
 print "Count is $count\n";
   }
  else
   {
 foreach $el(@arr)
  {
my $len=$#arr;
chomp($el);
   # print "$element\n";
#print "The length of arr is $len\n";
if($el ==  $element)
 {
   print "\t##Inside If##\t\n";
   print $element."\n";
   next;
   #push(@arr,$_);
 }

elsif($el != $element)
 {
   push(@arr,$element);
   print "\tInside Elseif\n";
   #next;
 }
  }
   }
 }

###
The problems I am facing are

1) The code is not getting entered into elsif block

2) I am comparing between 2 strings but if I use "eq" or "ne"  for
comparison I am getting some horrible output so I am using numeric
comparison.

3)If I am giving print the $element variable outside foreach loop it is
getting printed but Inside foreach loop it is not showing anything.

Can anybody Please suggest me where I am making the mistake?


The usual way to do what you want is to use a hash:

use strict;
use warnings;

print "Enter the Absolutepath of the file\t";
chomp( my $filename =  );

open my $FH, '<', $filename or die "Cannot open '$filename' $!";

my %seen;
while ( <$FH> ) {
unless ( $seen{ $_ }++ ) {
print;
}
}

__END__




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: What wrong with this code

2008-08-25 Thread Rob Dixon
Anirban Adhikary wrote:
> Dear List
> I have write the The following code to check a file and print only distinct
> lines to a new file and skips the duplicate lines. My source file is as
> follows
> 
> hello how are you?
> hello how are you?
> What language did you want to use?
> What language did you want to use?
> I am here
> You are there
> this is my first perl script
> What language did you want to use?
> 
> ###
> my code is as follows
> 
> 
> #use strict;
> #use warnings;

Never comment out these lines - they help enormously to find simple errors.

> print "Enter the Absolutepath of the file\t";
> my $input=;
> chomp($input);
> 
> dup($input);
> 
> sub dup
> {
>   my $filename=shift;
>   my $count=0;
>   my @arr;
>   my $el;
>   my $element;

- Variables should be declared as close as possible to their point of first use.

- Try to use meaningful variable names; the @ in @arr means 'array' so you have
something called "array arr". Also the difference between the function of $el
and $element isn't clear from their names.

>   open(FH,"$filename");
>   while()

- You must always check whether a file open succeeded.

- $filename should stand on its own. Read the perlfaq article

perldoc -q quoting

  entitled What's wrong with always quoting "$vars"?

- The three-parameter form of open and lexical file handles are preferred, like 
this

  open my $fh, '<', $filename or die $!;
  while (<$fh>) {

> {
>   chomp($_);
>   $element = $_;
>   if($count ==0)
>{
>  push(@arr,$element);
>  $count+=1;
>  print "Count is $count\n";

$count isn't a count, as it is only incremented when it is zero and never used
thereafter. You also don't need it at all, so you can remove this if statement
altogether.

>}
>   else
>{
>  foreach $el(@arr)
>   {
> my $len=$#arr;

$len is the index of the last element of @arr, not its length. Use

  my $len = @arr;

to get that.

> chomp($el);

The strings were chomped before they were added to @arr so there is no need to
do it again.

># print "$element\n";
> #print "The length of arr is $len\n";
> if($el ==  $element)

The == operator is for comparing numbers; to compare strings you must use
eq. This is why your elsif block wasn't being executed: the values are being
forced to numbers before they are compared, and since non-numeric strings
evaluate as zero they were always numerically equal.

If you had left warnings enabled you would have a message to tell you this.

>  {
>print "\t##Inside If##\t\n";
>print $element."\n";
>next;
>#push(@arr,$_);
>  }
> 
> elsif($el != $element)


There is no need to test again. If

  $el eq $element

failed, then

  $el ne $element

must succeed, and you need only an 'else' here.

>  {
>push(@arr,$element);

You shouldn't modify an array that you're currently iterating over, as the
results aren't guaranteed and anything may happen. In other words, don't write

  foreach (@arr) {
  :
push @arr, $val;
  :
  }

>print "\tInside Elseif\n";
>#next;
>  }
>   }
>}

- The braces aren't paired properly in your program. I presume an extra one
belongs here.

- You test each new line again /every/ element in @arr, and push the line onto
the array /every time/ it finds an array element that doesn't match. I assume
you want to push the new line onto the array only if none of the elements match?
Something like this perhaps

  while (my $element = <$fh>) {

chomp $element;

my $found;

foreach my $el(@arr) {
  if ($el eq $element) {
$found++;
last;
  }
}

if (not $found) {
  print "$element\n";
  push @arr,$element;
}
  }

>  }
> 
> ###
> The problems I am facing are
> 
> 1) The code is not getting entered into elsif block
> 
> 2) I am comparing between 2 strings but if I use "eq" or "ne"  for
> comparison I am getting some horrible output so I am using numeric
> comparison.
> 
> 3)If I am giving print the $element variable outside foreach loop it is
> getting printed but Inside foreach loop it is not showing anything.
> 
> Can anybody Please suggest me where I am making the mistake?

HTH,

Rob

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




Re: What wrong with this code

2008-08-25 Thread Xavier Mas
El Monday 25 August 2008 11:30:19 Anirban Adhikary va escriure:
> Dear List
> I have write the The following code to check a file and print only distinct
> lines to a new file and skips the duplicate lines. My source file is as
> follows
>
> hello how are you?
> hello how are you?
> What language did you want to use?
> What language did you want to use?
> I am here
> You are there
> this is my first perl script
> What language did you want to use?
>
> ###
> my code is as follows
>
>
> #use strict;
> #use warnings;
>
> print "Enter the Absolutepath of the file\t";
> my $input=;
> chomp($input);
>
> dup($input);
>
> sub dup
> {
>   my $filename=shift;
>   my $count=0;
>   my @arr;
>   my $el;
>   my $element;
>   open(FH,"$filename");
>   while()
> {
>   chomp($_);
>   $element = $_;
>   if($count ==0)
>{
>  push(@arr,$element);
>  $count+=1;
>  print "Count is $count\n";
>}
>   else
>{
>  foreach $el(@arr)
>   {
> my $len=$#arr;
> chomp($el);
># print "$element\n";
> #print "The length of arr is $len\n";
> if($el ==  $element)
>  {
>print "\t##Inside If##\t\n";
>print $element."\n";
>next;
>#push(@arr,$_);
>  }
>
> elsif($el != $element)
>  {
>push(@arr,$element);
>print "\tInside Elseif\n";
>#next;
>  }
>   }
>}
>  }
>
> ###
> The problems I am facing are
>
> 1) The code is not getting entered into elsif block
>
> 2) I am comparing between 2 strings but if I use "eq" or "ne"  for
> comparison I am getting some horrible output so I am using numeric
> comparison.
>
> 3)If I am giving print the $element variable outside foreach loop it is
> getting printed but Inside foreach loop it is not showing anything.
>
> Can anybody Please suggest me where I am making the mistake?
>
> Thanks & Regards in Advance
> Anirban Adhikary.

Did you try to use uniq comand from the Unix bash? I think code would be much 
easy (use exe or sytem to call the command).

Otherwise, $count always equals to zero when going into dup subroutine.

-- 
Xavier Mas


__ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y m�viles desde 1 c�ntimo por minuto. 
http://es.voice.yahoo.com


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




threads and processes with redirected STDOUT and STDERR on win32

2008-08-25 Thread Alexandru Maximciuc
Hello beginners,

  any hints on this problem?
  win32...
  I have N threads. in each thread I want to run a command and
  redirect it's STDERR and STDOUT to a filehandle/socket opened
  in the main thread. I tried with IPC::Run3 but the outputs get
  scrambled.
  

-- 
Best regards,
 Alexandru  mailto:[EMAIL PROTECTED]


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




What wrong with this code

2008-08-25 Thread Anirban Adhikary
Dear List
I have write the The following code to check a file and print only distinct
lines to a new file and skips the duplicate lines. My source file is as
follows

hello how are you?
hello how are you?
What language did you want to use?
What language did you want to use?
I am here
You are there
this is my first perl script
What language did you want to use?

###
my code is as follows


#use strict;
#use warnings;

print "Enter the Absolutepath of the file\t";
my $input=;
chomp($input);

dup($input);

sub dup
{
  my $filename=shift;
  my $count=0;
  my @arr;
  my $el;
  my $element;
  open(FH,"$filename");
  while()
{
  chomp($_);
  $element = $_;
  if($count ==0)
   {
 push(@arr,$element);
 $count+=1;
 print "Count is $count\n";
   }
  else
   {
 foreach $el(@arr)
  {
my $len=$#arr;
chomp($el);
   # print "$element\n";
#print "The length of arr is $len\n";
if($el ==  $element)
 {
   print "\t##Inside If##\t\n";
   print $element."\n";
   next;
   #push(@arr,$_);
 }

elsif($el != $element)
 {
   push(@arr,$element);
   print "\tInside Elseif\n";
   #next;
 }
  }
   }
 }

###
The problems I am facing are

1) The code is not getting entered into elsif block

2) I am comparing between 2 strings but if I use "eq" or "ne"  for
comparison I am getting some horrible output so I am using numeric
comparison.

3)If I am giving print the $element variable outside foreach loop it is
getting printed but Inside foreach loop it is not showing anything.

Can anybody Please suggest me where I am making the mistake?

Thanks & Regards in Advance
Anirban Adhikary.