tough combination problem

2008-12-22 Thread ankur
I have to parse a test file which can have multiple variable type which is of following type VAR1 = 1..10 VAR2 = 23..90 VAR3 = A,B,C So any no of variable and they can have any possible no of ranges so i have to generate all possible test cases out of this like one c

extracting href parts

2008-10-04 Thread Ankur
Hi, I am trying to develop an app for my website for which i need to get the name of the Shows from http://tv.yahoo.com/listings. If you go over the code you can see that some of the rows have the shows with hyperlink and others without. How do i get the Hyperlink and the show's name from the hyp

Re: Downloadable and Online Perl Documentation

2007-12-18 Thread Ankur Gupta
the best. You can also download it for off line viewing(has both html and pdf formats). http://perldoc.perl.org/perldoc.tar.gz -- Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: testing for a file type

2007-12-18 Thread Ankur Gupta
You can simply do this. foreach my $file (@ARGV) { if ( $file !~ /\.mdb$/ ) { print "$file is not a mdb file. Ignoring...\n"; next; } # code to pocess .mdb file ... ... } -- Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Use of uninitialized value in pattern match (m//)

2007-12-05 Thread Ankur Jain
You're right, I am passing a numeric value to the function and encountering the error. I used the function provided by you and it's working fine. Thanks Ankur Jain On Dec 4, 2007 8:27 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > Ankur wrote: > > > > I am running t

Use of uninitialized value in pattern match (m//)

2007-12-04 Thread Ankur
/; return $n; } print CommaFormatted(1); / **/ Please help. Thanks Ankur Jain -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

"premature end of header" script error

2007-11-29 Thread Ankur
#x27;t find any related reference for this error description on the web, though there are a lot of other references. Any idea? Ankur Jain -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

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] <http://learn.perl.org/> <http://learn.perl.org/first-response>

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
die $!; pop(@array); pop(@array); untie @array; This fixes the problem but is there a better way to get around this? perl version is 5.8.0 and latest version of Tie::File (0.97). Thanks, --Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

RE: deleting an element from an array

2006-04-22 Thread Ankur Gupta
ment is only "half" deleted I do not think there is such thing as half deleted. Its either deleted or not deleted. --Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Class::DBI is slow?

2006-04-20 Thread Ankur Gupta
t::Personal; use base 'Test::DBI'; Test::Personal->table('table'); Test::Personal->columns(Primary => qw/user start_time/); Test::Personal->columns(Others => qw/field/); 1; _Test::DBI___ package Test::DBI; use base 'Class::DBI'; Test::DBI->

RE: golf

2006-04-19 Thread Ankur Gupta
lrun and learned something new. It's > not quite what I set out to learn, but learning new things is good > anyway. > > I was actually looking for something doable in a file with a shebang > line and the executable bit set. { local $/ = undef; while (<>) {

RE: array help

2006-04-13 Thread Ankur Gupta
Enough work for today. Have a cup of coffee. --Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

RE: Perl regular exp

2006-04-11 Thread Ankur Gupta
27;print $_ if ' . $string; # $string will have 'print $_ if /a/ && /b/ && /c/ && /d/' while (<>){ eval $string; } But make sure that @words and $condition are not input by user as then it creates a security hole. Or if they are input by

RE: Perl regular exp

