Re: one liner for replacing under Windows?

2008-06-14 Thread Xavier Noria
On Sat, Jun 14, 2008 at 9:56 AM, Octavian Rasnita [EMAIL PROTECTED] wrote: Is there a one-liner command that can replace a certain text with another in more files specified with wildcards like *.html that works under Windows cmd? Since you ask this you probably know the Windows shell does not

Re: one liner for replacing under Windows?

2008-06-14 Thread Xavier Noria
On Sat, Jun 14, 2008 at 1:05 PM, Octavian Rasnita [EMAIL PROTECTED] wrote: From: Xavier Noria [EMAIL PROTECTED] On Sat, Jun 14, 2008 at 9:56 AM, Octavian Rasnita [EMAIL PROTECTED] wrote: Is there a one-liner command that can replace a certain text with another in more files specified

Re: what is ^M at the end of a line?

2008-05-21 Thread Xavier Noria
On Wed, May 21, 2008 at 4:20 PM, Remy Guo [EMAIL PROTECTED] wrote: it's really interesting... then how can i match that ^M using regex? i've tried chomp when reading each line but it doesn't work... That's \r everywhere except in Macs before Mac OS X. Some programs display \r as ^M but that's

Re: error message

2008-04-20 Thread Xavier Noria
On Apr 20, 2008, at 21:57 , Levente Kovacs wrote: Can anyone tell me what this error message mean? syntax error at ./dbubdate.pl line 181, near }continue The code around that line in that script is not well-formed. If you don't know what to do please send lines 170 to 190 specifying which

Re: error message

2008-04-20 Thread Xavier Noria
On Apr 20, 2008, at 22:45 , Levente Kovacs wrote: Thank you very much for your answer. I am sitting here for a day seeng what could be wrong, but I can't find it. I post a link to my code here. Thank you for your help in advance.

Re: Best way to grab lines n thru x of a file

2008-04-10 Thread Xavier Noria
On Apr 10, 2008, at 18:24 , Jonathan Mast wrote: Hi, I have a ~125MB file of which I want to read lines n thru n+x and write those into a separate file. What is the best way to go about this? Tie::File -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: Variables initialization

2008-03-17 Thread Xavier Noria
On Mar 17, 2008, at 11:51 , [EMAIL PROTECTED] wrote: How is it possible to initialize variable using 0 or '' and not having undef warning later on using them? Not reassigning to undef. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: to test maximum consecutive numbers

2007-12-11 Thread Xavier Noria
On Dec 11, 2007, at 9:53 PM, ciwei2103 wrote: Give a disk sequence know that is incrementing with base 16, such as , 0001 0003 0004 0008 0009 000A 000B 000F 0010 0011 how do I extract the a subset that is have at least 4 consecutives, such as 0008 0009 000A 000B I hope this has to do

Re: to test maximum consecutive numbers

2007-12-11 Thread Xavier Noria
On Dec 11, 2007, at 9:53 PM, ciwei2103 wrote: Give a disk sequence know that is incrementing with base 16, such as , 0001 0003 0004 0008 0009 000A 000B 000F 0010 0011 how do I extract the a subset that is have at least 4 consecutives, such as 0008 0009 000A 000B Sorry, the previous code

Re: fixed list combinatorics

2007-11-30 Thread Xavier Noria
On Nov 29, 2007, at 2:06 AM, Xavier Noria wrote: Indeed, the iterator provided by Algorithm::Combinatorics is faster only for lists of sizes = 7. (And gets to be twice as fast for size 16.) Certainly there's room for improvement here. For the archives, I copied the iterator in List

Re: fixed list combinatorics

2007-11-28 Thread Xavier Noria
On Nov 28, 2007, at 8:58 PM, yitzle wrote: In a personal email conversation, he realized what he was actually looking for is the power set. List::PowerSet http://search.cpan.org/~nikc/List-PowerSet-0.01/lib/List/PowerSet.pm If speed is an issue Algorith::Combinatorics provides subsets() in

Re: fixed list combinatorics

2007-11-28 Thread Xavier Noria
On Nov 28, 2007, at 9:54 PM, Xavier Noria wrote: On Nov 28, 2007, at 8:58 PM, yitzle wrote: In a personal email conversation, he realized what he was actually looking for is the power set. List::PowerSet http://search.cpan.org/~nikc/List-PowerSet-0.01/lib/List/PowerSet.pm If speed

Re: fixed list combinatorics

