Regading 'perlipc'

2007-06-14 Thread anand kumar
Hi all,
  I would like to know if there is any possibilty to handle a situation where 
in while executing a perl script if i press a Control-C (or terminate the 
execution explicitly) then my code should be in a position to handle it and 
display a predefined message(or specifically execute predefined code for 
cleanup) and then actually exit the code execution.
  
Thanks in advance for the help.
  regards
Anand


-
 Here’s a new way to find what you're looking for - Yahoo! Answers 

Set time period for a statement to execute

2007-06-20 Thread anand kumar
Please guide me with some code or documentation for the following problem :-
   
  I need to set some specific time for a command to execute. For example, If I 
am opening a very large file and it takes me more than 3 to 4 seconds then my 
code should be able to quit the program or kill the process of opening the file 
and display an error message.
   
  Thanks in advance for the help
   
  -Anand


-
 Here’s a new way to find what you're looking for - Yahoo! Answers 

Re: Set time period for a statement to execute

2007-06-20 Thread anand kumar
Thank You It worked fine
   
  -Anand

"Mumia W." <[EMAIL PROTECTED]> wrote:
  On 06/20/2007 02:07 AM, anand kumar wrote:
> Please guide me with some code or documentation for the following problem :-
> 
> I need to set some specific time for a command to execute. [...]
> 

The "alarm" function might help you:

At a command prompt, type "perldoc -f alarm"



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





-
 Here’s a new way to find what you're looking for - Yahoo! Answers 

Combine similar patterns

2006-03-28 Thread anand kumar
Hi all,
   
I have a problem in combining the nested/multiple patterns. The 
input of the file is as follows:
   
  Input:-
  
  A
  B
  C
  
   
  D
  E
  F
   
  
  G
  H
  
   
  I
  J
  
   
  K
   
  
  L
  M
  
   
  N
  O
  
   
   
  and i would like to convert in to the following manner
   
  Output:
  
  A
  B
  C
  G
  H
  K
  N
  O
  
  D
  E
  F
   
  I
  J
   
  L
  M
   
  I have got the file contents as showed in the input. I am trying to combine 
the matter between and  in to single …….
   
  Can anyone help in how to combine these nested/multiple patterns
   
  Thanks in advance for the help
   
  Regards
  Anand


-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Re: Combine similar patterns

2006-03-29 Thread anand kumar
Hi all     Sorry for not posting the question clearly, Please find the attachment of the sample file. The matter enclosed in …., …..….…… are all the foot notes that are spanning on various pages, now what I am trying to do is that to combine all the related footnotes that are spanned in various pages and place them at on place. Here  indicates the starting of the footnotes,  indicates that the footnote continues from previous page, the
  indicates that the foot notes continues in next page and  indicates the end of the footnotes     Note :- please open the attached file in DOS or Linux environment  please help in this matter     Thanks in advance for the helpRegardsAnandanand kumar <[EMAIL PROTECTED]> wrote:  Hi all,I have a problem in combining the nested/multiple patterns. The input of the file is as
 follows:Input:-ABCDEFGHIJKLMNOand i would like to convert in to the following mannerOutput:ABCGHKNODEFIJLMI have got the file contents as showed in the input. I am trying to combine the matter between and in to single …….Can anyone help in how to combine these nested/multiple patternsThanks in advance for the helpRegardsAnand-Jiyo cricket on Yahoo! India cricketYahoo! Messenger Mobile Stay in touch with your buddies all the time.
	

	
		 
Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.~APG 0020088
~SPG 81  
~TXT 
^C0^Sciences above separated, are not distinguishable at all by |differences in 
their degrees of generality. They are all |equally general; or rather they are 
all, considered as |groups, universal. Every object whatever presents at once 
|the subject-matter for each of them. In every fragment of |substance we have 
simultaneously illustrated the abstract |truths of relation in Time and Space; 
the abstract-concrete |truths in conformity with which the fragment manifests 
its |several modes of force; and the concrete truths resulting |from the joint 
manifestation of these modes of force, and |which give to the fragment the 
characters by which it is |known as such or such. Thus these three classes of 
|Sciences severally formulate different, but co-extensive, |classes of facts. 
Within each group there are truths of |greater and less generality: there are 
general abstract |truths, and special abstract truths; general 
abstract-concrete |truths, and special abstract-concrete truths; general 
|concrete truths, and special concrete truths. But while |within each class 
there are groups and sub-groups and subsub-groups |which differ in their 
degrees of generality, |the classes themselves differ only in their degrees of 
|abstractness.*

^F0^Let us pass to the sub-divisions of these classes. The |first class is 
separable into two parts\p=m-\the one containing |universal truths, the other 
non-universal truths. Dealing |



