Re: Downloadable and Online Perl Documentation

2007-12-18 Thread Ankur Gupta
On Dec 19, 2007 2:40 AM, <[EMAIL PROTECTED]> wrote: > Hello > > i am looking for perl documenation that would aid in the determining what > code to write and how to determine how one made a syntax error and also > available functions. > > I need the documentation 2 formats. The first would be so

Re: testing for a file type

2007-12-18 Thread Ankur Gupta
On Dec 18, 2007 10:08 PM, goldtech <[EMAIL PROTECTED]> wrote: > Hi, > > If I have: > > ... > foreach (@ARGV) { >print "do something only to .mdb files"; > } > > I could use File::Basename's fileparse and test for the file extension > and put a big if statement around or in the foreach loop. So

Better way to add one line at top of every file(one liner)

2006-05-18 Thread Ankur Gupta
perl -0777 -p -i -e 'print "abcdefgh\n"' *.ext or perl -0777 -p -i -e 's#^#abcdefgh\n#' *.ext or ??? --Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Tie::File adds extra lines if recsep is "\n\n"

2006-05-10 Thread Ankur Gupta
On 5/10/06, D. Bolliger <[EMAIL PROTECTED]> wrote: Ankur Gupta am Mittwoch, 10. Mai 2006 11.23: > Hi, > > Using Tie::File with recsep = "\n\n" adds two extra lines to the > original file when I iterate through the entire file. If I just change > one record then its

Tie::File adds extra lines if recsep is "\n\n"

2006-05-10 Thread Ankur Gupta
Hi, Using Tie::File with recsep = "\n\n" adds two extra lines to the original file when I iterate through the entire file. If I just change one record then its fine. Below is the program use strict; use warnings; use Tie::File; my @array; tie @array, 'Tie::File', 'file', recsep => "\n\n" or d

RE: deleting an element from an array

