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
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
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/
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/
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
/;
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/
#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/
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>
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
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>
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>
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->
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 (<>) {
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>
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
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
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
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
=> 2006,
'orderdaterangeinputstore:endm' => '01',
'orderdaterangeinputstore:end' => 15,
'orderdaterangeinputstore:sta' => 2006,
'orderdaterangeinputstore:star' => '01',
'orderdaterangeinputstore:st' =>
## 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
-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>
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
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: [
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
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''.
[..
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
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
# 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:
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
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'
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
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
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>
> 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
--
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
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
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.
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
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
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
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>
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
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>
lue in the require.file. Bad implementation.
TIA.
--Ankur
> -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,
> &
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
e". What am I doing wrong or it is
not possible to override [EMAIL PROTECTED]
Thanks,
Ankur
(\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>
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 => "$_",
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
[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:
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
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
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
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
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
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
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";
--
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
%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
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
[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
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
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>
#!/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
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
}
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
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>
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
69 matches
Mail list logo