Re: capturing output from c program inside of perl

2008-11-29 Thread Richard

Chas. Owens wrote:

On Sun, Nov 30, 2008 at 00:52, Richard <[EMAIL PROTECTED]> wrote:
  

i have a c program that I want to just run from perl and capture output

I would have thought

my $c_output = `/tmp/c_program`;

would get me the output of the program.

instead it prints out to the screen.

Is there way to redirect STOUT just for that line and put it back to normal?



Take a closer look at your c program.  Backticks do indeed grab
stdout, so it must be writing to stderr (or worse yet the console).
Try

my $c_output = `/tmp/c_program 2>&1`;


  

thank you guys!!

2>&1 fixed the issue..

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




Re:capturing output from c program inside of perl

2008-11-29 Thread Jeff Pang
> Message du 30/11/08 06:52
> De : "Richard"
> A : beginners@perl.org
> Copie à :
> Objet : capturing output from c program inside of perl
>
>
> i have a c program that I want to just run from perl and capture output
>
> I would have thought
>
> my $c_output = `/tmp/c_program`;
>


I was not sure what you're asking for, but the statement above really get what 
you wanted.
If you want to capture the STDERR too, could say:
my $output = `/tmp/c_program 2>&1`;

If you want to change the STDOUT temporarily, use a select.
my $old = select OTHER_FD;
some_statements;
select $old;

But, this is may not effective to a system call, since system may open an 
external shell.

--
Jeff Pang
http://home.arcor.de/pangj/

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


Re: capturing output from c program inside of perl

2008-11-29 Thread Chas. Owens
On Sun, Nov 30, 2008 at 00:52, Richard <[EMAIL PROTECTED]> wrote:
> i have a c program that I want to just run from perl and capture output
>
> I would have thought
>
> my $c_output = `/tmp/c_program`;
>
> would get me the output of the program.
>
> instead it prints out to the screen.
>
> Is there way to redirect STOUT just for that line and put it back to normal?

Take a closer look at your c program.  Backticks do indeed grab
stdout, so it must be writing to stderr (or worse yet the console).
Try

my $c_output = `/tmp/c_program 2>&1`;


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




capturing output from c program inside of perl

2008-11-29 Thread Richard

i have a c program that I want to just run from perl and capture output

I would have thought

my $c_output = `/tmp/c_program`;

would get me the output of the program.

instead it prints out to the screen.

Is there way to redirect STOUT just for that line and put it back to normal?

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





Re: system -> $variable

2008-11-29 Thread John W. Krahn

David wrote:

I am trying to get 081129 into $dayStamp.

#!/usr/bin/perl -w
use strict;
my $dayStamp;
$dayStamp = `date +\'%y%m%d\'` && die "Failure!";


You have three problems with that statement:

1) The '=' operator has higher precedence than the '&&' operator so you
   need to either enclose the assignment in parentheses or use the low
   precedence 'and' operator.

2) `date +\'%y%m%d\'` returns TRUE on success and FALSE on failure so
   using the '&&' operator means that the program will die when `date`
   worked correctly.

3) You are calling an external program to do something that Perl
   provides built-in functions for.


my $dayStamp = do {
my ( $day, $month, $year ) = ( localtime )[ 3, 4, 5 ];
sprintf '%02d%02d%02d', $year % 100, $month + 1, $day;
};



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: system -> $variable

2008-11-29 Thread Chas. Owens
On Sat, Nov 29, 2008 at 21:25, David <[EMAIL PROTECTED]> wrote:
> I am trying to get 081129 into $dayStamp.
>
> #!/usr/bin/perl -w
> use strict;
> my $dayStamp;
> $dayStamp = `date +\'%y%m%d\'` && die "Failure!";
> print "$dayStamp\n";
>
>
> My program outputs:
> Failure! at /Users/dave/perl/dateLogger01.pl line 4.
>
> I thought I did every conceivable combination of backticks and double quotes
> allowable. I'm quite stuck.
snip

Using external programs when that is not the main purpose of the
program is generally a bad idea.  Luckily the tools you need are part
of Core Perl:

#!/usr/bin/perl

use strict;
use warnings;
use POSIX qw(strftime);

#FIXME: give serious consideration to using %Y
#instead of %y, two digit years are not good
my $dayStamp = strftime "%y%m%d", localtime;
print "$dayStamp\n";


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




system -> $variable

2008-11-29 Thread David