2006-04-11 Thread Ankur Gupta
esn't work... What does $pattern1, $pattern and $pattern store. And please, BOTTOM POST. And atleast read perldoc perlintro.. --Ankur perl -e '[EMAIL PROTECTED]/(&^\+_' Warning: Use of comic-book profanity not allowed. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

RE: Date difference.

2006-04-05 Thread Ankur Gupta
s = $date1-$date2; > i want to get number of days between these two dates. > Can someone help me. Sure. What did you try till now? Anyway, perldoc -q 'How can I compare two dates and find the difference?' -Ankur $SIG{ALRM} = { snooze; sleep 300; } -- To unsubscrib

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
=> 2006, 'orderdaterangeinputstore:endm' => '01', 'orderdaterangeinputstore:end' => 15, 'orderdaterangeinputstore:sta' => 2006, 'orderdaterangeinputstore:star' => '01', 'orderdaterangeinputstore:st' =>

LWP: How to make sure login was successful

2006-01-09 Thread Ankur Gupta
## Get a response object $response = $ua->request($req); ## If the response is good then get its content else print why and what failed confess $response->status_line unless $response->is_success; print $response->status_line; #print $response->content

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

2005-09-25 Thread Ankur Gupta
-0.01/Source.pm HTH... -- Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: Looking for perl scripts to remove ^M

2005-09-23 Thread Ankur Gupta
you are using vi/vim as your editor then this is the good way to deal with it.. :%s/.$// will remove the last *pesky* character(^M) from all lines But as Chris said, did you try anything so far... -- Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail

Re: Hash of Arrays

2005-09-20 Thread Ankur Gupta
plies a LIMIT one larger than the number of variables in the list, to avoid unnecessary work. For the list above LIMIT would have been 4 by default. In time critical applications it behooves you not to split into more fields than you really need. [...] -- Ankur -- To unsubscribe, e-mail: [

Re: hash question

2005-09-06 Thread Ankur Gupta
quot;, "korte" => "pear" }; Should be %myhash = ( "alma" => "apple", "korte" => "pear" ); foreach $ky (keys (%myhash)) No need for any brackets around the hash foreach $ky (keys %myhash) { print $ky, ":" , $myhash

Re: Reg Closure in Perl

2005-08-25 Thread Ankur Gupta
ject lines like ``Help!'', and ``This isn't working!'' may be skipped by many people, and you may not get all the great help you want. Try to make your subject lines meaningful. For example, ``sprintf() trouble'', or ``Confused about formats''. [..

RE: "Join" Function

2005-08-08 Thread Ankur Gupta
x27;, @dna); > print "$dna\n"; > > THE OUTPUT IS EXACTLY THE SAME AS IN file.txt.Why don't we get > the string joined...of course i agree i must clean whitespace...bu > then what is expected out of join( '', ). WHAT '' means? '' mea

RE: Grep uniqueness issue

2005-07-29 Thread Ankur Gupta
ne). > > Now I am using word boudnary anchors (\b) in the grep so I am > confused as to why this is not working. > > Does anyone have any ideas as to why this is occuring and how I can > prevent it? HTH... --Ankur Why did kamikaze pilots wear helmets anyways? -- To unsu

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

2005-07-28 Thread Ankur Gupta
# OK return %hash1, %hash2; # May not be OK Please read the following perldocs: perldoc perldsc perldoc perlref perldoc perllol perldoc perldata It will make the things a lot clearer to you. --Ankur I don't suffer from insanity, I enjoy every minute of it! -- To unsubscribe, e-mail:

RE: question related to readdir function

