RE: reference trouble

2005-08-01 Thread Tim Johnson

It looks like you've made a lot of headway on refs, don't sell yourself
short.  It just looks like maybe you needed to back away from the
problem and see that the reason why it wasn't working was that you were
trying to stick a square peg in a round hole, so to speak.  It's easy to
do when you're dealing with that level of abstraction, which is where
references trip a lot of people up.

Also, your question could have been a little clearer.  Without giving
away any proprietary information, some background as to what you were
trying to do would have been nice.  It looks like what you really wanted
was a way to store by a named index because then you would have a
pre-sorted list of indexes.  Whenever you find yourself tempted to do
something like this, it might be worth thinking about whether a hash
might suit you better.  Of course, your email was kind of cryptic, so
it's hard to tell.





-Original Message-
From: Tom Allison [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 01, 2005 7:03 PM
To: Tim Johnson
Cc: beginners perl
Subject: Re: reference trouble

[Tim Johnson] 

I've changed it out to a hash and create a seperate array of keys that 
are sorted:

my @keys = sort { $b <=> $a } keys %hash

And this works just fine.

But I still have some more learning to do on refs...

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: reference trouble

2005-08-01 Thread Tim Johnson


I think you need to explain a little better what you're trying to do
here, and what you EXPECT to happen.  For one thing, why are you using
$u as your array index?  Are you sure you don't want a hash?



-Original Message-
From: Tom Allison [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 01, 2005 5:07 PM
To: beginners perl
Subject: reference trouble

I'm trying to convert a hash of hashes to an array of hashes...

$hash isa hash reference...

my $array;
while ( my ($k, $v) = each %$hash ) {
my $u = str2time($k);  #convert to unix timestamp
$$array[$u] = $v;
}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: How to install modules without ppm3 ?

2005-08-01 Thread Tim Johnson

I'm assuming you're using Windows?


-Original Message-
From: Clement [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 01, 2005 1:30 AM
To: beginners@perl.org
Subject: How to install modules without ppm3 ?

Hello ,

I am trying to install the module Image::MagicK & GD,
however, I can't get it with ppm3, so I goto cpan.perl.org
I can find it, but I know to how to install the .tar.gz file.
Anybody help ?

Thanks!
Clement

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Perl framework for windows-prob in makefile

2005-07-31 Thread Tim Johnson

I know this doesn't answer your question, but I have to ask.  If you're
on Windows, then why aren't you just installing ActivePerl from
ActiveState?  You're guaranteed to save yourself a lot of headache.
http://www.activestate.com.



-Original Message-
From: Anthony.leung [mailto:[EMAIL PROTECTED] 
Sent: Sunday, July 31, 2005 5:00 AM
To: Dhanashri Bhate
Cc: Perl-Beginners (E-mail); Perl-Tips (E-mail)
Subject: Re: Perl framework for windows-prob in makefile

[Tim Johnson] 

On Sat, 30 Jul 2005 11:06:32 +0530, Dhanashri Bhate wrote:
 Hi!
 I'm trying to get Perl framework installed on windows.
 
[Tim Johnson] 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Want code to display date in different timezone

2005-07-29 Thread Tim Johnson

The Time::Local module also works well.


-Original Message-
From: Tom Allison [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 29, 2005 4:03 PM
To: Anil Kumar, Malyala
Cc: beginners@perl.org
Subject: Re: Want code to display date in different timezone

[Tim Johnson] 

Another option is Date::Parse.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: MIME::Lite message text

2005-07-25 Thread Tim Johnson

How hard would it be to create a temporary variable where you store the
contents of the file?



my $data;
open(INFILE,"){
   $data .= $_;
}

# OR ###

while(my $ref = $sth->fetchrow_hashref()){
   $data .= $ref->{COLUMN};
}



Then you can use $data in your initialization statement.



-Original Message-
From: Charles Farinella [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 25, 2005 2:10 PM
To: Perl Beginners
Subject: RE: MIME::Lite message text

On Mon, 2005-07-25 at 16:46, Tim Johnson wrote:
> Looking at the documentation, it looks like what you want is the Data
> field when you initialize your message.
> 
> Data => "whatever";

That's true, but what I need is either:
Data => " "< the results of about 6 $sth->fetchrow_arrays"

I don't know how to do either, unfortunately.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: MIME::Lite message text

2005-07-25 Thread Tim Johnson
Looking at the documentation, it looks like what you want is the Data
field when you initialize your message.

Data => "whatever";


-Original Message-
From: Charles Farinella [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 25, 2005 1:50 PM
To: Perl Beginners
Subject: MIME::Lite message text

I'm trying to send a multipart mail message using MIME::Lite.

[Tim Johnson] 

I can do it by making 2 attachments, one a text file, the other the
tarball, but what I really want to do is print the text inline, not as
an attachment.  

[Tim Johnson] 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Pass a value to Perl script

2005-07-12 Thread Tim Johnson
If it is a console mode program then you can still use backticks in Windows.  
The only thing to watch out for is when a program prints to STDERR, which a few 
of the standard Windows command-line utilities will do in some circumstances.  
That, I believe, won't be caught by backticks (someone correct me if I'm wrong, 
I can't test it here and it's been a while since I used backticks).
 


From: Chris Devers [mailto:[EMAIL PROTECTED]
Sent: Tue 7/12/2005 10:12 PM
To: Dhanashri Bhate
Cc: Perl Beginners List; Perl
Subject: RE: Pass a value to Perl script






If nothing else, the platform this runs on may be a factor -- the
details of getting output from another program may differ on Windows,
for example...





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: threads

2005-07-06 Thread Tim Johnson

Yes.

-Original Message-
From: Patricio Bruna V [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 06, 2005 12:01 PM
To: Perl
Subject: threads

does perl support threads?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: modifying a file

2005-07-06 Thread Tim Johnson

There are some ways to do this, but they don't apply to all instances.
Really, you're usually better off just writing your changes to a temp
file and then replacing your original file.  Most methods that seem to
accomplish what you are asking for really just do this in the background
anyway.


-Original Message-
From: Eliyah Kilada [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 05, 2005 10:42 PM
To: beginners@perl.org
Subject: modifying a file

[Tim Johnson] 

modify FIN?!
i.e., I need to make modifications in the same file I read from.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: ???UNSURE??? RE: need help with regular expression

2005-06-14 Thread Tim Johnson



When you say "a series ... 3 to 5 characters in length", do you mean

LLL,III,VVV,FFF,YYY

Or

LIV,FLY,YYL,FFI

Because you could try something like

/[KRH][LIVFY]{3,5}[KRH]/

(not tested), but something like.




-Original Message-
From: Praedor Atrebates [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 14, 2005 4:30 PM
To: Wagner, David --- Senior Programmer Analyst --- WGO; Perl Beginner
Subject: Re: ???UNSURE??? RE: need help with regular expression

[Tim Johnson] 

Originally I had thought to assign L, I, V, F, Y, and A to another
variable, 
called $hydrophobe or some such and simply see about looking for a
series of 
hydrophobes between K, R, or Hs between 3 to 5 characters in length but
could 

[Tim Johnson] 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: GetOpt::Long

2005-04-20 Thread Tim Johnson


How about something like this?  It doesn't make it like GetOpt::Long,
but it does handle what you want.  Or you could just require that people
pass an array to your subroutine and save yourself a little work.  If
there is only one recipient, then it's a one-element array.

#

my $recipients = '[EMAIL PROTECTED]';
notify_email('[EMAIL PROTECTED]',$recipients,"test","this is my
body");
#my @recipients = qw([EMAIL PROTECTED] [EMAIL PROTECTED]
[EMAIL PROTECTED]);
#notify_email('[EMAIL PROTECTED]',[EMAIL PROTECTED],"test","this is the
body");

sub notify_email{
   my ($sender,$rcpt,$subj,$body) = @_;
   my $recipient;
   if(ref($rcpt)){
   if(ref($rcpt) eq 'ARRAY'){
   $recipient = join(',',@{$rcpt});
   }elsif(ref($rcpt) eq 'SCALAR'){
   $recipient = ${$rcpt};
   }else{
   die "Invalid recipient parameter!\n";
   }
   }else{
   $recipient = $rcpt;
   }
   print $recipient."\n";
}

#

-Original Message-
From: Olivier, Wim W [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 20, 2005 12:53 AM
To: Perl Beginners (E-mail)
Subject: GetOpt::Long

Hi all,

Is it possible to use GetOpt::Long (or something similar) in a
subroutine
using @_ instead of in the standard way (using @ARGV)?
I want to have the following scenario, but use GetOpt in a subrouting
within
the main script and pass options (and values) to the subroutine.
The values ($recipient, $subject, $body) must be configurable and they
must
be able to take multiple values, i.e. multiple recipients for a message.


# Notify recipients via SMTP (email)
sub notify_email {
  $ENV{"NTsendmail"}  = $smtp;
  $sender = "[EMAIL PROTECTED]";
  $recipient  = "[EMAIL PROTECTED]";
  $subject= "ALERT";
  $body   = join " ", @_;
  $mail   = new NTsendmail;
  $mail->send($sender, $recipient, $subject, $body);
}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: regex for l33t speak

2005-03-23 Thread Tim Johnson

First off, "perldoc perlre" is a good place to start.

What do you have so far?

Does something like /\b1337\b/ work?  Or am I taking you too literally?

-Original Message-
From: Andrew Gaffney [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 23, 2005 5:52 PM
To: beginners@perl.org
Subject: regex for l33t speak

I'm trying to come up with a regex for my IRC bot that detects 1337 (in
order to 
kick them from the channel). I can't seem to come up with one that will
have few 
false positives but also work most of the time. Has anyone done
something like 
this before? Does anyone have any suggestions?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Reference name

2005-03-14 Thread Tim Johnson

Did you try enumerating the keys of %hash?

foreach my $outerKey(sort keys %hash){
   print "$outerKey\n";
   foreach my $innerKey(sort keys %{$hash{$outerKey}}){
  print "\t$innerKey\n";
   }
}






-Original Message-
From: Peter Rabbitson [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 14, 2005 5:21 PM
To: beginners@perl.org
Subject: Reference name

[Tim Johnson] 

my %hash = ( 
abcd => {
a1 => 1,
a2 => 2,
a3 => 3
}
);


How can I access the name (abcd) of the passed reference inside of the 
subroutine (not just the data a1 a2 etc but the actual key name)?
Currently 
what I am doing is passing 'abcd' as a second value to the subroutine,
but there 
got to be another way...? 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Execute application with a space in it's path

2005-03-09 Thread Tim Johnson

Chances are the correct 8.3 filename you're looking for is Acroba~2, but
why are you using the old 8.3 filenames?

If you're just worried about spaces, try putting quotes in the command
you're sending to the system, like this:

system("\"C:\\Program Files\\Adobe\\Acrobat 7.0\\Reader\\AcroRd32.exe\"
C:\\PDFs\\test.pdf");



-Original Message-
From: Daniel Kasak [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 09, 2005 3:32 PM
To: beginners@perl.org
Subject: Execute application with a space in it's path

[Tim Johnson] 

I can get to the 'Adobe' folder with the commands ( from the command 
prompt ):

c:
cd c:\Progra~1\Adobe

However I can't get into the 'Acrobat 7.0' folder in the same way, ie:

c:
cd c:\Progra~1\Adobe\Acroba~1

[Tim Johnson] 

My code was going to be:

system("C:\\Progra~1\\Adobe\\Acroba~1\\Reader\\AcroRd32 
C:\\PDFs\\test.pdf");

[Tim Johnson] 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: call a perl script within another perl script

2005-03-03 Thread Tim Johnson

I guess it partly depends on what you are trying to accomplish.  Why are
you calling a second script?




-Original Message-
From: Nishi Prafull [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 03, 2005 3:47 PM
To: beginners@perl.org
Subject: call a perl script within another perl script

Hi:
I would like to call a perl script(B.pl) within another perl
script(A.pl).
Should I use the following approach or something else?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Detect platform

2005-02-16 Thread Tim Johnson

Check out the $^O variable.

-Original Message-
From: Daniel Kasak [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 16, 2005 3:00 PM
To: beginners@perl.org
Subject: Detect platform

How do I detect what platform I'm running from inside a Perl script?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Is there a regexp that will match two or more expressions???

2005-02-03 Thread Tim Johnson

Oh, ok.  So you mean like...

if($_ =~ /\bJan\b.*\bDec\b/){
   print $_;
}

?


-Original Message-
From: Harold Castro [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 03, 2005 5:02 PM
To: Tim Johnson; beginners@perl.org
Subject: RE: Is there a regexp that will match two or more
expressions???


--- Tim Johnson <[EMAIL PROTECTED]> wrote:

> 
> 
> You mean like this?  I'm not 100% sure what you're
> asking.
I guess not. For example,

[Tim Johnson] 

I just wanted to tell my program to look for those
lines that contains both Jan and 2005 regardless of
their positions. I've tried matching /(Jan & Dec)/ but
it didn't worked. Any more idea?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Is there a regexp that will match two or more expressions???

2005-02-03 Thread Tim Johnson


You mean like this?  I'm not 100% sure what you're asking.

##

use strict;
use warnings;

open(INFILE,"){
   if($_ =~ /Jan 12/){
push @LinesIWantToKeep,$_;
my $line = ;
push @LinesIWantToKeep,$line;   
   }else{
;
   }
}

print @LinesIWantToKeep;

###


-Original Message-
From: Harold Castro [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 03, 2005 3:55 PM
To: beginners@perl.org
Subject: Is there a regexp that will match two or more expressions???

Hi,

I'm looking for a regexp that will match two
expressions. Each line of the file I'm reading
contains different months and years. I'm only after
those lines with particular year and month. All those
lines with january and 2005 for example. Any idea?
Thanks!
here's a portion of the file.

Wed Jan 12 03:50:18 PHT 2005Wed Jan 12 04:00:17
PHT 20050.17 hours  2693
Sun Jan  9 10:00:10 PHT 2005Sun Jan  9 14:00:11
PHT 20054.00 hours  2636
Fri Jan  7 09:40:14 PHT 2005Fri Jan  7 09:50:14
PHT 20050.17 hours  2576
Sat Jan 31 19:18:53 PHT 2004Tue Feb  3 10:24:54
PHT 20042.63 days   106689
Sat Jan 31 13:25:15 PHT 2004Sat Jan 31 13:52:51
PHT 20040.46 hours  106678
Sat Jan 31 10:46:09 PHT 2004Sat Jan 31 12:48:11
PHT 20042.03 hours  106671




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Write stdout to a file as well as stdout

2005-01-11 Thread Tim Johnson

One solution would be to use a custom subroutine instead of print()ing
directly.  If you need something more robust, there are modules out
there that can do the heavy lifting for you.


#

use strict;
use warnings;
open(OUTFILE,">script.log") || die "Couldn't write to script.log!\n";

PrintOut("This goes to a file as well as the screen.\n");

sub PrintOut{
   print @_;
   print OUTFILE @_;
}

#





-Original Message-
From: Larry Guest [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 11, 2005 3:40 PM
To: 'Perl Beginners Mailing List'
Subject: Write stdout to a file as well as stdout

I have a script that does all kinds stuff.
When its running it outputs all kinds of useful information to the
screen and exits.

What I want to do is have this also sent to a file.

[Tim Johnson] 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: functions that returns two arrays

2005-01-03 Thread Tim Johnson

I think you're looking at this the wrong way.  What you want is to fill
two arrays with data from a function.  This does not necessarily mean
that you want the function to return two arrays (it can't actually be
done, since the function will flatten them both out into one list when
it returns them).  The best solution is probably to pass a reference to
the arrays you want filled.

I think this will do what you want:

##

#DECLARE THE ARRAYS
my (@array1,@array2);

#POPULATE THE ARRAYS
func([EMAIL PROTECTED],[EMAIL PROTECTED]);

#PRINT THE CONTENTS OF @array1
print '@array1'."\n";
foreach(@array1){
   print "\t$_\n";
}

print "\n\n";

#PRINT THE CONTENTS OF @array2
print '@array2'."\n";

foreach(@array2){
   print "\t$_\n";
}


#THE FUNCTION THAT POPULATES THE ARRAYS
sub func{
   #THESE ARE THE REFERENCES
   my($ref1,$ref2) = @_;

   [EMAIL PROTECTED] IS THE ARRAY THAT $ref1 REFERS TO
   @{$ref1} = (1..20);
   push(@{$ref1},"twenty-one");

   @{$ref2} = (22..40);
   push(@{$ref2},"forty-one");
}

###

-Original Message-
From: Khairul Azmi [mailto:[EMAIL PROTECTED] 
Sent: Monday, January 03, 2005 5:22 PM
To: beginners@perl.org
Subject: functions that returns two arrays

Hi,
I'm trying to write a function that could return two arrays.

[Tim Johnson] 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Is there a time module to help with this...

2004-12-17 Thread Tim Johnson

Ah.  I see.  You should respond to the list though.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Friday, December 17, 2004 1:33 PM
To: Tim Johnson
Subject: RE: Is there a time module to help with this...

HP-UX. But I would like to code it in such a manner so that it is
portable
to any platform that can run perl.

-Original Message-
From: Tim Johnson [mailto:[EMAIL PROTECTED]
Sent: Friday, December 17, 2004 4:23 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Is there a time module to help with this...



What OS are we talking about?



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Friday, December 17, 2004 12:42 PM
To: [EMAIL PROTECTED]
Subject: RE: Is there a time module to help with this...

That's a good idea. However I want it to run constantly, like a service.
So
in some respects it would have to be a loop. Maybe embedded loops. I
don't
really know :)



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Is there a time module to help with this...

2004-12-17 Thread Tim Johnson

What OS are we talking about?



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Friday, December 17, 2004 12:42 PM
To: [EMAIL PROTECTED]
Subject: RE: Is there a time module to help with this...

That's a good idea. However I want it to run constantly, like a service.
So
in some respects it would have to be a loop. Maybe embedded loops. I
don't
really know :)



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: how to assign an external command aoutput to an array

2004-10-16 Thread Tim Johnson
Or even

my @values = split(/ /,qx'..');

should work.  I can't test that where I am, but unless there is some weird caveat with 
the qx operator (which I don't usually use), then it should work.


-Original Message-
From: Mauro [mailto:[EMAIL PROTECTED]
Sent: Friday, October 15, 2004 1:17 AM
To: [EMAIL PROTECTED]
Subject: Re: how to assign an external command aoutput to an array


Ok Ok i found solution:
my $got_value=qx'.';
my @values=split / /,$got_value:

Thank You


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: output to one changing line

2004-09-15 Thread Tim Johnson

That doesn't work on my WinXP, but this does...

perl -e "$|=1; print \"\rLine $_\" and sleep 1 for 1..3; print \"\n\""

-Original Message-
From: JupiterHost.Net [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 15, 2004 2:03 PM
To: [EMAIL PROTECTED]
Subject: Re: output to one changing line

[Tim Johnson] 

perl -e '$|=1; print "\rLine $_" and sleep 1 for 1..3; print "\n"'


[Tim Johnson] 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: A simple way? A Perl way?

2004-09-01 Thread Tim Johnson
 
Just for the sake of showing another way to do it...
 


my $input = "2-8,9,11,18-21";

$input =~ s/-/\.\./g;

print join(',',eval($input));



or if you don't want to print out the list but iterate through it...



my $input = "2-8,9,11,18-21";

$input =~ s/-/\.\./g;

foreach(eval($input)){

 ...do something

}

#

-Original Message- 
From: John W. Krahn [mailto:[EMAIL PROTECTED] 
Sent: Tue 8/31/2004 11:31 PM 
To: Perl Beginners 
Cc: 
Subject: Re: A simple way? A Perl way?





> I am looking for a simple Perl way to decode the following, which can be any
> grouping of number
>
>2-8,9,11,18-21
>
> Into
>2,3,4,5,6,7,8,9,11,18,19,20,21

$ perl -le' print join ",", map /(\d+)-(\d+)/ ? $1 .. $2 : $_, split /,/,
"2-8,9,11,18-21"'
2,3,4,5,6,7,8,9,11,18,19,20,21




RE: get last record in a file

2004-08-25 Thread Tim Johnson
Another way to go:
 
my $lastline;
open(FILE,"test789.pl") || die "Couldn't open \"test789.pl\" for reading!\n";
while(){
   $lastline = $_;
}
print "\"$lastline\"\n is the last line.\n";

-Original Message- 
From: balaji venkat [mailto:[EMAIL PROTECTED] 
Sent: Wed 8/25/2004 8:56 PM 
To: Jeremy Kister; [EMAIL PROTECTED] 
Cc: 
Subject: Re: get last record in a file



The following code will do the required task.

#! /usr/bin/perl

open (FILE,"test789.pl");
@array1 = ;
$last = pop(@array1);
print $last;


 --- Jeremy Kister
<[EMAIL PROTECTED]> wrote:
> On Wednesday, August 25, 2004 6:15 PM, I wrote:
> > not extensively tested:
> 
>  this is a bit more tested:
> 
> #!/usr/local/bin/perl
>
> open(F, "file.txt");
> while(){
>  chomp(my $line = $_);
>  my ($key) = $line =~ /^(\S+)\s/;
>  $hash{$key} = $line;
> }
> close F;
>
> foreach my $value (values %hash){
>print "$value\n";
> }
>
> Jeremy Kister
> http://jeremy.kister.net/
>
> --
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
>
>
> 


   
   
   
___ALL-NEW Yahoo! 
Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 






RE: Need help to sort data

2004-08-23 Thread Tim Johnson

For starters, ALWAYS 'use strict;' and 'use warnings;' at the beginning
of your scripts.  It's a little annoying at first, but it saves you from
some very time-consuming mistakes down the line.

Okay, here is one way to do the kind of thing I think you are asking to
do.  Keep in mind that I took some liberties with style and naming, and
you may want to do it a bit differently if this doesn't make sense to
you.

##

use strict;
use warnings;

#Each key of %groups is a group,
#the value is an array of users
my %groups;
#Each key of %users is a user,
#the value is an array of groups
my %users;

#open the input file
open(USERFH,"){
chomp $line;
#First item is the user name, the rest are the groups
my($user,@groups) = split(/\s+/,$line);

#Create a key with the user name
#and add the groups as a value
$users{$user} = [EMAIL PROTECTED];

#For each group, create a key in %groups and add
#the user to the end of the list
foreach my $group(@groups){
push @{$groups{$group}},$user;
}
}
close USERFH;

#Print out a list of groups with members
print "GROUPS\n";
print "==\n\n";
foreach my $group(sort keys %groups){
print "$group:\n";
foreach my $user(sort @{$groups{$group}}){
print "\t$user\n";
}
}

print "\n\n";

#Print out a list of users with groups they belong to
print "USERS\n";
print "=\n\n";
foreach my $user(sort keys %users){
print "$user:\n";
foreach my $group(sort @{$users{$user}}){
print "\t$group\n";
}
}






-Original Message-
From: Robin Smith [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 23, 2004 6:04 PM
To: [EMAIL PROTECTED]
Subject: Need help to sort data 

Hi,
 
I have a flat  file data in the form of user and groups. The user always
come first follow by the groups. Now I need to arrange then by  groups.
This is the code I have been working with. the groups are listing but
the users are not.  I am still fairly new  to perl so I need someone
with simple code? Can someone offer any assistance ?
 

my %group_to_users = ();
while (my $line = ) {
chomp ($line);
my ($user, @user_groups) = split ('\s+', $line);
for my $group (@user_groups) {
  push @group_to_users, $user ;
   $group_to_users{$group} = [$user] ;
}
}
close (USERFH);
for my $group (sort keys %group_to_users) {
print $group . ":\n";
print $group_to_users{$group} . "\n";
}


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: COMPLEX ARRAY STRUCTURE

2004-08-09 Thread Tim Johnson

Are you sure you want that top level to be an anonymous array instead of
a hash?  This would make more sense (see below for how to access the
values).  Note the {} brackets instead of the [] brackets.

#

my $a = {'cn'   => ['Barbara Jensen', 
'Barbs Jensen'],
   'sn'   =>  'Jensen',
 'mail' =>  '[EMAIL PROTECTED]',
 'objectclass' => ['top',
   'person',
   'organizationalPerson',
   'inetOrgPerson' ],
  };

print $a->{objectclass}->[3]."\n"; #inetOrgPerson
print $a->{sn}."\n"; #Jensen

#







-Original Message-
From: Luis Daniel Lucio Quiroz [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 08, 2004 5:50 PM
To: [EMAIL PROTECTED]
Subject: COMPLEX ARRAY STRUCTURE

Hi,

$a = [
'cn'   => ['Barbara Jensen', 'Barbs Jensen'],
'sn'   => 'Jensen',
'mail' => '[EMAIL PROTECTED]',
'objectclass' => ['top', 'person',
'organizationalPerson',
   'inetOrgPerson' ],
   ];


I have this arrary structure, how should I read it?  For example how do
I 
acces to "inetOrgPerson' value or Jesen value?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: 1 Windows XP + 1 Office XP = $80 d dhhytzy vs dxq

2004-07-17 Thread Tim Johnson
I guess his name says it all...

-Original Message- 
From: Carl Colon [mailto:[EMAIL PROTECTED] 
Sent: Wed 7/21/2004 1:16 PM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: 1 Windows XP + 1 Office XP = $80 d dhhytzy vs dxq



Loads of cool soft at incredibly low prices
Windows XP Professional + Office XP Professional for as low as $80
Order here:




The stock is limited
The offer is valid till next 24 hours
Hurry!



.r yw  xygpylwa afroximrkuakvdtlxcl
egtcldmt
r
aajbxq ihquemuyh qqpb




RE: Windows Perl Environment

2004-07-17 Thread Tim Johnson
If you're ready to pay money for it, then there's Visual Perl from ActiveState (VS 
plug-in, works great), Komodo from ActiveState, PerlBuilder from SolutionSoft that 
have built-in debuggers.  The Visual Debugger that comes with the Perl Dev Kit from 
ActiveState is also pretty good.

-Original Message- 
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Sat 7/17/2004 2:44 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: Windows Perl Environment



Is there any program that allows one to write Perl scripts and and then test
them in a windows environment without using a DOS window, and actually have me
see the program run before I upload it to a server, rather than just testing
if the script runs without errors? Anyone know what I mean and know of any
such program?




RE: !$state

2004-07-16 Thread Tim Johnson
Thank you, yes.  That is an important distinction.

-Original Message- 
From: Randal L. Schwartz [mailto:[EMAIL PROTECTED] 
Sent: Fri 7/16/2004 7:17 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: Re: !$state



>>>>> "Tim" == Tim Johnson <[EMAIL PROTECTED]> writes:

Tim> "$state = ()" assigns the value of an empty list to the scalar $state, so 
it would evaluate to false.

No, it doesn't.  It evaluates () in a scalar context, which returns a
scalar undef.  Hence, same as "$state = undef".  Right conclusion,
wrong reasoning.

--




RE: !$state

2004-07-16 Thread Tim Johnson
 
 
Someone can probably give a better answer, but practically speaking, this is what I've 
seen to be true (someone please give me a verbal whipping if I'm off here):
 
Perl evaluates a statement as false if it 
 
a) is undefined
b) evaluates to 0
c) evaluates to '' (empty string)
 
and evaluates to true if it is not false.
 
"$state = ()" assigns the value of an empty list to the scalar $state, so it would 
evaluate to false.
"$state = []", however, assigns a reference to an anonymous array to $state.  It looks 
something like this:  ARRAY 0x999 (I don't know how many digits).  
This is not case a,b,or c above, so it is true, even though the dereferenced array 
itself (@{$state}) may be empty, and evaluate to false.
 
As for the way the reference docs are set up, I agree with you that they are not very 
intuitive.  I personally recommend installing ActivePerl on a computer somewhere so 
that you have the benefit of all of the documentation converted to HTML in a much more 
intuitive format.
 

-Original Message- 
From: Harald Richard Ashburner [mailto:[EMAIL PROTECTED] 
    Sent: Thu 7/15/2004 10:21 PM 
To: Tim Johnson 
Cc: David Arnold; [EMAIL PROTECTED] 
Subject: Re: !$state





so to investigate this further, I want to look at what perl takes as
"Truth". I want to nail down for my own benefit the differences between
uninitialized, undef, initialized as a reference to an empty hash or
array or whatever. How these compare with the return value of undef()
etc.
Quick, to the Fine Manual!

perldoc perldoc tells me all about formatting and gives me the actually
useful switches for the purposes of finding documentation:
-f if I want documentation on a function
-q to 'grep' the perl faqs

Question:
How do I get an index or a table of contents? How do I find out how to search 
the perldocs for
"control structures"





RE: !$state

2004-07-15 Thread Tim Johnson

$state evaluates as true (I think that's what you're asking).



$state = {};

if($state){
   print "\$state is true:  $state\n";
}else{
   print "\$state is false";
}



$state is true because it's not empty.  
It's a reference to a hash that is empty.





-Original Message-
From: David Arnold [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 15, 2004 7:24 PM
To: [EMAIL PROTECTED]
Subject: !$state

All,

If:

$state={};

Then, what is:

!$state


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: creating a table in Microsoft Word

2004-07-13 Thread Tim Johnson


One easy way with Win32::OLE is to create the table while recording a
macro in Word, and then convert the macro to Perl.


-Original Message-
From: Jenda Krynicky [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 13, 2004 10:47 AM
To: [EMAIL PROTECTED]
Subject: Re: creating a table in Microsoft Word

[Tim Johnson] snip-

Take a look at Win32::OLE. It will allow you to start an (invisible) 
instance of Word and control it.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Regex for numbers and text

2004-07-12 Thread Tim Johnson
Another good module for helping you understand what a complicated regex MEANS (which 
will help you know how to fix it) is YAPE::Regex::Explain.  It also helps with some 
issues where a regex may be working, but not for the reason you think.

-Original Message- 
From: Jerry Preston [mailto:[EMAIL PROTECTED] 
Sent: Mon 7/12/2004 6:32 PM 
To: [EMAIL PROTECTED]; 'Gunnar Hjalmarsson' 
Cc: [EMAIL PROTECTED] 
Subject: RE: Regex for numbers and text



Jeff,

What needs to be changed in /(-?\d+\.?\d*)/ so that it also see number like
.59?



RE: Clearing up Google history

2004-07-12 Thread Tim Johnson

This isn't a Perl question.  Please post it elsewhere.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 12, 2004 1:37 PM
To: [EMAIL PROTECTED]
Subject: Clearing up Google history

How do I clear up my "google history" (IE history can be cleared via
Tools,
Options).



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: how do you run the debuger for perl/TK in Windows-2000

2004-07-12 Thread Tim Johnson
Please don't send the same question to the list twice in a row.  The truth is there 
aren't many people answering questions on a Sunday night (US), but re-sending the 
question doesn't increase your chances of having your question answered, but some 
people really get irked by the extra traffic on an already congested list.
 
In any case, someone gave a good answer to your original question already.

-Original Message- 
From: Marco Perl [mailto:[EMAIL PROTECTED] 
Sent: Sun 7/11/2004 11:58 PM 
To: [EMAIL PROTECTED]; [EMAIL PROTECTED] 
Cc: 
Subject: how do you run the debuger for perl/TK in Windows-2000



Greetings,
I developed a perl/TK script in Win-2000 environment.
when I run it the DOS-screen pops up and displays my
program errors. but this screen closes so fast that
its impossible to read the error. so, how do I debug
my
perl.ptk script or how do I slow down the DOS-screen
to read the errors?
thanks so much,
regards,
Marco.


   
__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 






Launching scripts via command prompt [WAS RE: Could you please help with a PERL/TK question.]

2004-07-12 Thread Tim Johnson
 
Just one quick note:  I've seen a lot of people say that this is the way to run a 
script from the command-line, but any script that you can run by double-clicking 
should also be able to be run by just typing in the name of the script at the 
command-line (provided you are in the same directory as the script).
 
The only time you should have to use the syntax "perl path\to\script.pl" is if you 
don't have the file association set up correctly, for example if you decided to 
compile your own Perl distribution instead of using ActivePerl or another pre-packaged 
Win32 distribution.  But if that's the case, then you won't be able to double-click 
anyway.
 
-Original Message- 
From: Toby Stuart [mailto:[EMAIL PROTECTED] 
Sent: Sun 7/11/2004 11:34 PM 
To: 'Marco Perl' 
Cc: '[EMAIL PROTECTED]' 
Subject: RE: Could you please help with a PERL/TK question.





To run the script directly from cmd shell ie. click "Start" and then select
"Run" and type "cmd".  The cmd shell appears.  Then type: perl
path\to\my\script.pl




RE: Backticks alternative?

2004-07-06 Thread Tim Johnson
 
My bad.  I changed it to try to make it sound more descriptive, but didn't test.  
Thanks for pointing it out.

-Original Message- 
From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] 
Sent: Tue 7/6/2004 1:00 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: Re: Backticks alternative?






> $exec = "ls -l";
> $src = syscall($exec);
>
> sub syscall{
>return `$_[0]`;
> }
>
> should work.

Should it? Did you try it? syscall() is a built-in Perl function, so
the above does *not* work.





RE: Backticks alternative?

2004-07-05 Thread Tim Johnson
If you want the exact same function as the backticks, why not just make a small 
subroutine?
 
#
 
$exec = "ls -l";
$src = syscall($exec);
 
sub syscall{
   return `$_[0]`;
}
 
#
 
should work.

-Original Message- 
From: gohaku [mailto:[EMAIL PROTECTED] 
Sent: Mon 7/5/2004 9:28 PM 
To: Perl Beginners 
Cc: 
Subject: Backticks alternative?



Hi everyone,
After using backticks to retrieve executable output,
I would like to know if there is a backtick alternative.






RE: Win32::NetAdmin::LocalGroupGetMembers

2004-06-28 Thread Tim Johnson

That's because the SID is stored in binary, and when you try to print
it, it tries to convert that binary value into a series of characters,
one of which is the beep sound (I know it doesn't make any sense, but
it's true).

> Subject: Win32::NetAdmin::LocalGroupGetMembers
> Date: Fri, 25 Jun 2004 17:40:05 -0400
> From: "perl.org" <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
>
> I need to get the members of a local group on a Windows 2000 server.
I was
> reading the docs for Win32::NetAdmin
> (http://perlhelp.web.cern.ch/PerlHelp/site/lib/Win32/NetAdmin.html)
which
> looks like the  place to start, but it is giving me weird results
(including
> beeps).  Any suggestions?  SIDs I could understand, but a repeated
binary
> value is a little weird.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: [Doubt]: Retrieve System Info like Which OS and type

2004-06-22 Thread Tim Johnson

Check out the Win32::TieRegistry module.  It's pretty easy to get that
info from the Registry.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 22, 2004 11:32 AM
To: [EMAIL PROTECTED]
Subject: [Doubt]: Retrieve System Info like Which OS and type

Hi,


I need to retrieve the following system Info from the current system.

1. Operating System

2. Localization

3. 32 Bit or 64 Bit



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Answering Questions [WAS:RE: split]

2004-06-21 Thread Tim Johnson
I didn't say that Chetak's reply was wrong, or that he was somehow remiss in omitting 
that information.  It is, in the end, a somewhat philosophical difference, and as such 
I won't presume to try to change your mind, but let me clarify my point.
 
The OP was given a finished product.  I certainly won't disagree that he should have 
done some research and tried on his own, and there is no indication from the request 
that he did that.  But here's where we differ:  Regular expressions are quite possibly 
one the hardest part of learning effetive Perl programming,and arguably the most 
valuable.  Handing someone a finished regular expression without explaining how it 
works doesn't really help someone learn how to make their own regular expressions.  
The two references you mentioned would have been great suggestions as well.  What it 
comes down to is this:  If we're going to answer people's questions, then we should do 
it with an eye towards helping them learn the subject matter so that they can become 
self-sufficient.  If we feel like we're being asked for a freebie, then we have every 
right to say so and point them in a direction they should take before asking for a 
solution.  Breaking down a regex for a beginner is hardly giving away the magic, but 
if you'd rather point them towards some reference material that's fine.  But how 
exactly is a beginner supposed to know that 'perldoc perlretut' even exists unless you 
tell them?  The name isn't exactly intuitive, and most people have no idea what it is 
until you tell them or they start reading random parts of the perldoc in desperation.
 
To paraphrase the old saying:
 
A hungry man asked for a fish
 
He was given a fish
 
I suggested that maybe he should have been told how the fish was obtained
 
You maintained that if he really enjoyed the fish he was given and wanted another one 
bad enough, he would have gone out and found a book on fish and from there derived 
that fishing would have been the approprate way to get a fish, studied up on it and 
come back when he had problems fishing
 
 
-Original Message- 
From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] 
Sent: Mon 6/21/2004 6:18 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: Re: split

Tim Johnson wrote:
> Chetak Sasalu wrote:
>>
>> $var =~ m/Owner: (\w{5})\s*: rwx \(all\)/;
>> $y = $1;
>
> That is one way to do it, but maybe you should tell him what it is
> that the regex does.  I remember from my newbie days that it wasn't
> too useful when people just threw regexes at me without explaining
> them because they look so daunting before you are used to them.

Chetak *could* have done so, but doing it is certainly nothing you can
claim that he *should* do. What *should* happen is that the OP ("Jack
Jack") start studying some appropriate documentation, such as




RE: split

2004-06-21 Thread Tim Johnson
That is one way to do it, but maybe you should tell him what it is that the regex 
does.  I remember from my newbie days that it wasn't too useful when people just threw 
regexes at me without explaining them because they look so daunting before you are 
used to them.

-Original Message- 
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Mon 6/21/2004 3:14 AM 
To: [EMAIL PROTECTED] 
Cc: [EMAIL PROTECTED] 
Subject: RE: split




HI all,

HI,

I want to grep only   from $var , i want in a variable $y.

$var="Owner: X  : rwx (all)";

$var =~ m/Owner: (\w{5})\s*: rwx \(all\)/;
 $y = $1;



Chetak

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 






RE: script

2004-06-21 Thread Tim Johnson
What have you tried?  Are you stumped, are you trying to learn, or are you just trying 
to get people to write scripts for you?  When you ask a question, you should include 
what you have done so that people can give you answers that match the level of 
experience you have and so that they know they're not just being used for free 
consulting.
 
I think you were the one I recommended look into the Archive::Tar and Archive::Zip 
modules.  Did you decide not to go that route?

-Original Message- 
From: Vema Venkata [mailto:[EMAIL PROTECTED] 
Sent: Mon 6/21/2004 3:04 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: script





> 
> Hi ,
>
>   TIA
>
>   Need help
>
>   I have a following path
>
>   "/proj/ahd02/CAisd/site/mods/scripts/log" in this path i have a file 
called "archive-18-7-2003.tar.Z"
>
>   I want a script in perl by uncompress and untar it.
>
>   can any send me the same requested.
>
>
>   HTH
>
>   venkat
>
>
>
>
> 
> 
>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 






RE: Adding Arrays as Hash Keys

2004-06-20 Thread Tim Johnson
I'm a little hesitant to offer an answer because I'm not sure what you mean, but I'll 
give it a shot so that you have a chance to clarify if I'm way off.  It's possible 
that what you want is a hash of arrays, where each hash key points to a different 
array.  If so, then what you would want would be something like this:
 
my %hash = ( firstarray => ["this","is","my","list"],
  nextarray => ["this","is","another","list"] );
 
print $hash{firstarray}->[2]; #prints "my"
print $hash{firstarray}->[3]; #prints "list"
 
Note: the [] brackets indicate an anonymous array.  What I've done above is create an 
anonymous array and add a reference to it as the value to the firstarray and then 
nextarray keys.  You can then use the syntax above to access the values or dereference 
the array, like so:  @{$hash{firstarray}} if you wanted to use sort(), shift(), etc.

-Original Message- 
From: gohaku [mailto:[EMAIL PROTECTED] 
Sent: Sat 6/19/2004 10:04 PM 
To: Perl Beginners 
Cc: 
Subject: Adding Arrays as Hash Keys



Hello everyone,
I would like to know if there is a cleaner way of Merging Hash Keys
with Arrays




RE: Regexp

2004-06-19 Thread Tim Johnson

And for #2, how about:

s/\b\w{1,2}\b//g;

-Original Message-
From: Mandar Rahurkar [mailto:[EMAIL PROTECTED] 
Sent: Saturday, June 19, 2004 5:48 PM
Cc: [EMAIL PROTECTED]
Subject: Regexp



2. removing all one and two lettered words 
   e.g., a,an



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Regexp

2004-06-19 Thread Tim Johnson

What about:

$string =~ s/s\b//g;

-Original Message-
From: Mandar Rahurkar [mailto:[EMAIL PROTECTED] 
Sent: Saturday, June 19, 2004 8:06 PM
To: Tim Johnson
Cc: [EMAIL PROTECTED]
Subject: RE: Regexp

Hi,
   I am too old to have homeworks on perl :)
I tried for the first case:
s/\ws\b/$1/;

but trick to understand is that I need to substitute forests with
forest. 
I can probably use substr however was looking for a elegant solution.

Mandar


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: Regexp

2004-06-19 Thread Tim Johnson

This sounds like a homework project.  We don't generally do people's
homework for them.  If I'm wrong, I apologize.  Maybe you can tell us
what you've tried so far.  Have you read through 'perldoc perlre'?

I would recommend the module YAPE::Regex::Explain if you want some help
figuring out what your regular expressions are really doing.

-Original Message-
From: Mandar Rahurkar [mailto:[EMAIL PROTECTED] 
Sent: Saturday, June 19, 2004 5:48 PM
Cc: [EMAIL PROTECTED]
Subject: Regexp

Hi All,
   what wud be the regexp for :

1. substituting last s of every word 
   e.g., forests become forest,  goats becomes goat

2. removing all one and two lettered words 
   e.g., a,an



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Subtracting Zero Dates

2004-06-18 Thread Tim Johnson
How about:
 
if($time1 > $time2){
   $difference = $time1 - $time2;
}else{
   die "Invalid date!\n";
}

-Original Message- 
From: Werner Otto [mailto:[EMAIL PROTECTED] 
Sent: Fri 6/18/2004 5:34 AM 
    To: Tim Johnson; [EMAIL PROTECTED] 
Cc: 
Subject: Re: Subtracting Zero Dates



they are all ready in time format, that is the problem.

Example:
$time1 = Date_to_Time($year,$month,$day, $hour,$min,$sec);
$time2 = Date_to_Time($year,$month,$day, $hour,$min,$sec);

$difference = $time1 - $time2;

> One way:  Convert both dates to Perl time() format, then subtract.
>
>   -Original Message-
>   From: Werner Otto [mailto:[EMAIL PROTECTED]
>   Sent: Fri 6/18/2004 3:28 AM
>   To: [EMAIL PROTECTED]
>   Cc:
>   Subject: Subtracting Zero Dates
>  
>  
>
>   Hi All,
>  
>   Does anyone know how to handle subtracting two dates where one might be
> 0
>   or no time or blank?
>  
>  
>



--
Kind Regards,
Werner Otto
Web/Programming Support
Department of Computer Science
Kings College




RE: printing array elements in columns

2004-06-18 Thread Tim Johnson
 
I can't test this out where I am, but here's one thought...
 
##
 
my $columns = 5;
my $i = 0;
while($i < ($#X + $columns)){
   for($i..$i+$columns){
  print $X[$_];
  for(1..(20 - length($X[$_])){
 print " ";
  }
   }
   print "\n";
}
 

 
 
-Original Message- 
From: N, Guruguhan (GEAE, Foreign National, EACOE) [mailto:[EMAIL PROTECTED] 
Sent: Fri 6/18/2004 4:38 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: printing array elements in columns



Hi All,
  I have a one dimensional array @X, containing N elements. I would 
like to know how I can print this N elements in M columns?

TIA
Guruguhan


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 






RE: script

2004-06-18 Thread Tim Johnson
Check out the Archive::Zip and Archive::tar modules.

-Original Message- 
From: Vema Venkata [mailto:[EMAIL PROTECTED] 
Sent: Fri 6/18/2004 2:25 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: script



Hi Group,

TIA

Need help

I have a following path

"/proj/ahd02/CAisd/site/mods/scripts/log" in this path i have a file 
called "archive-18-7-2003.tar.Z"

I want a script in perl by uncompress and untar it.

can any send me the same requested.


HTH

venkat





> 
>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 






RE: Subtracting Zero Dates

2004-06-18 Thread Tim Johnson
One way:  Convert both dates to Perl time() format, then subtract.

-Original Message- 
From: Werner Otto [mailto:[EMAIL PROTECTED] 
Sent: Fri 6/18/2004 3:28 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: Subtracting Zero Dates



Hi All,

Does anyone know how to handle subtracting two dates where one might be 0
or no time or blank?





RE: array

2004-06-18 Thread Tim Johnson

-Original Message-
From: Stefan Weckx [mailto:[EMAIL PROTECTED]
Sent: Friday, June 18, 2004 1:38 AM
To: [EMAIL PROTECTED]
Subject: array


>hi list,

>2 questions about arrays:

>- I want to take 2 elements a time from an array within a foreach 
>control structure, which should be something like:
>foreach $a $b (@array) {...}. it this possible in perl??


Here's one way:
while(@array){
   my $a = shift @array;
   my $b = shift @array;
}

...I think that would do what you're asking.


>- is it possible to search an array for a certain element, and that the 
>search returns the element index? eg. searching for 156 in the array 
>(123, 456, 156, 1354, 35164, 654656, 654, 846) should give 2

This one's easy.

for(0..$#array){
   chomp $_;
   if($_ == 156){
  print "Found 156 at $_.\n";
  last;
   }
}

Take out the "last;" line if you want it to keep searching after it finds one.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Date and time calculation

2004-06-16 Thread Tim Johnson
 
Time::Local can come in very handy when you need to convert text dates to Perl time as 
well.

-Original Message- 
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
Sent: Wed 6/16/2004 7:27 AM 
To: Werner Otto; [EMAIL PROTECTED] 
Cc: 
Subject: Re: Date and time calculation





Date::Calc
Date::Manip
DateTime

All make this trivial.





RE: Microsoft Word and Perl

2004-06-14 Thread Tim Johnson

Or you can use the in() function from Win32::OLE, which will enumerate
all objects within a container

use Win32::OLE qw(in); 

foreach my $obj_Story(in($newdoc->StoryRanges)){


-Original Message-
From: Ichim, Adrian N. [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 14, 2004 12:12 AM
To: [EMAIL PROTECTED]
Subject: RE: Microsoft Word and Perl


Could you try instead

foreach my $obj_Story (@{$newdoc->StoryRanges}) {
  .
  ...
  }

As I remember from my past experience with Win32::OLE stuff, Perl
doesn't know that $newdoc->StoryRanges is a list, therefore you need to
be more explicit.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Microsoft Word and Perl

2004-06-13 Thread Tim Johnson
Try changing "Fields->{Update}" 
to
"Fields->{update}"
or
"Fields->update()"

-Original Message- 
From: Ilaiy [mailto:[EMAIL PROTECTED] 
Sent: Sat 6/12/2004 2:39 PM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: Microsoft Word and Perl 



I have been trying to update my word document using perl, i used

$word->Selection->WholeStory;
$word->Selection->Fields->{Update};


But this is a little slow and at times doesnot update completely. I
modified the code and right now getting a wired error but the same in
VBA works really well .


my $newdoc = $word->ActiveDocument;
foreach my $obj_Story ($newdoc->StoryRanges ){
 $obj_Story->Fields->{Update};   ==> Cannot find object
 while ($obj_Story->NextStoryrange != ""){
  $obj_Story = $obj_Story->NextStoryRange;
  $obj_Story->Fields->{Update};==> Cannot find object
 }
}


The equivalent in VBA is ..

Dim obj_Story As Range
For Each obj_Story In ActiveDocument.StoryRanges
obj_Story.Fields.update
While Not (obj_Story.NextStoryRange Is Nothing)
Set obj_Story = obj_Story.NextStoryRange
obj_Story.Fields.update
Wend
Next obj_Story
Set obj_Story = Nothing



Could someone tell me where am i going on.


Ilaiy



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 






RE: search and move 'expired files'

2004-06-11 Thread Tim Johnson
You can use the -d file test to check if the file is a directory before moving it.
 
unless(-d $whatever_file){
 do whatever...
 
 
-Original Message- 
From: "Shu Hung (æé)" [mailto:[EMAIL PROTECTED] 
Sent: Fri 6/11/2004 3:50 AM 
To: Perl Beginner Mail Group 
Cc: 
Subject: search and move 'expired files' 



Hello all,

I want a script to move all 'expired files' to a folder.
So I wrote the script below.

However, a problem came out: the find function run everything
in the address, including the entire folders structure!!!





RE: Concatenating line into array problem

2004-06-10 Thread Tim Johnson

This might be closer to what you want.  Just push the line onto the
array every time you come to the '>' character.  You'll get one empty
line at the beginning, that's why I put the shift line in.



while (<>) {
 if (/^>/) {
 push (@crseq, $line);
 next;
 }
 chomp;
 $line .= $_;
}
shift @crseq;
print join("\n", @crseq), "\n"; 



-Original Message-
From: Edward Wijaya [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 10, 2004 9:09 PM
To: [EMAIL PROTECTED]
Subject: Concatenating line into array problem



What I would like to do is to concatenate the line below > into one
single string.
Such as the output would be:

CAATATGCGAGGGACCTACATGTTGAGCATGACAATGAATTCTATTGA
ATAATTATTCCTGTTTCTTTAACCTGGTGTACAAACACTTAAGC



#---My Code --
while (<>) {
 if (/^>/) {
 next;
 }
 chomp;
 $line .= $_;
}
push (@crseq, $line);
print join("\n", @crseq), "\n";


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: procfarm equivalent

2004-06-09 Thread Tim Johnson

>-Original Message-
>From: drieux [mailto:[EMAIL PROTECTED] 
>Sent: Wednesday, June 09, 2004 11:15 PM
>To: Perl Beginners Mailing List
>Subject: Re: procfarm equivalent
>
>
>On Jun 9, 2004, at 8:25 PM, Ron Willmert wrote:
>
>> Is there a Unix equivalent Win32-ProcFarm? I really like having the 
>> module decide how many process' to create and how it doles out the 
>> jobs and getting the return values from the process' so easily.
>
>Forgive me for asking this,
>but why are you allowing a module
>work out how many processes to create?

It doesn't really tell you how many processes to create, but you give it
how many, and it makes sure that only that many are running at a time,
and creates a queue of threads waiting to be executed.  It saves you
time re-inventing the wheel so that you can focus on what your processes
are doing. 





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Searching a string

2004-06-09 Thread Tim Johnson

perldoc perlre 

Look at the /s switch for regexes.







-Original Message-
From: sudhindra k s [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 09, 2004 12:23 AM
To: [EMAIL PROTECTED]
Subject: Searching a string

  
Hi 

I have a string (not a file ) which looks something like this :

tools : Abcdef
abc: 
all:
def:
all:

Now i want to search the string for all occurances of "all:" and print that line 
containing "all:"

How can this be done?

Thanks
Sudhindra





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: system() command

2004-06-08 Thread Tim Johnson

Before going any further, you might want to tell us what operating
system you are using.  As far as I know, the << operator can be used to
feed a program certain input as if it came from STDIN, but I've never
used it because it always sounded a bit kludgy to me.
 

-Original Message-
From: june tantoolvesm [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 08, 2004 1:25 AM
To: [EMAIL PROTECTED]
Subject: system() command 

Hi,

I hope this is the right mailing list. I have two questions.

1. I was wondering if anyone here knows what this command is doing,
besides calling the program "neighbor"?

system ("neighbor >/dev/null 2>&1 << ! $inpwd 2 3 Y



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: DBI

2004-06-06 Thread Tim Johnson

Should be "install DBI", as in:


PPM - Programmer's Package Manager version 3.1.
Copyright (c) 2001 ActiveState SRL. All Rights Reserved.

Entering interactive shell. Using Term::ReadLine::Stub as readline
library.

Profile tracking is not enabled. If you save and restore profiles
manually,
your profile may be out of sync with your computer. See 'help profile'
for
more information.

Type 'help' to get started.

ppm> install DBI





-Original Message-
From: aditi gupta [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 06, 2004 11:45 PM
To: [EMAIL PROTECTED]
Subject: DBI

hi,
 
how to download DBI via PPM?
 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: how to retreive data from internet.

2004-06-06 Thread Tim Johnson

How far have you gotten?  Do you know any Perl yet, or are you just
starting?

Try checking out the documentation for Net::FTP.

-Original Message-
From: aditi gupta [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 06, 2004 9:42 PM
To: [EMAIL PROTECTED]
Subject: how to retreive data from internet.

hi,
 
i want to get a DNA sequence from internet for manipulations.i was told
that it requires ftp .. but i don't have any idea about it.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: log in to domain with script

2004-06-06 Thread Tim Johnson

Here are some modules that should give you a push in the right
direction.  I'm not sure from your email whether your clients are all
Windows 2000, or if you are running Active Directory.  AD gives you some
new challenges as well as more granular control of objects.

I'm going to assume you're still using an NT4 domain (most of these
modules will still work, but may not be the best way for 2k domains).

1.  AdminMisc from Dave roth http://www.roth.net/perl/adminmisc is a
great tool for getting and setting user information, and has a very low
learning curve.  To install it you should add the repository
http://www.roth.net/perl/packages to your PPM.(check the PPM
documentation for how to add a repository)

2.  NetAdmin is a module that comes standard with ActivePerl.  It has
functions that correspond to some of the basic administration APIs, but
is a little out-of-date IMO.

3.  I would heartily recommend using Win32::Lanman.  It has the most
complete list of functions, but has the highest learning curve.  The
documentation is humongous, but if you want, I have pulled it apart into
a series of Word documents by category.  It makes it a lot easier to
find what you need.  Just send me an email if you want the word docs.

Once you have the information you need, you will need a module for
sending out the emails:

1.  Net::SMTP is the most basic module for sending text messages.  I
usually go this route, unless I need to send an attachment, then I
usually use either

2.  MIME::Lite or

3.  Mail::Sender


Try some of these out.  If you get stumped, feel free to ask for help.


 



-Original Message-
From: Ronen Kfir [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 06, 2004 6:05 AM
To: [EMAIL PROTECTED]
Subject: log in to domain with script

Hi,

I work in a windows 2000 environment. 

Need to check & find out the users who haven't changed their password
from the default password given to them when the user was opened. I want
to the script will make a log in to the domain with each user, & try to
do it with the default password.  For the users successfully logged in
with default password I want to do 2 actions: 

1.  Send e-mail states that if password will not be changed, it will
be expired in a week from now. 
2.  Resets the "password expires" date attribute to one week from
now. 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: how to use perl in windows

2004-06-06 Thread Tim Johnson
My $0.02:
 
 Go to www.activestate.com and download ActivePerl.  Not only is it the de facto 
Win32 Perl distribution, but you will have access to PPM, which lets you install most 
commonly-used modules at the touch of a button (especially convenient because Windows 
doesn't come with a compiler).
 
After it is installed, it will  set up the file associations so that you just have to 
double-click on any .pl files or type the name at the command prompt, and the Perl 
interpreter will be automatically invoked.
 
For the database support, download DBI via PPM.  It has a kind of steep learning curve 
compared to other modules, but once you get the hang of it you can use it to retrieve 
data from just about any database.

-Original Message- 
From: aditi gupta [mailto:[EMAIL PROTECTED] 
Sent: Sat 6/5/2004 6:38 AM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: how to use perl in windows



hi,

for writing perl programs,notepad is used.But what should be done to execute 
the programs?

Also,how can i take input from online databases?like,if i have to get a
gene sequence from Genbank,what command should i write in program?

thanx in advance,

aditi

Yahoo! India Matrimony: Find your partner online. 



RE: references and freeing memory

2004-06-04 Thread Tim Johnson

Yes and no.  From what I understand (and someone please correct me if
I'm wrong), the memory is freed in the sense that it is returned to
Perl, but it is not returned to your system.  Once there are no
references to a variable, the memory can be overwritten by future
variables used in your program, but cannot be used by other programs. 

-Original Message-
From: Freimuth,Robert [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 03, 2004 1:25 PM
To: [EMAIL PROTECTED]
Subject: references and freeing memory

Hi all,

The perlref docs state "Hard references are smart--they keep track of
reference counts for you, automatically freeing the thing referred to
when its reference count goes to zero."  My interpretation of this is
that when a reference goes out of scope the memory used by the referent
is freed.  





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: printing contents between lines

2004-06-03 Thread Tim Johnson
 

Here's another way to do it, and the nice thing about this way is that
you can reuse the sub later.  This subroutine will print every line
starting after the $start phrase and until it finds the $end phrase.



###

PrintSection("myfile.txt","tools:","not a target:") || die "Couldn't
find a match!\n";

sub PrintSection{
my ($file,$start,$end) = @_[0..2];
my $print = 0;
open(TARGET,"$file") || return 0;
while(){
if($_ =~ /$start/i){
$print = 1;
next;
}
if($_ =~ /$end/i){
return 1;
}
if($print){
print $_;
}
}
close TARGET;
return 1;
}

###








-Original Message-
From: Sidharth [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 03, 2004 12:44 PM
To: [EMAIL PROTECTED]
Subject: printing contents between lines 

hi all ,
 consider the contentes of file as below




how  to  print  all the line between  tools:   and  # Not a target:
only



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: appending to a file

2004-05-27 Thread Tim Johnson

To append to a file, you must open() the file, like so:

open(OUTFILE,">>myfile.txt") || die "Could not open myfile.txt
for appending!\n";

Then when you want to write to the file, use print(), like so:

print OUTFILE "The text I want to add to the end of my file\n";





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 27, 2004 3:29 PM
To: [EMAIL PROTECTED]
Subject: appending to a file

more help please!  I looked through my Learning Perl book and only see
code >>filename for appending to a file.  Here is my code but it is not
writing to STDOUT designated as my file.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: recording the position of m// searches

2004-05-13 Thread Tim Johnson

Two thoughts here:

1) The $. Variable has the line number of the file you are iterating
through, so you could use that combined with pos()

2) You could also try something like this:

while(){
   if($_ =~ /.{20}$pattern.{20}/){
  push(@found,$1);
   }
}






-Original Message-
From: Tim & Kylie Duke [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 13, 2004 12:17 AM
To: Beginners perl
Subject: recording the position of m// searches

-

So I am thinking, use m//g to search, then push the found locations onto
a list, then come back, printing out parts of the text file based on the
search positions in the list, and use a context of 20 characters on
either side.

The pos() function within a m//g loop seems to return the position
within the line, not the position within the file.  Is there a different
function to return the absolute position in the file, which I could then
use later on as a basis for (very roughly)
for each sort(@found_locations)
 print text from $position - 20 to $position +20

--

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: How to find files in subdirectory

2004-05-12 Thread Tim Johnson

Check the documentation for the File::Find module.  It comes standard
with most Perl distributions. 

-Original Message-
From: LK Tee [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 12, 2004 6:52 PM
To: '[EMAIL PROTECTED]'
Subject: How to find files in subdirectory

Hi, I'm perls beginner now, I have a problem when create a script find
all file in subdirectory that have the same filename. How I write the
script using perl and return the result like below:

 

File1: ~/A/File~/A/AA/file1   ~/A/C/CC/CCC/file

 

Kuan.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: how to install perl

2004-05-06 Thread Tim Johnson
No, he's saying that the tabs are the same for Windows 2000 and XP.

  _  

From: Lino Iozzo [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 06, 2004 11:20 AM
To: Ned Cunningham; Tim Johnson; BeginnerPerl
Subject: RE: how to install perl


i am sorry i don't understand your comment.  Are you saying it is
advanced don't bother?
 
Lino

Ned Cunningham <[EMAIL PROTECTED]> wrote:

It is advanced, environment, system variables on win2000 also :)


HTH

Ned Cunningham
POS Systems Development
Monro Muffler Brake
200 Holleder Parkway
Rochester, NY 14615
(585) 647-6400 ext. 310
[EMAIL PROTECTED]

"There are two ways of constructing a software design; one way
is to make it so simple that there are obviously no deficiencies, and
the other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult." 

-Original Message-
From: Tim Johnson [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 06, 2004 1:54 PM
To: Lino Iozzo; BeginnerPerl
Subject: RE: how to install perl


If you have to type "perl command.pl" at the command-line, then
you
probably don't have your Perl install path in your system's PATH
variable. Try this:
1. Right-click on My Computer and select Properties.
2. On the Advanced Tab, click the Environment Variables button.
3. In the system variables, find PATH.
4. Append C:\Perl\bin to the path variable and save.
5. Any open programs will be updated with the current
environment, but
if you have any console windows open you will have to close and
re-open
them.

Note: I did this on WinXP, you may have to use the Performance
Tab or
button on Windows 2000 instead of Advanced, I think. I don't
have one
here to check on.

-Original Message-
From: Lino Iozzo [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 06, 2004 10:39 AM
To: BeginnerPerl
Subject: how to install perl

-

I have also downloaded activestate's perl. But I find it
frustrating
that i have to type perl command.pl at the command line.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
additional commands, e-mail: [EMAIL PROTECTED]






RE: how to install perl

2004-05-06 Thread Tim Johnson

If you have to type "perl command.pl" at the command-line, then you
probably don't have your Perl install path in your system's PATH
variable.  Try this:

1. Right-click on My Computer and select Properties.
2. On the Advanced Tab, click the Environment Variables button.
3. In the system variables, find PATH.
4. Append C:\Perl\bin to the path variable and save.
5. Any open programs will be updated with the current environment, but
if you have any console windows open you will have to close and re-open
them.

Note:  I did this on WinXP, you may have to use the Performance Tab or
button on Windows 2000 instead of Advanced, I think.  I don't have one
here to check on.

-Original Message-
From: Lino Iozzo [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 06, 2004 10:39 AM
To: BeginnerPerl
Subject: how to install perl

-
 
I have also downloaded activestate's perl.  But I find it frustrating
that i have to type perl command.pl at the command line.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: how do you install perl on windows 2000

2004-05-06 Thread Tim Johnson
Your original question was how to install perl on Windows 2000.  The most common 
problem that I see with Windows users and installing is figuring out how to install.  
Many of the resources out there on the Internet are Unix/Linux-centric and go on about 
compiling the source, and Windows does not come with a built-in C compiler.  
Activestate puts their install in a MSI file so that users can install it the way they 
install any other program, like putting it into an RPM file for Red Hat.  One of the 
things the install does for you is to set up the file associations for .pl files so 
that you don't have to type "perl perlscript.pl" when you run a script.  There is 
always the offchance that there could be a problem creating the file association, but 
then you run into the next great thing about ActivePerl.   There are 
ActivePerl-specific mailing lists and support mailboxes you can use to resolve your 
issue.
 
The reason why it doesn't act like Unix has nothing to do with Perl.  It isn't Unix.  
It's Windows.  But if you want to simulate your Unix development environment and have 
access to Perl the same way you would on your other systems, try downloading Cygwin.  
It's free, and the last time I checked it works very well.  Otherwise you're free to 
use the shebang line, but Perl will ignore it except to pick up the parameters like -w.
 

-Original Message- 
From: lino_iozzo [mailto:[EMAIL PROTECTED] 
Sent: Thu 5/6/2004 2:51 AM 
To: Tim Johnson 
Cc: 
Subject: RE: how do you install perl on windows 2000



in my file i have #!/usr/local/bin/perl -w

so why do i need to type at the command prompt:

perl filename.pl?

what does this mean: with the file associations already set up in a convenient 
MSI file.

yes you are correct it does work but not the same way it does at work on a 
unix system.

The most frustrating part is that it is just not clear...it is very different 
and I can't figure it out.

Please help further.

Thank you,

Lino




RE: how do you install perl on windows 2000

2004-05-05 Thread Tim Johnson
Go to www.activestate.com and download ActivePerl.  It is the de facto standard for 
Win32 Perl (closely followed by Cygwin).  You will have a fully functional Perl 
install with the file associations already set up in a convenient MSI file.

-Original Message- 
From: lino_iozzo [mailto:[EMAIL PROTECTED] 
Sent: Wed 5/5/2004 7:54 PM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: how do you install perl on windows 2000



Hello,

I downloaded Perl 5.8 how do i get it to work on the windows
environment?

It appears to be quite confusing...please be as specific as possible.

thanks,

Lino




RE: Quick Perl on Windows Newbie Questions

2004-05-05 Thread Tim Johnson
 
See answers below.

-Original Message-
From: JupiterHost.Net [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 05, 2004 12:30 PM
To: [EMAIL PROTECTED]
Subject: Quick Perl on Windows Newbie Questions

Hello ActiveState ActivePerl users (any on this list?) :)

I have a couple quick questions for you Windows users...

Is ActivePerl automatically set to execute .pl files if doubleclicked?
  If not how do you set that up?
[ANSWER] Yes, the file associations are set up by default.

To run it via DOS all you need to do is run "c:\> perl
path\to\script.pl" correct?
  If not how do you do that?
[ANSWER] I assume by DOS you mean the command-line interface.  You
should be able to just type 'script.pl' on the command-line to launch
the program, but that will also work.

TIA

Lee.M - JupiterHost.Net

--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] 





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: [ Hash of Arrays]

2004-05-05 Thread Tim Johnson
 
Which brings up a good point.  The OP should be using 

use strict;
use warnings;

As a prerequisite to submitting a post.  Many times this will keep you
from making these kinds of mistakes, and save the time of waiting for a
response.



-Original Message-
From: JupiterHost.Net [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 05, 2004 5:36 AM
To: [EMAIL PROTECTED]
Subject: Re: [ Hash of Arrays]



If you want it to be a hash ref you need
  my $ModelPath = { ... };
and if you want it to be a hash you'd need to use () instead of {}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: [ Hash of Arrays]

2004-05-04 Thread Tim Johnson
 
Oops!  That last line should be:

   my @tempArray = @{$_};

-Original Message-
From: Tim Johnson 
Sent: Tuesday, May 04, 2004 10:36 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: [ Hash of Arrays]

 
I think you might actually want an array of arrays (list of lists,
etc.).  Then you can just do something like this:

push @BigArray,[EMAIL PROTECTED];

And then when you're done, you can do something like this:

foreach(@BigArray){
   my $temp = $_->[0];
   my @tempArray = @{$temp};
}


-

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




RE: [ Hash of Arrays]

2004-05-04 Thread Tim Johnson
 
I think you might actually want an array of arrays (list of lists,
etc.).  Then you can just do something like this:

push @BigArray,[EMAIL PROTECTED];

And then when you're done, you can do something like this:

foreach(@BigArray){
   my $temp = $_->[0];
   my @tempArray = @{$temp};
}


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 04, 2004 10:22 PM
To: [EMAIL PROTECTED]
Subject: RE: [ Hash of Arrays]

---

Also is there a better way to define a hash when I already have existing
arrays rather than defining the hash for every individual key and array.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: [ Hash of Arrays]

2004-05-04 Thread Tim Johnson


First I'll show you ONE of the right ways:



use strict;
use warnings;

#declare the arrays
my @one = ("abc", "def");
my @two = ("ABC", "DEF");

#initialize the hash (note the parens)
my %ModelPath = ();

#add the arrays to the hash
$ModelPath{1} = [EMAIL PROTECTED];
$ModelPath{2} = [EMAIL PROTECTED];

#retrieve the values and assign to
[EMAIL PROTECTED] by dereferencing the hash key
my @temp = @{$ModelPath{1}};

#retrieve just one value
my $temp2 = $ModelPath{1}->[0];
 
#

You have to remember that when you add an array via a structure like
this:

$ModelPath{1} = [EMAIL PROTECTED];

Or

$ModelPath{1} = [EMAIL PROTECTED];

You are assigning a SCALAR REFERENCE to the hash key, not the array
itself (although there is some magic there that can be used sometimes).
Therefore, you must treat the hash key the same way you would any other
reference, not as if it was an array by itself.  Sometimes it's easier
to do this:

#assign the reference to a temp variable
my $temp = $ModelPath{1};

#retrieve the first element
my $firstElement = $temp->[0];

#dereference the array and assign to a new array
my @fullArray = @{$temp};





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 04, 2004 9:58 PM
To: [EMAIL PROTECTED]
Subject: [ Hash of Arrays]

---

For eg. I have two arrays.

my @one = ("abc", "def");

my @two = ("ABC", "DEF");

Now I will initialize a hash in the following way.

my %ModelPath = {};

$ModelPath{"1"} = [EMAIL PROTECTED];

$ModelPath{"2"} = [EMAIL PROTECTED];

---

When I retrieve the value from hash I have to do in the following way,
if I am not wrong.

my @temp = $ ModelPath{"1"}; #but here the temp[0] contains the whole
array "one" rather than individual "$one[0]".

---

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




OT: RE: Security Question

2004-04-26 Thread Tim Johnson
 
I think this is off-topic for this list.  It's more of a cryptography
question than a Perl question (and it's not even really a question).


-Original Message-
From: Jenda Krynicky [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 26, 2004 3:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Security Question



> Please, decode this key:
> 
> SxEyj/gJs5pXISX11386025

I don't think I understand. What is this supposed to mean?



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Who is running my program?

2004-04-11 Thread Tim Johnson

If you are on a Win32 system, you can check the $ENV{USERNAME} value. 

-Original Message-
From: Chance Ervin [mailto:[EMAIL PROTECTED] 
Sent: Saturday, April 10, 2004 5:07 PM
To: beginners
Subject: Who is running my program?

I am writing a perl program to access client information for reading,
writing, and updating.

I only want superuser to be able to do the writes and updates, though,
while all other accepted gpg users can read the information.

Is there an easy way to check which user is running your scripts?

Thank you.

--Chance


--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] 





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Getting into programming with perl.

2004-04-08 Thread Tim Johnson

There have been many threads on this discussion, so if you want a good
list, try doing a search on google groups. 

-Original Message-
From: Flemming Greve Skovengaard [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 08, 2004 9:06 AM
To: Leke Lapinkangas; [EMAIL PROTECTED]
Subject: Re: Getting into programming with perl.

Leke Lapinkangas wrote:
> Hi, Can anyone recommend books which might be useful to somebody who 
> has never programmed in any language before? Though something linked 
> in with perl would be an advantage.
> Thanks,
> Leke
> 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: illegal octal digit '8'?

2004-04-02 Thread Tim Johnson

Just another suggestion on how you might accomplish the same thing: 

##

my @months = qw(XXX JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC);

return $months[$tmp]

##





-Original Message-
From: Charlotte Hee [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 02, 2004 4:45 PM
To: [EMAIL PROTECTED]
Subject: illegal octal digit '8'?




if ( $tmp == 01 ){ $xmon = 'JAN'; }
if ( $tmp == 02 ){ $xmon = 'FEB'; }
if ( $tmp == 03 ){ $xmon = 'MAR'; }
if ( $tmp == 04 ){ $xmon = 'APR'; }
if ( $tmp == 05 ){ $xmon = 'MAY'; }
if ( $tmp == 06 ){ $xmon = 'JUN'; }
if ( $tmp == 07 ){ $xmon = 'JUL'; }
if ( $tmp == 08 ){ $xmon = 'AUG'; }  #<-- illegal error
if ( $tmp == 09 ){ $xmon = 'SEP'; }  #<-- illegal error
if ( $tmp == 10 ){ $xmon = 'OCT'; }
if ( $tmp == 11 ){ $xmon = 'NOV'; }
if ( $tmp == 12 ){ $xmon = 'DEC'; }

}

return $xmon;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: directory operations

2004-04-01 Thread Tim Johnson
If you did want to filter based on a regular expression, you can always do it the long 
way:
 
opendir(DIR,".") || die;
my @file_list = readdir(DIR);
foreach my $file(@file_list){
 if(-f $file && ($file =~ /Place Regex Here/)){
  #do something...
 }
}
 
You get the general idea.  Also, if you want to do a recursive search, look into the 
standard File::Find module.
 

-Original Message- 
From: Randy W. Sims [mailto:[EMAIL PROTECTED] 
Sent: Thu 4/1/2004 2:02 AM 
To: MuthuKumar 
Cc: [EMAIL PROTECTED] 
Subject: Re: directory operations



[snip]



> my @file_list = 
> foreach $file (@file_list){
> file loop
> .
> close(file-handle);
> }
>
> I have checked like this.. i did not get any response at all..
> No files are stored in the array too. what is wrong with this.. and how to
> accomplish this.

my @file_list = <*.txt>;





RE: What is happening here

2004-03-29 Thread Tim Johnson
Apparently (++$count) evaluates to 0, but I can't figure out why.  So the second 
expression is evaluated first.  From there it's pretty self-explanatory.  (++$count) 
will always evaluate to TRUE, since it will only get higher, and the first expression 
is evaluated.
 
Maybe someone can enlighten us to some of the lesser known properties of the -- and ++ 
operators?  It's definitely counterintuitive.
 

-Original Message- 
From: WC -Sx- Jones [mailto:[EMAIL PROTECTED] 
Sent: Mon 3/29/2004 9:01 PM 
To: '[EMAIL PROTECTED]' 
Cc: 
Subject: What is happening here



What is happening here -

#! /usr/bin/perl
use strict;
use warnings;

my $count;

while(1) {
   (++$count) ? $count += $count-- : $count += $count++;

   print "$count\n"; exit if $count > 60_000;
   sleep 1;
}

__END__
-Sx-




RE: importing to excel file..

2004-03-18 Thread Tim Johnson

That depends.  You can definitely make an excel file using Perl (see the
docs for Win32::OLE for a small example), or for the quick and dirty
route you can either:

A) Create a comma-separated-values file

Or

B) Create a tab-separated-values file

And then you can just open it in Excel later.


 

-Original Message-
From: Hiremath Arun [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 17, 2004 10:22 PM
To: [EMAIL PROTECTED]
Subject: importing to excel file..

hi

 Anyone help me in importing data from a text file in to a excel..



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: CMD Install Doesn't Work

2004-03-11 Thread Tim Johnson

 You need to invoke PPM first.

C:\> PPM

PPM> install Win32-My-Module

...

-Original Message-
From: KENNETH JANUSZ [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 11, 2004 9:21 AM
To: PERL Beginners
Subject: CMD Install Doesn't Work


I tried Start -> Run -> CMD

This is what I got.  Install is not recognized as a command.  I also
tried running COMMAND with the same results.
Any idea what the problem is?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Disable Screensaver with Keyboard input

2004-03-05 Thread Tim Johnson

Check out the Win32::SetupSup module.  It will allow you to send
keystrokes to the console.

 

-Original Message-
From: Stefan Lubitz [mailto:[EMAIL PROTECTED] 
Sent: Friday, March 05, 2004 4:16 AM
To: [EMAIL PROTECTED]
Subject: Disable Screensaver with Keyboard input

Hi there,
 


Now I thought, that I could write a small Perl Script, which is turning
on and off the Scrolllock Key, means "simulating" a Keyboard input.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Threads in Perl

2004-03-02 Thread Tim Johnson

Can anyone give me a quick hint as to where to find documentation on how
to use threads w/Perl?  

I understand that it's one of the main differences between 5.8.x and
5.6.x, but I'm having trouble finding docs on it.  I get back way too
many irrelevant results when I google, etc.


RE: WIN2K Active Directory qtn. execute system command with login script.

2004-03-01 Thread Tim Johnson

Make sure you import the in function from the Win32::OLE module, then
you can do something like this:

###

use strict;
use warnings;
use Win32::OLE qw(in);

my $obj = Win32::OLE->GetObject("LDAP://server/OU=MyOU,DC=company,DC=com
") || die;
$obj->{Filter} = ["User"];
foreach( in($obj) ){
  print "$_->{sAMAccountName}\n";
}

###

It's unfortunate that there aren't more code samples out there, because
it's really pretty easy once you know how.

-Original Message-
From: Ronen Kfir [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 01, 2004 2:50 AM
To: [EMAIL PROTECTED]
Subject: WIN2K Active Directory qtn. execute system command with login
script.

Hi,
I have a command line tool (tscmd), which works fine on single user. My
goal is to change TS profile for Organization Unit user. I want to put a
login script inside a GPO of this OU in order to do it.
What I miss is how to create the array of users included in this
Organization Unit, so I can run on this list with my command through
foreach loop.
Please help!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: 1 liner question

2004-02-25 Thread Tim Johnson

That's not really a one-liner, that's just a script with the whitespace
taken out.  Just my opinion, but I thought the whole point to one-liners
was to try to reduce a complex operation to its most compact form so
that you could just type it at the command-line when you needed it
quickly.  If you really want to do it that way, then you should just put
the whitespace back in, get the script to work, and then take it out
again.

Really, though, one-liners are for the most part beyond the scope of a
beginners list.
 


-Original Message-
From: chad kellerman [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 25, 2004 11:29 AM
To: '[EMAIL PROTECTED]'
Subject: 1 liner question

Hello everyone...

I am working on a perl one liner for adding quota on multiple
partitions.  But I can not, for the life of me get the number to add
up..


Here is what I have:

/usr/bin/quota michele | perl -ne 'if(/none$/){print
"9\n"}elsif(m:^\s+/dev/:){($q,
$l)=(split(/\s+/))[2,3];$t=($l-$q)*1024};next if(!$t);{print $t."\n"}'

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: regular expression that doesn't match any string

2004-02-25 Thread Tim Johnson
I believe the '.' character does not have the same special meaning within a character 
class, and that's why it isn't matching what you think it does.  You should check out 
the YAPE::Regex::Explain module.  It's great for debugging regular expressions.

-Original Message- 
From: Ãznur Tastan [mailto:[EMAIL PROTECTED] 
Sent: Tue 2/24/2004 11:56 PM 
To: Perl Lists 
Cc: 
Subject: regular expression that doesn't match any string



Hi all
Just for fun (really no context) i was wondering how to create regular
expressions that
will never match any string.

/^[^\w\W]/ is one of them am I right? No string can start with a character
that is neither alphanumeric nor  nonalhanumeric.

But why does
/^[^.\n]/ matches .
doesn't that mean the string should begin a character that is not  any
character or not a newline(nothing else should be left).

Could someone enligthen me?
Below is to code I use to check.
thanks
oznur

use strict;
use warnings;

my $string="does it match";

if ($string=~/(^[^\w\W])/){
  print "matches $1\n";
}
else  {
  print "doesn't match \n";
}

if ($string=~/(^[^.\n])/){
   print "matches $1\n";
}
else  {
   print "doesn't match \n";
}

- Original Message -
From: "R. Joseph Newton" <[EMAIL PROTECTED]>
To: "Ãznur Tastan" <[EMAIL PROTECTED]>
Cc: "'Perl Lists'" <[EMAIL PROTECTED]>
Sent: Wednesday, February 25, 2004 9:09 AM
Subject: Re: how to push a double dimensional array


> Ãznur Tastan wrote:
>
>
> > Well actually storing the examples doesn't need the information for the
> > alignment but
> > if you are interested.
> > Pairwise sequence alignment is a widely used terms to visualize the
> > similarity of protein or DNA
> > sequences. So the characters denotes the aminoacids(or nucleotides in
DNAs)
> > and the conservation substitutions or deletions of  give clues about
> > biological meanings actualy predict the evolution at that site of the
> > protein.
> > Substitution scoring matrices which are mostly based on frequency
analysis
> > are used to align the alignments. These are matrices that tell how
similiar
> > one aminoacid to another so to say how it is likely to be replaced by
the
> > other aminoacid. so Aligning L with L will have positive score that you
can
> > get from the scoring matrice entry yet the gaps will be penalized
although
> > mismatches will be penalized.
> > The alignment is obtained by using a dynamic programing appraach,
> > Needleman-Wunch algorithm.
> > The score is the sum of the score of aligning each character.
> >
> > >
> > > I await the conclusion and enlightment as this thread has proven
> > > interesting.  :)
> > >
> > > Thx/Sx
>
> Okay.  This is getting a bit more clear.  Can you always count on being
able to
> express the score as an integer?  If so, this can be pretty
straightforward, but
> there will be a Perl learning curve.  It sounds to me like you really need
a
> class for these alignments.  The meaning of their internal data is very
specific
> to this context.  You could use a hash for any particular alignment, of
course,
> but then you are re-doing the work with each one.  You class could start
out as
> simple as the structs you were seeking earlier.  Perlis very liberal [too
> liberal IMHO] about access to data members of its objects.  So your
package
> could start out as simple as:
>
> package SequenceAlignment;
>
> use strict;
> use warnings;
>
> use Exporter;
>
> my @ISA = Exporter;
>
> sub new {
>my $class = shift;
>my ($sequence1, $sequence2, $alignment_score) = @_;
>
>my $self = {
>   'base sequence'  => $sequence1,
>   comparison sequence' => $sequence2,
>   'alignment score'=> $alignment_score
>}
>
>bless $self, $class;
>return $self;
> }
>
> Even without any methods defined, this at least gives you a framework for
> storing the alignments.  Since you obviously have some fairly specific
> operations relating to them, you will want to create some methods to
ma

RE: Searching through a directory.

2004-02-13 Thread Tim Johnson

I know this doesn't actually answer your initial question, but you
should try using the File::Find module.  It's one of the standard
modules that comes with just about any distribution.

'perldoc File::Find'  should give you more information.




-Original Message-
From: John Lin [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 13, 2004 5:07 PM
To: [EMAIL PROTECTED]
Subject: Searching through a directory.

Hi List,

This is probably a really simple question, but I need some help with
this.
Basically,  I am searching through a directory and if something matches
what I am looking for, then save that filename to a text file.  

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Perl Executable

2004-02-10 Thread Tim Johnson

Why not just do it from your shell?

'path/to/perl scriptname' works quite nicely, so why not just make an
alias for the path to perl?


-Original Message-
From: Jeffery Malloch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 10, 2004 11:08 AM
To: '[EMAIL PROTECTED]'
Subject: Perl Executable

> #!/usr/bin/perl
> 
> Is there a way of setting the path used to some variable and use it 
> like
> this:
> 
> #!$PERL

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Reg. string matching using reg-exp

2004-02-06 Thread Tim Johnson
Use the 's' option at the end of your regex after the closing '/'.
 
$var =~ /match\nsomething\nelse/s;
 
read 'perldoc perlre' for more about regexes.
 
Also, please reply to the list next time, because I might not be at my
desk or able to reply, and someone  else probably will.


  _  

From: Balaji Thoguluva [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 06, 2004 12:07 PM
To: Tim Johnson
Subject: RE: Reg. string matching using reg-exp


Thanks Tim Johnson. I removed the /r/n from the reg-ex and it works. I
have another question. How to assign a multiline string or string having
many lines(strings having \n) to a $string-variable?. In C, there is a
"\" operator.
 
Thanks for your help,
Balaji
 


RE: Reg. string matching using reg-exp

2004-02-06 Thread Tim Johnson

It looks like there is no '\r\n' at the end of $line.



 

-Original Message-
From: Balaji Thoguluva [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 06, 2004 11:45 AM
To: [EMAIL PROTECTED]
Subject: Reg. string matching using reg-exp


 
#!/usr/bin/perl -w
my $line= 'INVITE sip:[EMAIL PROTECTED] SIP/2.0'; if($line =~
/^\s*(\w+)\s*(.*)\s+(sip\/\d+\.\d+)\s*\r\n/i)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: * CSV to HTML * zero reads as empty space

2004-02-05 Thread Tim Johnson

We might need a little code if we're going to help.  As far as I know there are no 
CSV-HTML gotchas that would do this, so it's probably your algorithm.  Are you doing 
something like this?

if($my_var){
   print $my_var;
}

that would print nothing if the value was a zero, because zero evaluates to FALSE.

-Original Message-
From: Gregg O'Donnell [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 05, 2004 8:38 AM
To: [EMAIL PROTECTED]
Subject: * CSV to HTML * zero reads as empty space


I have a script that reads a CSV file into an HTML template. The template reads the 
CSV data accurately unless the field shows zero, in which case the HTML page displays 
a blank space. Any suggesstions? Thanks!


-
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Using compression on Win32 systems

2004-02-05 Thread Tim Johnson

Try looking for Archive::Zip




-Original Message-
From: Ned Cunningham [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 05, 2004 8:35 AM
To: Paul Kraus; [EMAIL PROTECTED]
Subject: RE: Using compression on Win32 systems


Yes,
I have looked and googled and searched aspn.

Have not been able to find an example.


Ned Cunningham
POS Systems Development
Monro Muffler Brake
200 Holleder Parkway
Rochester, NY 14615
(585) 647-6400 ext. 310
[EMAIL PROTECTED]

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




  1   2   3   >