2006-04-22 Thread Ankur Gupta
Johan Meskens CS3 jmcs3 scribbled on Saturday, April 22, 2006 5:26 PM: > hello > i want to delete an element from an anonymous array in a hash with: > > delete ${$alltheworlds{ $d }}[$num]; perldoc -f splice. my $deleted_element = splice(@{$alltheworlds{ $d }} , $num

Class::DBI is slow?

2006-04-20 Thread Ankur Gupta
Hi All, My first try with Class::DBI and DBI modules and I find that making a query using Class::DBI takes much much more time than compared to DBI. Is it me who is doing something wrong or Class::DBI is always slower(I have kind of feeling that its me who is doing something wrong). Also, I have

RE: golf

2006-04-19 Thread Ankur Gupta
Chad Perrin scribbled on Wednesday, April 19, 2006 6:59 PM: > On Wed, Apr 19, 2006 at 06:51:21PM -0700, Timothy Johnson wrote: >> >> You mean like this? >> >> perl -p -e "s/\n/ /" > > Thanks. I looked -p up in perlrun and learned something new. It's > not quite what

RE: array help

2006-04-13 Thread Ankur Gupta
Irfan J Sayed scribbled on Thursday, April 13, 2006 9:46 AM: > Hi, > > I am executing following command. > > my @activity = system "cleartool lsactivity -short -view > Admin_Irfan_Project_int"; > > but the output of this command is not storing in the array. array is

RE: Perl regular exp

2006-04-11 Thread Ankur Gupta
Sonika Sachdeva scribbled on Tuesday, April 11, 2006 4:27 PM: > Actually I am looking for AND and OR combinations..and the number of > words are not fixed. > ie @words is the variable and I need to have OR and AND combinations > of @words. to match in LINES How do I go

RE: Perl regular exp

2006-04-11 Thread Ankur Gupta
Sonika Sachdeva scribbled on Tuesday, April 11, 2006 3:39 PM: > Hi , Please state your problem statement. What are you trying to achieve with this program. add use strict; use warnings; at the top of your perl program and then try to run. > print $line if ($line

RE: Date difference.

2006-04-05 Thread Ankur Gupta
hridyesh pant scribbled on Wednesday, April 05, 2006 11:25 PM: > Hi, > i have two date string reading from the log file like below. > $date1="Mon Mar 27 02:45:15 2006"; > $date2="Wed Apr 5 23:20:46 2006"; > > $Number_of_Days = $date1-$date2; > i want to get number of d

Re: problem extracting data with WWW::Mechanize whe

2006-01-15 Thread Ankur Gupta
On 1/15/06, Ankur Gupta <[EMAIL PROTECTED]> wrote: > Hi, > > I have a very simple WWW::Mechanize perl program which does the following > task. > 1. Gets the login URL. > 2. Enters username and password. > 3. Get another URL. > 4. Fill some fields of date range and

problem extracting data with WWW::Mechanize whe

2006-01-15 Thread Ankur Gupta
Hi, I have a very simple WWW::Mechanize perl program which does the following task. 1. Gets the login URL. 2. Enters username and password. 3. Get another URL. 4. Fill some fields of date range and submit. 5. Parse the content and create a report. It used to work until the web designer changed th

LWP: How to make sure login was successful

2006-01-09 Thread Ankur Gupta
I am writing a LWP program. I need to login to 10 different sites and extract information out of them.. Each site has its own username/password. I am writing a common module which will do the job of logging in. I am doing all sorts of error catching such as whether internet is up or not, the url i

Re: getting shell environment varibale in perl after sourcing a file

2005-09-25 Thread Ankur Gupta
On 9/24/2005 6:10 PM Manish Sapariya wrote: Hi all, I have some SHELL environment file which I need to get the variable from and use it my perl script. As I understand, the ENV hash will be populated using the environment of the shell that I have executed the perl script from. Is there any way

Re: Looking for perl scripts to remove ^M

2005-09-23 Thread Ankur Gupta
On 9/23/2005 11:28 PM Dave Adams wrote: Sometimes I get perl scripts that were developed on windows and then brought over to UNIX and the scripts contain all the pesky metacharacters of ^M and excessive blank lines. Does anyone have a simple script to clean these files up or suggestions? If y

Re: Hash of Arrays

2005-09-20 Thread Ankur Gupta
On 9/20/2005 11:16 PM Christopher Spears wrote: I've been learning about data structures by reading the Programming Perl book. Here is a code snippet: while ($line = <>) { # If $line = "abcd: efgh: ijkl"; ($who, $rest) = split /:\s*/, $line, 2; # then $who = "abcd" and $rest = "efgh:

Re: hash question

2005-09-06 Thread Ankur Gupta
On 9/6/2005 4:50 PM Gergely Buday wrote: Hi there, do you have a clue why is this not working? The interpreter complains about a syntax error in line 7 near $myhash. Seems like you are confused with the brackets... #!/usr/bin/perl %myhash = { "alma" => "apple", "korte" => "pear" }; Shou

Re: Reg Closure in Perl

2005-08-25 Thread Ankur Gupta
On 8/25/2005 10:46 AM praba har wrote: Dear All, Kindly let me know what is closure and why we need it. People will explain you what it is once you go through the FAQs of this mailing list. http://learn.perl.org/beginners-faq [...] 2.2 - What is this list _not_ for? * SPAM

RE: "Join" Function

2005-08-08 Thread Ankur Gupta
Vineet Pande wrote: > hi, > In the following code which reads a file.txt (SEE ATTACHMENT) where I > am trying to understand how to put the DNA sequence in to a single > string... > > print "enter file with DNA sequence: "; > $seqfile = ; > chomp $seqfile; > unless ( op

RE: Grep uniqueness issue

2005-07-29 Thread Ankur Gupta
[EMAIL PROTECTED] wrote: > Hey Guys > > I am having an odd problem using grep to ensure an array only > contains distinct entries. > > I have a list similar to the following in a file (short example of a > much longer list) > > support01-FastEthernet1/0 > support01-R

RE: passing hash data from one subroutine to another using refs

2005-07-28 Thread Ankur Gupta
Brent Clark wrote: > Hi Hi, > Would someone please clear up / help me understand this. Sure. > I have a hash > > my %allTariffData = {}; I think you meant my %allTariffData = (); > and in my sub > > I have > my %tariffData = {}; Same here.. my %tariffData = ()

RE: question related to readdir function

2005-07-15 Thread Ankur Gupta
Li, Aiguo (NIH/NCI) wrote: > Dear all. > > I wrote a piece of code to read and open all files from a directory > to do something with it. > But I found that the variable assigned to @file_array split the file > names into pieces. For example ". . test.rpt" file will be

RE: sorting list of array

2005-07-13 Thread Ankur Gupta
Jeff 'japhy' Pinyan wrote: > On Jul 13, Beast said: > >> Jeff 'japhy' Pinyan wrote: >>> Is there any builtin function in perl to sort the above array based on uid, username or fulname? >>> >>> There is a built-in function to sort a list, yes. But the mechani

RE: sorting list of array

2005-07-13 Thread Ankur Gupta
Beast wrote: > I have an array: > > > my @employee = ( [29243, 'john', 'John doe'], > [24322, 'jane', 'Jane doe'], > [27282, 'james', 'James doe'] > ); > > > Is there any builtin function in perl to sort the above ar

RE: mail header split

2005-05-31 Thread Ankur Gupta
From: John W. Krahn [mailto:[EMAIL PROTECTED] > Ankur Gupta wrote: > > > > You can use splice to capture only the relevant fields. > > change it to this... > > > > my ($bookrefNumber) = (split(/-/,$pop3MailContent{'To'}))[0]; > > Y

RE: mail header split

2005-05-31 Thread Ankur Gupta
> I have an email To field that I want regex on > > The email is as so: > > [EMAIL PROTECTED] > > Im trying to get the number before the hyphen. > > Currently I have it as so > > my ($bookrefNumber, $discard) = split('-',$pop3MailContent{'To'}); You don't need to use $discard variable. You c

RE: on warning die

2005-05-20 Thread Ankur Gupta
> Hello beginners@perl.org, > > it is possible to setup somewhere, I want my script dies, if > warning occurs. BEGIN { $SIG{__WARN__} = sub{ print STDERR @_; exit 1}; } warn "I am going to die\n"; I hope you are looking for something like this. --Ankur -- To unsubscribe, e-mail:

RE: extracting columns

2005-05-17 Thread Ankur Gupta
From: Aditi Gupta [mailto:[EMAIL PROTECTED] > Hi everybody, > to extract data columnwise from a file, the following code > was written with the help of perl experts of this list. the > script is as follows: > > -- > -

RE: How would I simulate this in Perl?

2005-05-06 Thread Ankur Gupta
> I have the following find/grep line running just fine from a > telnet prompt on the server. I'm trying to include this line > into a web app using CFEXECUTE (ColdFusion) but can't get it > to work. I know that a compiled perl script would work since > I'm already using some previously written

RE: SFTP

2005-05-06 Thread Ankur Gupta
> From: Octavian Rasnita [mailto:[EMAIL PROTECTED] > > > > good luck with Net::SFTP under windoze. If you will have problems, > > just look to thread: mid:[EMAIL PROTECTED] > > > > > > Thank you. I have found some problems with Net::SFTP under > Windows, because it tells me that: > > Can't ma

problem with GD

2005-05-04 Thread Ankur Gupta
Hi, Today I installed gdlib, GD and GD::Graph. There were some problems with make test but make install went fine. So I installed them forcefully. Now when I run a sample file from the samples directory I am getting the following error. /usr/bin/perl sample63.pl Processing sample63 ld.so.1: /depo

RE: Installing module for different platforms

2005-05-04 Thread Ankur Gupta
> DynaLoader module is installed for linux platform but not for > solaris. I also want to install it for solaris platform. When > I try to install from solaris platform(through CPAN) then it > says DynaLoader is already installed. > I am trying to use GD::Graph module from Solaris platform but

Installing module for different platforms

2005-05-04 Thread Ankur Gupta
Hi, DynaLoader module is installed for linux platform but not for solaris. I also want to install it for solaris platform. When I try to install from solaris platform(through CPAN) then it says DynaLoader is already installed. I am trying to use GD::Graph module from Solaris platform but seems to

RE: Sort array by value length ?

2005-04-22 Thread Ankur Gupta
> Hello, Hi, > I have an array of names and would like to sort the array by > the length of the name but am having difficulty. > > Any suggestions ? if you want to sort in ascending order @sorted = sort { length($a) <=> length($b) } @unsorted; or if in descending order @sorted = sort { le

How to set system limit through perl

2005-04-21 Thread Ankur Gupta
Hi, I can set limit on coredumpsize, stacksize, etc. using the limit command. limit coredumpsize 2048 But how can I do the same thing from a perl script? I tried Shell::Source but I guess its only for inherting environment. TIA. --Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For a

RE: pointers - references ??

2005-04-11 Thread Ankur Gupta
> If anyone has the time and / or the will to help me understand. > > I know how to create / use references for perl. But would why would you > use it. > And I think more importantly when. > > Im busy reading / learning the Oreilly Advanced Perl Programming book. > But for the likes of me I cant

Which script called require?

2005-04-06 Thread Ankur Gupta
Hi, I have many perl files which have the following require statement. require "require.file"; I just want to know who called require.file in the require.file script. Right now I am setting an environmental variable in each of the scripts and checking its value in the require.file

RE: My own die message

2005-03-30 Thread Ankur Gupta
> -Original Message- > From: Offer Kaye [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 31, 2005 2:21 AM > To: Ankur Gupta; Perl Beginners > Subject: Re: My own die message > > On Thu, 31 Mar 2005 00:18:14 +0530, Ankur Gupta wrote: > > Hi, > &

RE: My own die message

2005-03-30 Thread Ankur Gupta
No I do not wanna die so fast.. I want to do some processing based on the died message. -- Ankur -Original Message- From: Todd de Gruyl [mailto:[EMAIL PROTECTED] Sent: Thursday, March 31, 2005 12:24 AM To: Ankur Gupta Cc: beginners@perl.org Subject: Re: My own die message On 03/30/2005

My own die message

2005-03-30 Thread Ankur Gupta
Hi, I have the following code : eval{ require "file" or die "unable to find file"; }; print "$@"; But it always prints "Can't locate file in @INC. blah blah " I want $@ to contain "unable to find file". What am I doing wrong or it is not possible to overr

Re: regexp help

2005-03-11 Thread Ankur Gupta
radhika wrote: Hi, I need to parse this string: 2005-03-11 13:49:41.19 to just get the hour and minute. my program has: if( $string = /([\d]+)-([\d]+)-([\d]+)\s([\d\d):(\d\d):(\w+)/ ) I guess it should have been =~ instead of = { print("Hour:Minute = $4:$5\n"); } if ( $string =~ /.*\s+(\d\d):(\d\

Re: filehandle into a hash?

2005-03-10 Thread Ankur Gupta
Gavin Henry wrote: Dear all, I have the following: #!/usr/bin/perl use strict; use warnings; use Mail::Sendmail; my $from = '"Test e-mails" <[EMAIL PROTECTED]>'; my $subject = 'Testing for survey e-mail'; open LIST, " open MESSAGE, " my $message = ; foreach () { my %mails = ( To => "$_",

Re: tricky hash

2005-03-08 Thread Ankur Gupta
Ing. Branislav Gerzo wrote: Hello beginners@perl.org, anyone could me help with: use strict; use warnings; my %kw = (); my $kw = \%kw; for my $cat (split(/\//, 'something/other/foo/bar')) { $kw->{cnt}++; $kw->{cat${kw->{cnt}}} = $cat } Change this line to for my $cat (split(/\//, 'something/oth

Re: output from system call

2005-03-08 Thread Ankur Gupta
[EMAIL PROTECTED] wrote: Hi, Is there a way to store the output of a system call on unix? eg. system("date"); use backticks... $date = `date`; Don't forget to chomp the $date variable as I guess you just want the date, not the newline character with it... chomp($date); -- To unsubscribe, e-mail:

Re: Verify that a directory exists.

2005-02-28 Thread Ankur Gupta
So its better to use if(-d "$dir/test") { I see. Well I would not call this good practice. You simply have to quote the string literal. Or construct it via concatenation: if(-d ($dir . "/test")) { I would use the first form. Anyway my point was that you should not quote a simple vari

Re: Verify that a directory exists.

2005-02-28 Thread Ankur Gupta
Also, if you are hard coding the path then you need to quote them if (-d "/home/user"){ if you are using a variable then if (-d $dir){ would work. But its always a good practice to quote filenames/directories , even if they are variables. What? You mean like: if (-d "$dir") { ... Why

Re: Verify that a directory exists.

2005-02-28 Thread Ankur Gupta
Carlos Mantero wrote: El lun, 28-02-2005 a las 14:49 +0300, Vladimir D Belousov escribió: 1) if (-d $DIR_NAME) { directory exists }; 2) if((lstat($DIR_NAME))[1] & 004) { directory exists and it is the real directory (not the symbolic link) }else{ ... No such di

Re: capture output in perl

2005-02-28 Thread Ankur Gupta
[EMAIL PROTECTED] wrote: hi, I would like to capture all the output in my perl program during execution. I have code that basically opens and closes an output file multiple times just to write the output. Because I have system calls between lines of code, I have to close the file in order to captur

Re: Load an hash from a text file

2005-02-28 Thread Ankur Gupta
Web Solving wrote: i rebuilt the scipt without using any hash in this way: open(INFILE,"lista.txt") || die "Cant read lista.txt. Reason: $!"; while( ){ > Where is the closing braces for this while loop my ($search, $replace) = split /|/; open(READIT,"testo.txt") || die "Cant read file.t

Re: Understanding split in a while loop

2005-02-28 Thread Ankur Gupta
I am not sure why? It misses the odd ones. while () { my @passwds = split /:/, ; You are reading the file twice in each while loop. Whenever you access , it returns a line and moves to the next line of the file. So in "while () {" it returns one line of the passwd file . As you are reading the l

Re: printing output of ping command

2005-02-23 Thread Ankur Gupta
TapasranjanMohapatra wrote: Hi All, I have a script as follows my $host = shift; my $count = shift; my $result = `ping -c $count $host`; if($result =~ m/$count packets transmitted, $count packets received/) { $success = 1; } print "$result\n"; --

Re: Never done perl before

2005-02-18 Thread Ankur Gupta
Lucio Crusca wrote: "Perl newbie" is way too much when referred to me. I've never even thought to try to understand a single character of a perl program. Now I need to. But, still, I don't want. I live more than well with my knowledge of other languages. However I'm facing a wonderful Courier ESMTP

Re: Idiomatic Perl for GPA Calculation

2005-02-16 Thread Ankur Gupta
#!/usr/bin/perl # This is the GPA calculation routine for the # Eduadmin system again. # $ifile = 'gpa.dat'; open (INF, "<$ifile") || die "Can't open file $ifile:$!\n"; $cp_total = 0; $id = 0; $temp = 0; LINE: while () { ($id, $grade, $cp) = split; if (

Re: How to add leading zeros?

2005-02-16 Thread Ankur Gupta
Bastian Angerstein wrote: Hello, I have some Numbers 1 2 3 40 51 and I want them to be in the format 001 002 003 ... 040 ... 051 ... What is the fastest way to do this?? use sprintf $num = 1; $zero_num = sprintf("%03d", $num); #$zero_num will now have 001 perldoc -f sprintf -- To unsubscribe

Re: Request for regex: Strip last dash in a record

2005-02-15 Thread Ankur Gupta
[EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Hi All, The code below does what I want to do, but it takes 3 lines and a temporary array (yuck). I can't come up with a one line regex substitution. Anyone got one? my $tmp = reverse split //, $_; $tmp =~ s/-//; $_ = rever

Re: getting +*-/ from $operator= in print

2005-02-15 Thread Ankur Gupta
print "First value: "; chomp ($value1=; print "Second Value: "; chomp ($value2=; print "Operator: "; chomp ($value3=; print ($value1 $value3 $value2, "\n"); But that was malfaunctioning. Is there a way to put the STDIN for the operator directly in the print line or do I always have to keep it that

Re: flush function

2005-01-31 Thread Ankur Gupta
Urs Wagner wrote: Hello I have a problem on WinXP. In perl I want to read the tail of a file. The file is written with another windows program. If I am using a sleep(5) before of the read command I get the new tail content. It seems the program has longer to write it or it is buffered. Is there

Re: how to use hash as parameter

2005-01-31 Thread Ankur Gupta
#!/usr/bin/perl my %hs; $hs{"one"} = 1; $hs{"two"} = 2; sub pr { my $ref = $_; foreach $key (sort keys %$ref) { print "$key = ${$ref{$key}}"; } } pr(\%hs); This should work.. -- Ankur Hou Feng.Leo wrote: > Dear all, > I want to pass a hash to a function which prints out hash's content. > My

Re: How to find the Index of an element in array?

2005-01-27 Thread Ankur Gupta
I have another solution using grep but its kinda weird @array = (..); #your array here $i=1; eval{ grep { (/$element/o && die ) or ++$i } @array; }; print "index of $element = $i\n"; #prints the index of $element.. If $i > scalar(@array), element not found. -- Ankur Manav Math

Re: Bareword "INPUT" not allowed while "strict subs"

2005-01-27 Thread Ankur Gupta
I think you can't pass filehandles directly to a sub. You need to use typeglob. Just add this after opening the file. my $file = *INPUT; $message = &processTextMails($file); sub processTextMails { my $file = shift; while(<$file>) { $returnMessage=$returnMessage.$_; } close($file);

Re: hashes of arrays?

2005-01-25 Thread Ankur Gupta
It is possible to store an array in a hash by using references #foreach $destination (@dest_users) { # NO NEED FOR THIS #print "==>$destination\n"; push( @{$aliases{$alias}}, @dest_users ); foreach $key ( keys %aliases ){ print "$key: @{$aliases{$key}}\n

Slow SFTP rate through perl script.

2004-07-15 Thread Ankur Gupta
Hi, I have a script which downloads a file from a sftp server. But it takes almost 2-3 hours to download a file of 40mb.. while I am able to download the same file though SSH Client in 15-20 minutes. Any clues why it is happening so.. Thanks, Ankur