I am trying to get 081129 into $dayStamp.

#!/usr/bin/perl -w
use strict;
my $dayStamp;
$dayStamp = `date +\'%y%m%d\'` && die "Failure!";
print "$dayStamp\n";


My program outputs:
Failure! at /Users/dave/perl/dateLogger01.pl line 4.

I thought I did every conceivable combination of backticks and double 
quotes allowable. I'm quite stuck.



-David



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




Re: How to match HTML tag with RegExp

2008-11-29 Thread Chas. Owens
On Sat, Nov 29, 2008 at 20:50, Canol Gökel <[EMAIL PROTECTED]> wrote:
> Chas. Owens  gmail.com> writes:
>
>>
>> On Sat, Nov 29, 2008 at 20:02, Canol Gökel  canol.info> wrote:
>
>> Can't be done*.  You need a parser.
>
> snip
>
> It can be done.
snip

Note that asterisk.

snip
>> Learn to write a parser instead.  This is like asking how to build a
>> bridge for people out of toothpicks.  It can be done (but I wouldn't
>> walk on it), but it is a waste of your time.
>
> snip
>
> I don't want to parse a language, I want to match just "a tag". Do you thing,
> for example, forum scripts do language parsing for their bbcode?
snip

Yes, if they are any good.  I think you are over estimating the effort
of writing/using a parser.  If you had any interest in Perl as the
language I would point you to Parse::RecDescent, but I am sure what
ever language you are using will have something similar available to
it.  If you are trying to deal with an existing format I would
strongly advise you to use an existing parser.

snip
>> And yet you are asking a Perl list.  Perhaps you would be better
>> served by asking this question on a list for whatever language you are
>> using?  Perl's regexes are not standard.  They contain many extensions
>> that make this sort of thing easier, but since you are using some
>> mystery language for this mystery project we cannot help you.
>>
>
> snip
>
> I could ask this question to any language list which has regular expressions 
> as
> a feature. I guess parsing bbcode can be done with almost any programming
> language out there and I think the logic should not be that complicated which
> requires modules/extensions etc. right? Since Perl is the most powerful 
> language
> with RegExps I decided to ask this in this list. Also, should I ask what
> "variables" are to Pascal list just because I use Pascal?

The most power comes from using Perl's variant of regexes.  Since
other languages don't implement those extensions, and you are planning
on using a language other than Perl, you are wasting your time here.
And yes, asking about what variables are on a different languages list
is foolish.  For instance, Perl's variables are dynamic and loosely
typed, whereas Pascals are static and strongly typed.  If you asked
here about variables and then tried to use what you were told in
Pascal you would wonder why none of your code even compiled.

snip
>> * Not 100% true, but the amount of effort you will put into trying to
>> get regex that matches even 80% of valid, expected HTML dwarfs the
>> amount of time it takes to write a parser.  Given the fact that high
>> quality parsers exist already, there is no reason to waste your time.
>>
>
> Who said that I want to parse the whole HTML standard? I just want to match 1
> single HTML tag with no attributes or something. Just  and that's all.

Sadly, this is what many people think.  It isn't that easy.  What if
the code looks like this



Now you have to understand image tags and paragraph tags, there are
countless other examples.  The cavalier "I'll just through some regex
at it" attitude is why we have things like XSS and injection attacks.

snip
> Please before answering a post with judgments inside, read it carefully and 
> try
> to understand what this person is asking.
snip

I understand what you are asking for and I am trying to tell you that
you are looking in the wrong place (both on this list and in regard to
using a regex for this problem).

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


Re: How to match HTML tag with RegExp

2008-11-29 Thread Canol Gökel
Chas. Owens  gmail.com> writes:

> 
> On Sat, Nov 29, 2008 at 20:02, Canol Gökel  canol.info> wrote:

> Can't be done*.  You need a parser.

snip

It can be done.

snip

> Learn to write a parser instead.  This is like asking how to build a
> bridge for people out of toothpicks.  It can be done (but I wouldn't
> walk on it), but it is a waste of your time.

snip

I don't want to parse a language, I want to match just "a tag". Do you thing,
for example, forum scripts do language parsing for their bbcode?

snip

> And yet you are asking a Perl list.  Perhaps you would be better
> served by asking this question on a list for whatever language you are
> using?  Perl's regexes are not standard.  They contain many extensions
> that make this sort of thing easier, but since you are using some
> mystery language for this mystery project we cannot help you.
> 

