Re: Copying from an array?

2002-07-02 Thread Sudarsan Raghavan
Mark-Nathaniel Weisman wrote: > I've got a script that reads a mail file, then copies it into an array. > The same script then pulls the data out of the array into another file > location. I've got a situation here, in that when I do the print > OUTFILE "@array"; it adds a singular space in front

Re: extract info from file name

2002-07-02 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi > > filenameRnott230602.txt > > I want to break down the name and compare with other text, it breaks down > as R / nott / 230602 (3 items) > the length does not change. If this is an equality compare, why don't you concatenate the other texts and compare the res

Re: Obtaining a slice of unique values from an array

2002-07-01 Thread Sudarsan Raghavan
"Shishir K. Singh" wrote: > >on Sun, 30 Jun 2002 12:08:23 GMT, Dan Fish wrote: > > > What is the most efficient (or at least AN efficient :-) way of > > obtaining a slice from an array wherein the slice contains only > > unique values found in the array? > > >See > > perldoc -q duplicate >

Re: Please explain forking

2002-06-20 Thread Sudarsan Raghavan
Langa Kentane wrote: > Greetings, > I wish to use the fork() function on one of my scripts. I would like more > clarity on the way it works. > > Take for instance the ff code: > > Sub mysub > { > while () > If ($_ eq "SCANME") > { > fork() After the fork c

Re: email body question still

2002-06-13 Thread Sudarsan Raghavan
tom poe wrote: > Hi: I really appreciate the input on separating $header and $body from those > on the list so far. The suggested modules all seem too complicated to me, so > I continue to read Chapter One, over and over. In the meantime, I think I > have something close to what I want to acco

Re: More efficient ??

2002-06-12 Thread Sudarsan Raghavan
David vd Geer Inhuur tbv IPlib wrote: > Hello, > > Last time I got so much feedback that I will try it again. I learned a lot of > the last recommendations, but the next issue could not be made more efficient by > me. Can you ? > > #!/usr/local/bin/perl > # > my $base = "/user/IPlib/IPlib/Analog_

Re: Can you make it use one or more less vars?

2002-06-12 Thread Sudarsan Raghavan
Thanks for that Jenda Krynicky wrote: > Then how come > > $x = 'Hello'; > sub foo { > $_[0] = 'Hi'; > } > foo($x); > print $x,"\n"; > > prints > Hi > ? > > The parameters are passed by reference, though in little strange way. > If f

Re: Can you make it use one or more less vars?

2002-06-11 Thread Sudarsan Raghavan
Elias Assmann wrote: > On Tue, 11 Jun 2002, Jeff 'japhy' Pinyan wrote: > > > modifies the ACTUAL argument you passed to rcsname()? Only if you had > > done > > > > sub rcsname { > > $_[0] =~ s/foo/bar/; > > } > > or some other specific effort would you have modified the argument to the >

Re: taking a line with ; and surrounding it with %22

2002-06-11 Thread Sudarsan Raghavan
Tara Calishain wrote: > three mice > > While some of the lines have semicolons: > > three;mice > > For the semicolon'd lines, I need to remove the semicolons and > surround them with %22, like so: > > %22three mice%22 Loop through all the lines (assuming the line is in $str) and ad this line $s

Re: s/foreach/??/g

2002-06-11 Thread Sudarsan Raghavan
David vd Geer Inhuur tbv IPlib wrote: > Hi Sudarsan, > > Sorry forgot to mention that : > > $pwuser = ($ENV{'REMOTE_USER'}); ## Apache var > > $groupfile is the group-file apache uses to authenticate. Unfortunetly there is > no such thing as : > > $group = ($ENV{'REMOTE_GROUP'}); > > The

Re: s/foreach/??/g

2002-06-11 Thread Sudarsan Raghavan
David vd Geer Inhuur tbv IPlib wrote: > Hi, > > I am currently almost done with my current job. > As I am reviewing my scripts the foreach-loop started to anoy me. > > I am afraid this is slowing down the script. Does anyone know a faster way to > do the following : > > # -- > open(FH, "< $gr

Re: invisible syntax error

2002-06-11 Thread Sudarsan Raghavan
> while (){ > if(S/\>//){ '>' does not have to be escaped (this is not an error, it is the capitalized s as you mentioned) You can just write this as s/>//. $_ = a>a>a>a>'; s/>//g; print "$_\n"; This prints -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,

Re: Is this an eye sore?

2002-06-10 Thread Sudarsan Raghavan
> > > #!/usr/bin/perl -w > > system("/usr/bin/clear"); > @arg1 = qw( > mail > sysquota > root > nobody > smmsp > daemon > testing > ); When you are doing does it exist operation a hash would be a better data structure than an array. > > > unless (open(

Re: code efficiency

2002-06-10 Thread Sudarsan Raghavan
> > > You are assuming that your string if it ends with a number will only be 4 digits >wide. > if $str is assigned "hello fred 12345" it will print nothing. > $str should actually be $ff, sorry -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: code efficiency

2002-06-10 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi All > The code I have written below works, and yes I could leave it at that.. but > I want if possible to write efficient > code as this seems to be what PERL is all about. So any thoughts anyone ?? > > = > this cod

Re: sequences of capitalized words

2002-06-05 Thread Sudarsan Raghavan
patrick hall wrote: > Hi, > > I'd like to push all sequences of capitalized words > onto an array. > > So, given this paragraph (which I just snagged off AP) > > Indian Prime Minister Atal Bihari Vajpayee said > Wednesday that India would consider jointly monitoring > the disputed Kashmir border

Re: probably a simple question

2002-06-05 Thread Sudarsan Raghavan
Zachary Buckholz wrote: > Is there any function to tell if a number is even or odd? > I am looking for an easy way to loop through a list and > output table cell bgcolor based on even / odd. > > if its an even numbered row make it red if its odd make > it blue. $_ % 2 ? print "blue\n" : print "r

Re: split

2002-06-04 Thread Sudarsan Raghavan
> > > ($bash, ($rest)) = split(/\s/, $line); $rest will still only contain 'FRI'. This is the same as my ($a) = (1, 2, 3, 4); $a becomes 1 after this 2, 3, 4 are just ignored > > > to force the slurp and then dump it into a string. Try 'em both; neither > is tested. > -- To unsubscribe, e

Re: split

2002-06-04 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > hi guys, > I would like to split a line like that > > # FRI MAY 02 > > in two parts: > > $bash = # > $rest = FRI MAY > > in my version ($bash, $rest) = split(/\s/, $line); Change this line to ($bash, $rest) = split (/\s/, $line, 2); perldoc -f split > > >

Re: Subroutine

2002-05-31 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi, > > I'm having a very frustrating time with a small test program I'm trying to > write. I'm using ActivePerl 5. I'm sure the answer is simple and I'll kick > myself when someone clarifies the matter, but here goes anyway: > > The error message is: > > "Undefined sub

Re: Back Chat:RE: Help with parsing output

2002-05-31 Thread Sudarsan Raghavan
drieux wrote: > On Friday, May 31, 2002, at 02:13 , Sudarsan Raghavan wrote: > > > while () { > > chomp; > > s/^\s+//; > > next if ((1 .. /^NPROC/) || m/^$/); > ># The conditions have been swapped here > ># Expla

Re: Tk GUI problem

2002-05-31 Thread Sudarsan Raghavan
"Mok T.Y.-r15382" wrote: > While executing an example Tk code from the book, the following message prompts: > > "Can't locate Tk/FBox.pm in @INC (@INC contains: d:\perl\lib\site d:\perl\lib >c:\perl\lib c:\perl\lib\site c:\perl\lib\site .) at regexE > valuater1.0.2.pl line 111, chunk 1." > > Pr

Re: Back Chat:RE: Help with parsing output

2002-05-31 Thread Sudarsan Raghavan
"CATHY GEAR (TRUST HQ)" wrote: > Yes please post the final working solution! This is always helpful. > > Thanks > > Cathy > The best solution was John's offer while () { if ((/NPROC/ .. /^Total/) && /\d/) { my ($user, $mem, $cpu) = (split)[1, 4, 6]; print

Re: DB_file help.

2002-05-31 Thread Sudarsan Raghavan
Postman Pat wrote: > I am trying to create a small database with the information like this: > > Each record has a name ie : > Dog > And has the following traits: > color > weight > nick > > For example I could have the following data: > > Name: dog > Color: green > Weight:

Re: Help with parsing output

2002-05-31 Thread Sudarsan Raghavan
> < ... > so I fear his (1../^NPROC/) isn't doing quite what he was hoping that > it would be doing >> > > yes, i noticed that, but was easily fixed with minor adjustments I failed to notice this mail, was the adjustment what I had mentioned about swapping the conditions in the if statement.

Re: [Fwd: Re: Help with parsing output] (forgot to post to the list)

2002-05-30 Thread Sudarsan Raghavan
Sudarsan Raghavan wrote: > Original Message > Subject: Re: Help with parsing output > Date: Fri, 31 May 2002 11:07:16 +0530 > From: Sudarsan Raghavan <[EMAIL PROTECTED]> > Organization: HP ISO > To: "John W. Krahn" <[EMAIL PROTECTED]> >

[Fwd: Re: Help with parsing output] (forgot to post to the list)

2002-05-30 Thread Sudarsan Raghavan
Original Message Subject: Re: Help with parsing output Date: Fri, 31 May 2002 11:07:16 +0530 From: Sudarsan Raghavan <[EMAIL PROTECTED]> Organization: HP ISO To: "John W. Krahn" <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> <[EMAIL PROTECT

Re: Help with parsing output

2002-05-30 Thread Sudarsan Raghavan
"Kipp, James" wrote: > > > > # INPUTDATA is the filehandle through which you are getting the input > > while () { > > chomp; > > s/^\s+//; > > next if (m/^$/ || (1 .. /^NPROC/)); > > >what does the range thing do? > >wouldn't just ... || /^NPROC/ be enough? > > I think that is how h

Re: Help with parsing output

2002-05-30 Thread Sudarsan Raghavan
"Kipp, James" wrote: > I am reading output from a pipe to a command called 'prstat' (like top). > just wanted to get some ideas on the best way to capture the data i am > looking for. below is an example of the output: # INPUTDATA is the filehandle through which you are getting the input while (

Re: iterating over the contents of a directory

2002-05-29 Thread Sudarsan Raghavan
"Shishir K. Singh" wrote: > don't think there is a way to get the full path. The only way I can think of is by >concatening the results of the readdir with the $path that you used for opening the >directory. perldoc -f glob print while (<$your_src_dir/*>); This will print all the files with $y

Re: Shredding a file

2002-05-28 Thread Sudarsan Raghavan
"Jonathan E. Paton" wrote: > > > Greetings, > > > How would I go about shredding a file with perl, for instance, I have a > > > script opening a time file, writing something in there and then deleting > > > the temp file when execution is done. How would I go about securely > > > deleting the tem

Re: total newbie - to programming and to perl

2002-05-28 Thread Sudarsan Raghavan
can download from www.activestate.com > > > Apologies for sounding so dim, but, will either of these machines have perl > installed ? > > If I don't have perl, can I download it from the web? - if so, where from ? > > Many thanks.. > > Jonathan > > -Original Message

Re: Shredding a file

2002-05-28 Thread Sudarsan Raghavan
Sudarsan Raghavan wrote: > Anders Holm wrote: > > > Hi folks! > > > > Of relevance her would be what OS you are on as well. > > > > Windows > > Solaris > > Linux > > Mac > > Other? > > > > Why? Because different OS's

Re: total newbie - to programming and to perl

2002-05-28 Thread Sudarsan Raghavan
TAWN Jonathan wrote: > Hi.. > > What are these "perdoc perl and perldoc perltoc "?? - I have NO idea !! perldoc is a utility that comes along with the standard perl distribution similar to man on unix (man perl and man perltoc would also work) type perldoc perl on the command line and see what h

Re: Shredding a file

2002-05-28 Thread Sudarsan Raghavan
Anders Holm wrote: > Hi folks! > > Of relevance her would be what OS you are on as well. > > Windows > Solaris > Linux > Mac > Other? > > Why? Because different OS's treat this differently. Anyone here ever tried > to get back a deleted file on a Unix box? Not a very fun prospect. I am not sure

Re: Shredding a file

2002-05-28 Thread Sudarsan Raghavan
"Langa F. Kentane" wrote: > Greetings, > How would I go about shredding a file with perl, for instance, I have a > script opening a time file, writing something in there and then deleting > the > temp file when execution is done. How would I go about securely deleting > the > temp file afterwards

Re: perl one-liner for find->exec->rm - SOLVED

2002-05-28 Thread Sudarsan Raghavan
Gary Stainburn wrote: > Hi all, > > I added a chomp giving - > > find . -type f|perl -ne 'chomp ; unlink||die "$_ : $!\n"' You could avoid the pipes and try this instead perl -MFile::Find -e 'find (sub {unlink|| die "$File::Find::name : $!\n" if (-f)}, ".")' > > > and it worked. > > Gary > >

Re: Remove 1 or more whitespaces at the end of $_

2002-05-27 Thread Sudarsan Raghavan
Felix Geerinckx wrote: > on Mon, 27 May 2002 13:01:36 GMT, [EMAIL PROTECTED] (Harry > Jackson) wrote: > > > s/\s+$//g; > > As explained by Sudarsan Raghavan, the 'g' modifier is not necessary. > The '+' in '\s+' gobbles up all trai

Re: Remove 1 or more whitespaces at the end of $_

2002-05-27 Thread Sudarsan Raghavan
David vd Geer Inhuur tbv IPlib wrote: > Hi, > > I know how to delete 1 or more whitespaces at in a line using : > > while { > s/\s+//g; > } > close IN; > > #- > > But How do I specific delete 1 or more whitespaces at the end of the line ? > using : > > while { >

Re: deleting lines from a text file using index from another file

2002-05-24 Thread Sudarsan Raghavan
Sudarsan Raghavan wrote: > > > > > > > > I need to do something, but being new to Perl I'm not sure it's possible > > or how to do it. I need to remove lines of information from a text file > > based on information in another file. The first fil

Re: deleting lines from a text file using index from another file

2002-05-24 Thread Sudarsan Raghavan
> > > > > I need to do something, but being new to Perl I'm not sure it's possible > or how to do it. I need to remove lines of information from a text file > based on information in another file. The first file contains information > about some business transactions, each line describing one tra

Re: Regexp needed

2002-05-23 Thread Sudarsan Raghavan
Jorge Goncalvez wrote: > Hi, i have this: > open INFILE, "< $_Globals{SYSLOG}" or die $!; > #ModifiedFile(); > while () { > if (/([0-9a-z:]+)\s*via eth0)/) { > $_Globals{MAC_ADDR} = $1; >} > } > And my file is like this: > . > LOG_INFO :

Re: ftp

2002-05-23 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi > > Does any one know how to ftp a file using a perl script? are there modules > etc that can be used? perldoc Net::FTP > > > Thanks > > Stephen Redding > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Split

2002-05-22 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi all, > > I have the following data stored in a variable ($str_line), but I only need the >usernames (ie the first column) from this information. How do i extract just the >user names? > > aragonm 172.24.142.136 aupoza528 (v1.1), start Thu 23/5 13:54 >

Re: File copy

2002-05-21 Thread Sudarsan Raghavan
Slavtek wrote: > Hello, > I want to copy some files from one place to another. Maybe someone tell me how can I >do this using Perl? > Thanks in advance! perldoc File::Copy Loop through the files in your source directory (using glob or opendir and readdir) and copy them. perldoc -f glob perldoc

Re: ls --> index.txt in each directory

2002-05-21 Thread Sudarsan Raghavan
Sudarsan Raghavan wrote: > Bryan R Harris wrote: > > > I have a large directory tree that I'd like to build index files for, > > essentially an > > > > ls > index.txt > > > > in each directory in the tree. Obviously I'm having

Re: ls --> index.txt in each directory

2002-05-21 Thread Sudarsan Raghavan
Bryan R Harris wrote: > I have a large directory tree that I'd like to build index files for, > essentially an > > ls > index.txt > > in each directory in the tree. Obviously I'm having trouble figuring it > out. =) > > I've tried the following: > > use File::Find; > sub process_file { > i

Re: extracting array info from text file

2002-05-20 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi All > > I have a textfile comprised of x number races each with x number of runners > eg. > > 13:00 > runner1 > runner2 > runner3 > runner4 > > 14:00 > runner1 > runner2 > runner3 > > 15:00 > runner1 > runner2 > > I want to put each race time into seperate array and

Re: my & local variables

2002-05-20 Thread Sudarsan Raghavan
> > > #!/usr/bin/perl -w > use strict; > > my $var=1; > > sub thisSub { > local( $var ); > This will give this error "Can't localize lexical variable ..." A working example #!/usr/bin/perl -w use strict; $main::var=1; sub print_var { print "packa

Re: my & local variables

2002-05-19 Thread Sudarsan Raghavan
http://perl.plover.com/FAQs/Namespaces.html Postman Pat wrote: > Greetings, > I read in the book SAMS Teach Yourself Perl in 21 Days that you can use > my/local to declare vars. They explanation I got from the book did not do > much explaining on exactly what the difference is between the two.

Re: passing array-ref from sub to sub

2002-05-17 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi there, > > I would like to transfer an array-reference from sub "get_link_attr_entry_list" > to sub "get_link_priority", but it doesn't work. > Here is the code: > > use strict; > > my $link_id = ''; > my $link_attr_entry_list_ref = ''; > > > get_link_attr_entry

Re: Delete a line and replace

2002-05-13 Thread Sudarsan Raghavan
Could try this too perl -p -i.bak -e '/^ftp/ ? undef $_ : s/\bguest\b/ftp/gi' /etc/passwd the -i.bak will also create a /etc/passwd.bak for you Timothy Johnson wrote: > > Actually it's a good question, and I should have explained myself. When you > do this line on a file, it slurps up the ent

Re: Ok- real dumb question

2002-05-07 Thread Sudarsan Raghavan
Marc M Dawson wrote: > I am supposed to parse a text file such as this- > 781457 Hartanto Victor Setiawan <[EMAIL PROTECTED]> > 777557 Hatfield Benjamin <[EMAIL PROTECTED]> > 779777 Henry James <[EMAIL PROTECTED]> > 777947 Hergert Michael William <[EMAIL PROTECTED]> > 778097 Iverson Jennifer

Re: Piping mail spool through a Perl script?

2002-05-06 Thread Sudarsan Raghavan
jc wrote: > Hello, > > I inherited a project where we use a procmail filter to filter emails as > they come to our web server and pipe them through a perl script. The > script called "filterme" goes through the email line by line and grabs > information on the email, puts it into an array, and w

Re: Taking data from the screen to a file

2002-05-06 Thread Sudarsan Raghavan
> > > I'm just new to Perl and have no idea where to start with the task that I have to >complete. Any help would be appreciated. > > Currently when a particular .exe is run, the following is displayed in the command >window - > > License server on host "kronos". > Running since Monday 4/04/96

Re: To exract data from text file

2002-05-06 Thread Sudarsan Raghavan
Take a look at perldoc -f open perldoc -f split [EMAIL PROTECTED] wrote: > I had been assigned a work of extracting data from a text file.The text > file has these datas > 193.9.200.123,prashant , ,y,22/04/02,12:09:43, , , > ,http://rediffmail.com. > I have to fetch IP address,uesr name

Re: map() definition help

2002-05-03 Thread Sudarsan Raghavan
Scott Lutz wrote: > What is the purpose of the following code? > > @list = keys %{{map{$_,1} @list}}; map {$_, 1} @list > $_ is holds the value of the current element of @list i.e. being processed for e.g. if @list contains ("abc", "def", "ghi"), a list like ("abc", 1, "def", 1, "ghi", 1) is

Re: scanning files in a directory

2002-04-24 Thread Sudarsan Raghavan
A Taylor wrote: > Hi all, > I am trying to read all the files in a certain directory. I can open a > directory using: > > opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!"; while (my $file = readdir (DIR)) { #Do your stuff, readdir returns only the filenames #you will have to pr

Re: print hash

2002-04-23 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hello everybody, > my code below should read in data from a file info.txt into a hash, the sub > print_hash should print all hash-elements. actually it only prints the last > key-value-pair. Does anybody see the mistake?Thank you for your help!!! > The scripts runs

Re: Assigning values from files into an aray

2002-04-23 Thread Sudarsan Raghavan
> > > 405^100^200^A^B C D E > > while () { > $number_of_elements= 0; > chop; > ($record, $customer, $location, $plan, @items) = split(/\^/, $_); > $number_of_elements= $#items + 1; > print "number_of_elements: $number_of_elements\n"; > } > > At th

Re: Read file symbol by symbol?

2002-04-16 Thread Sudarsan Raghavan
Dave K wrote: > Here is one script I used to inspect files > > use strict; > my $fn; > print"Enter the name of a file you want to examine "; > while (<>) { It is better to write this as while (). The reason being if all the command line arguments (if any are provided) have not been shifted

fcntl with F_GETLK returns lock holders pid as 0 with perl 5.6.1

2002-04-11 Thread Sudarsan Raghavan
Hi All, The following code gives the pid of the process holding the lock as 0 when run with perl 5.6.1 on Redhat linux 7.2. It works fine with perl 5.6.0 on the same machine. The code that locks the file works fine (tested by getting the lock information with C code and using 5.6.0 perl). Has any

Re: Checking if a hash has blank values.

2002-04-10 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi, > > What's the preferred waying of doing things... > > if ($var eq '') > > or > > if (defined $var) > > I assume they both mean pretty much the same thing? > No, defined is used to tell if the value is undef or not. undef is a special scalar value, it is tr

Re: read and write to same file

2002-04-08 Thread Sudarsan Raghavan
Arvind Baldeo wrote: > Hi All, > > Can some one please look at my code ad see what I am doing wrong. > > For some reason it is not working. The idea is to search the file using the > commandline argument. It is supposed to read the file and if a match is > found, it outputs to another file. If a

Re: How to install Perl At Win 2000

2002-04-08 Thread Sudarsan Raghavan
Rosa malliber wrote: > Halo all, > > i want install perl at windows 2000, so what can i do ? > some body help me, step by step installation perl at windows 2000 http://www.activestate.com/Products/Download/Get.plex?id=ActivePerl&a=e > > Please. > > Tx's > > Best Regard's > Rosa > > __

Re: Arguments

2002-04-04 Thread Sudarsan Raghavan
Michael Gargiullo wrote: > I have a bit of code thats throwing errors. "Use of uninitialized value..." > > > #!/usr/bin/perl -w > my $setup=0; > while ($ARGV[0] =~ /^\-/) { > if ($ARGV[0] eq '-s') { >$setup = 1; > shift; The shift here removes $ARGV[0] from

Re: perl

2002-04-04 Thread Sudarsan Raghavan
Schelstraete Bart wrote: > (sorry, my previous message was signed, which can give some problems) > > Hello, > > Can somebody tell me if it's possible: > a) to count all the files in a directory , with extension 'msg' with perl Check out the glob operator of perl (perldoc -f glob or perldoc F

Re: grep (small doubt)

2002-04-03 Thread Sudarsan Raghavan
followed by 'd', not followed either 's' or 'k' or 'i' or 'p', 0 or more characters except newline, literal '.' and finally fea. Is this what you want to match. Can you provide some example strings. > > > this does not match as

Re: grep (small doubt)

2002-04-02 Thread Sudarsan Raghavan
Mandar Rahurkar wrote: > Hi, > Its me again.. > > 169b2_vow_band_1.fea > 2168d6_vow_band_1.fea > > @files = grep /^.{3}g[^1].*\.fea$/, @files; > > can i have an or like for eg : > @files = grep /^.{3|4}g[^1].*\.fea$/, @files; > You can write it as /^.{3,4}g(?!1).*\.fea$/ .{3,4} matches

Re: grep

2002-04-02 Thread Sudarsan Raghavan
On Tue, 2 Apr 2002, John W. Krahn wrote: > > > Sudarsan Raghavan wrote: > > > > > > Mandar Rahurkar wrote: > > > > > > > thanks to everyone for replying however I think i failed to define the > > > > problem accurately : > >

Re: grep

2002-04-02 Thread Sudarsan Raghavan
Sudarsan Raghavan wrote: > Mandar Rahurkar wrote: > > > Hi, > > thanks to everyone for replying however I think i failed to define the > > problem accurately : > > > > i have files assigned to @files variable : > > > > 2168a5_vow_band_1.fea &g

Re: grep

2002-04-02 Thread Sudarsan Raghavan
lier suggestion holds. > > > ls ???[^g][^1] *.fea > > Many Thanksplease do send in ur replies. > > Mandar > > On Wed, 3 Apr 2002, Sudarsan Raghavan wrote: > 2168a5_vow_band_1.fea > > > 169b2_vow_band_1.fea > > > 2168d6_vow_band_1.fea > &g

Re: grep

2002-04-02 Thread Sudarsan Raghavan
Mandar Rahurkar wrote: > Hi, > I need to select particular files from list that looks like this : > > 2168a5_vow_band_1.fea > 169b2_vow_band_1.fea > 2168d6_vow_band_1.fea > 169g3_vow_band_1.fea > neutral.txt > > This is how the list if files look like.I need files with only g for > eg > I can d

Re: Length of a string

2002-04-01 Thread Sudarsan Raghavan
Ron wrote: > For the life of me, I cannot remember how to find the certain numbers in a > string. I remember how to find the length of an array but I cannot find how > to find the length of a string in a variable. perldoc -f length > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For

Re: Maximum ,Minumum

2002-03-27 Thread Sudarsan Raghavan
"Jonathan E. Paton" wrote: > > > @data = (10,45,2,439); > > > ($min,$max) = (sort {$a <=> $b} @data)[0,$#data]; > > > > IMHO sorting a list to find the max and min > > element is not a good idea. The sort is of > > O(nlgn) and the usual run through the list > > to find the max element is O(n).

Re: Maximum ,Minumum

2002-03-27 Thread Sudarsan Raghavan
Robert Graham wrote: > Hi Ozgur > > You can use the following: > > @data = (10,45,2,439); > ($min,$max) = (sort {$a <=> $b} @data)[0,$#data]; IMHO sorting a list to find the max and min element is not a good idea. The sort is of O(nlgn) and the usual run through the list to find the max

Re: telnet...???

2002-03-25 Thread Sudarsan Raghavan
Take a look at Net::Telnet on cpan subbu wrote: > hi to all.. > can we use perl expect module to telnet to a specified > machine and to execute a specified command on a > remote machine..? > > regards > keshav -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMA

Re: Finding words between words...

2002-03-07 Thread Sudarsan Raghavan
Timothy Johnson wrote: > > Out of curiosity, what happens if you leave off the parentheses on $btwn? Putting a parantheses on $btwn assigns $1 to $btwn. The statement can be broken into two statements as if ($str =~ /In:(.*)Your/) { $btwn = $1; } > > > -Original Message---

Re: finding consecutive numbers

2002-03-07 Thread Sudarsan Raghavan
Charles Lu wrote: > Hi > >I am trying to think of a quick and simple way to find out if a number > appears only in consecutive fashion once. In other words, a function that > will return true if a particular number in a list appears only consecutively > once. > > For example: Does "2" appea

Re: File substitutions??

2002-03-07 Thread Sudarsan Raghavan
> Thanks for the help!! Unfortunetly this solution only copies the modified > line to the tmp file. I need the all the other data to stay unchanged. > e.g. John:111:0 > Peter:222:0 > Jane:333:0 > > becomes > > John:111:0 > Peter:222:1

Re: File substitutions??

2002-03-07 Thread Sudarsan Raghavan
Patrick Bateman wrote: > Hi everyone > > Need help with this please, pretty please!! > > I open a file containing this: > e.g. > John:111:0 > Peter:222:0 > Jane:333:0 > > Now I select a particular name from an input. > Now comes the part I'm having trouble with. For that name I've

Re: Beginner question

2002-02-27 Thread Sudarsan Raghavan
Frank 'Olorin' Rizzi wrote: >Hello everybody. > >I am just starting with Perl, >so the following question will probably appear simple to most of you. > >I am trying to get a Perl program to provide me with a listing of the files >stored on the machine (where the program runs). >The environment is

Re: renaming files (versioning)

2002-02-20 Thread Sudarsan Raghavan
Bill Akins wrote: > Hi all, > > After processing files in my perl script, I need to move them to the final > destination. My problem is if the file already exists (lets call it > data.txt), I need to rename it to data-v01.txt (where -v01 is version 01). > > So... if there are four other esisting

Re: How this works?

2002-02-19 Thread Sudarsan Raghavan
Tushar Kulkarni wrote: > Hi, > I have this code, but I am not getting how this works. Can someone > help? > > %h = ( one => 15, > two => 26, > three => 37 ); > > my @a; Not sure what purpose this declaration serves. The 'a' referred to from here on in the code is the has

Re: simple question

2002-02-07 Thread Sudarsan Raghavan
Stuart Clark wrote: > Hi all, > Can anyone help please? > > # example values > $Charge = "55"; > $CreditCard = "423452345654532"; > > > $VisaCard = /^4\d{15}/; > $BankCard = /^(6565\d{12})|(555[10]00\d{10})/; The regular expressions will try to match the contents of $_ here. From your previ

Re: Comparing strings

2002-01-29 Thread Sudarsan Raghavan
[EMAIL PROTECTED] wrote: > Hi > > I wish to do string comparisons where the case is ignored, for example: > > $one = "ExanPle"; > $two = ""example"; > > if ($one eq $two){ > THIS RETURNS TRUE if (lc($one) eq lc($two)) { #perldoc -f lc HTH, Sudarsan > > > What do I add s

Re: listing files

2002-01-29 Thread Sudarsan Raghavan
Michael Pratt wrote: > This is what I want to do and I dont know where to start: > > List files in a directory taking that list with just the filename and no > other information Use the glob operator of perl (perldoc -f glob) while (<*>) { print "$_\n"; } This should

Re: Processing a text file

2002-01-25 Thread Sudarsan Raghavan
Morgan, You will have to refer the manpages for these functions 1) split (perldoc -f split) 2) open (perldoc -f open) 3) chomp (perldoc -f chomp) The way to do this would be 1) Read in every line of the text file and chomp of the newline 2) Split the line such that you end up an array like this

Re: -d test file

2002-01-22 Thread Sudarsan Raghavan
COLLINEAU Franck FTRD/DMI/TAM wrote: > > > I've found. I have to put the absolute path. > Is there a way without absolute path ? > Use the glob operator (perldoc -f glob) while ($rep = <$chemin/*>) { # Do your stuff here # } HTH, Sudarsan > > Franck > > -Mess

Re: File::Find

2002-01-16 Thread Sudarsan Raghavan
Gary Hawkins wrote: > > Read through 'preprocess' subsection of the File::Find docs > > (perldoc File::Find). > > This might be of help to you. > > I already read the fantastic manual and was hoping for something that conveys > understanding. > > "preprocess" >The value should

Re: File::Find

2002-01-16 Thread Sudarsan Raghavan
Gary Hawkins wrote: > Here's a fairly simple little script to list directories and files recursively. > Couple questions: > > -- Is it fairly simple to make it list everything in a properly indented > heirarchy? (Somewhat similar to what windows explorer would look like if every > level were exp

Re: File::Basename, linux, and extensions

2002-01-11 Thread Sudarsan Raghavan
zentara wrote: > On Fri, 11 Jan 2002 04:39:05 -0800, [EMAIL PROTECTED] (John W. Krahn) wrote: > > >Zentara wrote: > > > >> I've been playing with File::Basename and > >> the docs are not absolutely clear on whether > >> you can get an extension on a linux system. > >> I have had no success trying

Re: Returning values from the Find Function

2002-01-11 Thread Sudarsan Raghavan
"McCollum, Frank" wrote: > I am not getting the Find Function. (FILE::FIND). I have found all of > these great examples on the web describing how to use the find function > under the following two conditions... > > 1) You know the exact File Name you are looking for, or you just want a > list

Re: how to read a line from a file and find its subtr?

2002-01-11 Thread Sudarsan Raghavan
are looking for hth, Sudarsan Sudarsan Raghavan wrote: > Use index (preldoc -f index). > index ($str_from_file, $search_string); > This will return a -1 if $search_string is not present in $str_from_file. > > hth, > Sudarsan > -- To unsubscribe, e-mail: [EMAIL PROTECTED

Re: how to read a line from a file and find its subtr?

2002-01-11 Thread Sudarsan Raghavan
Use index (preldoc -f index). index ($str_from_file, $search_string); This will return a -1 if $search_string is not present in $str_from_file. hth, Sudarsan > How can I read a line from a file, and judge whether > this line include some substr? > Now I only can open(HANDLE," then how should I d

Re: traversing a file tree...one step further

2002-01-10 Thread Sudarsan Raghavan
The find routine of File::Find traverses a file tree (recurses through the subdirectories as well). Try out the following piece of code use strict; use File::Find; find (sub {print "$File::Find::name\n";}, $yourdirname); This should print all the files and subdirectories within $yourdirname to t

Re: HELP - finding a float while reading a file

2002-01-04 Thread Sudarsan Raghavan
Nestor Florez wrote: > Hi there, > > I am trying to read a file and find the last numeric value in the line read. > example: > 123 45 -23 56 <-3.45 > 145 555 112 -12.0 -2.55 > > all of the values are separated by a space and I am looking for the last > value. > I tried If you know that the valu

Re: Deleting from a list

2001-12-21 Thread Sudarsan Raghavan
Use splice (perldoc -f splice) To delete array index $i splice (@myList, $i, 1) hth, Sudarsan Sharat Hegde wrote: > Hello, > > I need to delete an element from a list (array). The delete function does > not seem to work. For example if I need to delete element number "i" from > the list "myList

Re: Taking Backup of some files in a directory structure

2001-12-21 Thread Sudarsan Raghavan
Perl modules and functions that will be useful for this are File::Find (type perldoc File::Find at the command prompt) substr (perldoc -f substr) rindex (perldoc -f rindex) rename (perldoc -f rename) After you have read through these docs you will be able to figure out the perl script yourself. h

Re: Opening multiple files in a directory

2001-12-14 Thread Sudarsan Raghavan
You can use perl's glob operator (type perldoc -f glob at the command prompt for help) Wrap your script, except the exit(0) by while (<$some_dir_name/*.txt>) { # Assuming you are searching for .txt files. } hth, Sudarsan pn wrote: > Hello, > > My question: I would like to be able to have

  1   2   >