^F0^* Some propositions laid down by M˙ Littr\l=e'\, in his 
book\p=m-\Auguste Comte et |la Philosophie Positive (published in 1863), 
may fitly be dealt with here. In |the candid and courteous reply he makes to my 
strictures on the Comtean |classification in ``The Genesis of Science,'' he 
endeavours to clear up some of |the inconsistencies I pointed out; and he does 
this by drawing a distinction |between objective generality and subjective 
generality. He says\p=m-\``qu'il |existe deux ordres de 
g\l=e'\n\l=e'\ralit\l=e'\, l'une objective et dans les choses, l'autre 
|subjective, abstraite et dans l'esprit.'' This sentence, in which M˙ 
Littr\l=e'\ |makes subjective generality synonymous with abstractness, led me 
at first to |conclude that he had in view the same distinction as that which I 
have above |explained between generality and abstractness. On re-reading the 
paragraph, |however, I found this was not the case. In a previous sentence he 
says\p=m-\ |``La biologie a pass\l=e'\ de la consid\l=e'\ration des organes 
\l=a`\ celles des tissus,


›
~DNO 357
~APG 0020089
~SPG 82  
~TXT 
^C0^wholly with relations apart from related things, Abstract |Science 
considers first, that which is common to all relations |whatever; and, second, 
that which is common to each order |of relations. Besides the indefinite and 
variable connexions |which exist among phenomena, as occurring together in 
|Space and Time, we find that there are also definite and |invariable 
connexions\p=m-\that between each kind of phenomenon |and certain other kinds 
of phenomena, there exist |uniform relations. This is a universal abstract 
truth\p=m-\that |there is an unchanging order, or fixity of law, in Space and 
|Time. We come next to the several kinds of unchanging |order, which, taken 
together, form the subjects of the |
›


^C0^vinay As the existence of seven cervical vertebr\l=ae\ in each mammal is a 
concrete |fact, the statement of it is a concrete truth, and the statement 
colligating |such truths is not made other than concrete by holding of case 
after case.  M˙ Littr\l

Re: Combine similar patterns

2006-03-29 Thread anand kumar
Hi
   
  Yes, of course the code u have sent is very helpful and thanks for that. But 
the problem here is that in a single file there may be various number of foot 
notes i.e. ,.so on. For all these the conventions are the same 
as told before. I am having problem in combining the relevant ones. Please help 
in this matter
  
Thanks in advance for the help
   
  Regards
  Anand
Xavier Noria <[EMAIL PROTECTED]> wrote:
  On Mar 29, 2006, at 10:28, anand kumar wrote:

> Sorry for not posting the question clearly, Please find the 
> attachment of the sample file. The matter enclosed in ….> f1=c>, …..….…… are 
> all the foot notes that 
> are spanning on various pages, now what I am trying to do is that 
> to combine all the related footnotes that are spanned in various 
> pages and place them at on place. Here indicates the starting 
> of the footnotes, indicates that the footnote continues from 
> previous page, the indicates that the foot notes continues 
> in next page and indicates the end of the footnotes

Looks like the code I sent before is a good starting point. The only 
new relevant stuff I see are the "" tags, but you could adapt the 
script easily to deal with that correctly and to do what's needed 
with empty lines. If you understand the flip-flop operator you've got 
the script.

-- fxn



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






-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Re: [SPAM DETECT] Re: Combine similar patterns

2006-03-29 Thread anand kumar
Hi     Please find the file as an attachment with this mail     Regards  AnandXavier Noria <[EMAIL PROTECTED]> wrote:  On Mar 29, 2006, at 12:01, anand kumar wrote:> Yes, of course the code u have sent is very helpful and thanks for > that. But the problem here is that in a single file there may be > various number of foot notes i.e. ,.so on. For all > these the conventions are the same as told before. I am having > problem in combining the relevant ones. Please help in this matterI think we can go back to the simplification. Would you please send an analogous simplified example that contains sections f1, f2, f3, following the same structure as in the original data?-- fxn--To
 unsubscribe, e-mail: [EMAIL PROTECTED]For additional commands, e-mail: [EMAIL PROTECTED]
	

	
		 
Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.~DNO 357
~APG 0020145
~SPG 126 
~TXT 

main, par sa nature, emploie |successivement dans chacune de |ses recherches 
trois m\l=e'\thodes |de philosopher, dont le caract\l=e`\re |est 
essentiellement diff\l=e'\rent |m\l=e^\me radicalement oppos\l=e'\: |d'abord la 
m\l=e'\thode th\l=e'\ologique, |ensuite la m\l=e'\thode m\l=e'\taphysique, |et 
enfin la m\l=e'\thode positive.'' |Cours˙ de Philosophie |Positive, 
1830, Vol˙ i. p˙ 3.
to the width of the generalizations which |experiences have determined; and 
they |change just as gradually as experiences |accumulate. The integration of 
causal |agencies, originally thought of as multi-tudinous |and local, but 
finally believed to |be one and universal, is a process which |involves the 
passing through all intermediate |steps between these extremes; |and any 
appearance of stages can be but |superficial. Supposed concrete and individual 
|causal agencies, coalesce in the |mind as fast as groups of phenomena are 
|assimilated, or seen to be similarly caused. |Along with their coalescence, 
comes a |greater extension of their individualities, |and a concomitant loss of 
distinctness in |their individualities. Gradually, by continuance |of such 
coalescences, causal |agencies become, in thought, diffused and |indefinite. 
And eventually, without any |change in the nature of the process, there |is 
reached the consciousness of a universal |causal agency, which cannot be 
conceived.*