snip

I could ask this question to any language list which has regular expressions as
a feature. I guess parsing bbcode can be done with almost any programming
language out there and I think the logic should not be that complicated which
requires modules/extensions etc. right? Since Perl is the most powerful language
with RegExps I decided to ask this in this list. Also, should I ask what
"variables" are to Pascal list just because I use Pascal?

snip

> * Not 100% true, but the amount of effort you will put into trying to
> get regex that matches even 80% of valid, expected HTML dwarfs the
> amount of time it takes to write a parser.  Given the fact that high
> quality parsers exist already, there is no reason to waste your time.
> 

Who said that I want to parse the whole HTML standard? I just want to match 1
single HTML tag with no attributes or something. Just  and that's all.

Please before answering a post with judgments inside, read it carefully and try
to understand what this person is asking.


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




Re: How to match HTML tag with RegExp

2008-11-29 Thread Chas. Owens
On Sat, Nov 29, 2008 at 20:02, Canol Gökel <[EMAIL PROTECTED]> wrote:
> Hi,
>
> My problem is to match HTML tags with RegExp.
snip

Can't be done*.  You need a parser.

snip
> Note: Most probably there is a module for this but:
>  - I want to learn the logic,
snip

Learn to write a parser instead.  This is like asking how to build a
bridge for people out of toothpicks.  It can be done (but I wouldn't
walk on it), but it is a waste of your time.

snip
>  - I don't use Perl in this project,
>  - Actually my problem is different than matching HTML tags but I choose them 
> to
> explain my problem, easily.
snip

And yet you are asking a Perl list.  Perhaps you would be better
served by asking this question on a list for whatever language you are
using?  Perl's regexes are not standard.  They contain many extensions
that make this sort of thing easier, but since you are using some
mystery language for this mystery project we cannot help you.

* Not 100% true, but the amount of effort you will put into trying to
get regex that matches even 80% of valid, expected HTML dwarfs the
amount of time it takes to write a parser.  Given the fact that high
quality parsers exist already, there is no reason to waste your time.

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


How to match HTML tag with RegExp

2008-11-29 Thread Canol Gökel
Hi,

My problem is to match HTML tags with RegExp. I managed to match something like
this, properly:

la la la a paragraph bla bla bla another paragraph ya ya ya

But when nested, there arises problems:

a paragraph bla bla bla la la la

It matches

A paragraph bla bla bla

instead of matching the most inner part:

bla bla bla

How can one write an expression to match always the most inner part? I couldn't
write an expression like "match a non-greedy .* which does not have a 
inside.

Note: Most probably there is a module for this but:
 - I want to learn the logic,
 - I don't use Perl in this project,
 - Actually my problem is different than matching HTML tags but I choose them to
explain my problem, easily.


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




Re: Not getting all the element.

2008-11-29 Thread John W. Krahn

slow_leaner wrote:

Hello all,


Hello,


what am i missing!!!
#!/usr/bin/perl -w
@array_number =;
@new_array = half( @array_number );
print "@new_array\n";