2005-07-15 Thread Ankur Gupta
ir (DIR, $dirtoget) or die 'Can not open DIR'; > > my @file_array; > > @file_array =readdir(DIR); > closedir(DIR); > > foreach my $filename (@file_array) { ## You don't want to open '.' and '..' directories so ignore them next if ( $filena

RE: sorting list of array

2005-07-13 Thread Ankur Gupta
lity use sort '_quicksort'; # use a quicksort algorithm use sort '_mergesort'; # use a mergesort algorithm use sort 'defaults'; # revert to default behavior no sort 'stable'; # stability not important use sort '_qsort'

RE: sorting list of array

2005-07-13 Thread Ankur Gupta
ting by column 0 24322 jane Jane doe 27282 james James doe 29243 john John doe $-> test-perl.pl 1 Sorting by column 1 27282 james James doe 24322 jane Jane doe 29243 john John doe $-> test-perl.pl 2 Sorting by column 2 27282 james James doe 24322 jane Jane doe 29243 john John doe There can b

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
ound then $1 would be undef. my $bookrefNumber = $1; And if you want, go through perlre/perlretut. It has lots of information on regular expressions. --Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

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 --

RE: extracting columns

2005-05-17 Thread Ankur Gupta
tatements in various parts of the program where you think the problem can be. Something like print "I am here". print "this is iteration number $x, $j". Do not simply die but give some message. Atleast die $! should be enough. I know you did not ask for an intro on "How to de

RE: How would I simulate this in Perl?

2005-05-06 Thread Ankur Gupta
word =~ s#{}#$name#g } if ($ok) { my $old = select(STDOUT); $| = 1; print "@_"; select($old); return 0 unless =~ /^y/; } chdir $cwd; #sigh system @_; chdir $File::Find::dir; return !$?; } --Ankur If the automobile had followed the

RE: SFTP

2005-05-06 Thread Ankur Gupta
dows, because it tells me that: > > Can't map service name 'ssh' to port number at > D:/usr/site/lib/Net/SFTP.pm line 36 > Make an entry in the \system32\drivers\etc\services file ssh 22/tcp Hope this should work. --Ankur Ability is nothing without opportunity.

problem with GD

2005-05-04 Thread Ankur Gupta
present. I printed the @LIBS array and following is the output. -lgd, -lpng, -lz. I I did not have the libiconv library but still the same problem. Can someone please help me.. Thanks a lot, --Ankur The opposite of a correct statement is a false statement. But the opposite of a profound truth

RE: Installing module for different platforms

2005-05-04 Thread Ankur Gupta
is platform but > seems to give an error as it could not find DynaLoader in > sun4-solaris directory. > > FYI.. I am not root and accessing the bin/perl from NFS. Please ignore my previous mail. It is already installed. Damn! --Ankur Love may not make the world go round, but I m

Installing module for different platforms

2005-05-04 Thread Ankur Gupta
give an error as it could not find DynaLoader in sun4-solaris directory. FYI.. I am not root and accessing the bin/perl from NFS. --Ankur Those who can, do. Those who cannot, teach. Those who cannot teach, HACK! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail

RE: Sort array by value length ?

2005-04-22 Thread Ankur Gupta
order @sorted = sort { length($b) <=> length($a) } @unsorted; perldoc -f sort will give you many useful examples. --Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

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

RE: pointers - references ??

2005-04-11 Thread Ankur Gupta
on how to reference and dereference hashes. --Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Which script called require?

2005-04-06 Thread Ankur Gupta
lue in the require.file. Bad implementation. TIA. --Ankur

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
e". What am I doing wrong or it is not possible to override [EMAIL PROTECTED] Thanks, Ankur

Re: regexp help

2005-03-11 Thread Ankur Gupta
(\d\d):(\d\d):.*$/ ){ print("Hour:Minute = $1:$2\n"); } This should work. Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

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
you want to print your output to the screen as well as to the log file. Use open(STDOUT, "| tee /tmp/tmp.log STDOUT"); So whatever you print would go to the screen as well as to the log file. (--> Taken from Perl Cookbook) Same you can do with the STDERR to capture your warnings and errors

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
%student){ print "GPA for $id : $gpa{$id}\n"; } BTW, I got these values GPA for 216 : 1.98 GPA for 386 : 1.40 Although it is correct for 386.. it does not matches for id 216. Are you sure gpa for 216 is correct. Hope you got the idea of how you can use hashes to make the progra

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
a command in perl to flush a file? Thanks Urs to flush the contents, set at the top of your perl program. $| = 1; HTH -- Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

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 w

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 f

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

2005-01-27 Thread Ankur Gupta
} close($file); return $returnMessage; } I hope this works. -- Ankur Anish Kumar K. wrote: Hi I open a file and pass the file handle to the sub routine. I have used "Use Strict" I am getting the error in the filehandle. Why is this caused.. Is it because I need to pass any other

Re: hashes of arrays?

2005-01-25 Thread Ankur Gupta
y: @{$aliases{$key}}\n"; } HTH -- Ankur -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

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