``Le syst\l=e`\me th\l=e'\ologique est |parvenu \l=a`\ la plus haute 
perfection |dont il soit susceptible, |quand il a substitu\l=e'\ l'action 
|providentielle d'un \l=e^\tre unique |au jeu vari\l=e'\ des nombreuses 
|divinit\l=e'\s ind\l=e'\pendantes qui avaient |\l=e'\t\l=e'\ imagin\l=e'\es 
primitivement. |De m\l=e^\me, le dernier |terme du syst\l=e`\me metaphysique
As the progress of thought is one, so is |the end one. There are not three 
possible |terminal conceptions; but only a single |terminal conception. When 
the theological |idea of the providential action of one |being, is developed to 
its ultimate form, |by the absorption of all independent |secondary agencies, 
it becomes the conception |of a being immanent in all phenomena; |and the 
reduction of it to this

›

^F0^* A clear illustration of this process, is furnished by the 
recent mental integration |of Heat, Light, Electricity, etc˙, as modes of 
molecular motion. If |we go a step back, we see that the modern conception of 
Electricity, resulted |from the integration in consciousness, of the two forms 
of it involved in the |galvanic battery and in the electric-machine. And going 
back to a still |earlier stage, we see how the conception of statical 
electricity, arose by the |coalescence in thought, of the previously-separate 
forces manifested in rubbed |amber, in rubbed glass, and in lightning. With 
such illustrations before |him, no one can, I think, doubt that the process has 
been the same from the |beginning.


›
~APG 0020146
~SPG 127 
~TXT 

consiste \l=a`\ concevoir, au lieu des |diff\l=e'\rentes entit\l=e'\s 
particuli\l=e`\res, |une seule grande entit\l=e'\ g\l=e'\n\l=e'\rale, |la 
nature, envisag\l=e'\e comme la |source unique de tous les 
ph\l=e'\nom\l=e`\nes. |Pareillement, la perfection |du syst\l=e`\me positif, 
vers |laquelle il tend sans cesse, quoiqu'il |soit tr\l=e`\s-probable qu'il ne 
|doive jamais l'atteindre, serait |de pouvoir se repr\l=e'\senter tous |les 
divers ph\l=e'\nom\l=e`\nes observables |comme des cas particuliers |d'un seul 
fait g\l=e'\n\l=e'\ral, tel que |celui de la gravitation, par |exemple.'' 
p˙ 5.
state, implies the fading-away, in thought, |of all those anthropomorphic 
attributes by |which the aboriginal idea was distinguished. |The alleged last 
term of the |metaphysical system\p=m-\the conception of a |single great general 
entity, nature, as the |sourc

Re: Combine similar patterns

2006-03-29 Thread anand kumar
Hi
   
  Please find the attached input.dat and output.dat
   
  Thanks in advance for the help
   
  Regards
  Anand

Xavier Noria <[EMAIL PROTECTED]> wrote:
  On Mar 29, 2006, at 12:32, anand kumar wrote:

> Please find the file as an attachment with this mail

Well, that didn't look like a simplification at all. I asked for 
another example with simplified notation because we already have an 
idea of the actual input and because you need to provide the 
*expected output* as well, which will be easier to produce and 
understand that way.

-- fxn


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






-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Re: Combine similar patterns

2006-03-29 Thread anand kumar
Hi     Please find the attached input.dat and output.dat     Thanks in advance for the help     Regards  AnandXavier Noria <[EMAIL PROTECTED]> wrote:  On Mar 29, 2006, at 12:32, anand kumar wrote:> Please find the file as an attachment with this mailWell, that didn't look like a simplification at all. I asked for another example with simplified notation because we already have an idea of the actual input and because you need to provide the *expected output* as well, which will be easier to produce and understand that way.-- fxn-- To unsubscribe, e-mail: [EMAIL PROTECTED]For additional commands, e-mail: [EMAIL PROTECTED]
	

	
		 
Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.~DNO 357
~APG 0020145
~SPG 126 
~TXT 

main, par sa nature, emploie |successivement dans chacune de |ses recherches 
trois m\l=e'\thodes |de philosopher, dont le caract\l=e`\re |est 
essentiellement diff\l=e'\rent |m\l=e^\me radicalement oppos\l=e'\: |d'abord la 
m\l=e'\thode th\l=e'\ologique, |ensuite la m\l=e'\thode m\l=e'\taphysique, |et 
enfin la m\l=e'\thode positive.'' |Cours˙ de Philosophie |Positive, 
1830, Vol˙ i. p˙ 3.
to the width of the generalizations which |experiences have determined; and 
they |change just as gradually as experiences |accumulate. The integration of 
causal |agencies, originally thought of as multi-tudinous |and local, but 
finally believed to |be one and universal, is a process which |involves the 
passing through all intermediate |steps between these extremes; |and any 
appearance of stages can be but |superficial. Supposed concrete and individual 
|causal agencies, coalesce in the |mind as fast as groups of phenomena are 
|assimilated, or seen to be similarly caused. |Along with their coalescence, 
comes a |greater extension of their individualities, |and a concomitant loss of 
distinctness in |their individualities. Gradually, by continuance |of such 
coalescences, causal |agencies become, in thought, diffused and |indefinite. 
And eventually, without any |change in the nature of the process, there |is 
reached the consciousness of a universal |causal agency, which cannot be 
conceived.*