sub half {
  @numbers = @_;
 while (<@numbers>){


That is short for:

while ( defined( $_ = glob join $", @numbers ) ) {



 @n = $_ / 2;


That could also be written as:

  $n[ 0 ] = $_ / 2;



 @new_a = pop(@n);


That could also be written as:

  $new_a[ 0 ] = pop(@n);



   }
 return @new_a;


Since you are only dealing with scalar values that could also be written as:

  return $new_a[ 0 ];



}

#I am calling a sub function "half".
#but it return only the last element in to @new_array.
#here what i am exception.
#input  return
#1 > 0.5
#2 > 1
#3 > 1.5


#!/usr/bin/perl
use warnings;
use strict

chomp( my @array_number =  );

$_ /= 2 for my @new_array = @array_number;

print "$_\n" for @new_array;

__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: Return available address book fields

2008-11-29 Thread Chas. Owens
On Sat, Nov 29, 2008 at 11:32, John J. Foster
<[EMAIL PROTECTED]> wrote:
> Hi again,
>
> Is it possible to modify the following script to return a list of
> available fields? I'm trying to query my address at fastmail.fm and
> would like to display as much info as possible.
snip

Replace

if ($entry->get_value('mail')) {
print($entry->get_value('mail'),"\t",
  decode("UTF-8", $entry->get_value('cn')),"\tFrom Exchange 
LDAP
database\n");
}
}

with

print map { "$_\n" } $entry->attributes;

You can find the documentation here:
http://search.cpan.org/dist/perl-ldap/
http://search.cpan.org/dist/perl-ldap/lib/Net/LDAP.pod
http://search.cpan.org/~gbarr/perl-ldap-0.39/lib/Net/LDAP/Message.pod
http://search.cpan.org/~gbarr/perl-ldap/lib/Net/LDAP/Search.pod
http://search.cpan.org/dist/perl-ldap/lib/Net/LDAP/Entry.pod


-- 
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: Return available address book fields

2008-11-29 Thread John J. Foster
OK - let's try the script this time!

http://bsdconsulting.no/tools/mutt-ldap.pl

On Sat, Nov 29, 2008 at 09:32:32AM -0700, John J. Foster wrote:
> Hi again,
> 
> Is it possible to modify the following script to return a list of
> available fields? I'm trying to query my address at fastmail.fm and
> would like to display as much info as possible.
> 
> Thanks in advance,
> festus
> 
> -- 
> I just want to break even.
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
> 
> 

-- 
I just want to break even.

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




Return available address book fields

2008-11-29 Thread John J. Foster
Hi again,

Is it possible to modify the following script to return a list of
available fields? I'm trying to query my address at fastmail.fm and
would like to display as much info as possible.

Thanks in advance,
festus

-- 
I just want to break even.

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




Re:Mailing list

2008-11-29 Thread Jeff Pang
> Message du 29/11/08 12:55
> De : "Sureshkumar M (HCL Financial Services)"
> A : beginners@perl.org, [EMAIL PROTECTED]
> Copie à :
> Objet : Mailing list
>
> Hi All,
>
>
>
> Can someone send the maid's for Perl forum where I can clear
> all my doubts? I would like to discuss lot of doubts and get answer and
> get quick answers.
>


This list is the right place.
For more info about special lists you could see: lists.cpan.org.


--
Jeff Pang
http://home.arcor.de/pangj/

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


Re: Not getting all the element.

2008-11-29 Thread Mr. Shawn H. Corey
On Fri, 2008-11-28 at 11:56 -0800, slow_leaner wrote:
> Hello all, what am i missing!!!
> #!/usr/bin/perl -w
> @array_number =;
> @new_array = half( @array_number );
> print "@new_array\n";
> 
> sub half {
>   @numbers = @_;
>  while (<@numbers>){
>  @n = $_ / 2;
>  @new_a = pop(@n);
>}
>  return @new_a;
> }
> 
> #I am calling a sub function "half".
> #but it return only the last element in to @new_array.
> #here what i am exception.
> #input  return
> #1 > 0.5
> #2 > 1
> #3 > 1.5
> Thanks.
> 
> 

You are confusing array variables with scalar variables.

#!/usr/bin/perl

use strict;
use warnings;

chomp( my $input =  );
my @array_number = split /\D+/, $input;
my @new_array = half( @array_number );
print "@new_array\n";

sub half {
  my @numbers = @_;

  for my $number ( @numbers ){
$number /= 2;
  }
  return @numbers;
}



-- 
Just my 0.0002 million dollars worth,
  Shawn

The key to success is being too stupid to realize you can fail.


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




Not getting all the element.

2008-11-29 Thread slow_leaner
Hello all, what am i missing!!!
#!/usr/bin/perl -w
@array_number =;
@new_array = half( @array_number );
print "@new_array\n";

sub half {
  @numbers = @_;
 while (<@numbers>){
 @n = $_ / 2;
 @new_a = pop(@n);
   }
 return @new_a;
}

#I am calling a sub function "half".
#but it return only the last element in to @new_array.
#here what i am exception.
#input  return
#1 > 0.5
#2 > 1
#3 > 1.5
Thanks.


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




Re: date format search insdie the files

2008-11-29 Thread Dr.Ruud
"Sureshkumar M (HCL Financial Services)" schreef:

> Can someone help me on this

Impossible. 

-- 
Affijn, Ruud

"Gewoon is een tijger."

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




Re: date format search insdie the files

2008-11-29 Thread Dr.Ruud
"Sureshkumar M (HCL Financial Services)" schreef:

> Can you explain me this part how it's works?
>
>  (?:\d{2}|\w{3})
>
> ?:   what this will do?

Read perlre (and find out what (?:) means).



> And also, the output is like below
>
>
> (C)/tmp/d$ perl 1
> 10-11-81
> 20-NOV-2008
> 05-07-1981
> 15-110-2008   this should not come as this as 3 digit month.
> (C)/tmp/d$

Read perlre (and find out what \w means).


> Program:
>
> (C)/tmp/d$ cat 1
> #/usr/bin/perl
> use strict;
>
> open(DATA," while()
> {
> print if /\b\d{2}\b-(\d{2}|\w{3})-\b\d{2,4}\b/;
>
> }
> close(DATA);
> exit 0;

Compare your program to my version, and study what I changed about it.
Every change had a good reason.


Never fully quote a message, only quote (and summarize) what is relevant
for your reply.
React after each relevant part.

-- 
Affijn, Ruud

"Gewoon is een tijger."


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




RE: date format search insdie the files

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

Thanks a lot for your help,,


Can you explain me this part how it's works? 

 (?:\d{2}|\w{3})

?:   what this will do? 

And also, the output is like below


(C)/tmp/d$ perl 1
10-11-81
20-NOV-2008
05-07-1981
15-110-2008   this should not come as this as 3 digit month.
(C)/tmp/d$


Program:

(C)/tmp/d$ cat 1
#/usr/bin/perl
use strict;

open(DATA,")
{
print if /\b\d{2}\b-(\d{2}|\w{3})-\b\d{2,4}\b/;

}
close(DATA);
exit 0;
(C)/tmp/d$














-Original Message-
From: Dr.Ruud [mailto:[EMAIL PROTECTED] 
Sent: Saturday, November 29, 2008 5:30 PM
To: beginners@perl.org
Subject: Re: date format search insdie the files

"Sureshkumar M (HCL Financial Services)" schreef:

> #/usr/bin/perl
> open(DATA,"a1")||die"Unable to open the file";
> while()
> {
> if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/)
> {
> print $_;
> }
> }
> close(DATA);
> exit 0;

  #!/usr/bin/perl
  use strict;
  use warnings;

  my $in_name = "data.in";
  {   open my $in_fh, "<", $in_name
or die "Error with '$in_name': $!";

  while ( <$in_fh> ) {
  print if /\b\d{2}-(?:\d{2}|\w{3})-\d{1,4}/;
  }
  }
  __END__

-- 
Affijn, Ruud

"Gewoon is een tijger."

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



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

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




Re: date format search insdie the files

2008-11-29 Thread Dr.Ruud
"Sureshkumar M (HCL Financial Services)" schreef:

> #/usr/bin/perl
> open(DATA,"a1")||die"Unable to open the file";
> while()
> {
> if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/)
> {
> print $_;
> }
> }
> close(DATA);
> exit 0;

  #!/usr/bin/perl
  use strict;
  use warnings;

  my $in_name = "data.in";
  {   open my $in_fh, "<", $in_name
or die "Error with '$in_name': $!";

  while ( <$in_fh> ) {
  print if /\b\d{2}-(?:\d{2}|\w{3})-\d{1,4}/;
  }
  }
  __END__

-- 
Affijn, Ruud

"Gewoon is een tijger."

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




Mailing list

2008-11-29 Thread Sureshkumar M (HCL Financial Services)
Hi All,

 

Can someone send the maid's for Perl forum where I can clear
all my doubts? I would like to discuss lot of doubts and get answer and
get quick answers.

 

Regards,

Suresh



RE: date format search insdie the files

2008-11-29 Thread Sureshkumar M (HCL Financial Services)
Hi all ,

 

Can someone help me on this

 



From: Sureshkumar M (HCL Financial Services) 
Sent: Saturday, November 29, 2008 4:21 PM
To: 'David Schmidt'
Cc: beginners@perl.org
Subject: RE: date format search insdie the files

 

Hi David,

 

  Thanks for the reply, but still I am not able to get expected
output from this.

Pls help me how to get this.

 

(C)/tmp/d$ cat a1

 

115-06-1979

10-11-81

20-NOV-2008

05-07-1981

welcome

20-03-20009

15-10-2008

 

 

(C)/tmp/d$ cat 1

#/usr/bin/perl

 

use strict;

use warnings;

 

open(DATA,"a1")||die"Unable to open the file";

 

while()

{

#if($_=~/\d\d\D(\d\d|\[a-zA-Z]{3})\D\d\d/)

if(/(\d{2}-(\d{2})|(\w{3})-\d{1,4})/)

{

#print $_;

print ;

}

}

close(DATA);

exit 0;

 

(C)/tmp/d$ perl 1   

115-06-1979

10-11-81

20-NOV-2008

05-07-1981

20-03-20009

15-10-2008

(C)/tmp/d$

 

 

 

 

 

 

 

 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
David Schmidt
Sent: Saturday, November 29, 2008 3:12 PM
To: Sureshkumar M (HCL Financial Services); beginners@perl.org
Subject: Re: date format search insdie the files

 

You missed some parentheses

 

#!/usr/bin/perl

 

use strict;

use warnings;

 

open(DATA, '<', "data") || die"Unable to open the file";

while() {

#if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/) {

if(/(\d{2}-(\d{2})|(\w{3})-\d{1,4})/) {

print;

}

}

close(DATA);

exit 0;

 

 

On Sat, Nov 29, 2008 at 10:11 AM, Sureshkumar M (HCL Financial

Services) <[EMAIL PROTECTED]> wrote:

> Hi All,

> 

>I try to search the string which has the date format inside

> the file,

> 

> But i am not able to get the desired files. Pls help me on this..

> 

> 

> 

> 

> 

> 

> 

> C)/tmp/sms/perl$ cat a1

> 

> 

> 

> 115-06-1979

> 

> 10-11-81

> 

> 20-NOV-2008

> 

> 05-07-1981

> 

> welcome

> 

> 15-10-2008

> 

> 12-03-20009

> 

> 

> 

> 

> 

> (C)/tmp/sms/perl$ cat 1

> 

> 

> 

> #/usr/bin/perl

> 

> open(DATA,"a1")||die"Unable to open the file";

> 

> 

> 

> while()

> 

> {

> 

> if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/)

> 

> {

> 

> print $_;

> 

> }

> 

> }

> 

> close(DATA);

> 

> exit 0;

> 

> (C)/tmp/sms/perl$

> 

> 

> 

> 

> 

> 

> 

> Output should be  :

> 

> 

> 

> 10-11-81

> 

> 20-NOV-2008

> 

> 05-07-1981

> 

> 15-10-2008

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

 

 

 

-- 

David Schmidt   |   http://www.fm5.at



Web File Download

2008-11-29 Thread Ирина Пуляхина
Hi all,

I work with ssm-server - server for bioinformatic purposes
(http://www.ebi.ac.uk/msd-srv/ssm/).
For each request it gives information of several html-pages.
Also there is a possibility save file in preferable format:
to click on "save"-button, click Yes on "Do you want to save"-window.

When I click on "save"-button, a virtual link is generated:
http://www.ebi.ac.uk/msd-srv/ssm/cgi-bin/reslist.dat

I write perl-code in commonly as when I work with simply web pages,
but the response is a web page of ssm-server with no information.

my $response4 =
$browser->post('http://www.ebi.ac.uk/msd-srv/ssm/cgi-bin/reslist.dat',
 [
   'page_key' => 'res_list_page',
   'action_key' => 'none',
   'dir_key' => $hash{$key},
   'match_key' => '0',
   'download_rlist' => ' \>\;\>\; ',
 ],
);


But it doesn't really exist in a way that You can write "wget
http//..." and load file. It is created with a script:

function JSDownloadRList ( f ) {
 f.action = "reslist.dat";
 f.action_key.value = "download_rlist";
 f.submit();
}

and html-code



How can I do the same (load this file) in perl?

Thank You

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




RE: date format search insdie the files

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

Hi David,

 

  Thanks for the reply, but still I am not able to get expected
output from this.

Pls help me how to get this.

 

(C)/tmp/d$ cat a1

 

115-06-1979

10-11-81

20-NOV-2008

05-07-1981

welcome

20-03-20009

15-10-2008

 

 

(C)/tmp/d$ cat 1

#/usr/bin/perl

 

use strict;

use warnings;

 

open(DATA,"a1")||die"Unable to open the file";

 

while()

{

#if($_=~/\d\d\D(\d\d|\[a-zA-Z]{3})\D\d\d/)

if(/(\d{2}-(\d{2})|(\w{3})-\d{1,4})/)

{

#print $_;

print ;

}

}

close(DATA);

exit 0;

 

(C)/tmp/d$ perl 1   

115-06-1979

10-11-81

20-NOV-2008

05-07-1981

20-03-20009

15-10-2008

(C)/tmp/d$

 

 

 

 

 

 

 

 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
David Schmidt
Sent: Saturday, November 29, 2008 3:12 PM
To: Sureshkumar M (HCL Financial Services); beginners@perl.org
Subject: Re: date format search insdie the files

 

You missed some parentheses

 

#!/usr/bin/perl

 

use strict;

use warnings;

 

open(DATA, '<', "data") || die"Unable to open the file";

while() {

#if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/) {

if(/(\d{2}-(\d{2})|(\w{3})-\d{1,4})/) {

print;

}

}

close(DATA);

exit 0;

 

 

On Sat, Nov 29, 2008 at 10:11 AM, Sureshkumar M (HCL Financial

Services) <[EMAIL PROTECTED]> wrote:

> Hi All,

> 

>I try to search the string which has the date format inside

> the file,

> 

> But i am not able to get the desired files. Pls help me on this..

> 

> 

> 

> 

> 

> 

> 

> C)/tmp/sms/perl$ cat a1

> 

> 

> 

> 115-06-1979

> 

> 10-11-81

> 

> 20-NOV-2008

> 

> 05-07-1981

> 

> welcome

> 

> 15-10-2008

> 

> 12-03-20009

> 

> 

> 

> 

> 

> (C)/tmp/sms/perl$ cat 1

> 

> 

> 

> #/usr/bin/perl

> 

> open(DATA,"a1")||die"Unable to open the file";

> 

> 

> 

> while()

> 

> {

> 

> if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/)

> 

> {

> 

> print $_;

> 

> }

> 

> }

