Re: Regex search using scalar

2003-11-06 Thread Sudarshan Raghavan
Paul Harwood wrote: The search patterns I am looking for are contained inside the list (each element of the list is going to be used to scan an entire log file). So "if ( /match/ )" needs to reference each element of the FOREACH loop which I will have nested inside a while loop. That's what's con

Re: Training in the Middle and Far East

2003-11-05 Thread Sudarshan Raghavan
Rob Dixon wrote: To all. I wonder if any subscriber from the middle and far eastern countries Why not just say "Asian Countries" can explain what training and IT experience people like them are likely to have had? Can't speak for the entire asian region (only India and Bangalore in particular

Re: Simple CGI Question

2003-11-04 Thread Sudarshan Raghavan
Jack wrote: Hello, In my perl CGI script, I'm trying to extract the PID that corresponds to it. $$ contains the PID that corresponds to your script (perldoc perlvar) How do I do this? I'm also trying to extract the timestamp. The built-in perl function localtime will interest you perldoc -f loc

Re: Reading a directory and Renaming the file

2003-10-30 Thread Sudarshan Raghavan
James Parsons wrote: Hi all I've this Perl script to read all files in a directory and if it finds a file with a certain then rename the file to header, but is doesn't search the right directory and doesn't even look for the HPAY header. Ops forgot to include the script. #!/usr/bin/perl -w

Re: What is my name

