Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Jim Gibson
> On Mar 24, 2015, at 7:27 AM, Anirban Adhikary > wrote: > > Hi Jim > > In your code there is some hard coded value [ /RXMOI:MO=RXOTRX > But I can't put any hard coded value since I use this code as a function and > pass the filename as an argument. > As you can see in my code there is no har

Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Anirban Adhikary
Hi Jim In your code there is some hard coded value [ * /RXMOI:MO=RXOTRX* But I can't put any hard coded value since I use this code as a function and pass the filename as an argument. As you can see in my code there is no hard coded value. Best Regards Anirban. On Tue, Mar 24, 2015 at 7:44 PM,

Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Simon Reinhardt
Am 24.03.2015 um 14:03 schrieb Shlomi Fish: > This can be more idiomatically written as: > > $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] I agree, a sort { $a->[0] <=> $b->[0] or $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } is certainly more readable than the C-style sort {

Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Jim Gibson
> On Mar 24, 2015, at 3:42 AM, Anirban Adhikary > wrote: > > Hi List > I have a file like this. > RXMOI:MO=RXOTRX-473-0,SC=0,DCP1=178,SIG=SCCONC,DCP2=179&&186,TEI=0; > RXMOI:MO=RXOTRX-473-5,SC=0,DCP1=223,SIG=SCCONC,DCP2=224&&231,TEI=5; > RXMOI:MO=RXOTRX-473-1,SC=0,DCP1=187,SIG=SCCONC,DCP2=188&&

Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Shlomi Fish
Hi Simon, thanks for helping Anirban, but I have a small comment about your code: On Tue, 24 Mar 2015 13:11:56 +0100 Simon Reinhardt wrote: > Hi Anirban, > > first we have to be clear how you want to sort the lines. > Does 10-1 sort before 1-11 ? > Do you want numeric (use <=>) or alphabetic (

Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Simon Reinhardt
Hi Anirban, first we have to be clear how you want to sort the lines. Does 10-1 sort before 1-11 ? Do you want numeric (use <=>) or alphabetic (use cmp) order? > while (my $line = <$RFH>) { > chomp($line); > if ($line =~ m/.*?\-(\d+)\-(\d+).*/) { > $sequence_no = "

Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Shaji Kalidasan
Hi Anirban, In case if you print the complete data (the full line) then the following approach may help. Here is one way to do it [code] use strict; use warnings; my %data; open my $fin, '<', 'data.txt' or die "Cannot open file ($!)"; while(<$fin>) { chomp; my($val) = split ',', $_; #s

Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Shaji Kalidasan
Hi Anirban, Here is one way to do it [code] use strict; use warnings; my @data; open my $fin, '<', 'data.txt' or die "Cannot open file ($!)"; while(<$fin>) { my($val) = split ',', $_; #split the data using comma my($key, $value) = split '=', $val; #split the values using equal sign (=)

Re: How to sort a file based on numerical values exists in each line

2015-03-24 Thread Anirban Adhikary
Hi List I have completed the code successfully. Please find the code below. #!/usr/bin/perl use strict; use warnings; my $file_name = "RXMOI_TRX_CMD"; open my $RFH, '<', $file_name; my $sequence_no; my %file_content_hash; while (my $line = <$RFH>) { chomp($line); if ($line =~ m/.

How to sort a file based on numerical values exists in each line

2015-03-24 Thread Anirban Adhikary
Hi List I have a file like this. RXMOI:MO=RXOTRX-*473-0*,SC=0,DCP1=178,SIG=SCCONC,DCP2=179&&186,TEI=0; RXMOI:MO=RXOTRX-*473-5*,SC=0,DCP1=223,SIG=SCCONC,DCP2=224&&231,TEI=5; RXMOI:MO=RXOTRX-*473-1*,SC=0,DCP1=187,SIG=SCCONC,DCP2=188&&195,TEI=1; RXMOI:MO=RXOTRX-*473-9*,SC=0,DCP1=259,SIG=SCCONC,DCP2=26

Re: compare and replace each line with Hash

2012-11-18 Thread Jim Gibson
On Nov 15, 2012, at 7:30 PM, Mohan L wrote: > Dear All, > > The below is my input data: > > $ cat demo.txt > 159350,PP02,Backup,0,Done > 159349,B02_bkp,Backup,0,Done > 159347,B02_bkp,Backup,0,Done > 159346,B02_bkp,Backup,0,Done > 159345,B02_bkp,Backup,0,Not > 159344,02_bkp,Backup,0,Done > > I

compare and replace each line with Hash

2012-11-15 Thread Mohan L
Dear All, The below is my input data: $ cat demo.txt 159350,PP02,Backup,0,Done 159349,B02_bkp,Backup,0,Done 159347,B02_bkp,Backup,0,Done 159346,B02_bkp,Backup,0,Done 159345,B02_bkp,Backup,0,Not 159344,02_bkp,Backup,0,Done I am using Text::CSV_XS to read the above comma separated file. Here is th

Re: join each entries in a file

2012-08-14 Thread jet speed
Thanks Shawn, Appreciate your help !! On Tue, Aug 14, 2012 at 12:57 PM, Shawn H Corey wrote: > On Tue, 14 Aug 2012 11:50:14 +0100 > jet speed wrote: > > > i have an @newfa with 50:00:00:08:44:9a:fb:79:90 > > 50:00:00:90:44:9a:fb:30:90 50:00:00:55:44:9a:fb:79:66 and a file as > > below. now i wa

Re: join each entries in a file

2012-08-14 Thread Shlomi Fish
L45 > 10:00:00:00:c7:d5:cd:16:ca > 50:00:00:08:44:9a:fb:74:90 > > > Thanks > Sj > Well, there's a limit to how much we are going to write your code for you because then you will learn little. What I suggest you do is: 1. Read eac

Re: join each entries in a file

2012-08-14 Thread Shawn H Corey
On Tue, 14 Aug 2012 11:50:14 +0100 jet speed wrote: > i have an @newfa with 50:00:00:08:44:9a:fb:79:90 > 50:00:00:90:44:9a:fb:30:90 50:00:00:55:44:9a:fb:79:66 and a file as > below. now i want check if the @newfa entry present in the file if it > exists then i need to print the matching zone: nam

Re: join each entries in a file

2012-08-14 Thread jet speed
file.txt > > 5008449AFB7494 > > 5008449AFB749C > > 50000008449AFB779D > > > > now i want to introduce : inbetween as below for each of these > > entries in the file > > > > 50:00:00:08:44:9A:FB:74:90 > > > > i did come across join function in perl,

Re: join each entries in a file

2012-08-14 Thread Shlomi Fish
Hi Sj, On Tue, 14 Aug 2012 10:55:13 +0100 jet speed wrote: > Hi All, > > I have a file as below > > file.txt > 5008449AFB7494 > 5008449AFB749C > 5008449AFB779D > > now i want to introduce : inbetween as below for each of these > entries in the

join each entries in a file

2012-08-14 Thread jet speed
Hi All, I have a file as below file.txt 5008449AFB7494 5008449AFB749C 5008449AFB779D now i want to introduce : inbetween as below for each of these entries in the file 50:00:00:08:44:9A:FB:74:90 i did come across join function in perl, not sure how to apply inbetween each entries

Re: Read line by line from a file & search each line on another file

2010-03-13 Thread John W. Krahn
manu wrote: Want to do a perl program - Read from file 1 - line1, line2etc Search line1 on file2 (all lines) Then Search line 2 on file 2... Ouput results of search. perldoc -q "How can I read in an entire file all at once" perldoc -q "How do I efficiently match many regular expressions

Re: Read line by line from a file & search each line on another file

2010-03-13 Thread Shawn H Corey
manu wrote: > Want to do a perl program - > > Read from file 1 - line1, line2etc > Search line1 on file2 (all lines) > Then Search line 2 on file 2... > > Ouput results of search. > > What code do you have so far? -- Just my 0.0002 million dollars worth, Shawn Programming is as m

Read line by line from a file & search each line on another file

2010-03-13 Thread manu
Want to do a perl program - Read from file 1 - line1, line2etc Search line1 on file2 (all lines) Then Search line 2 on file 2... Ouput results of search. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.or

Re: How to toggle a variable with each iteration?

2009-11-25 Thread Jim Gibson
On 11/25/09 Wed Nov 25, 2009 2:14 AM, "kusuma ramaswamy" scribbled: > Hello, I am new to perl. I would like to know how to toggle a variable with > each iteration in a loop ?? while( ... ) { $variable = ! $variable; } Does that do what you want? -- To unsubscribe, e

Re: How to toggle a variable with each iteration?

2009-11-25 Thread Dermot
2009/11/25 kusuma ramaswamy : > Hello, I am new to perl. I would like to know how to toggle a variable with > each iteration in a loop ?? Hi, I'm not entirely sure that I understand your requirements but this might get you started. You want to scope your variables with the keywo

How to toggle a variable with each iteration?

2009-11-25 Thread kusuma ramaswamy
Hello, I am new to perl. I would like to know how to toggle a variable with each iteration in a loop ?? Regards, suma

Re: ending a character to each line

2009-02-07 Thread sf
On Feb 5, 6:09 pm, jwkr...@shaw.ca (John W. Krahn) wrote: > stuforman wrote: > > i want to use perl to end each line with a '~'. i would really > > appreciate any syntax that would help me do this... > > $line =~ s/$/~/; > > John > -- > Those people

Re: ending a character to each line

2009-02-05 Thread John W. Krahn
stuforman wrote: i want to use perl to end each line with a '~'. i would really appreciate any syntax that would help me do this... $line =~ s/$/~/; John -- Those people who think they know everything are a great annoyance to those of us who do.-- Isaac Asimov -- To unsu

Re: ending a character to each line

2009-02-05 Thread Telemachus
On Thu Feb 05 2009 @ 11:17, stuforman wrote: > i want to use perl to end each line with a '~'. i would really > appreciate any syntax that would help me do this... > > thanks in advance Here's one quick version. This will work and ignore lines without any t

ending a character to each line

2009-02-05 Thread stuforman
i want to use perl to end each line with a '~'. i would really appreciate any syntax that would help me do this... thanks in advance -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: read line in, print each line to separate file

2008-12-24 Thread John W. Krahn
Charlie Farinella wrote: On Wednesday 24 December 2008, Mr. Shawn H. Corey wrote: On Wed, 2008-12-24 at 13:16 -0500, Charlie Farinella wrote: I need to read in a file of 200 lines and print each out to a separate file. I've been stumbling with this, but I don't know how to name eac

Re: read line in, print each line to separate file

2008-12-24 Thread Charlie Farinella
On Wednesday 24 December 2008, Mr. Shawn H. Corey wrote: > On Wed, 2008-12-24 at 13:16 -0500, Charlie Farinella wrote: > > I need to read in a file of 200 lines and print each out to a separate > > file. > > > > I've been stumbling with this, but I don&

Re: read line in, print each line to separate file

2008-12-24 Thread Mr. Shawn H. Corey
On Wed, 2008-12-24 at 13:16 -0500, Charlie Farinella wrote: > I need to read in a file of 200 lines and print each out to a separate > file. > > I've been stumbling with this, but I don't know how to name each outfile > individually. I was hoping to see 200 fil

read line in, print each line to separate file

2008-12-24 Thread Charlie Farinella
I need to read in a file of 200 lines and print each out to a separate file. I've been stumbling with this, but I don't know how to name each outfile individually. I was hoping to see 200 files named tx1 - tx200, but instead I get tx1234. for 123 files and th

Re: Script neeed for creating home directories for each student!!

2008-08-19 Thread yitzle
On Tue, Aug 19, 2008 at 10:39 AM, Jyotishmaan Ray <[EMAIL PROTECTED]> wrote: > I would need it in a different server to create all the home directories. > > Kindly provide a different script for that. There are websites out there that allow you to hire someone to work on a project for you... --

Re: Script neeed for creating home directories for each student!!

2008-08-19 Thread Jyotishmaan Ray
ectories for each student!! To: [EMAIL PROTECTED] Cc: beginners@perl.org Date: Tuesday, August 19, 2008, 7:01 PM You can do one thing you just add the following lines at end of the while  loop like this The lines in bold character are newly added And one more thing when u will creating the home

Re: Script neeed for creating home directories for each student!!

2008-08-19 Thread Anirban Adhikary
You can do one thing you just add the following lines at end of the while loop like this The lines in bold character are newly added And one more thing when u will creating the home directory of the users then u have the write ownership on /mnt/btech directory. Regards Anirban Adhikary. use str

Script neeed for creating home directories for each student!!

2008-08-19 Thread Jyotishmaan Ray
Thank you Anirban. Also do you any script for creating the home directories in a server machine for 424 students in the path :  /mnt/btech/uid, where uid = s08-1-5-097 for the same file read, as before. All the students must have all permissions to read, write and execute in their home dir

Re: going through array of hash, it only goes through limited amount of keys while doing for each command

2008-04-23 Thread Richard Lee
x_var.. Tracing the program, it only goes through 6 lines of keys in @t_array (random keys) (it has 89 keys total).. what am i doing wrong? while (my ($keys,$values) = each(%yahoo) ) { no strict 'refs'; MF: for my $i (0 .. $#t_array) {

Re: going through array of hash, it only goes through limited amount of keys while doing for each command

2008-04-23 Thread Richard Lee
x_var.. Tracing the program, it only goes through 6 lines of keys in @t_array (random keys) (it has 89 keys total).. what am i doing wrong? while (my ($keys,$values) = each(%yahoo) ) { no strict 'refs'; MF: for my $i (0 .. $#t_array) {

Re: going through array of hash, it only goes through limited amount of keys while doing for each command

2008-04-23 Thread Richard Lee
x_var.. Tracing the program, it only goes through 6 lines of keys in @t_array (random keys) (it has 89 keys total).. what am i doing wrong? while (my ($keys,$values) = each(%yahoo) ) { no strict 'refs'; MF: for my $i (0 .. $#t_array) {

Re: going through array of hash, it only goes through limited amount of keys while doing for each command

2008-04-23 Thread Richard Lee
x_var.. Tracing the program, it only goes through 6 lines of keys in @t_array (random keys) (it has 89 keys total).. what am i doing wrong? while (my ($keys,$values) = each(%yahoo) ) { no strict 'refs'; MF: for my $i (0 .. $#t_array) {

Re: going through array of hash, it only goes through limited amount of keys while doing for each command

2008-04-23 Thread John W. Krahn
m, it only goes through 6 lines of keys in @t_array (random keys) (it has 89 keys total).. what am i doing wrong? while (my ($keys,$values) = each(%yahoo) ) { no strict 'refs'; MF: for my $i (0 .. $#t_array) { for ( my($k,$v) = each

going through array of hash, it only goes through limited amount of keys while doing for each command

2008-04-23 Thread Richard Lee
ugh 6 lines of keys in @t_array (random keys) (it has 89 keys total).. what am i doing wrong? while (my ($keys,$values) = each(%yahoo) ) { no strict 'refs'; MF: for my $i (0 .. $#t_array) { for ( my($k,$v) = each

Re: Passing each of the files in a directory as parameter to theperl script

2007-08-08 Thread Dr.Ruud
Ken Foskey schreef: > On Wed, 2007-08-08 at 22:26 +0200, Dr.Ruud wrote: >> You might be able to change this to creating (and filling) the files >> in a tmp directory, and move them to the processing directory once >> they are finished. Then there is no need to have those 0-bytes flag >> files. A b

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-08 Thread Ken Foskey
On Wed, 2007-08-08 at 22:26 +0200, Dr.Ruud wrote: > You might be able to change this to creating (and filling) the files in > a tmp directory, and move them to the processing directory once they are > finished. Then there is no need to have those 0-bytes flag files. A bit > like how a maildir work

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-08 Thread Dr.Ruud
"Mihir Kamdar" schreef: > There is a parent directory where the input files will be stored. > These files will keep on coming into the parent directory. There is a > child directory where these input files will just get touched(0 byte > files). You might be able to change this to creating (and fi

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mihir Kamdar
e, write the output to a different directory, and then delete the processed file. But, the way we read files in a directory through readdir, how do we write output of each of the processed files to a different directory. @Rob: After processing each of the files, if we are removing them, then why do

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mr. Shawn H. Corey
Mihir Kamdar wrote: It has to be ASAP Shawn..but if that's not possible, as a workaround we may also look at every half hour or something like that... do you have any suggestions in mind? Well, if I could change anything, I'd change my program to a deamon and have it listen on a socket.

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Rob Dixon
Mihir Kamdar wrote: Can you explain with reference to your code, what does this do: my $access = (stat $fname)[8]; In my last post I asked you to please bottom-post your responses to this group. That means to put your reply after the text of the message you are replying to. If you look at

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Paul Lalli
On Aug 1, 11:57 am, [EMAIL PROTECTED] (Mihir Kamdar) wrote: > > On 8/1/07, Paul Lalli < [EMAIL PROTECTED]> wrote: > > > my %already_seen; > > > while (1) { > > >opendir my $dh, '.' or die "Could not open this directory: $!"; > > >while (my $file = readdir($dh)) { > > >next if $file

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread hwigoda
i believe it returns the permissions of the file to $access. -Original Message- >From: Mihir Kamdar <[EMAIL PROTECTED]> >Sent: Aug 1, 2007 10:49 AM >To: Paul Lalli <[EMAIL PROTECTED]> >Cc: beginners@perl.org >Subject: Re: Passing each of the files in a directo

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mihir Kamdar
Also.after reading each file and processing it, I want to write the output for each of them to a different directory. @Paul: my process_file($file) would scan the file and remove duplicate records from the file and write the o/p into another directory. That part is taken care of. On 8/1/07

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mihir Kamdar
ssible, as a workaround > we > > may also look at every half hour or something like that... > > So enter an infinite loop in which you process the directory, sleep > one second, process the directory, sleep, etc. > > > do you have any suggestions in mind? > > I a

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Paul Lalli
process the directory, sleep, etc. > do you have any suggestions in mind? > I am also unaware how to scan the directory for each of the fileslike in > shell i can do something like > for i in 'ls -lrt *.*" perldoc -f opendir perldoc -f readdir. I'm really not understand

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mihir Kamdar
hir Kamdar wrote: > >>> > >>> I have a requirement to read each of the files from a directory and > pass > >>> each one of them as a parameter to my perl script one by one. The > >>> requirement is such that my perl script should keep running in the &

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Rob Dixon
Mihir Kamdar wrote: On 8/1/07, Rob Dixon <[EMAIL PROTECTED]> wrote: Mihir Kamdar wrote: I have a requirement to read each of the files from a directory and pass each one of them as a parameter to my perl script one by one. The requirement is such that my perl script should keep runn

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mihir Kamdar
will scan through the child directory and process only those files which are present there... And yeah...as u said..i will use sleep after each processing.. Thanks, Mihir On 8/1/07, Tom Phoenix <[EMAIL PROTECTED]> wrote: > > On 8/1/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote:

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mihir Kamdar
It has to be ASAP Shawn..but if that's not possible, as a workaround we may also look at every half hour or something like that... do you have any suggestions in mind? I am also unaware how to scan the directory for each of the fileslike in shell i can do something like for i in &#x

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Tom Phoenix
th half-finished files? > There is a child > directory where these input files will just get touched(0 byte files). I think you're saying that your program has to create a zero-byte file in this "child" directory for each file it discovers in the "parent" directory.

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mr. Shawn H. Corey
Mihir Kamdar wrote: Also, these input files will keep on coming from some source. So, my perl file has to run continuously and pick each of the files as they come. How quickly does the Perl program have to process these files? ASAP, once an hour, once a day? -- Just my 0.0002 million

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mihir Kamdar
child directory and then go to the parent directory to process it. Only those files in the parent directory will be processed which have been touched in the child directory. Also, these input files will keep on coming from some source. So, my perl file has to run continuously and pick each of the

Re: Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Rob Dixon
Mihir Kamdar wrote: I have a requirement to read each of the files from a directory and pass each one of them as a parameter to my perl script one by one. The requirement is such that my perl script should keep running in the background and it should take each of the files as they enter into

Passing each of the files in a directory as parameter to the perl script

2007-08-01 Thread Mihir Kamdar
Hi, I have a requirement to read each of the files from a directory and pass each one of them as a parameter to my perl script one by one. The requirement is such that my perl script should keep running in the background and it should take each of the files as they enter into the target directory

Re: 2 modules share each other's methods, is that safe ?

2007-02-22 Thread Mug
w { > my ($class, $packA_ref) = @_; > my $self = { > A => $packA_ref; > }; > bless $self, $class; > return $self; > } That's a very great approach to make them know each other as early as by the construct level ! I don't need to worry about where I should create there link-up s

Re: 2 modules share each other's methods, is that safe ?

2007-02-22 Thread Igor Sutton
= {}; bless $self, $class; my $self->{B} = PackB->new($self); return $self; } package PackB; sub new { my ($class, $packA_ref) = @_; my $self = { A => $packA_ref; }; bless $self, $class; return $self; } This way they know about each other. But I

2 modules share each other's methods, is that safe ?

2007-02-21 Thread Mug
Hello List, My question is if this work safe ? Here I have the way to use 2 modules and shares their methods cross along, because I don't want to split out the common part as another package, since there are class properties inside. If I split out something, I have to rebuild the object again in

Re: Hi, how to extract five texts on each side of an URI? I post my own perl script and its use.

2006-11-14 Thread Jenda Krynicky
From: ťÔ Íő <[EMAIL PROTECTED]> > my $text; > for my $left_index (1..WIDTH) { >last if $start_index < $left_index; > $text .= $texts_arr[$start_index - $left_index] . ' '; > } > $text .= join(" ", @texts_arr[$start_index..$end_index]) . ' '; >for my $right_index (1..WIDTH) { >

RE: Hi, how to extract five texts on each side of an URI? I post my own perl script and its use.

2006-11-11 Thread Charles K. Clarkson
Hui Wang wrote: : Can anybody tell me how to improve the running speed of this : program? Thanks. I don't know if this is faster, but it is a more accurate solution. Your submitted code failed under some untested circumstances. I created another page similar to the

Re: Hi, how to extract five texts on each side of an URI? I post my own perl script and its use.

2006-11-11 Thread Robin Sheat
On Sunday 12 November 2006 13:17, 辉 王 wrote: > I can make my program do its job at last, but it runs slowly. > Can anybody tell me how to improve the running speed of this   > program? Thanks. Have you had a look with the Perl profiler to see which bits are going slow. That way you know to look at

Hi, how to extract five texts on each side of an URI? I post my own perl script and its use.

2006-11-11 Thread 辉 王
Hello everyone; Recently, when I want to implement Chakrabarti's algorithm using Perl, I found it difficult for me to extract five texts on each side of an URL(except anchor text). I can make my program do its job at last, but it runs slowly. Can anybody tell me how to im

Hi, how to extract five texts on each side of an URI? I post my own perl script and its use.

2006-11-09 Thread 辉 王
Hello, everyone, Recently, when I want to implement Chakrabarti's algorithm using Perl, I found it difficult for me to extract five texts on each side of an URL(except anchor text). I can make my program do its job at last, but it runs slowly. Can anybody tell me how to im

RE: Hi everyone, how to extract five texts on each side of an URI? I post my own perl script this time.

2006-11-09 Thread Charles K. Clarkson
Hui Wang wrote: : I can make my program do its job at last, but it runs : slowly. Can anybody tell me how to improve the running : speed of this program? You only provided the module. Can you supply a working example? Something we can actually run? HTH, Charles K.

Hi everyone, how to extract five texts on each side of an URI? I post my own perl script this time.

2006-11-09 Thread 辉 王
Hello, everyone, Recently, when I want to implement Chakrabarti's algorithm using Perl, I found it difficult for me to extract five texts on each side of an URL(except anchor text). I can make my program do its job at last, but it runs slowly. Can anybody tell me h

Re: Hi everyone, who can tell me how to extract five texts on each side of an URI? Thanks

2006-11-08 Thread Bjørge Solli
On Thursday 09 November 2006 01:33, 辉 王 wrote: > Hello, everyone, > > Recently, when I want to implement Chakrabarti's algorithm > > using Perl, I found it difficult for me to extract five texts on > > each side of an URL. > > I can make my program do its job at l

Re: Hi everyone, who can tell me how to extract five texts on each side of an URI? Thanks

2006-11-08 Thread Jeff Pang
> > Recently, when I want to implement Chakrabarti's algorithm > >using Perl, I found it difficult for me to extract five texts on > >each side of an URL. > > No one can give helps unless he also know this special algorithm. -- Books below translate

Hi everyone, who can tell me how to extract five texts on each side of an URI? Thanks

2006-11-08 Thread 辉 王
Hello, everyone, Recently, when I want to implement Chakrabarti's algorithm using Perl, I found it difficult for me to extract five texts on each side of an URL. I can make my program do its job at last, but it runs slowly. Can anybody tell me how to improve the running

Re: READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE.

2006-10-14 Thread perl pra
thanks a lot . it works.. --perlpra On 10/14/06, Dr.Ruud <[EMAIL PROTECTED]> wrote: "perl pra" schreef: > Subject: READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE. Don't shout. > Is there any other way of using the values in text file as varibales > in

Re: READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE.

2006-10-14 Thread Dr.Ruud
"perl pra" schreef: > Subject: READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE. Don't shout. > Is there any other way of using the values in text file as varibales > in perl script. Use a hash. See Uri Guttman's reply of yesterday in the "read from a file

Fwd: READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE.

2006-10-14 Thread perl pra
hi ALL, I am new to perl and I need some help from you guys, I have text file which looks like following(its about 100 lines) OUTPUTDIR=C:\Project\Module\outputdir INPUTDIR=C:\Project\Module\Inputdir Now I have to use each and every line of the text file in my perlscript as command line

READ TEXT FILE AND SET EACH LINE AS ENV VARIABLE.

2006-10-14 Thread perl pra
hi ALL, I am new to perl and I need some help from you guys, I have text file which looks like following(its about 100 lines) OUTPUTDIR=C:\Project\Module\outputdir INPUTDIR=C:\Project\Module\Inputdir Now I have to use each and every line of the text file in my perlscript as command line

Re: Print to new file for each results

2006-08-30 Thread Ken Foskey
ry often...) then you can simply reopen the file for each record. while( <> ) { my @lines = split(/[|]/); my $file; open( $file, '>>', "$lines[1].out" ) or die... print $file $_; close( $file ) or die...; } -- Ken Foskey FOSS developer -- To unsubscri

Re: Print to new file for each results

2006-08-29 Thread John W. Krahn
this and > create > a file for each result. > > So I would have a deptA.out file with deptA info then a deptB.out > file with dept b info and etc. > > This is not exactly doing what I need: > > [ snip ] > > How would I create a file for each hash then print t

Print to new file for each results

2006-08-29 Thread Ron McKeever
I am tring to use part of someones elses code that creates a data file which prints out like this: ip|result|deptA|data ip|result|deptB|data ip|result|deptC|data My goal instead of having all the data in one big file is to loop this and create a file for each result. So I would have a

Re: Print to new file for each results

2006-08-29 Thread Mumia W.
for each result. So I would have a deptA.out file with deptA info then a deptB.out file with dept b info and etc... [...] Although this is very different from your program, it should give you the general idea: use strict; use warnings; use File::Slurp; use File::Spec::Functions; my

Re: Intersection for each pair of arrays

2006-08-23 Thread Adriano Ferreira
my $b = shift; my %c; my %h; %h = (); foreach (@$a) { $c{$_}++ unless $h{$_}++ }; %h = (); foreach (@$b) { $c{$_}++ unless $h{$_}++ }; #$c{$_}++ foreach @$a; #$c{$_}++ foreach @$b; my (@union, @isect); while (my ($k, $v) = each %c)

Re: Intersection for each pair of arrays

2006-08-23 Thread Derek B. Smith
fy this example > that I can > > calculate union and intersection for each pair of > "n" arrays. > > Use a pair of nested loops; the outer picks one item > from the n > arrays, the inner picks a second. Inside, call your > current code once > for each pai

Re: Intersection for each pair of arrays

2006-08-23 Thread Mumia W.
On 08/23/2006 09:58 AM, Andrej Kastrin wrote: Hi, below is simple solution for union and intersection for a pair of arrays (@a and @b). How to modify this example that I can calculate union and intersection for each pair of "n" arrays. You could turn your code into a function a

Re: Intersection for each pair of arrays

2006-08-23 Thread Tom Phoenix
On 8/23/06, Andrej Kastrin <[EMAIL PROTECTED]> wrote: below is simple solution for union and intersection for a pair of arrays (@a and @b). How to modify this example that I can calculate union and intersection for each pair of "n" arrays. Use a pair of nested loops; the oute

Intersection for each pair of arrays

2006-08-23 Thread Andrej Kastrin
Hi, below is simple solution for union and intersection for a pair of arrays (@a and @b). How to modify this example that I can calculate union and intersection for each pair of "n" arrays. Thanks in advance for any suggestion, Andrej ## use warnings; @a = (

Re: Each char / letter --> array from string value

2005-12-29 Thread Dr.Ruud
Chris Devers: > $ perl -le '$i = "abcd"; @j = split //, $i; print join "\n", @j;' A good alternative to [print join "\n", @list] is to set the (see perldoc perlvar) to "\n". perl -le "$,=qq{\n}; print split //, q{abcd}" The qq{} is to make it work under CMD.EXE too, the q{abcd} can also be w

Re: Each char / letter --> array from string value

2005-12-28 Thread Umesh T G
On 12/28/05, Adriano Ferreira <[EMAIL PROTECTED]> The usual way to tear apart a string into an array with characters is @chars = split '', $string; It is documented at C. On 12/28/05, Chris Devers <[EMAIL PROTECTED]> wrote: > > $ perl -le '$i = "abcd"; @j = split //, $i; print join "\n", @j;'

Re: Each char / letter --> array from string value

2005-12-28 Thread Chris Devers
On Wed, 28 Dec 2005, Umesh T G wrote: > I want an alternative solution, if any. Here's one: $ perl -le '$i = "abcd"; @j = split //, $i; print join "\n", @j;' a b c d $ -- Chris Devers 0ª¸IQ'‘éL -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTE

Re: Each char / letter --> array from string value

2005-12-28 Thread Adriano Ferreira
On 12/28/05, Umesh T G <[EMAIL PROTECTED]> wrote: > I need to put each letter from a string to an array. The usual way to tear apart a string into an array with characters is @chars = split '', $string; It is documented at C. -- To unsubscribe, e-mail: [EMAIL PROTEC

Each char / letter --> array from string value

2005-12-28 Thread Umesh T G
Hi List, I need to put each letter from a string to an array. I am doing it this way and it works. I wanna know if there is any other better way to do this / a built-in function. #! /usr/bin/perl $srt ="123"; $sl = length $srt; $val= join (':', split(/ */, $srt) ); @

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

Re: for each

2005-10-07 Thread Mark Sargent
Wijaya Edward wrote: Hi Mark, Edward, for a beginner, would you mind explaining what the >(1 .. $#arr) $#arr is the index of the last element in the array ok, so 1 .. $#arr is the same as 1 .. 2 where 2 is the index of b, yes..? and qw actually do in this code.? Cheers

RE: for each

2005-10-07 Thread Thomas Bätzler
Mark Sargent <[EMAIL PROTECTED]> asked: > >>$ perl -e ' > >>@arr = qw (a b c); > >> foreach(1 .. $#arr) > >>{ > >> print "$arr[$_]\n"; > >>}' > Edward, for a beginner, would you mind explaining what the (1 > .. $#arr) and qw actually do in this code.? Cheers I'm not Edward, but I'll give it a

Re: for each

2005-10-07 Thread Wijaya Edward
Hi Mark, > > > > Edward, for a beginner, would you mind explaining what the >(1 .. $#arr) $#arr is the index of the last element in the array > and qw actually do in this code.? Cheers with "qw" you are treating values inside as individual words automatically. Thus you don't need to put quo

Re: for each

2005-10-07 Thread Mark Sargent
$ perl -e ' @arr = qw (a b c); foreach(1 .. $#arr) { print "$arr[$_]\n"; }' prints: b c Is that what you want? -- Regards, Edward WIJAYA SINGAPORE Hi All, Edward, for a beginner, would you mind explaining what the (1 .. $#arr) and qw actually do in this code.? Cheers Mark Sarg

RE: for each

2005-10-07 Thread Thomas Bätzler
Hi, [EMAIL PROTECTED] <[EMAIL PROTECTED]> asked: > How do I get a for each-statement to start at element 1 > (second element) # probably bad for long lists foreach my $item ( @list[1..$#list] ){ ... } # quick but destroys @list foreach my $item ( splice @list,1 ){ ... } Of

Re: for each

2005-10-07 Thread gustav
Hi there! Yes, exactly. Thanx a lot! :-) /G > > > - Original Message - > From: [EMAIL PROTECTED] > Date: Friday, October 7, 2005 3:29 pm > Subject: for each > >> Hi there! >> > Hi! > >> How do I get a for each-statement to start at element

  1   2   >