> 

> close(DATA);

> 

> exit 0;

> 

> (C)/tmp/sms/perl$

> 

> 

> 

> 

> 

> 

> 

> Output should be  :

> 

> 

> 

> 10-11-81

> 

> 20-NOV-2008

> 

> 05-07-1981

> 

> 15-10-2008

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

> 

 

 

 

-- 

David Schmidt   |   http://www.fm5.at



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: date format search insdie the files

2008-11-29 Thread David Schmidt
You missed some parentheses

#!/usr/bin/perl

use strict;
use warnings;

open(DATA, '<', "data") || die"Unable to open the file";
while() {
#if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/) {
if(/(\d{2}-(\d{2})|(\w{3})-\d{1,4})/) {
print;
}
}
close(DATA);
exit 0;


On Sat, Nov 29, 2008 at 10:11 AM, Sureshkumar M (HCL Financial
Services) <[EMAIL PROTECTED]> wrote:
> Hi All,
>
>I try to search the string which has the date format inside
> the file,
>
> But i am not able to get the desired files. Pls help me on this..
>
>
>
>
>
>
>
> C)/tmp/sms/perl$ cat a1
>
>
>
> 115-06-1979
>
> 10-11-81
>
> 20-NOV-2008
>
> 05-07-1981
>
> welcome
>
> 15-10-2008
>
> 12-03-20009
>
>
>
>
>
> (C)/tmp/sms/perl$ cat 1
>
>
>
> #/usr/bin/perl
>
> open(DATA,"a1")||die"Unable to open the file";
>
>
>
> while()
>
> {
>
> if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/)
>
> {
>
> print $_;
>
> }
>
> }
>
> close(DATA);
>
> exit 0;
>
> (C)/tmp/sms/perl$
>
>
>
>
>
>
>
> Output should be  :
>
>
>
> 10-11-81
>
> 20-NOV-2008
>
> 05-07-1981
>
> 15-10-2008
>
>
>
>
>
>
>
>
>
>
>
>



-- 
David Schmidt   |   http://www.fm5.at

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




date format search insdie the files

2008-11-29 Thread Sureshkumar M (HCL Financial Services)
Hi All,

I try to search the string which has the date format inside
the file,

But i am not able to get the desired files. Pls help me on this..

 

 

 

C)/tmp/sms/perl$ cat a1

 

115-06-1979

10-11-81

20-NOV-2008

05-07-1981

welcome

15-10-2008

12-03-20009

 

 

(C)/tmp/sms/perl$ cat 1

 

#/usr/bin/perl

open(DATA,"a1")||die"Unable to open the file";

 

while()

{

if($_=~/\d{2}-(\d{2}|\w{3})-\d{1,4}/)

{

print $_;

}

}

close(DATA);

exit 0;

(C)/tmp/sms/perl$

 

 

 

Output should be  :

 

10-11-81

20-NOV-2008

05-07-1981

15-10-2008