2003-10-30 Thread Sudarshan Raghavan
[EMAIL PROTECTED] wrote: Hi, I have a little problem. I have script "test.pl" and inside this script I want to know what is "my name" (I mean this "test.pl". $0 will contain the program name perldoc perlvar -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PR

Re: Hash Issue or Understanding

2003-10-30 Thread Sudarshan Raghavan
The output works but it not in the order I expected: I expected my output to be: hostname, IP addrress, OS, Version, Release, Server Type, Model, Memory Size, Total CPU's. But what I got was: Model, Server Type, cpu, Release, hostname, OS, Memory Size, Version It seems to me the hash sta

Re: join question - maybe map

2003-10-16 Thread Sudarshan Raghavan
Gary Stainburn wrote: Hi folks, I've got a hash such as: %masters=('VSL01'=>{'type'=>'S','name'=>'Vehicle Ledger accounts'}, 'ALD01'=>{'type'=>'S','name'=>'ALD Automotive Ltd'}, 'ALP01'=>{'type'=>'S','name'=>'Alphabet GB Ltd'}, 'ANC01'=>{'type'=>'S','name'=>'ANC Rent

Re: finding a blank line

2003-10-15 Thread Sudarshan Raghavan
Jerry Preston wrote: > Hi! > > I know this is a no brainer, but this line of code does not always work: > > last if( /^\n/ or /^\s+\n/ ); last if (/^\s*$/); Out of curiosity, can you post the cases for which your statement did not work? Are these strings with embedded newlines? > > > What am I

Re: Another sub clean up

2003-10-14 Thread Sudarshan Raghavan
Sudarshan Raghavan wrote: > simran wrote: > > > I wrote my self this subroutine... which comes in very handy :-) > > > > ..snip > > > > sub strip { > > my $self = shift; > > my $ref = shift; > > > > if (! ref($ref)) { > >

Re: Another sub clean up

2003-10-14 Thread Sudarshan Raghavan
simran wrote: > I wrote my self this subroutine... which comes in very handy :-) > > ..snip > > sub strip { > my $self = shift; > my $ref = shift; > > if (! ref($ref)) { > $ref =~ s/(^[\s\t]*)|([\s\t]*$)//g if (defined $ref); Why is it better to do this in two steps? Read through this

Re: Another sub clean up

2003-10-14 Thread Sudarshan Raghavan
[EMAIL PROTECTED] wrote: > Can someone hlpe me clean up this trim? > > Rule: remove all trailing blanks and newline/LF perldoc -q 'How do I strip blank space from the beginning/end of a string' > > > Do I need a chomp here somewhere? No, the \s+ will take care of that > > > sub trim > { my $

Re: How do I convert strings to floating number?

2003-10-14 Thread Sudarshan Raghavan
Marcus Claesson wrote: > > lt, gt etc. are used for string comparisons. Change 'lt' to < and 'gt' to > > > and your code should work. > > > > You're right, but this script was a simplification of a bigger one where > '>' didn't work (my mistake to not spot the difference...). Here is a > more 'rea

Re: How do I convert strings to floating number?

2003-10-14 Thread Sudarshan Raghavan
Marcus Claesson wrote: > Hi there, > > I have a simple problem that I'm sure has been asked before (so why not > again ;)) > > I have a list like this: > > 1e-100 > 2e-100 > 1e-45 > 5e-10 > 1 > 10 > 20 > > and want to make correct assignments: > > 1e-100 SMALL > 2e-100 SMALL > 1e-45 BIGGER > 5

Re: array inside an array

2003-10-13 Thread Sudarshan Raghavan
"N, Guruguhan (GEAE, Foreign National, EACOE)" wrote: > Hi All, > I have recently started using Perl for my project. I have a problem in > getting elements of the following array. > > @array1 = ( [ x1, x2, x3], > [ x4, x5, x6], > [ x7, x8, x9]); @array1 is an

Re: regex, is this possible?

2003-10-08 Thread Sudarshan Raghavan
Jerry Preston wrote: > Hi! > > I am trying to break down the following: > >printf("numsteps=%d i=%d im=%g vfr=%g \n",numsteps,i,imeas,vforce); > into >"numsteps= numsteps i=i im=imeas vfr=vforce \n" > >printf ("\noriginal cap = %g, offset = %g", *ci, cap_offset); > into >"\nor

Re: Add text to beginning every line

2003-10-07 Thread Sudarshan Raghavan
Chris Charley wrote: > "Chris Charley" <[EMAIL PROTECTED]> wrote in message news:... > [snip] > > while (<>) { > > s/^/Line: $. /; > > } > > Should be (works correctly): > > while (<>) { >s/^/Line: $. /; You don't need a regular expression to do this. This should suffice $_ = "Line

Re: make changes to a file, then reading in those changes. . .

2003-10-07 Thread Sudarshan Raghavan
Trina Espinoza wrote: > I have a file that I want to run multiple actions on. First, the file is > read in as one long string. I want to > substitute some words with others so I run a substitution. That seems to > change the data in the first > while, HOWEVER, when I run the second while loop on t

Re: regex. help

2003-09-24 Thread Sudarshan Raghavan
Pandey Rajeev-A19514 wrote: Hi , I have a question regarding matching strings that have embeded perl special characters. $abc = 'MC10.G(12)3c'; $efg = 'MC10.G(12)3c'; Now I want to check whether they are same or not by doing if ($abc =~ /$efg/) { do something;} Why not use the 'eq' operator

Re: newbie stuck in a loop de loop

2003-09-24 Thread Sudarshan Raghavan
Pam Derks wrote: Hi all, thanks in advance for any help... what I want to do is: 1) read in a file containing daily total hits to certain urls within a subdirectory so total.030922 would contain: month date subdir and total count for this date example: Sep 22 airport 4 Sep 22 alumni 5 2) read in

Re:

2003-09-15 Thread Sudarshan Raghavan
Vema Venkata wrote: dude still the problem persits... This certainly seems like a buffering problem, the $| solution should work. Does your script or any of the modules that you are using selecting another filehandle (perldoc -f select, 1 argument form of select). The value of $| will affect t

Re: Perl Module to print $string in exact possition

2003-09-11 Thread Sudarshan Raghavan
Hari Fajri wrote: Hi All, What is perl module to print $string in exact position in sceen. For example: i wanna print "time remaining: 59 second(s)" after that, i want to replace it with: "time remaining: 58 second(s)" Use '\r' (carraige return) instead of '\n' in your print statements and tu

Re: pls do reply

2003-09-09 Thread Sudarshan Raghavan
Vema Venkata wrote: How do i get the process id into a variable ? can any one help Process Id of what? $$ will contain the process id your current perl script. perldoc perlvar If you want to get the process id based on the command name, Proc::ProcessTable will interest you. $pid = qx(ps -f|gre

Re: chmod -- chomp not chmod!!

2003-09-04 Thread Sudarshan Raghavan
Christiane Nerz wrote: Oh-oh - there was a mistake - I tried chomp, not chmod.. How do I use chomp correctly? I have an array of strings, want to cut off the last \n in each line and use the rest of the line. (concatenate it to another string) Jane Hi all! I like to read several rows out of tw

Re: passing an argument to a subroutine

2003-09-04 Thread Sudarshan Raghavan
B. Fongo wrote: Hello Please don't cross post An argument passed to a subroutine returns wrong value. Code example: @x = (1..5); $x = @x; You are trying to assign an array to a scalar. An array evaluated in a scalar context gives the no elements present in it. In this case the value 5 will b

Re: Editing files inplace with the <> operator

2003-09-04 Thread Sudarshan Raghavan
Babylon wrote: I know how it's supposed to be done but when i tried it in a program i'm writing at the moment it isn't working quite how i expected. The program is, in it's simplest form (which still doesn't work): -- #!perl for $file () { push @

Re: exact string match?

2003-09-02 Thread Sudarshan Raghavan
James Edward Gray II wrote: On Tuesday, September 2, 2003, at 01:52 PM, Dan Muey wrote: if($mystr =~ m/^exactstr$/) { print 'Ye haw it matches!'; } This isn't a pattern, this is an equality test. I would consider the above a poor use of Regular Expressions. $mystr =~ /^exactstr$/ is identi

Re: Bidirectional pipes

2003-09-02 Thread Sudarshan Raghavan
les;\n"; while () { print ; } Sudarshan Raghavan

Re: Bidirectional pipes

2003-09-02 Thread Sudarshan Raghavan
[EMAIL PROTECTED] wrote: Hi all, I wonder how can I open pipe to STDIN and STDOUT of a process ? perldoc IPC::Open2 If you need a handle to STDERR perldoc IPC::Open3 Tnx. Mehmet -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Need help on modules

2003-07-31 Thread Sudarshan Raghavan
Pandey Rajeev-A19514 wrote: Hi, I want to create a module, say ABC.pm. I dont want to build and install the module. Not sure what you mean by this. I want to use a function xyz() of the module ABC in some other script. AND, I want to call the function as xyz(); instead of ABC::xyz(); This is p

Re: Can't figure out this warning.

2003-07-30 Thread Sudarshan Raghavan
Sachin Hegde wrote: Hi, There is this warning which I can't remove : Illegal hexadecimal digit ' ' ignored at test.pl line 131, line 23. It is the newline at the end test.pl is the name of the program while FH is a file handle(read only). Part of my code is: <129> $ln = ; <130> @f

Re: How to add modul directory to @INC

2003-07-28 Thread Sudarshan Raghavan
[EMAIL PROTECTED] wrote: It is my first time writing a module. After executing a script that requires my module, I got an error "blabla not found in /usr/lib/perl etc.". So I moved my module to /usr/lib/perl/ and it work o.k. Recently I read somewhere that, instead of always moving my modules to

Re: Problem with pass by reference

2003-07-28 Thread Sudarshan Raghavan
Pandey Rajeev-A19514 wrote: Hi, The dimension of the data increases by each pass by reference. In this subroutine, @FORMATTED_OUTPUT was filled up as a 2 dimensional array $FORMATTED_OUTPUT[$i][$j]. sub ABC { .. SOME CODE return (\$rows, \$cols, [EMAIL PROTECTED]); } In subroutine DEF, ABC

Re: regex problem

2003-07-24 Thread Sudarshan Raghavan
awarsd wrote: Hi, I have a number $page = 500; now i want to check that if $page matches a word character then make $page =1; so originally i did this my $page =500; if(($page =~ /\w/) || ($page <= 0)){ $page=1; } print"$page"; since it always returns $page = 1; then i did this if(($page =~ /(\w)

Re: modifing and writing to a file

2003-07-24 Thread Sudarshan Raghavan
NYIMI Jose (BMB) wrote: s/a-z/A-Z/g should be s/[a-z]/[A-Z]/g; Character classes are only possible in the matching part of the regex, not in the replacement part. You regex says substitute all occurences of a lowercase alphabet with the string '[A-Z]' -- To unsubscribe, e-mail: [EMAIL PROTEC

Re: passing a var to a sub

2003-07-22 Thread Sudarshan Raghavan
jdavis wrote: hello, I would like to pass subs vars to work on. right now I,m using globals to pass messages to the subs.Is this the right way to do this? Avoid global variables if possible, some of the issues are code maintenance, readability etc. Read through this doc to learn about perl su

Re: Is $1 ever undefined or set to null?

2003-07-21 Thread Sudarshan Raghavan
Ed Christian wrote: I assumed that, $1 would be reset (either undefined or set to null) once I exited the scope of the while loop my regexp was called in. Sadly, I was mistaken. :) Below is a test example of code I wrote, with $1 values differing from those I expected. Do I need to explicitly set

Re: Regular Expression (fwd)

2003-07-17 Thread Sudarshan Raghavan
trensett wrote: -- Forwarded message -- Date: Wed, 16 Jul 2003 18:23:35 -0500 (EST) From: trensett <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: Regular Expression On Wed, 16 Jul 2003, Janek Schleicher wrote: Nick Diel wrote at Tue, 15 Jul 2003 11:12:18 -0600:

Re: Creating a hash of arrays from row data

2003-07-11 Thread Sudarshan Raghavan
Robin Norwood wrote: To sort-of change the subject, I think the 'deep_copy' subroutine quoted in this article contains a bug... the sub in question: sub deep_copy { my $this = shift; if (not ref $this) { $this; } elsif (ref $this eq "ARRAY") { [map deep_copy($_), @$this]; } elsif (ref $t

Re: delete file

2003-07-11 Thread Sudarshan Raghavan
Boon Chong Ang wrote: Hi, My name is Boon Chong. I have question. Just say, I run a perl script and in between of the process I create a temporarily file for checking purpose. Now, how do I ask perl to delete the file automatically? Automatically as in, when the script finished executing? Use t

Re: a program problem for print?

2003-07-10 Thread Sudarshan Raghavan
Julie Xu wrote: Greeting, I am trying to create a simple perl script to read a text file (8 columns separated by space) and output the colume6,8. The file format is: Entry11 entry12 entry13 entry14 entry15 entry16 entry17 entry18 Entry21 entry22 entry23 entry24 entry25 entry26 entry27 entry28

Re: Creating a hash of arrays from row data

2003-07-09 Thread Sudarshan Raghavan
Kevin Pfeiffer wrote: In article <[EMAIL PROTECTED]>, Sudarshan Raghavan wrote: [...] Reason: 'shallow copying' vs 'deep copying' Read through this link http://www.stonehenge.com/merlyn/UnixReview/col30.html I looked at this article and tried the code but I ge

Re: Creating a hash of arrays from row data

2003-07-09 Thread Sudarshan Raghavan
s post is the result of a misconception, just saying this in general terms. Maybe I should start using more smileys in my mails. You spelt my name wrong :-) (here you go) Sudarshan Raghavan wrote: Rob Anderson wrote: Hi Jeroen, while (@values = $lcsr->fetchrow) {

Re: Creating a hash of arrays from row data

2003-07-09 Thread Sudarshan Raghavan
Rob Anderson wrote: Hi Jeroen, while (@values = $lcsr->fetchrow) { This is probably the root of your problem every time you go through this loop, you are repopulating your array, put a my before @values. Why do you think this is a problem? All the my would do is create a new lexical @val

Re: how to create/use data structures in perl ?

2003-07-08 Thread Sudarshan Raghavan
Madhu Reddy wrote: Hi, How to create data structures in perl ? I have following data structure in C...and i have to create similar data structure in perl and use... how to create data strutures in perl and how to use ? perldoc -f pack perldoc -f unpack typedef struct { charPref

Re: Stat() - Getting one element

2003-07-07 Thread Sudarshan Raghavan
Paul Kraus wrote: What's an easy way to grab just one element out of a function that returns a list. For instance if I was to stat a file and all I wanted was the $atime or if I just wanted the three timestamps atime mtime and ctime. Thanks. my ($atime, $mtime, $ctime) = (stat ($your_file))[8, 9

Re: help SFTP perl

2003-07-07 Thread Sudarshan Raghavan
vemulakonda uday bhaskar wrote: hi all have run this simple code , which is nothing but file transfer using SFTP between two linux systems #!usr/bin/perl Add these lines, trust you will be glad you did use strict; use warnings; Let them stay as long as you are developing and testing your co

Re: newbie needs help

2003-07-07 Thread Sudarshan Raghavan
dakenah johnson wrote: Hi I am writing a script that uses backquotes and the ps-ef command to print the UID and command for all currently running processes. #!/usr/bin/perl use strict; my $process = `ps -ef`; while (<>);{ This should flag an error, note the semi-colon What you are reading from

Re: help perl needed

2003-07-03 Thread Sudarshan Raghavan
vemulakonda uday bhaskar wrote: hi all This is the fifth time you have posted the same mail. Please avoid this, it is annoying i have got a code for file transger between two linux systems through ssh here is the code Did you run this code and see what happens? #!usr/bin/perl when y

Re: how to remove last comma in file?

2003-07-03 Thread Sudarshan Raghavan
Rob Dixon wrote: Sudarshan Raghavan wrote: anthony wrote: Hi, I have a question, what i do is if i have $string = "a,b,c,d,e,f,g," I just do chop $string; there is no while loop with this Would this be as good?? Careful, chop removes the last character no matter w

Re: Getting the size of special files in a directory?

2003-07-03 Thread Sudarshan Raghavan
hi, thanks for your answer. but how can i do that together with glob? Please keep the thread going in the list, you might get a faster reply by posting to the list #!/usr/bin/perl @dateien=glob("/var/*.html"); #i need the age etc here? $size=0; foreach (@dateien) {$size+=(-s $_);} print $

Re: how to remove last comma in file?

2003-07-03 Thread Sudarshan Raghavan
anthony wrote: Hi, I have a question, what i do is if i have $string = "a,b,c,d,e,f,g," I just do chop $string; there is no while loop with this Would this be as good?? Careful, chop removes the last character no matter what. It is advisable to use chomp in this scenario. chomp removes any tra

Re: Getting the size of special files in a directory?

2003-07-03 Thread Sudarshan Raghavan
[EMAIL PROTECTED] wrote: hi, is it possible to get the size of special files in a directory? i need the size of all gz or html files. this works, i did it with glob. but how can i get the size of files that match a pattern? for example all filesnames that contain the string "setup". or all files

Re: [OT]Re: log file -help

2003-07-01 Thread Sudarshan Raghavan
Vema Venkata wrote: Raghavan Can you re-write the same functionality in the perl pgm since i cudn't find any mailing list for shell wud be appreicated ur reply asap rgds venkat If you can get my boss' approval and pay for it, certainly :-) shell programming newsgroups must be under either comp.l

Re: combining array to scalar

2003-07-01 Thread Sudarshan Raghavan
Steve Grazzini wrote: On Tue, Jul 01, 2003 at 03:43:31PM +0530, Sudarshan Raghavan wrote: array vs list, an array in a scalar context evaluates to the number of elements in it. The same does not apply to a list, infact I don't think there is a list in scalar context. Yep. "T

[OT]Re: log file -help

2003-07-01 Thread Sudarshan Raghavan
Vema Venkata wrote: Hi All My code looks like this xapipgm=srvtst26.pl pgrep -f $xapipgm > /dev/null if [ $? -eq 0 ] then set `pgrep -f $xapipgm ` echo "AHD XAPI Server ($xapipgm) Running with Process Id: $1" else echo "AHD XAPI Server is now Started Running." set `date '+%Y %m %d %H %M' ` xap

Re: combining array to scalar

2003-07-01 Thread Sudarshan Raghavan
Kevin Pfeiffer wrote: In article <[EMAIL PROTECTED]>, Sudarshan Raghavan wrote: Ling F. Zhang wrote: say I have array: @a=["I","LOVE","PERL"] [...] This will do what you want my $arr_to_str = "@a"; [...] Wow! I tried a co

Re: password encrytion perl help

2003-07-01 Thread Sudarshan Raghavan
vemulakonda uday bhaskar wrote: hi all my code looks like this: #!/usr/bin/perl $ftp=Net::FTP->new("xxx.xxx.xxx.xxx") else die "not connected"; $u=; CHOMP $u; $p=; CHOMP $p; $ftp->login($u,$p) or die "login failed"; the code is working fine but the problem is when it asks password i need to give

Re: combining array to scalar

2003-07-01 Thread Sudarshan Raghavan
Ling F. Zhang wrote: say I have array: @a=["I","LOVE","PERL"] You have created a reference to an anonymous array here, I guess you meant @a = qw/I LOVE PERL/; I would like to make a scalar: $b="I Love Perl\n" Please don't name variables as $b etc, they make the code unreadable and read through

Re: Moving between directories

2003-06-30 Thread Sudarshan Raghavan
T.S. Ravi Shankar wrote: Mr. Sudharshan, Very thanks for your quick reply ! So do you say that it is not possible through any means to change the directories (since we are moving between the shells) ? You can change the cwd of the current process. But, this change will not be reflected in the

Re: Help perl

2003-06-29 Thread Sudarshan Raghavan
vemulakonda uday bhaskar wrote: hi all This is the 5'th copy of your mail, please don't send multiple copies thanks for the reply. i got the Net::FTP module installed and my code is working my code is as follows : #!usr/bin/perl use Net::FTP; $ftp=Net::FTP->new("192.168.255.xxx") or dir

Re: Moving between directories

2003-06-29 Thread Sudarshan Raghavan
T.S. Ravi Shankar wrote: Hi all : Could anyone tell me how I could move between the directories ( or change the present working directory ) with any perl command ?? I have tried these system '/bin/cd $HOME'; , chdir '$HOME'; , exec 'cd $HOME'; After I execute the perl code, the PWD still re

Re: Help : Net::FTP

2003-06-27 Thread Sudarshan Raghavan
vemulakonda uday bhaskar wrote: Dear all Can u give me a site from where i can download and install "Net::FTP" For all you perl module download needs, go here http://search.cpan.org Please bookmark it. Regards uday bhaskar.v.v. ___ Click bel

Re: HELP! Reg-ex question

2003-06-27 Thread Sudarshan Raghavan
Mike wrote: Given the following code snippet: - print "$text\n"; my $text="sour red apples"; my $pattern="(sour)"; my $replacement="very \$1"; $text=~s/$pattern/$replacement/; print "$text\n"; - I was expecting "very sour red appl

Re: Count Function?

2003-06-27 Thread Sudarshan Raghavan
Nelson Ray wrote: Does anyone know of any sort of a function or method in perl that returns the number of times a search string exists in a scalar. Say, how many "a's" are there in this sentence? I am able to write it myself, but I was wondering if Perl had an inherent function for cleaner opera

Re: help perl

2003-06-26 Thread Sudarshan Raghavan
vemulakonda uday bhaskar wrote: sir Please don't address me as sir, sudarshan would do as u asked me to do i have gone thru the below site for ssh tranfer of files in two linux systems http://search.cpan.org/author/IVAN/Net-SCP-0.06/SCP.pm I would appreciate it if you would keep this threa

Re: put path together?

2003-06-26 Thread Sudarshan Raghavan
Kevin Pfeiffer wrote: In article <[EMAIL PROTECTED]>, Sudarshan Raghavan wrote: [EMAIL PROTECTED] wrote: hello to everyone. when i have a path like that: /usr/X11R6/lib/X11/locale how can i cut this path into strings like that: / /usr /usr/X11R6 /usr/X11R6/lib /usr/X11R6/lib/X1

Re: linefeed

2003-06-26 Thread Sudarshan Raghavan
Charles Scheepers wrote: Thanks for the reply... I an actually running the program on an UNIX platform, but it still uses CRLF in the output. I have actually tried: "print FILHNDL "Text...\012";" and the output is still translated to CRLF. Will utilities like dos2unix make a difference? Is the s

Re: put path together?

2003-06-26 Thread Sudarshan Raghavan
[EMAIL PROTECTED] wrote: hello to everyone. when i have a path like that: /usr/X11R6/lib/X11/locale how can i cut this path into strings like that: / /usr /usr/X11R6 /usr/X11R6/lib /usr/X11R6/lib/X11 /usr/X11R6/lib/X11/locale You have multiple options 1) split (perldoc -f split) 2) index and

Re: Help needed perl

2003-06-26 Thread Sudarshan Raghavan
vemulakonda uday bhaskar wrote: dear all i have got two linux systems with perl on it i want perl programming workable code through which i can transfer files from one system to another using sftp or ssh. sftp http://search.cpan.org/search?query=sftp&mode=module ssh http://search.cpan.org/sea

Re: dynanic declaration of arrays

2003-06-25 Thread Sudarshan Raghavan
Tim McGeary wrote: Can I dynamically declare an array by doing something like: for (keys %codes_hash) { my @$_; { so that I have an array for each code in my hash that I can push data to whatever array is associated with the code that I searching on at that iteration? What you are referr

Re: File Handles in subroutines

2003-06-25 Thread Sudarshan Raghavan
Scott, Joshua wrote: What do I need to do in order to use a filehandle that was opened earlier in a program within a subroutine? I've included an example of the code I have that is not doing what I would like. Basically, I never get any output to the file. If I change it so that it doesn't use

Re: Simple doublt of $_ and print;

2003-06-24 Thread Sudarshan Raghavan
Chris San wrote: It is supose this code prints the first line of file text.txt (which is not empty), but it doesn't print anything. $file = "text.txt"; open (file); ; The above statement does not store the result in $_, this is special only inside a while statement while () is equivalent t

Re: reading file into hash?

2003-06-24 Thread Sudarshan Raghavan
Tim McGeary wrote: This works great, except when I do: for (keys %codes_hash) { print "$_|$codes_hash{$_}\n"; } for my own confirmation, I'm getting a blank line in the printout. I re-checked my config file and made sure there was not an extra blank line at the end of the file. Do you have

Re: searching the solution

2003-06-24 Thread Sudarshan Raghavan
. thanks in advance. Thanks and Regards -Gayatri - Original Message - From: Sudarshan Raghavan <mailto:[EMAIL PROTECTED]> Cc: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> Sent: Tuesday, June 24, 2003 4:37 PM Subject: Re: searching the solution G

Re: searching the solution

2003-06-24 Thread Sudarshan Raghavan
Gayatri wrote: Hi Please start a new thread to ask a question I am writing a perl scipt in that I want to change the dir to some other and run a exe from there is it possible? Yes it is possible, it is also possible to do that without changing to that directory Because chdir is not working t

Re: Parsing .csv file

2003-06-24 Thread Sudarshan Raghavan
Sparrow, Dave wrote: I'm reading an Excel .csv file. Fields are separated by commas. If a field contains a comma, the whole field is double-quoted (Excel does this by default). An example of an input line is as follows: field1,field2,"field3a, field3b, field3c",field4,"field5a, field5c",field6

Re: Perl Best Practices

2003-06-24 Thread Sudarshan Raghavan
Nyimi Jose wrote: Hello, I'm looking for a link where i can find information about Perl's best practices programming. For starters you can take a look at these docs perldoc perlstyle perldoc perltrap perldoc perlmodstyle #If you are interested in developing modules Thanks in advance. ==

Re: while (<>)

2003-06-15 Thread Sudarshan Raghavan
Bryan Harris wrote: Is there a way to discover the filename of the current file being read when using the angle brackets (e.g. while (<>) {} )? perldoc perlop #Search for 'null filehandle' The filename will be stored in $ARGV TIA. - Bryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For a

Re: compare, checking and listing

2003-06-14 Thread Sudarshan Raghavan
Boon Chong Ang wrote: Hi, I have two array, @test1, @test2. Just say, I want compare @test2 with @test1 in such manner. @test2 could contains more, less or equal elements compare to @test1 which I don't know. I want to write a perl script to compare @test2 to @test1 and list out those element wi

Re: misunderstanding the /g modifier on REGEX

2003-06-13 Thread Sudarshan Raghavan
Tim Johnson wrote: David, if you don't mind, could you give an explanation of what you're doing here? I'm not sure if everyone is familiar with the method you're using to look ahead. I will take a crack at this -Original Message- From: david [mailto:[EMAIL PROTECTED] Sent: Thursday, Ju

Re: $?

2003-06-12 Thread Sudarshan Raghavan
Olivier Wirz wrote: Hello, I would like to know if there is a way to check $? to see whether the programm ran correctly in such a statement: @results =`grep $search $_`; Yes using the $? variable. ($? >> 8) will give you the exit status. perldoc perlvar perldoc -f system Thank you Olivi

Re: Wanted: Help with modules/packages

2003-06-12 Thread Sudarshan Raghavan
Richard Heintze wrote: I apologize if I'm posting this twice. I assume that it did not go out to the group because I did not get any responses and the folks at [EMAIL PROTECTED] have been extremely helpful in the past. Can somone help me make my sample program work below? (1) I cannot call funct

Re: Returning the first key in a hash...

2003-06-12 Thread Sudarshan Raghavan
Rob Dixon wrote: Hamish Whittal wrote: Ok, thanks Sudarshan, but why did this not work? pop ( keys (%hash) ); 'pop' operates on an array, not a list. This would work my @keys = keys %hash; my $key = pop @keys; I guess you meant shift (@keys), pop will return the last key returned by

Re: Returning the first key in a hash...

2003-06-12 Thread Sudarshan Raghavan
ay not the first. shift will return the first element of the array (perldoc -f shift) But, shift will work on arrays only not lists. Thanks. H On Thu, 2003-06-12 at 14:39, Sudarshan Raghavan wrote: Hamish Whittal wrote: Hi all, I have a hash and want to return the first key in the hash. Ho

Re: Returning the first key in a hash...

2003-06-12 Thread Sudarshan Raghavan
Hamish Whittal wrote: Hi all, I have a hash and want to return the first key in the hash. How can I do this? The answer is (keys (%your_hash))[0]. This will return the first element in the list of hash keys returned by keys. But, you can never be sure of the order in which the keys will be re

Re: Urgent : Can I override #! defn. through any command line option ??

2003-06-04 Thread Sudarshan Raghavan
Please don't cross post T.S. Ravi Shankar wrote: Thanks Beau .. This works !! But the command line "/blah/blah/local/bin/perl" doesn't seem to override any #! definition. I am not sure what you mean by overriding the she-bang line. perl will treat the '#!' line only as a comment (she-bang proc

Re: Reading data from a text file

2003-06-04 Thread Sudarshan Raghavan
Gibson Scott (air4sag) wrote: I'm trying to come up with a script that will read a list of files from a text file and copy them from one path to another. I can't seem to get perl to use the text file as on a Win2000 PC. I call the perl program from the command line using the < to direct the dat

Re: $|

2003-03-31 Thread Sudarshan Raghavan
On Mon, 31 Mar 2003, Rob Dixon wrote: > Janek Schleicher wrote: > > Rob Dixon wrote at Sat, 29 Mar 2003 12:59:22 +: > > > > > use IO::Handle; > > > autoflush STDOUT; > > > autoflush STDERR; > > > > > > print STDERR "STDERR\n"; > > > print STDOUT "STDOUT\n"; > > > > > > so t

Re: Find Text in files

2003-03-26 Thread Sudarshan Raghavan
On Wed, 26 Mar 2003, James Ferree wrote: > Hi, > > I am looking to write a script that will look in a > file for a list of text strings to search for like > > req_ > req_bbb > req_ccc > > and search all the files in a subdirectory and below > for the string, if it is found, then it prints o

Re: building hash table

2003-03-26 Thread Sudarshan Raghavan
On Tue, 25 Mar 2003, Pam Derks wrote: > Hi all, > > am struggling with this, and it must be the something simple but for the life of me > I don't see it. > > Am trying to build a hash table with: > instructor name and their biography > > I've tried just about everything, but I can't get the va

Re: Reading Directories

2003-03-25 Thread Sudarshan Raghavan
On Tue, 25 Mar 2003 [EMAIL PROTECTED] wrote: > Does anyone know how to read a directory in perl, and make a list of all the > files therein, and also of any sub directories and their files? To get a list of files in a directory (not recursive) perldoc -f glob perldoc File::Glob my @files_list =

Re: rename in windows doesn't work

2003-03-24 Thread Sudarshan Raghavan
On Mon, 24 Mar 2003, Rosenstein, Leon wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi everyone, > > I am having some problems with a script. > > Currently the script reads: > opendir (DIR, "c:/temp") or die "Cant Open Temp Buddy Boy! \n"; > @filenames = readdir (DIR) or di

Re: 1) Automated FTP 2) txt to html 3) pstools vs WMI

2003-03-23 Thread Sudarshan Raghavan
On Mon, 24 Mar 2003, Pradeep Goel wrote: > Hi All ,pls answer if u know anything out of 3 different questions. > > 1) > Can somebody give some pointers where to look for or any particularly good one ( > free ofcourse) automated ftp tool which can be used for transfering a txt/doc file > from my

Re: showing directories and subdirectories.

2003-03-21 Thread Sudarshan Raghavan
On Thu, 20 Mar 2003, Christopher M Burger wrote: > Hello, > > I was wondering if anyone had any ideas on how I can get a list of > directories and subdirectories. Take a look at File::Find, comes with the standard distribution perldoc File::Find > > I'm currently trying something like this: >

Re: Linux Environment Variable

2003-03-21 Thread Sudarshan Raghavan
On Thu, 20 Mar 2003, Ankit Gupta wrote: > Hi, > > I want to print some linux environment variables that have already been set. > Could some one let me know which command I can use to get value of > environment variables. Environment variables are available through the %ENV hash. For e.g. to get

RE: Unix ls -lrt | tail -1 in Perl

2003-03-21 Thread Sudarshan Raghavan
gt; > $filename = `ls -ltr|tail -1 $DIRECTORY`; > > print $filename; > > Sorry, i didn't mentioned that i wanted a pure perl solution, thanks anyway. > > my $latest = (sort {-M $a <=> -M $b} <$dir/*>)[0]; > Will be my way to go, thanks Sudarshan Raghavan >

Re: Unix ls -lrt | tail -1 in Perl

2003-03-20 Thread Sudarshan Raghavan
On Thu, 20 Mar 2003, NYIMI Jose (BMB) wrote: > Hello, > > How can I do this unix command in Perl ? : ls -lrt | tail -1 > Actually, i would like to get the most recent file from a given directory. my $latest = (sort {-M $b <=> -M $a} <$dir/*>)[-1]; or my $latest; while (<$dir/*>) { $lates

Re: PERL OSX --- reading a local text file

2003-03-19 Thread Sudarshan Raghavan
On Tue, 18 Mar 2003, Scott R. Godin wrote: > John W. Krahn wrote: > > > David Gilden wrote: > >> > >> OK, one problem is solved, which was the path to the data file. > >> I know there is a simple way to read in a file like the following: > >> > >> apple,2 > >> banana,4 > >> kiwi,1 > >> > >> an

Re: Query: System Errors

2003-03-12 Thread Sudarshan Raghavan
On Wed, 12 Mar 2003, Manish Uskaikar wrote: > Hi, > > Thanks for the reply. I was working with the regular expressions wanted to > know if i can have an equivalent of > > try > { > my code here > } > catch(exception e) > { > } > > Regards > Manish U > This might be of interest to you http

Re: Query: System Errors

2003-03-11 Thread Sudarshan Raghavan
On Wed, 12 Mar 2003, Manish Uskaikar wrote: > Hi, > > Can anyone help me, regarding the trapping of system errors like segmentation fault? > I want the program to exit only after i finish completing my error_log file. 1) What kind of errors are you looking at? 2) Is this a perl question? 3) Are

  1   2   3   >