2007-11-28 Thread Xavier Noria
On Nov 28, 2007, at 10:37 PM, Xavier Noria wrote: On Nov 28, 2007, at 9:54 PM, Xavier Noria wrote: On Nov 28, 2007, at 8:58 PM, yitzle wrote: In a personal email conversation, he realized what he was actually looking for is the power set. List::PowerSet http://search.cpan.org/~nikc/List

Re: Writing DOS CRLF via Unix Perl

2007-11-09 Thread Xavier Noria
On Nov 8, 2007, at 9:33 PM, C.R. wrote: I run a script on unix Perl to write a text file. By default, when Perl writes \n it writes a line ending sequence which is native to the current OS. How do I force this particular script to always write DOS CRLF line endings? A good approach is to

Re: peek next line in file

2007-09-27 Thread Xavier Noria
On Sep 27, 2007, at 1:29 AM, Mahurshi Akilla wrote: Is there a way in perl to peek the next line in the file while keeping the line pointer the same? I want to do something like this: while (INFILE) { //do some stuff //?? peek next line ?? and enter conditional block// //do

Re: replace existing text within multiple text files: How?

2007-09-11 Thread Xavier Noria
On Sep 11, 2007, at 9:43 PM, Gerald Wheeler wrote: I have about 400 text files I need to replace the contents. All files are in the current directory as the perl script runs out of my $newText = This is my new text.. anybody's text goes here; open(INFILE, $plants) while () { print

Re: replace existing text within multiple text files: How?

2007-09-11 Thread Xavier Noria
On Sep 11, 2007, at 10:05 PM, Gerald Wheeler wrote: Correct That can be done with a one-liner: perl -0777 -pi.bak -e '$_ = q{new text goes here}' *.txt The options -p, -i, and -e are documented in perlrun. The flag -0777 has the side-effect of slurping the whole file into $_ (one file

Re: String question

2007-09-07 Thread Xavier Noria
On Sep 7, 2007, at 10:07 AM, Santana wrote: Hei all, i'am a newbie in PERL and i find a solution for this problem : I have a string xxx , i want put ones(1) on left of string, if this string dont have a length of 20 character. Example : if i have th string HELLO and woul like get this

Re: how to remove ^M character from every line

2007-09-03 Thread Xavier Noria
Those ^Ms are \015s, which is \r practically everywhere. Note that line-oriented scripts almost work on CRLF text files on Unix because CRLF has a trailing \n by chance. I think this is unfortunate because instead of just breaking your program there's the annoying situation where you

Re: substitution key-value

2007-08-27 Thread Xavier Noria
On Aug 27, 2007, at 10:59 AM, Petra Vide Ogrin wrote: Hi all, I have a hash and some prose text and want my perl to identify the keys of the hash in this text and replace them with the corresponding values of the keys. I tried the following foreach (keys %expan) { if ($sbl =~ m/$_/g)

Re: substitution key-value

2007-08-27 Thread Xavier Noria
On Aug 27, 2007, at 1:29 PM, Chas Owens wrote: Bad idea*, at least until Perl 5.10 (and maybe not even then). Well, it may or may not be a bad idea. On the one hand that performance penalty may be negligible for the OP problem and thus it just does not matter. On the other hand your

Re: Convert int for string

2007-08-26 Thread Xavier Noria
On Aug 26, 2007, at 3:22 AM, Randal L. Schwartz wrote: Perl is a very strongly typed language. The problem is that people keep thinking number or string is a type in Perl. It isn't. The type is called scalar. Other types are array and hash and filehandle and dirhandle and built-in

Re: Convert int for string

2007-08-26 Thread Xavier Noria
On Aug 26, 2007, at 3:52 PM, Peter Scott wrote: The term strong typing is so ill-defined as to make this an angels-dancing-on-a-pinhead discussion and unlikely to lead to any enlightenment. Even the Wikipedia definition says that there *is* no accepted definition and some of the common usages

Re: Convert from unix newlines to dos newlines

2007-08-25 Thread Xavier Noria
On Aug 25, 2007, at 4:54 AM, Yoyoyo Yoyoyoyo wrote: I use a mac and I was wondering if there was a way to convert unix newlines in a text file to dos newlines. Yeah, with a Perl one-liner it would be perl -pi -we 's/\n/\r\n/' file.txt or perl -pi.bak -we 's/\n/\r\n/' file.txt if you

Re: Convert from unix newlines to dos newlines

2007-08-25 Thread Xavier Noria
On Aug 25, 2007, at 4:53 PM, Yoyoyo Yoyoyoyo wrote: Thanks, but quick question. If I do it from the command line it works fine. But if I add: `perl -pi -we 's/\n/\r\n/' ./student.csv`; to my perl script it doesn't make the change to the file. Is there a reason for this? Sure, the

Re: How to create a package level variable

2007-08-24 Thread Xavier Noria
On Aug 24, 2007, at 11:58 AM, Sundeep Gupta wrote: The problem was that this module (XYZ) module uses another module, which again has the use statement to load XYZ. I don't know if the perl loads the module again and might be this caused to reset the value back to 0. When I commented the

Re: How to create a package level variable

2007-08-24 Thread Xavier Noria
On Aug 24, 2007, at 8:13 PM, Dr.Ruud wrote: Chas Owens schreef: [$db_initiali.ed] Unless you have some funky source filter installed that normalizes spelling variants Perl is going to have a problem. Yes, I like the idea: use autocorect; I think there's an Acme:: module that did

Re: perl include dependencies?

2007-08-22 Thread Xavier Noria
On Aug 21, 2007, at 3:37 PM, infobank wrote: I'm trying to embed djabberd (perl5 net-im) onto a m0n0wall base (FreeBSD). I found scandeps, and ran it on DJAbberd and found some useful information about the modules it relies upon. Is there any way to find out which files it relies upon? You

Re: Array modification

2007-08-16 Thread Xavier Noria
On Aug 16, 2007, at 11:47 AM, Sayed, Irfan (Irfan) wrote: I have one array which stores some data after executing specific command. Depends on situation , command has different output at different time. sometime array may store 4 values or it may store 5 values. Now my req. is that I need to

Re: One liner to change one line

2007-08-15 Thread Xavier Noria
On Aug 15, 2007, at 6:45 PM, Dennis G. Wicks wrote: Greetings; I have, conservatively, dozens of html files to change. I can find them and pass the file name to perl and do the usual s/// changes but there is one change I can't figure out. There is a line in each file that looks like

Re: One liner to change one line

2007-08-15 Thread Xavier Noria
On Aug 15, 2007, at 7:04 PM, Xavier Noria wrote: perl -0777 -pi.bak -we 's{(h1)(.*?)(/h1)}{$x = $2; $x =~ tr:-: :; $1$x$3}geis' *.html A small improvement, groups are unnecessary because the elements are guaranteed not to have hyphens (in general they could, for instance in a class

Re: die and exit

2007-08-13 Thread Xavier Noria
On Aug 13, 2007, at 9:29 AM, Jeff Pang wrote: Does die call exit when it's excuted? If so,when I overwrote exit() function in my script,would die call this customized exit? Do you want some code executed if the program dies? If that's the case assign a coderef to $SIG{__DIE__}:

Re: die and exit

2007-08-13 Thread Xavier Noria
On Aug 13, 2007, at 1:57 PM, Jeff Pang wrote: Yes that's fine. I think when we say 'use Apache qw/exit/' in modperl scripts,it may do the same things as you mentioned -- modify the typeglob directly -- but I'm not so sure. I don't know too much XS but looks like this code in

Re: Problem with my code

2007-08-03 Thread Xavier Noria
El Aug 3, 2007, a las 1:45 PM, Mr. Shawn H. Corey escribió: But the expression $hash{@cdr[2,3,6,7]} is the same as $hash{join ($,@cdr[2,3,6,7])} You have just replaced one special variable with another and $ is a bad choice since it's default is a space character, which may easily appear

Re: Convert Scientific Notation to decimal equivalent

2007-07-19 Thread Xavier Noria
El Jul 19, 2007, a las 12:19 AM, Joseph L. Casale escribió: Interesting, I see from your regexp you use a \A and \z, from Perldoc this means: \A Match only at beginning of string \z Match only at end of string I am not sure I understand this requirement? ^ and $ depend on flags,

Re: Convert Scientific Notation to decimal equivalent

2007-07-18 Thread Xavier Noria
El Jul 18, 2007, a las 11:19 PM, Joseph L. Casale escribió: How can I detect this, I have been running some code for a few days to develop some files and ran into the situation where I am getting the following data for input: 14.95313 14.45312 0 14.95313 1.570813E-015 0 14.95313 -14.45313

Re: interpolation of function reference in a here doc

2007-07-02 Thread Xavier Noria
On Jul 2, 2007, at 2:46 PM, Gabriel Striewe wrote: Dear List, I wanted to interpolate a function reference in a here doc. The following works fine: my $hello = sub { return hello world!; }; printf hello $s\n, $hello(); In Perl printf is rarely used because

Re: Redirecting file handler to STDOUT

2007-06-22 Thread Xavier Noria
On Jun 22, 2007, at 11:57 AM, Ben Edwards wrote: I am opening a log file: open( LOGFILE, cronlog.txt ); This is being written to in lots of places. I have been asked to change the program so if -m (manual) flag is passed the stuff that goes to the log file is send to standard out instead.

Re: regexp problem

2007-06-14 Thread Xavier Noria
On Jun 14, 2007, at 12:04 PM, Jorge Almeida wrote: I'm missing something about Perl's regexp: 1 #!/usr/bin/perl -w 2 use strict; 3 my $s=STDIN; 4 $s=~s/\D*//; 5 $s=~s/\D*//; 6 print $s\n; When input is 'a123b', I get '123b', but I expected '123'. s/\D+//g; -- fxn -- To

Re: regexp problem

2007-06-14 Thread Xavier Noria
On Jun 14, 2007, at 12:10 PM, Martin Barth wrote: On Thu, 14 Jun 2007 11:04:51 +0100 (WEST) Jorge Almeida [EMAIL PROTECTED] wrote: I'm missing something about Perl's regexp: 1 #!/usr/bin/perl -w 2 use strict; 3 my $s=STDIN; 4 $s=~s/\D*//; 5 $s=~s/\D*//; 6 print $s\n; When

Re: regexp problem

2007-06-14 Thread Xavier Noria
On Jun 14, 2007, at 12:49 PM, Jorge Almeida wrote: Martin was right (and I should have seen it from the start). The will go ahead as much as possible is true only in the sense that the greatest possible string of non-digits will be selected for deletion. With '$s=~s/\D*//;' in line 5 that

Re: Is there a perl equivalent to PHP variables $_POST and $_GET?

2007-06-11 Thread Xavier Noria
On Jun 10, 2007, at 9:18 PM, On Ali wrote: Is there a perl equivalent to PHP variables $_POST and $_GET? Perl is a general-purpose programming language and does not have web stuff builtin. To do web programming you need to pick some library/ framework like CGI.pm or Catalyst for example.

Re: Removing decimal points

2007-06-09 Thread Xavier Noria
On Jun 8, 2007, at 9:52 PM, ash wrote: I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. Use de int() function. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: Declaring constants in perl

2007-06-08 Thread Xavier Noria
On Jun 8, 2007, at 1:33 PM, Nath, Alok (STSD) wrote: Hi, What is the convention used to declare constants in perl ? In C we declare constant type in Capital letters , not sure how its in perl. Same convention: use constant FOO = 3; -- fxn -- To unsubscribe,

Re: Algorithm or module needed

2007-06-01 Thread Xavier Noria
On Jun 1, 2007, at 4:29 PM, Beginner wrote: Hi, I am trying to copy some file from a removable HDD to a network drive. I want replicate the directory structure and omit un-needed files. The directory paths a 4-5 levels deep and I am trying to work out an efficient way to recreate the

Re: Assign a delimiter variable

2007-05-15 Thread Xavier Noria
On May 15, 2007, at 6:42 PM, Mike Blezien wrote: Hello, this one has been driving me nuts and I'm sure it's something very simple I maybe overlooking. I need to assign a delimiter variable IE: Pipe or Comma delimiter: my $del = '|'; # use either a '|' or ',' my $dataline =

Re: Assign a delimiter variable

2007-05-15 Thread Xavier Noria
On May 15, 2007, at 6:49 PM, Xavier Noria wrote: To prevent this there's quotemeta(), which is available in literals as \E: Oh sorry, I meant \Q there. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: call system command

2007-05-14 Thread Xavier Noria
On May 14, 2007, at 3:44 PM, Tatiana Lloret Iglesias wrote: Hi all, I have to execute this command from perl: my $status = system(d:\\blast\\bin\\blastall -p blastn -i $file -d $patDB -o $workdir\\blast_$blast_file_id.txt); but the problem is that $workdir contains spaces how can I

Re: call system command

2007-05-14 Thread Xavier Noria
On May 14, 2007, at 3:52 PM, Tatiana Lloret Iglesias wrote: Thank a lot! Another related question,,, system command can be used also for linux? Sure. Of course it is unlikely that the arguments themselvels are portable in practice, I mean blastall won't probably be located at d:

Re: cpan question

2007-05-14 Thread Xavier Noria
On May 14, 2007, at 3:50 PM, Robert Hicks wrote: I am working on a Perl 5.6.0 project and went to use cpan at the command line and behold it was not there. I download the 5.6.1 tar file and behold cpan the command line program wasn't in there either. Did it not come with 5.6.0/5.6.1? I

Re: Detecting whether a script was called via CGI or the command line

2007-05-04 Thread Xavier Noria
On May 4, 2007, at 2:44 PM, Nigel Peck wrote: Within the script I want to know where it was executed from; CGI or command line/cron job. I'm currently checking @ARGV to do this i.e. if there is data in @ARGV then it was called from the command line, but obviously this means there must be

Re: basename equivalent?

2007-04-26 Thread Xavier Noria
On Apr 26, 2007, at 2:34 AM, Nishi wrote: What is the equivalent of basename? Ie if I dont want to use basename package to get the filename off a path, what reg expr can i use in perl? File::Basename is a standard module, why you don't want to use it? -- fxn -- To unsubscribe, e-mail:

Re: Removing lines

2007-04-16 Thread Xavier Noria
On Apr 15, 2007, at 6:38 PM, Mário Gamito wrote: I have this site that auto generates an index.html file every 15 minutes (it's a blog aggregator). I need that every time the file is generated, all the contents between the lines h4 class=post-titlea

Re: Uninstalling perl module

2007-04-14 Thread Xavier Noria
On Apr 13, 2007, at 1:02 PM, Randal L. Schwartz wrote: No, because the CPAN.pm shell is an installer, not a packager. It does not maintain a list of which files belong to which installations, and will happily let two installations both write to the same file. This will be problematic

Re: Is there any way to use C header files in perl program?

2007-02-20 Thread Xavier Noria
On Feb 20, 2007, at 7:49 AM, Dharshana Eswaran wrote: I need to use a C header file in Perl program in Unix. Is it possible to use the header files from perl in any way? I do not want to use any modules for the same. I do not want to enable the perl program to call a routine in C library

Re: DOS to Windows format tr/\n\r\t/ /

2007-02-11 Thread Xavier Noria
On Feb 11, 2007, at 1:36 AM, [EMAIL PROTECTED] wrote: I wonder if there is a format that preserves paragraph breaks while it kills line breaks? How do you define a paragraph break. Why does the subject mentions DOS to Windows. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For

Re: DOS to Windows format tr/\n\r\t/ /

2007-02-11 Thread Xavier Noria
On Feb 11, 2007, at 9:39 PM, [EMAIL PROTECTED] wrote: Well, here's my problem: I have found a way to wrap a text file down to a narrower column width. But it looses paragraph formatting. What I need is the same thing as converting a file from DOS (line break after each line) to Windows

Re: Removing file extension

2007-01-24 Thread Xavier Noria
On Jan 23, 2007, at 9:55 AM, Dr.Ruud wrote: Use an anchor and a negated character set: s/\.[^.]*$// That solution is broken, think /foo/bar.baz/woo. Correct regexps and other approaches have already been posted. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: Removing file extension

2007-01-23 Thread Xavier Noria
On Jan 23, 2007, at 8:22 AM, Saravana Kumar wrote: Hi list, I am trying to remove the extension from the a list of filenames and manipulate the names further. Tried to doing this: $file=~ s/\..*//; The above works fine. I get the result 'filename' if the filename is filename.ext. There are

Re: memory issues?

2007-01-19 Thread Xavier Noria
On Jan 19, 2007, at 5:53 PM, Bertrand Baesjou wrote: Thank you very much, this is indeed the solution. The explanation is that when you process lines this way foreach my $line (FH) { ... } the readline operator is evaluated in list context and, thus, the file is slurped into a single

Re: Cannot modify read-only value in while loop?

2007-01-19 Thread Xavier Noria
On Jan 19, 2007, at 12:55 PM, Richard Jones wrote: while ( my $ref = $sth-fetchrow_arrayref() ) { # $ref is arrayref push @$ref, 1; # line xx } dies with 'Modification of read-only value attempted at .. line xx' I can't see the difference here between the two $ref arrayrefs, but Perl

Re: comparing hashes

2007-01-13 Thread Xavier Noria
On Jan 13, 2007, at 6:29 PM, xavier mas wrote: hello list, I am trying to find if an element in one primary file (transformed to array) is included in two other different secondary files (transformed to arrays, too); the result is going to be printed as 1 or 0: According to the code

Re: comparing hashes

2007-01-13 Thread Xavier Noria
On Jan 13, 2007, at 7:43 PM, xavier mas wrote: Here's an example: in (file, array and hash) contains: woman, lion, ball img (file, array and hash) contains: ball, dog, cat, lion. dict (file, array and hash) contains: house, man, woman, kid, kitchen, lion Comparing in with dict ans img,

Re: Line ending with Gary^M on UNIX

2006-12-08 Thread Xavier Noria
This article explains how this works and has this and other tricks: http://www.onlamp.com/pub/a/onlamp/2006/08/17/understanding- newlines.html -- fxn PS: I am in fact the author but that is irrelevant. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: calling system

2006-10-21 Thread Xavier Noria
On Oct 21, 2006, at 9:52 AM, xavier mas wrote: Dear all, Hi Xavier! I'm trying to rename a bunch of files to the estination names included in a prepared files calling the system function mv inside a while loop (that reads the destination files one by one). But when doing this, I get an

Re: perl built in function for mean

2006-09-09 Thread Xavier Noria
On Sep 9, 2006, at 9:00 PM, chen li wrote: I want to calculate the mean of an array. I know how to let the job done by using a loop. But I just wonder if Perl has the short-cut/built-in function for this. There are modules, but nothing builtin. -- To unsubscribe, e-mail: [EMAIL PROTECTED]

Re: perl built in function for mean

2006-09-09 Thread Xavier Noria
On Sep 9, 2006, at 9:48 PM, Randal L. Schwartz wrote: Xavier == Xavier Noria [EMAIL PROTECTED] writes: Xavier On Sep 9, 2006, at 9:00 PM, chen li wrote: I want to calculate the mean of an array. I know how to let the job done by using a loop. But I just wonder if Perl has the short-cut/built

Re: Connecting to Oracle

2006-08-23 Thread Xavier Noria
On Aug 23, 2006, at 7:52 AM, anand kumar wrote: 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

Re: empty line in REs

2006-08-22 Thread Xavier Noria
On Aug 22, 2006, at 5:36 PM, chen li wrote: Just a quick question: what is the line code for an empty line using regular expression in Perl? Empty lines match /^$/, blank lines do not match /\S/. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: Help on chomp()

2006-08-21 Thread Xavier Noria
On Aug 21, 2006, at 8:51 PM, Mazhar wrote: use strict; use warnings; my $file_name=$ARGV[0]; open(FILE,$file_name) || die Not been Accessed ; No quotes needed around $file_name there. @host_array=FILE; That variable was not declared before, so that script does not run because it does

Re: Perl on Windows Server.

2006-08-16 Thread Xavier Noria
On Aug 16, 2006, at 2:33 PM, Krishnakumar K P wrote: Hi, There is a problem in coding perl in windows and using it in linux. When you code in windows the file will contain dos/windows new line pairs instead of the Linux/UNIX single New Line character which may cause error in linux server.

Re: Perl on Windows Server.

2006-08-16 Thread Xavier Noria
On Aug 16, 2006, at 2:54 PM, Xavier Noria wrote: On Aug 16, 2006, at 2:33 PM, Krishnakumar K P wrote: Hi, There is a problem in coding perl in windows and using it in linux. When you code in windows the file will contain dos/windows new line pairs instead of the Linux/UNIX single New Line

Re: How to sort an array which contains a value several times ?

2006-08-15 Thread Xavier Noria
On Aug 15, 2006, at 2:02 PM, SFantar wrote: Hello everyone I would like to sort an array so that it does not contain any values twice or three times. Unfortunately, perldoc -q sort does not help me very much. Here is an example of this array : @array = ('smith ', 'john ', 'edward ',

Re: How to sort an array which contains a value several times ?

2006-08-15 Thread Xavier Noria
On Aug 15, 2006, at 2:28 PM, SFantar wrote: Thank for your quick reply. Your solution should suit me. Can you give me more details/ explanations about your code? What does your code do exactly? Sure, we are using a hash table as a way to deal with duplicates, which is a standard idiom in

Re: How to sort an array which contains a value several times ?

2006-08-15 Thread Xavier Noria
On Aug 15, 2006, at 3:42 PM, Xavier Noria wrote: %seen = (); @uniq = grep { my $is_new = 0; if not exists $seen{$_} { Oh sorry I wrote that off the top of my head and forgot the parens. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: How to sort an array which contains a value several times ?

2006-08-15 Thread Xavier Noria
On Aug 15, 2006, at 5:49 PM, SFantar wrote: On the contrary, the code written above is not clear yet. What does your code do exactly when it comes to deal with smith, edward which appear twice in @array initially? What's what you don't understand, do you know grep? -- fxn -- To

Re: How to sort an array which contains a value several times ?

2006-08-15 Thread Xavier Noria
On Aug 15, 2006, at 6:19 PM, SFantar wrote: I know the grep function. Normally, grep needs a pattern to match with values found in @array. All the values found are returned in an array. Is that right? Not quite. The elements of the array are passed to grep's block, one at a time, and the

Re: How to split a file on the CR carriage Return and/or replace the \r with \n ??

2006-07-28 Thread Xavier Noria
On Jul 28, 2006, at 9:50 PM, Joshua Colson wrote: On Fri, 2006-07-28 at 21:28 +0200, Dr.Ruud wrote: Robert Citek schreef: Try a different value for the INPUT_RECORD_SEPARATOR ($/): $/ = \n ; (spaces added for clarity) Is that different from the default? (see perlvar) Using ActiveState

Re: How to split a file on the CR carriage Return and/or replace the \r with \n ??

2006-07-26 Thread Xavier Noria
On Jul 26, 2006, at 21:59, Steve Pittman wrote: I am using activestate on a windows box ...the files I am parsing are Unix files...I tried this so far... open ( IN, $_[0] )||die Can't open DAT source file: $tempFile $!\n; while (IN){s/\r/\n/g;@lines = IN;}# close (IN);

Re: split function

2006-07-19 Thread Xavier Noria
On Jul 19, 2006, at 9:57, Sayed, Irfan ((Irfan)) wrote: I need to split following string cs_backup_restore_cmvobsvr1mum the output which i am looking for is cs_backup_restore and _cmvobsvr1mum Which is the criteria, everything up to the last underscore? -- fxn -- To unsubscribe,

Re: split function

2006-07-19 Thread Xavier Noria
On Jul 19, 2006, at 10:05, Sayed, Irfan ((Irfan)) wrote: I think criteria shud be _ but I need output in following manner That criteria is ambiguous becasue there are several _s and you need to deal with them differently, that is, ignoring some and splitting on some. Can you be more

Re: doubt..

2006-07-19 Thread Xavier Noria
On Jul 19, 2006, at 13:59, Ankam, Ramesh Babu wrote: Can any one please tell me what this pattern meanss|.*/|| . Assuming there are no newlines in the string, that s/// means remove everything up to, and including, the last slash. It's a typical regexp for getting the basename of a

Re: Next

2006-07-06 Thread Xavier Noria
On Jul 6, 2006, at 6:26, Geetha Weerasooriya wrote: Dear all, When I was reading a Perl code I found the following line. Can u please explain what it means? !defined($rt_nearest) or $dh$dist or next; It means next unless !defined($rt_nearest) or $dh $dist; or, equivalently, next

Re: Need help with error from certain ASCII characters in a CSV file

2006-07-06 Thread Xavier Noria
On Jul 6, 2006, at 10:41, Roman Daszczyszak wrote: Does anyone have a suggestion for how I can handle this, or even where I can look to solve this issue? Is there another possibility for where the error is occurring that I am not seeing? I would create the filehandle specifying the character

Re: newlines on win32, old mac, and unix

2006-06-19 Thread Xavier Noria
On Jun 19, 2006, at 22:45, Anthony Ettinger wrote: # order matters $raw_text =~ s/\015\012/\n/g; $raw_text =~ s/\012/\n/g unless \n eq \012; $raw_text =~ s/\015/\n/g unless \n eq \015; Does it make any difference if I use s/\cM\cJ/cJ/ vs. s/\015\012/\n/ g ? The regexp is OK,

Re: Help understand documentation

2006-06-13 Thread Xavier Noria
On Jun 13, 2006, at 6:14, Vijay Kumar Adhikari wrote: I understand. My question is that Net::Ping does not use that info at all. If a host is alive, it will be listed in the output no matter what port you specify. Is this a bug? The module uses the port in several subroutines, like this

Re: newlines on win32, old mac, and unix

2006-06-13 Thread Xavier Noria
On Jun 13, 2006, at 20:26, Anthony Ettinger wrote: I have to write a simple function which strips out the various newlines on text files, and replaces them with the standard unix newline \n In Perl \n depends on the system, it is eq \012 everywhere except in MacOS pre-X, where it is \015.

Re: plugins

2006-06-11 Thread Xavier Noria
On Jun 11, 2006, at 11:16, OROSZI Balázs wrote: Chad Perrin wrote: On Sat, Jun 10, 2006 at 10:53:30PM +0200, OROSZI Balázs wrote: Makefiles are for installing modules, not for using them. If you use the CPAN module management that is provided with common Perl distributions, you shouldn't

Re: Help understand documentation

2006-06-11 Thread Xavier Noria
On Jun 11, 2006, at 14:20, Vijay Kumar Adhikari wrote: This is from http://perldoc.perl.org/Net/Ping.html # Like tcp protocol, but with many hosts $p = Net::Ping-new(syn); $p-{port_num} = getservbyname(http, tcp); foreach $host (@host_array) { $p-ping($host); } while

Re: Newline error

2006-06-06 Thread Xavier Noria
On Jun 6, 2006, at 12:59, joseph wrote: All, Just like to ask for correction on what's wrong with my script it gives spit out this error when i run it. Unsuccessful open on filename containing newline at disksize.pl line 8. Can't open file No such file or directory But it runs without

Re: Newline error

2006-06-06 Thread Xavier Noria
On Jun 6, 2006, at 14:16, John W. Krahn wrote: Mr. Shawn H. Corey wrote: $output_file =~ s/\r//g; # chomp only removes linefeed characters \n # BTW, there is no such thing as a newline; # it is either a linefeed: \n ASCII LF 0x0A # or a carriage return: \r ASCII CR 0x0D \n is inherited

Re: monitoring file like tail -f in perl

2006-05-29 Thread Xavier Noria
On May 29, 2006, at 18:19, Ken Foskey wrote: I want to monitor a daemon's logs that updates randomly through the day and night. Is there a way to open the log file and read the new records as they come in the same way as tail -f does? Sure, with File::Tail for example. -- fxn -- To

Re: suppressing selected warning messages

2006-05-24 Thread Xavier Noria
On May 24, 2006, at 18:48, Gavin Bowlby wrote: I can suppress all warning checks by doing a: no warnings; if ($a == 7) { use warnings; but I would like all other normal Perl warnings to be used for the statement: if ($a == 7) other than the check for the LHS of the equality check being a

Re: Converting a string to a filehandle

2006-05-22 Thread Xavier Noria
On May 22, 2006, at 4:44, Wijaya Edward wrote: Is there a way to do it? Module for it? Suppose I have this large string. my $string = 'foo bar qux woo etc etc'; I would like to convert that string as if it is stored inside a file, and bypassing the file

Re: Extracting a bit of a scalar variable

2006-04-21 Thread Xavier Noria
On Apr 21, 2006, at 20:59, Praveena Vittal wrote: Is there any way to print a particular bit of a digit after converting to binary form. That can be easily done with substr y sprintf, this would take the second bit of 7 written in base 2: % perl -wle 'print substr sprintf(%b, 7), -2,

Re: regular expressions

2006-04-21 Thread Xavier Noria
On Apr 21, 2006, at 16:10, Bowen, Bruce wrote: In perldoc under this topic s is listed as Treat string as a single line and m as Treat string as multiples lines. If I have text that has varying spaces at the begging of each line, and I use $string =~ s/^\s+//; It will remove the spaces

Re: regex help

2006-04-19 Thread Xavier Noria
On Apr 19, 2006, at 9:13, Murphy, Ged (Bolton) wrote: Hi all. I have a log containing strings as follows : 21259 auditO 72398 Mar 09 00:18 dll/ldr/elf.c The format is the same throughout with the exception of the 'O', as it doesn't always appear. I need to match when the 'O'

Re: split function in perl

2006-04-17 Thread Xavier Noria
On Apr 17, 2006, at 10:30, Irfan J Sayed wrote: Hi, I have a following line stored in one variable $test. deliver.Admin_Irfan_Project.20060413.212355 . I need to split this line into the words and store the output in array. words should like this. deliver admin irfan project 20060413

Re: Combine similar patterns

2006-03-29 Thread Xavier Noria
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…./ f1=c, f1=c…../f1=c….f1=c……/f1 are all the foot notes that are spanning on various pages, now what I am trying to do is that

Re: [SPAM DETECT] Re: Combine similar patterns

2006-03-29 Thread Xavier Noria
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. f1,f2f3.so on. For all these the conventions are the same as told before.

  1   2   3   >