``Le syst\l=e`\me th\l=e'\ologique est |parvenu \l=a`\ la plus haute 
perfection |dont il soit susceptible, |quand il a substitu\l=e'\ l'action 
|providentielle d'un \l=e^\tre unique |au jeu vari\l=e'\ des nombreuses 
|divinit\l=e'\s ind\l=e'\pendantes qui avaient |\l=e'\t\l=e'\ imagin\l=e'\es 
primitivement. |De m\l=e^\me, le dernier |terme du syst\l=e`\me metaphysique
As the progress of thought is one, so is |the end one. There are not three 
possible |terminal conceptions; but only a single |terminal conception. When 
the theological |idea of the providential action of one |being, is developed to 
its ultimate form, |by the absorption of all independent |secondary agencies, 
it becomes the conception |of a being immanent in all phenomena; |and the 
reduction of it to this

›

^F0^* A clear illustration of this process, is furnished by the 
recent mental integration |of Heat, Light, Electricity, etc˙, as modes of 
molecular motion. If |we go a step back, we see that the modern conception of 
Electricity, resulted |from the integration in consciousness, of the two forms 
of it involved in the |galvanic battery and in the electric-machine. And going 
back to a still |earlier stage, we see how the conception of statical 
electricity, arose by the |coalescence in thought, of the previously-separate 
forces manifested in rubbed |amber, in rubbed glass, and in lightning. With 
such illustrations before |him, no one can, I think, doubt that the process has 
been the same from the |beginning.

^F0^* Possibly it will be said that M˙ Comte himself admits 
that what he calls |the perfection of the positive system, will probably never 
be reached; and |that what he condemns is the inquiry into the natures 
of causes and not the |general recognition of cause. To the first of these 
allegations I reply that, as |I understand M˙ Comte, the obstacle to the 
perfect realization of the positive |philosophy is the impossibility of 
carrying generalization so far as to reduce |all particular facts to cases of 
one general fact\p=m-\not the impossibility of

^C0^excluding the consciousness of cause. And to the second allegation I reply 
|that the essential principle of his philosophy is an avowed ignoring of cause 
|altogether. For if it is not, what becomes of his alleged distinction 
between |the perfection of the positive system and the perfection of the 
metaphysical |system? And here let me point out that, by affirming exactly 
the opposite to |that which M˙ Comte thus affirms, I am excluded from the 
positive school. |If his own definition of positivism is to be taken, then, as 
I hold that what he |defines as positivism is an abs

Re: Learning Perl

2006-04-11 Thread anand kumar
HI
   
  Try this
   
  #!/bin/perl 

use strict;
use diagnostics;

print "\t Enter Month of a year \n";

my $month = ();
chomp($month);
my %days_month = (
January => 31,
February => 28, 
March => 31
);


print "\t Number of Days in month of $month is $days_month{$month} \n ";

Regards
  Anand
  
joseph tacuyan <[EMAIL PROTECTED]> wrote:
  Hi List,

I'm learning learning perl thru a book, as part of my exercises i tried to run 
this code:


#!/bin/perl 

use strict;
use diagnostics;

print "\t Enter Month of a year \n";

my $month = ();

my %days_month = (
January => 31,
February => 28, 
March => 31
);


print "\t Number of Days in month of $month is $days_month{$month} \n ";

i got an error of uninitialized ...blah...blah ..blah...

But if i declare the value of $month in hard code it runs without glitch but i 
like to have an input from keyboard. plz enlighten.


/joseph 
perl convert.


-
Blab-away for as little as 1¢/min. Make PC-to-Phone Calls using Yahoo! 
Messenger with Voice.


-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

one small question

2006-07-26 Thread anand kumar
Hi all, 
   
  Can any one say a command or procedure to find out on which OS/Platform does 
our current perl script is running.
   
  Thanks in advance for the help
   
  Reards
Anand Kumar


-
 Here’s a new way to find what you're looking for - Yahoo! Answers 

doubt in quote-like operators

2006-08-06 Thread anand kumar
hi all,
   
  I could not understand clearly the functions 
qw(),qq(),qr(),qx(),q(),quotemeta(). I 
  have read the explanation for these functions in the perl documentation but i 
  could not get idea of where exactly we can use these functions. So please 
  send some other links or examples for these functions.
   
  Thanks in advance for the help
   
  Regards
  Anand Kumar


-
 Here’s a new way to find what you're looking for - Yahoo! Answers 

Re: doubt in quote-like operators

2006-08-07 Thread anand kumar
Hi,
   
  Thanks alot for the detailed explanation.
   
  Regards
  Anand Kumar

Prabu <[EMAIL PROTECTED]> wrote:
  anand kumar wrote:
> hi all,
> 
> I could not understand clearly the functions 
> qw(),qq(),qr(),qx(),q(),quotemeta(). I 
> have read the explanation for these functions in the perl documentation but i 
> could not get idea of where exactly we can use these functions. So please 
> send some other links or examples for these functions.
> 
> Thanks in advance for the help
> 
> Regards
> Anand Kumar 

Hello Anand,

q/STRING/
’STRING’

A single-quoted, literal string.A generalized single-quote operation.

A backslash represents a backslash unless followed by the delimiter or 
another backslash, in which case the delimiter or backslash is interpolated.

for example
$foo = q!Hello World!; This is equivalent to $foo='hello world';

_
qq/STRING/
"STRING"

A double-quoted, interpolated string.

for example
$foo = qq!Hello World!; This is equivalent to $foo='hello world';

_
qr/STRING/imosx

This operator quotes (and possibly compiles) its STRING as a regular 
expression. STRING is interpolated the same way as PATTERN in "m/PATTERN/"

Options are:
i Do case-insensitive pattern matching.
m Treat string as multiple lines.
o Compile pattern only once.
s Treat string as single line.
x Use extended regular expressions.

For example
$rex = qr/my.STRING/is;
s/$rex/foo/;

This is equivalent too

s/my.STRING/foo/is;

_
qx/STRING/
‘STRING‘

A string which is (possibly) interpolated and then executed as a system 
command with "/bin/sh" or its equivalent. Shell wildcards, pipes, and 
redirections will be honored. The collected standard output of the 
command is returned; standard error is unaffected.

qx(ls); This is equivalent to `ls` (backtics)

qw/STRING/
Evaluates to a list of the words extracted out of STRING, using embedded 
whitespace as the word delimiters.

@a=qw(foo bar baz); This is equivalent too @a=("foo", "bar", "baz");

_
quotemeta EXPR

Returns the value of EXPR with all non-"word" characters backslashed.
_

A Small Example

PROGRAM

$ cat func.pl
#!/usr/bin/perl
$foo = q!Hello World\n!;
print "single-quote operation\n\t",$foo."\n";
$foo = qq!Hello World\n!;
print "double-quote operation\n\t",$foo;
$foo = "Hello world";
$pattern = qr!Hello!is;
$foo=~s/$pattern/HELL0/;
print "Regex operation\n\t",$foo;
@a=qw(hello perl world);
print "\nTurn a space-delimited string of words into a list\n\t";
foreach(@a){
print "$_\n\t";
}
$foo="Hello*world";
$non_word_char = quotemeta($foo);
print "\nBackslashed non-word characters\n\t",$non_word_char."\n";
print qx/ps/;


OUTPUT

$ perl func.pl
single-quote operation
Hello World\n
double-quote operation
Hello World
Regex operation
HELL0 world
Turn a space-delimited string of words into a list
hello
perl
world

Backslashed non-word characters
Hello\*world
PID TTY TIME CMD
20453 pts/5 00:00:00 bash
20737 pts/5 00:00:00 perl
20738 pts/5 00:00:00 ps





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






-
 Here’s a new way to find what you're looking for - Yahoo! Answers 

Connecting to Oracle

2006-08-22 Thread anand kumar
Hi all
   
  Can anyone please explain how to connect to oracle database server using perl 
script which is in separate linux server. Please note that currently I am using 
putty to connect to linux server for perl scripting and we have the Oracle 
database on a windows server. I have tried using the DBD::Oracle module from 
cpan.org but i could not install the module because the oracle drivers are 
accessible to Perl on the Linux server.
   
  In this regard please suggest any solution or any documentation
   
  Regards
Anand Kumar


-
 Here's a new way to find what you're looking for - Yahoo! Answers 
 Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it 
NOW

Doubt

2005-12-11 Thread anand kumar

  Hi 
 I am new to perl .i have a doubt in analysing the following regex.
   (my $book = $ref_string) =~ s/\s*(\d+(?::\d+(?:-\d+(?::\d+)?)?)?)\Z//;
   
  here i want to know the meaning of '?:'
   
  thanks in advance
  Anand


-
 Yahoo! India Matrimony: Find your partner now.

Doubt

2005-12-11 Thread anand kumar

  Hi 
 I am new to perl .i have a doubt in analysing the following regex.
   (my $book = $ref_string) =~ s/\s*(\d+(?::\d+(?:-\d+(?::\d+)?)?)?)\Z//;
   
  here i want to know the meaning of '?:'
   
  thanks in advance
  Anand


-
 Yahoo! India Matrimony: Find your partner now.

manipulating each string in a file

2005-12-13 Thread anand kumar

  Hi All,
   
  I have a task i.e , I have to read each string from a file check 
wheather it is in the list(predifned array) or not, if found i have to make 
some changes to the string and rewrite back to file. here on exception is that 
in some cases :
   
  for eg:
   
  if the string is "JOHN" then i have to check wheather it is preceeded by 
"2."(any digit and '.')
   
  for this task i have used the following task
   

while (<>) {  for $chunk (split) {  # do something with $chunk  
}  }

here the the problems iam facing are i donot know how to read the previous 

string in specific cases and also rewritng the contents 

inthe same file or any new file

 

please send me your suggestions.

 

Thanks in advance

Anand


-
 Yahoo! India Matrimony: Find your partner now.

syntax of a perl program?

2005-12-20 Thread anand kumar
Hi all
 Can anyone let me know some functions or some tutorial on how to 
check the syntax of a perl program.
   
  Thanks in advance
   
  Anand

Send instant messages to your online friends http://in.messenger.yahoo.com 

Reading contents of file

2006-01-08 Thread anand kumar

  Hi
   
  I am new to PERL. I have a doubt, The following script is used to read the 
contents of a file (word by word (or) word preceeded by a number), check for 
the existence of the matched pattern which is done by the help of bookref() 
sub, if it is found then the matched pattern is prefixed with the tag . 
When I run the following script it goes to unending because it is not pointing 
to the next string after the complete execution of the loop . Please correct me 
   
  open IN, "r1.dat";
  open OUT, ">r1.txt";
  $/=undef;
  $line=;
  while ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
  {
  $book=$1;
  print $book,"\n";
  $t_book=$book;
  $t_book=~s/\.//g;
  $t_book=~s/\\l=([a-z]+)\\/$1/ig;
  $t_book=~s/<(|\/)(B|I|SC|U)>//ig;
  $quote=bibref($t_book);
  if($quote)
  {
  $line=~s/($book)/$1/ig;
  }
  }
  print OUT $line;
  close(IN);
   
  Thanks in advance for the help.
   
  Regards
  Anand

Send instant messages to your online friends http://in.messenger.yahoo.com 

RE: Reading contents of file

2006-01-08 Thread anand kumar
Hi
   
 I have already tried the way u have told but when i use ' 
while($line=)' and the regex in the if loop then the regex pattern is 
matched only once in the current line and does'nt get repeated for the same 
line with differnt bookname present in the same line.
   
  For Eg.
   
  If the input is Genesis 45. with 1 chron ..
   
  here genesis an 1 chron are the book names which can be identified by the 
function .
   
  the output is:
  Genesis 45. eith 1 chron..
  here the loop does'nt get repeated for 1 chron.
   
  Please help in this regard

Dhanashri Bhate <[EMAIL PROTECTED]> wrote:
  Hi Anand,
You know where its going wrong then change it :)

Ok, I haven't gone into the regex etc. but I see these 2 major problems:

1. $line=; should be also there inside the while loop, to make the
program get the next line in the file, and hence eventually come out of the
loop when it reaches EOF.
Or, make the change the while loop as "while ( $line = )" and put the
regex check in "if" conditional.

2. Again, you want to make some changes to the line you've read, and then
print it to the output file, the line "print OUT $line;" should be in the
while loop, not outside.

See this:
while ( $line = {
if ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
{
..
... do what u want if regex matches
...
print OUT $line;
}
}

Dhanashri

-Original Message-
From: anand kumar [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 09, 2006 11:31 AM
To: beginners@perl.org
Subject: Reading contents of file


Hi

I am new to PERL. I have a doubt, The following script is used to read the
contents of a file (word by word (or) word preceeded by a number), check for
the existence of the matched pattern which is done by the help of bookref()
sub, if it is found then the matched pattern is prefixed with the tag
. When I run the following script it goes to unending because it is
not pointing to the next string after the complete execution of the loop .
Please correct me 

open IN, "r1.dat";
open OUT, ">r1.txt";
$/=undef;
$line=;
while ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
{
$book=$1;
print $book,"\n";
$t_book=$book;
$t_book=~s/\.//g;
$t_book=~s/\\l=([a-z]+)\\/$1/ig;
$t_book=~s/<(|\/)(B|I|SC|U)>//ig;
$quote=bibref($t_book);
if($quote)
{
$line=~s/($book)/$1/ig;
}
}
print OUT $line;
close(IN);

Thanks in advance for the help.

Regards
Anand

Send instant messages to your online friends http://in.messenger.yahoo.com 


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



  


Send instant messages to your online friends http://in.messenger.yahoo.com 

RE: Reading contents of file

2006-01-09 Thread anand kumar
Hi
   
  I have tried the way u explained, Thanks for that But I have few new problems 
. The code after the modification is as below:
   
  open IN, "r1.dat";
open OUT, ">r1.txt";
$/=undef;
$line=;
 while($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/cig)
{
 $book=$1;
 print $book,"\n";
 $t_book=$book;
 $t_book=~s/\.//g;
 $t_book=~s/\\l=([a-z]+)\\/$1/ig;
 $t_book=~s/<(|\/)(B|I|SC|U)>//ig;
 $quote=bibref($t_book);
 if($quote)
 {
  print OUT "$book";
 }
 else
 {
  print OUT $book," ";
 }
$line=~s/$book//;
 
}
close(IN);
   
  Input:
  Genesis 45. anand 1 chron mca 2 chron
  1 chron kumar
   
  output:
  Genesis. anand 1 chron  mca 2 chron1 chron 
 kumar 

  Here the problems are :
  1) The new line character '\n' cannot be detected.
  2)I am not able to print the unmatched data i.e in the above example '45' 
doesn't match the regex in the while loop so this cannot be printed in the 
output file.
   
  Plz suggest me in the matter . Is there any way to find the data which is 
unmatched with the regex.
   
  Thanks for the help
   
  Regards
  Anand
  
Dhanashri Bhate <[EMAIL PROTECTED]> wrote:
v\:* {behavior:url(#default#VML);}  o\:* {behavior:url(#default#VML);}  
w\:* {behavior:url(#default#VML);}  .shape {behavior:url(#default#VML);}
Ok, got it now J , sorry, I misunderstood your problem earlier.
  If you are expecting multiple matches in a single line, then i would suggest, 
keep the regex match as it is  i.e. while 
($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi),
  But inside the loop when you a find a match and do relevant things, modify 
$line in such a way, that you get the next ( may be replace the matched 
substring with empty string? ) This way the lop will end once all matches on 
the line are found.
   
  Well I’m not a Perl expert, so this is what I could think of J But I’m sure 
there must be a better way to do it!
   
  Dhanashri
   
   
   
   
  
-
  
  From: anand kumar [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 09, 2006 12:56 PM
To: [EMAIL PROTECTED]; beginners@perl.org
Subject: RE: Reading contents of file

   
Hi

 

   I have already tried the way u have told but when i use ' 
while($line=)' and the regex in the if loop then the regex pattern is 
matched only once in the current line and does'nt get repeated for the same 
line with differnt bookname present in the same line.

 

For Eg.

 

If the input is Genesis 45. with 1 chron ..

 

here genesis an 1 chron are the book names which can be identified by the 
function .

 

the output is:

Genesis 45. eith 1 chron..

here the loop does'nt get repeated for 1 chron.

 

Please help in this regard

Dhanashri Bhate <[EMAIL PROTECTED]> wrote:

Hi Anand,
Yo! u know where its going wrong then change it :)

Ok, I haven't gone into the regex etc. but I see these 2 major problems:

1. $line=; should be also there inside the while loop, to make the
program get the next line in the file, and hence eventually come out of the
loop when it reaches EOF.
Or, make the change the while loop as "while ( $line = )" and put the
regex check in "if" conditional.

2. Again, you want to make some changes to the line you've read, and then
print it to the output file, the line "print OUT $line;" should be in the
while loop, not outside.

See this:
while ( $line = 
{
if ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
{
..
... do what u want if regex matches
...
print OUT $line;
}
}

Dhanashri

-Original Message-
From: anand kumar [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 09, 2006 11:31 AM
To: beginners@perl.org
Subject: Reading conte! nts of file


Hi

I am new to PERL. I have a doubt, The following script is used to read the
contents of a file (word by word (or) word preceeded by a number), check for
the existence of the matched pattern which is done by the help of bookref()
sub, if it is found then the matched pattern is prefixed with the tag
. When I run the following script it goes to unending because it is
not pointing to the next string after the complete execution of the loop .
Please correct me 

open IN, "r1.dat";
open OUT, ">r1.txt";
$/=undef;
$line=;
while ($line=~m/([123]?[\.\s]*[a-z\\=\.]+)/oi)
{
$book=$1;
print $book,"\n";
$t_book=$book;
$t_book=~s/\.//g;
$t_book=~s/\\l=([a-z]+)\\/$1/ig;
$t_book=~s/<(|\/)(B|I|SC|U)>//ig;
$quote=bibref($t_book);
if($quote)
{
$line=~s/($book)/$1/ig;
}
}
print OUT $line;
close(IN);

Thanks in advance for the help.

Regards
Anand
Send instant messages to your online friends http://in.messenger.yahoo.com 


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



 

  Send instant messages to your online friends http://in.messenger.yahoo.com 


  

Send instant messages to your online friends http://in.messenger.yahoo.com 

Duplicates elements in an array

2006-02-05 Thread anand kumar
Hi all
   
 I have an array with hundreads of elements in it. Can anyone 
suggest the easiest way to keep only the duplicate elements in the array.
   
  Thanks in Advance for the help
   
  Regards
  Anand


-
 Jiyo cricket on Yahoo! India cricket

regex problem

2006-02-14 Thread anand kumar
Hi all,
   
   I have the following problem in the following regex replace. 
   
  $line=~s!\b($name)\b!$1!g;
   
  here this regex finds the exact matching of the content in $name and does the 
needed but in some examples the variable $name may contain backslash characters 
like 'gene\l=s\' , in this type of cases the replace string does not work so i 
have removed '\b' on either side and used the following
   
  $line=~s!(\Q$name\E)!$1!g;
   
  This works fine but the problem is that the replacement is not done on the 
exact word but also on substrings which is unnecessary.
   
  if i use both \b\b and \Q\E then the code fails to replace.
   
  please send suggestions in this regard
   
  Thanks in advance for the help
   
  Regards
  Anand
   


-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Re: regex problem

2006-02-15 Thread anand kumar


"John W. Krahn" <[EMAIL PROTECTED]> wrote:anand kumar wrote:
> Hi all,

Hello,

> I have the following problem in the following regex replace.
> 
> $line=~s!\b($name)\b!$1!g;
> 
> here this regex finds the exact matching of the content in $name and does
> the needed but in some examples the variable $name may contain backslash
> characters like 'gene\l=s\' , in this type of cases the replace string does
> not work so i have removed '\b' on either side and used the following
> 
> $line=~s!(\Q$name\E)!$1!g;
> 
> This works fine but the problem is that the replacement is not done on the
> exact word but also on substrings which is unnecessary.
> 
> if i use both \b\b and \Q\E then the code fails to replace.
> 
> please send suggestions in this regard

$line=~s!\b(\Q$name\E)\b!$1!g;



John
-- 
use Perl;
program
fulfillment
   
  Hi john,
   
   i have tried the above method but the replace ment is done .
  regards
  anand


-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

hash array

2006-02-15 Thread anand kumar
Hi all
   
 while learning hash arrays i have got a doubt i.e if the data is 
in the following manner
   
  Name ABC
  AGE  25
  Book perl
  Name DEF
  AGE 20
  Book linux
  Name GHI
  AGE 21
  Book PHP
  .
  ..
  
  (assume that the above data is already present in a file or it is being 
accepted from user using a program in the above format)
  can anyone help me on how to store the data with hash key as the 'Name' and 
the hash strings as the details of 'AGE' and 'Book'
   
  Thanks in advance for the help
   
  Regards
  Anand


-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Re: hash array

2006-02-15 Thread anand kumar
Hi ,
   
  Thanks for the reply. but can u help me out if the data is large and need a 
loop to store(also if possible give instructions if the record has variable or 
optional number of fields).

Jeff Pang <[EMAIL PROTECTED]> wrote:
  

Name ABC
AGE 25
Book perl
Name DEF
AGE 20
Book linux
Name GHI
AGE 21
Book PHP
.

can anyone help me on how to store the data with hash key as the 'Name' and the 
hash strings as the details of 'AGE' and 'Book'


Hello,I think you could do it as following:

my %hash = ( 'ABC' => { 'AGE' => 25,
'Book' => 'perl',
},
'DEF' => { 'AGE' => 20,
'Book' => 'linux',
},
);

Then,you could access the final value,for example the 'perl',with this syntax:

print $hash{'ABC'}->{'Book'};

if you want to access all the value of 'ABC',you can do:

print $_," ",$hash{'ABC'}->{$_},"\n" for (keys %{$hash{'ABC'}});

Hope that helps.


--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

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






-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Re: hash array

2006-02-15 Thread anand kumar
Hi all
   
  Thanks alot that works fine.
   
  Regards
  anand

Jeff Pang <[EMAIL PROTECTED]> wrote:
  hello,I wrote it as below simply,maybe it's not so good,you could modify it.

use strict;
use warnings;

my %hash;
while(<>)
{
next if /^$/;
if (/Name\s+(.*)$/)
{
my $name = $1;
my $age = $1 if ($_ = <>) =~ /AGE\s+(.*)$/;
my $book = $1 if ($_ = <>) =~ /Book\s+(.*)$/;
$hash{$name}->{age} = $age;
$hash{$name}->{book} = $book;
}
}

# then print the value




-----Original Message-
From: anand kumar 
Sent: Feb 15, 2006 10:33 PM
To: beginners@perl.org
Subject: Re: hash array

Hi ,

Thanks for the reply. but can u help me out if the data is large and need a 
loop to store(also if possible give instructions if the record has variable or 
optional number of fields).

Jeff Pang 
wrote:


Name ABC
AGE 25
Book perl
Name DEF
AGE 20
Book linux
Name GHI
AGE 21
Book PHP
.

can anyone help me on how to store the data with hash key as the 'Name' and the 
hash strings as the details of 'AGE' and 'Book'


Hello,I think you could do it as following:

my %hash = ( 'ABC' => { 'AGE' => 25,
'Book' => 'perl',
},
'DEF' => { 'AGE' => 20,
'Book' => 'linux',
},
);

Then,you could access the final value,for example the 'perl',with this syntax:

print $hash{'ABC'}->{'Book'};

if you want to access all the value of 'ABC',you can do:

print $_," ",$hash{'ABC'}->{$_},"\n" for (keys %{$hash{'ABC'}});

Hope that helps.


--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

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






-
Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com



-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.