Rename "File" to "File$date"

2002-09-12 Thread Kauffmann, Andreas

Hy everybody in the List!

I have a Problem writing a little perl application...

Im a very newbie to programming and need your help :)


The Problem is:

I have a file "dev.txt" and I want to rename it once a day (with a cronjob) like 
"dev13092002.txt"

So i need to rename it with a date variable.

All I have at the moment is:

#!/usr/bin/perl
$d = `date`;
$d = /pattern1(pattern2)/;
sytem("cp test.txt test`$d`.txt");


Does anyone of you know how to do that?


THANKS in advance!


| Telematikzentrum Dürrwangen GmbH & Co. KG |
| Im Schloss Dürrrwangen|
|   |
| Andreas Kauffmann |
| Tel: 09856/979 48-0   | Fax: -19  |
| [EMAIL PROTECTED]|
|   |
PS: Besuchen Sie uns doch mal im Web!
 
> http://www.tzdan.de <
 
Jetzt im neuen Design!


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




RE: replace

2002-09-12 Thread Timothy Johnson


How about this?  

$tmpview1 =~ s/\\//g;

-Original Message-
From: Javeed SAR [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 11:03 PM
To: [EMAIL PROTECTED]
Subject: replace



Hi,

I have \\blrk35ed\views\test_merge.vws in a variable $tmpview1 

How to replace \\blrk35ed\views\test_merge.vws with
blrk35ed\\views\\test_merge1.vws


TIA

jav


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




Re: Regular expression

2002-09-12 Thread nyec

On Thursday 12 September 2002 08:11 pm, Javeed SAR wrote:
> I have a statement as follows;
> I need to split them into 3 parts;
>
> * test_merge1  \\blrk35ed\views\test_merge1.vws
>
>
> LIke this:
> $var1 should have *
> $var2 should have test_merge1
> $var3 should have  \\blrk35ed\views\test_merge1.vws
>
>
>
> TIA
>
> Jav

Here's what I came up with. I had a bit of trouble with the leading '\\' on 
the path. Using /\s+\ in 'split' causes the the first '\' to be dropped. It's 
acting like a special character escape. So, after the split I put the leading 
'\' back in. 
Perhaps someone has a more efficient method of keeping the double backslashes 
during the 'split'. Hope this helps.

nyec

# begin 
my $string = '* test_merge1 \\blrk35ed\views\test_merge1.vws';
my ($var1, $var2, $var3) = split/\s+/,$string;

$var3 =~ s/^\\//g;  #puts the double quote back in front

print "var1 is: $var1\n";
print "var2 is: $var2\n";
print "var3 is: $var3\n";

__END__

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




Packaging my perl program

2002-09-12 Thread Rum Pel



I have written a perl program which I want to give to my
friends to try out. But the program uses a few libraries
that are normally not installed by default. So how do I
ship my program? What is the general way of doing this?

In java, when I give my program I also give the libraries
ie., the jar files. and one just has to make sure he has
them in the classpath while running my java program.

But with perl, it seems one has to "install" the libraries
before he can use them.

can somebody help me what I should be doing? How do other
deal with this issue?

thanks
--rp

_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


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




replace

2002-09-12 Thread Javeed SAR


Hi,

I have \\blrk35ed\views\test_merge.vws in a variable $tmpview1 

How to replace \\blrk35ed\views\test_merge.vws with
blrk35ed\\views\\test_merge1.vws


TIA

jav




Re: Regular expression

2002-09-12 Thread John W. Krahn

Javeed Sar wrote:
> 
> I have a statement as follows;
> I need to split them into 3 parts;
> 
> * test_merge1  \\blrk35ed\views\test_merge1.vws
> 
> LIke this:
> $var1 should have *
> $var2 should have test_merge1
> $var3 should have  \\blrk35ed\views\test_merge1.vws


$_ = '* test_merge1  \\blrk35ed\views\test_merge1.vws';
my ( $var1, $var2, $var3 ) = split;

# OR using an explicit variable

my $string = '* test_merge1  \\blrk35ed\views\test_merge1.vws';
my ( $var1, $var2, $var3 ) = split ' ', $string;



John
-- 
use Perl;
program
fulfillment

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




Re: Mod Installations -- as non root

2002-09-12 Thread Michael Fowler

On Thu, Sep 12, 2002 at 04:30:12PM -0700, Jeff wrote:
> I want to install some mods on my Unix system but don't have root access. 
> Is there a way to do a local installation (ie, under my home directory)??? 
> Seems you have to be root since there is some linking to the system
> libraries.

Yes, see perldoc -q 'my own module'.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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




Re: Regular expression

2002-09-12 Thread George P.


On Fri, 13 Sep 2002, Javeed SAR wrote:

>
>
> I have a statement as follows;
> I need to split them into 3 parts;
>
> * test_merge1  \\blrk35ed\views\test_merge1.vws
>
>
> LIke this:
> $var1 should have *
> $var2 should have test_merge1
> $var3 should have  \\blrk35ed\views\test_merge1.vws
>

I guess this should do the trick.

$str = '* test_merge1  \\blrk35ed\views\test_merge1.vws';
my ($var1, $var2, $var3) = split(/\s+/, $str, 3);

George.


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




Converting IE 'Favorites' to other formats

2002-09-12 Thread Phil

I've been working on moving from Win2k to Linux and learning Perl 
at the same time, so I thought I'd kill two birds with one stone and 
write a Perl program to convert my IE bookmarks to Mozilla format.  
The meat of the code is at the end - comments and suggestions are 
more than welcome.

At any rate, the code works and I have my bookmarks in Mozilla.
However, I'm not completely happy with it.  The output is too 
closely tied to the input.  I'd like to rewrite it so that the 
output type could be specified - html, Mozilla, Galeon, etc. 
I'm not sure where to start, though.  I had thought of reading in
the favorites and storing it in a tree-type data structure, but
wasn't sure exactly how to do this or how to write a routine 
to walk the tree.  Any ideas or pointers to resources?

-Phil

code follows:

open(OUTFILE,">$outfile") || 
die "Couldn't open $outfile for writing: $!";

print_header(\*OUTFILE,$rootdir);
 
# Walk the directory tree and print the links 
print_favs(\*OUTFILE,$rootdir);

print_footer(\*OUTFILE);

# recursive function to walk the directory tree underneath
#   the directory passed in as a parameter.  First the directory
#   is opened, then a list of the files/folders is read into
#   an array, and then the array is split into a list of files and
#   a list of directories.  html links are output for the files
#   and the function is called again for each of the directories.
#   Stopping condition is when a directory is reached that has only
#   files, no sub-directories.   
sub print_favs {
   my $fh = $_[0];  # output file handle
   my $dir = $_[1]; # current directory
   my (@itemlist, @filelist, @dirlist);

   opendir(CURDIR, $dir) || die "Couldn't open $dir: $!\n";
   @itemlist = readdir(CURDIR);
   chdir($dir) || die "Couldn't chdir to $dir: $!\n";
  
   if ($dir ne $rootdir) {
   print $fh "$dir\n";
   print $fh "\n";
}
$foldernum++;
   
   foreach (@itemlist) {
  # print $fh "Item: $_\n";
  # Only process non-symbolic links
  if (!(-l $_)) {  
 if ((-d $_) && ($_ !~ /\.\.?/)) {
@dirlist = (@dirlist, $_);
 }
 elsif ((-f $_) && ($_ =~ /\.url$/i)) {
@filelist = (@filelist, $_);
 }
  } 
   }
   foreach (sort @filelist) {
  print $fh "".getlink($_)."\n";
   }
   foreach (sort @dirlist) {
  print_favs($fh,$_,$foldernum);
   }
   print $fh "\n";
   chdir("..");
}
  
# takes the name of a windows internet shortcut file (from 'Favorites')
#   opens the file and parses out the url it refers to.  The function 
#   returns an html link with the url as the href and the name of 
#   the file (without the .url file extension) as the label
sub getlink {
  my ($file, $line, $url, $name, $link); 
  $file = $_[0];
  open(URLFILE,$file) || die "Can't open $file: $!";
  while (defined($line=) && ($line !~ /^URL=/)) {
  }
  if (defined($line)) {
 chomp $line; 
 $url = substr($line,4);
 $url =~ s/\cM//;
 #print "URL:  $url\n";
 $name = $file; 
 $name =~ s/.+\///;
 $name =~ s/\.url//;
 #print "Name:  $name\n"; 
 $link = "$name";
 close(URLFILE);
 return $link;
   }
   else {
  return ""; 
   }
}



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




Re: Regular expression

2002-09-12 Thread Thanatos

Javeed SAR wrote:
> 
> I have a statement as follows;
> I need to split them into 3 parts;
> 
> * test_merge1  \\blrk35ed\views\test_merge1.vws
> 
> 
> LIke this:
> $var1 should have *
> $var2 should have test_merge1
> $var3 should have  \\blrk35ed\views\test_merge1.vws
> 
> 
> 
> TIA
> 
> Jav
> 
> 
> 

how about

$foo = '* test_merge1 \\blrk35ed\views\test_merge1.vws';
$foo =~ m/^(\*)\s+(\w+)\s+(\\.*)$/;

$1,$2,$3 are special variables. they equal whatever is matched between 
each set of () successivly.

$1 will be *
$2 will be test_merge1
$3 will be \blrk35ed\views\test_merge1.vws

Note, if you want $3 to have two \\ you will need to add one like this:

my $tmp = $3;
$tmp = "\\$tmp";

or just add another \ to your string .. \\\blrk35ed\views\test_merge1.vws

Hope that works for ya,
Thanatos

privided ofcourse that the spaces are actually spaces and not tabs .. if 
they are tabs, replace \s+ with \t+



Thanatos


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




Regular expression

2002-09-12 Thread Javeed SAR



I have a statement as follows;
I need to split them into 3 parts;

* test_merge1  \\blrk35ed\views\test_merge1.vws


LIke this:
$var1 should have *
$var2 should have test_merge1
$var3 should have  \\blrk35ed\views\test_merge1.vws



TIA

Jav





Re: Mod Installations -- as non root

2002-09-12 Thread Karl Kaufman

And once you've installed the modules, you'll need to either append your "personal 
library" to the 'PERL5LIB' environment variable or include the 'use lib' pragma in 
your program.

Karl
  - Original Message - 
  From: drieux 
  To: begin begin 
  Sent: Thursday, September 12, 2002 6:58 PM
  Subject: Re: Mod Installations -- as non root



  On Thursday, Sep 12, 2002, at 16:30 US/Pacific, Jeff wrote:

  > I want to install some mods on my Unix system but don't have root 
  > access.  Is there
  > a way to do a local installation (ie, under my home directory)???  
  > Seems you have to
  > be root since there is some linking to the system libraries.
  >
  > I've checked the documentation for perlmodinstall, but don't see the 
  > answer to this.
  >  Thanks in advance,

  the answer is to set a few basic variables when you
  are doing the

  perl Makefile.pl

  I have a script I use, see below so that I have it all
  nice and neatly set to put it in

  $HOME/lib/perl

  with the man pages installing in

  $HOME/man

  rather than having to remember that it would be

  perl Makefile.pl PREFIX=$HOME LIB=$HOME/lib/perl 



  ciao
  drieux

  ---

  ### #!/usr/bin/perl -w
  ### use strict;
  ### #
  ### #/home/drieux/bin/PerlInstall - you know to install stuff locally
  ### #
  ###
  ### my $prefix = $ENV{HOME};
  ### my $lib = "$prefix/lib/perl";
  ### my $man = "$prefix/man";
  ### my $cmdArgs = "PREFIX=$prefix LIB=$lib ";
  ### $cmdArgs .= " INSTALLMAN3DIR=$man/man3 INSTALLMAN1DIR=$man/man1";
  ###
  ### my $cmd = "perl Makefile.PL $cmdArgs";
  ###
  ### system("make clean");
  ###
  ###
  ### system($cmd);
  ### system("make test");
  ### system("make install");


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




Re: go to next file

2002-09-12 Thread Michael Fowler

On Thu, Sep 12, 2002 at 05:04:20PM -0700, Harry Putnam wrote:
> david <[EMAIL PROTECTED]> writes:
> 
> I must be a real dunce, but I still don't get the point.
> If a bad regex is given, I want the program to stop.
> 
> Your script above doesn't spit an error, it just fails and gives some
> other error.
> 
> cat chop2.pl
> #!/usr/local/bin/perl -w
> use strict;
> 
> my $reg = shift;
> 
> while(){
> chomp;
> eval{
> print "$_\n" if(/$reg/o);
> }
> print "ERROR: $@\n" if($@);
> }
> 
> ../chop2.pl '\' Mail/xfce/*
> $ ./chop2.pl '\'  ~/Mail/xfce/*
> syntax error at ./chop2.pl line 12, near "print"
> Execution of ./chop2.pl aborted due to compilation errors.

The original code does have a syntax error; there should be a ";" after the
eval:

#!/usr/local/bin/perl -w
use strict;
 
my $reg = shift;
 
while(){
chomp; 
eval{  
   print "$_\n" if(/$reg/o);
};
print "ERROR: $@\n" if($@);
 }

The original poster's point remains, however.  If you want the program to
stop if the regex compilation failes, do something else if $@:

if ($@) {
print "ERROR: $@\n";
exit(1);
}


I haven't been following this thread, so perhaps there is a reason for doing
this the way it's being done, but I would change the code to do something
more along the lines of:

#!/usr/bin/perl -w

use strict;


my $regex;
eval { $regex = qr/$ARGV[0]/ };
if ($@) { ... }
 
while () {
chomp;
print if /$regex/;
}

The functional difference is where and how the regex is checked for
validity.  Instead of checking its validity each time through the loop, it's
compiled and checked once, before entering the loop.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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




Re: go to next file

2002-09-12 Thread david

Harry Putnam wrote:

> david <[EMAIL PROTECTED]> writes:
> 
>> Harry Putnam wrote:
>>
>>> david <[EMAIL PROTECTED]> writes:
>>> 
>>> Won't is still quite even with the eval, in the above case?
 passing it to Perl
>>> 
>>> Can you give an example of this?
>>
>> no it doesn't. if you put it inside an eval{}, it won't quit. consider:
>>
>> #!/usr/bin/perl -w
>> use strict;
>>
>> my $reg = shift;
>>
>> while(){
>> chomp;
>> eval{
>> print "$_\n" if(/$reg/o);
>> }
>> print "ERROR: $@\n" if($@);
>> }
>>
>> __END__
> 
> I must be a real dunce, but I still don't get the point.
> If a bad regex is given, I want the program to stop.
> 

ok then, how about changing:

print "ERROR: $@\n" if($@);

to:

die("You probably supply a bad reg. in $reg. Aborted!\n") if($@);

david

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




Re: A better way to list variable names in report format?

2002-09-12 Thread chris

Thank you. Now I can quit the horizontal scrolling.

On Wed, 11 Sep 2002 20:52:59 -0400, [EMAIL PROTECTED] (Bob
Showalter) wrote:
>
>I know beans about formats, but perldoc perlform contains this statement:
>
>"The expressions may be spread out to more than one line if enclosed in
>braces.  If so, the opening brace must be the first token on the first
>line."
>


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




Re: go to next file

2002-09-12 Thread Harry Putnam

david <[EMAIL PROTECTED]> writes:

> Harry Putnam wrote:
>
>> david <[EMAIL PROTECTED]> writes:
>> 
>> Won't is still quite even with the eval, in the above case?
>>> passing it to Perl
>> 
>> Can you give an example of this?
>
> no it doesn't. if you put it inside an eval{}, it won't quit. consider:
>
> #!/usr/bin/perl -w
> use strict;
>
> my $reg = shift;
>
> while(){
> chomp;
> eval{
> print "$_\n" if(/$reg/o);
> }
> print "ERROR: $@\n" if($@);
> }
>
> __END__

I must be a real dunce, but I still don't get the point.
If a bad regex is given, I want the program to stop.

Your script above doesn't spit an error, it just fails and gives some
other error.

cat chop2.pl
#!/usr/local/bin/perl -w
use strict;

my $reg = shift;

while(){
chomp;
eval{
print "$_\n" if(/$reg/o);
}
print "ERROR: $@\n" if($@);
}

../chop2.pl '\' Mail/xfce/*
$ ./chop2.pl '\'  ~/Mail/xfce/*
syntax error at ./chop2.pl line 12, near "print"
Execution of ./chop2.pl aborted due to compilation errors.


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




Re: Mod Installations -- as non root

2002-09-12 Thread drieux


On Thursday, Sep 12, 2002, at 16:30 US/Pacific, Jeff wrote:

> I want to install some mods on my Unix system but don't have root 
> access.  Is there
> a way to do a local installation (ie, under my home directory)???  
> Seems you have to
> be root since there is some linking to the system libraries.
>
> I've checked the documentation for perlmodinstall, but don't see the 
> answer to this.
>  Thanks in advance,

the answer is to set a few basic variables when you
are doing the

perl Makefile.pl

I have a script I use, see below so that I have it all
nice and neatly set to put it in

$HOME/lib/perl

with the man pages installing in

$HOME/man

rather than having to remember that it would be

perl Makefile.pl PREFIX=$HOME LIB=$HOME/lib/perl 



ciao
drieux

---

### #!/usr/bin/perl -w
### use strict;
### #
### #/home/drieux/bin/PerlInstall - you know to install stuff locally
### #
###
### my $prefix = $ENV{HOME};
### my $lib = "$prefix/lib/perl";
### my $man = "$prefix/man";
### my $cmdArgs = "PREFIX=$prefix LIB=$lib ";
### $cmdArgs .= " INSTALLMAN3DIR=$man/man3 INSTALLMAN1DIR=$man/man1";
###
### my $cmd = "perl Makefile.PL $cmdArgs";
###
### system("make clean");
###
###
### system($cmd);
### system("make test");
### system("make install");


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




Mod Installations -- as non root

2002-09-12 Thread Jeff

I want to install some mods on my Unix system but don't have root access.  Is there
a way to do a local installation (ie, under my home directory)???  Seems you have to
be root since there is some linking to the system libraries.

I've checked the documentation for perlmodinstall, but don't see the answer to this.
 Thanks in advance,


Jeff

__
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

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




Re: file seek anomolies

2002-09-12 Thread david

Zentara wrote:

> Hi,
> I'm losing my patience with this one.
> Can anyone tell me why in the following script,
> the second printout, is missing the first line?
> Why dosn't the second file seek reset the filehandle?
> 
> #!/usr/bin/perl -w
> use strict;
> 
> my $file = 'test.txt';
> my $buffer;
> 
> open(FILE, "+<", $file) or die "Couldn't open $file: $!\n";
> 
> seek (FILE,0,0);
> my @lines = ();
> print "@lines\n"; #this prints fine
> 
> seek (FILE,0,0);
> while (){read (FILE, $buffer, 1024);
>   print "$buffer\n"; #this omits the first line
>  }
> close FILE;
> exit  0;
> ##
> 

that's because you discarded. the second seek() does reset the file pointer 
back to the beginning of your file but you then have:

while(){
read(FILE,$buffer,1024);
print "$buffer\n";
}

the '' reads a line from FILE but your are not using it. you then read 
another K with 'read(FILE,$buffer,1024)' and then prints it. as you can 
see, your '' discard the first line! that's why you won't see the 
first line from your output. if you were to:

while(read(FILE,$buffer,1024) > 0){
print "$buffer\n";
}

you should see the first line as well.

david





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




file seek anomolies

2002-09-12 Thread zentara

Hi,
I'm losing my patience with this one.
Can anyone tell me why in the following script,
the second printout, is missing the first line?
Why dosn't the second file seek reset the filehandle?

#!/usr/bin/perl -w
use strict;

my $file = 'test.txt';
my $buffer;

open(FILE, "+<", $file) or die "Couldn't open $file: $!\n";

seek (FILE,0,0);
my @lines = ();
print "@lines\n"; #this prints fine

seek (FILE,0,0);
while (){read (FILE, $buffer, 1024);
  print "$buffer\n"; #this omits the first line
 }
close FILE;
exit  0;
##

test.txt
##
# Bail out if the file is empty
die "No passwords in $passwords\n" unless $count;
my $key = 1 + int rand $count;
my $password;
# Localised in-place edit
{
local $^I = '';
local @ARGV = $passwords;
ZZ
###


my output:

# Bail out if the file is empty
 die "No passwords in $passwords\n" unless $count;
 my $key = 1 + int rand $count;
 my $password;
 # Localised in-place edit
 {
 local $^I = '';
 local @ARGV = $passwords;
 ZZ
die "No passwords in $passwords\n" unless $count;
my $key = 1 + int rand $count;
my $password;
# Localised in-place edit
{
local $^I = '';
local @ARGV = $passwords;
ZZ




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




Re: go to next file

2002-09-12 Thread david

Harry Putnam wrote:

> david <[EMAIL PROTECTED]> writes:
> 
> Won't is still quite even with the eval, in the above case?
>> passing it to Perl
> 
> Can you give an example of this?

no it doesn't. if you put it inside an eval{}, it won't quit. consider:

#!/usr/bin/perl -w
use strict;

my $reg = shift;

while(){
chomp;
eval{
print "$_\n" if(/$reg/o);
}
print "ERROR: $@\n" if($@);
}

__END__

again, this is just an example of what you can do. you should consider 
quoting your $reg also

david



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




Re: go to next file

2002-09-12 Thread Harry Putnam

david <[EMAIL PROTECTED]> writes:

> Harry Putnam wrote:
>
>> 
>> Excuse my skull bone density... not sure I follow this.  Not sure I
>> see how `chop' does anything to `\'
>> 
>> [...]
>> 
>
> assume your program is named scan.pl, what happen is you call it:
>
> scan.pl '\'

It will wait for input since files are required.
So if you supply files:
scan.pl '\' files
Trailing \ in regex m/\/ at /home/reader/scripts/perl/hdrscn1 line 22, <> line 1

> your script always assume user will be entering a valid reg to use. i am 
> suggest that you should not trust the user on that. there is a good chance 
> that your user will not supply a valid reg. in that case, your program will 
> crash. you should trap that with the eval{} or with quote your reg before 

Won't is still quite even with the eval, in the above case?
> passing it to Perl

Can you give an example of this?

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




RE: reading external cmd io

2002-09-12 Thread Timothy Johnson


The only advantage I can think of is if you are getting tremendous amounts
of output from the program.  I don't know if it would cut down on the memory
used if you could while(<>) it with a filehandle.

-Original Message-
From: HENRY,MARK (HP-Roseville,ex1) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 2:02 PM
To: '[EMAIL PROTECTED]'
Subject: reading external cmd io


Hi All,

Thanks for reponses to my recent question.

Regarding external program IO, wondering what is the best approach?

To date I've used backticks, and processed each line as it has passed..

Wondering if perhaps file handles would be a better approach - I can't see
the advantage, but then I can't see the problems either..

Many thanks,

Mark

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




reading external cmd io

2002-09-12 Thread HENRY,MARK (HP-Roseville,ex1)

Hi All,

Thanks for reponses to my recent question.

Regarding external program IO, wondering what is the best approach?

To date I've used backticks, and processed each line as it has passed..

Wondering if perhaps file handles would be a better approach - I can't see
the advantage, but then I can't see the problems either..

Many thanks,

Mark

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




Re: go to next file

2002-09-12 Thread david

Harry Putnam wrote:

> 
> Excuse my skull bone density... not sure I follow this.  Not sure I
> see how `chop' does anything to `\'
> 
> [...]
> 

assume your program is named scan.pl, what happen is you call it:

scan.pl '\'

your script always assume user will be entering a valid reg to use. i am 
suggest that you should not trust the user on that. there is a good chance 
that your user will not supply a valid reg. in that case, your program will 
crash. you should trap that with the eval{} or with quote your reg before 
passing it to Perl

david


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




RE: Window Services - stop/start (Newbie)...

2002-09-12 Thread Timothy Johnson


It looks like you might want to do a full uninstall/reinstall of ActivePerl
and see if that clears it up.

-Original Message-
From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 1:33 PM
To: 'Perl Beginners'; 'Timothy Johnson'
Subject: RE: Window Services - stop/start (Newbie)...


Tim, 

Thanks for this information.

I managed to install Win32::Lanman using PPM. But I still got an error
message installing Win32::Service. I'm going to see how difficult Lanman is
before racking my head with Win32::Service. 

But here is the error I got if anyone is interested. :)

*
E:\>ppm
PPM interactive shell (2.1.6) - type 'help' for available commands.
PPM> set repository dave http://www.roth.net/perl/packages
PPM> set save
PPM> install win32-service
Install package 'win32-service?' (y/N): y
Installing package 'win32-service'...
Error installing package 'win32-service': Read a PPD for 'win32-service',
but it is not intended for this build of Perl (MSWin32-x86-multi-thread)
PPM> quit
Quit!
*
Thanks.

Alex


> --
> From: Timothy Johnson[SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 4:13 PM
> To:   'Yuen, Alex'; 'Perl Beginners'
> Subject:  RE: Window Services - stop/start (Newbie)...
> 
> 
> Why don't you install it via PPM?  If it's not in the Activestate
> repository, you can install it using Dave Roth's PPM repository.
> 
> PPM> set repository dave http://www.roth.net/perl/packages
> PPM> set save
> PPM> install win32-service
> 
> For Win32::Lanman (and many other useful modules), use Jenda's repository:
> http://jenda.krynicky.cz/perl
> 
> 
> -Original Message-
> From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 11:50 AM
> To: 'Perl Beginners'
> Subject: RE: Window Services - stop/start (Newbie)...
> 
> 
> Hi,
> 
> I just tried to install both modules (Win32::Service & Win32::Lanman). Get
> the message that I am using the wrong build of Perl. Both files were
> downloaded from CPAN. 
> 
> Didn't see a make.pl file, but did see an install.pl file. Ran that file
> and
> get the error message above. Do I need to create a make.pl file to install
> the module?
> 
> Or am I missing something very simple?
> 
> I am using ActiveState Perl 5.6.1 Build 633. I copied this from the
> command
> prompt...using Windows NT 4.0.
> 
> **
> **
> ***
> E:\>perl -v
> 
> This is perl, v5.6.1 built for MSWin32-x86-multi-thread
> (with 1 registered patch, see perl -V for more detail)
> 
> Copyright 1987-2001, Larry Wall
> 
> Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
> Built 21:33:05 Jun 17 2002
> 
> 
> Perl may be copied only under the terms of either the Artistic License or
> the
> GNU General Public License, which may be found in the Perl 5 source kit.
> 
> Complete documentation for Perl, including FAQ lists, should be found on
> this system using `man perl' or `perldoc perl'.  If you have access to the
> Internet, point your browser at http://www.perl.com/, the Perl Home Page.
> **
> **
> ***
> Thanks.
> 
> Alex
> 
> 
> > --
> > From:   Timothy Johnson[SMTP:[EMAIL PROTECTED]]
> > Sent:   Tuesday, September 10, 2002 4:34 PM
> > To: 'Yuen, Alex'; 'Perl Beginners'
> > Subject:RE: Window Services - stop/start (Newbie)...
> > 
> > 
> > Check out Win32::Service or Win32::Lanman.  Lanman is a whole lot to
> chew,
> > but it can do just about anything involving remote administration of
> > NT/2000/XP machines.
> > 
> > -Original Message-
> > From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, September 10, 2002 1:33 PM
> > To: 'Perl Beginners'
> > Subject: Window Services - stop/start (Newbie)...
> > 
> > 
> > Hi,
> > 
> > Does anyone know if Perl can stop or start a Service in Windows NT or
> > 2000?
> > 
> > Trying to write a script to stop the Service of an application, archive
> > the
> > log files and then restart the Service. Plus, record this transaction to
> a
> > seperate log file. Another plus, send out an e-mail notification if an
> > error
> > were to occur in any step of the Perl script.
> > 
> > Haven't decided to attach the log to the e-mail or not. But would be
> using
> > Mime::Lite for this.
> > 
> > Thanks.
> > 
> > Alex
> > 
> > -- 
> > 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]
> 

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




Re: go to next file

2002-09-12 Thread Harry Putnam

david <[EMAIL PROTECTED]> writes:

> you are feeding reg directly to Perl from the user in 'if(/$regex/)' there 
> is a chance that this will crash your program consider:
>
> #!/usr/bin/perl -w
> use strict;
>
> eval{
> while(){
> chop;
> /$_/o;
> }
> };
>
> print $@ if($@);
>
> __END__

> the program crash if i supply '\':
>
> Trailing \ in regex m/\/ at ./tmp.pl line 31,  line 2.


Excuse my skull bone density... not sure I follow this.  Not sure I
see how `chop' does anything to `\'

[...]

> you should consider things like that when you taking stuff directly from the 
> user. you should also consider putting a 'o' like:


> if(/$regex/o)

This looks usefull... thanks

But now about that `\'.  I don't see an error here when I use it.
like one might in a regex. However the program isn't exactly the same
one I posted.  This is the actuall useable program.  Its designed to
scan only headers of mail messages in one message per file format.

User sets the regex to search for on the command line.  a shift
leaves the rest for ARGV.

Using a regex like '@\w+\.'  Finds all instances in headers of a 
@,followed by one or more word chars, followed by a dot.

Not sure I see where a trailing \ would be involved.  Unless one were
looking for a trailing slash then the regex would be `@\w+\\', which 
doesn't cause an error here.  Having that error occur on 'some\'
might be a good thing since it is not a good regex.

Actual program:

#!/usr/local/bin/perl -w
# Keywords: hdrscn1 -  designed to print selected headers by regex. 
# Sep 11 17:50:54 2002 3
# &&

($myscript = $0) =~ s:^.*/::; 

if (! $ARGV[0] || $ARGV[0] eq "help"){
&usage;
exit;
}
$regex = shift;
## Note that the empty <> below are really the same as
## 
while(<>){

  $cnt++;
  $tcnt++;
  if($cnt == 1){
print "\n$ARGV\n";
  }
  if(/$regex/){
printf "%-3d %s", $cnt, $_;
## Here we can test whether all lines are scanned or
## we stop at the first blank one.
  }elsif(/^$/){
#}elsif(eof){
$cnt = 0;
## IMPORTANT (From Bob Showalter on perl beginner list
## If we don't close ARGV here we just skip to next blank line
## not next file.
close(ARGV);
next;
  }
}
print "$tcnt\n";
sub usage{
  print <


RE: Window Services - stop/start (Newbie)...

2002-09-12 Thread Yuen, Alex

Tim, 

Thanks for this information.

I managed to install Win32::Lanman using PPM. But I still got an error
message installing Win32::Service. I'm going to see how difficult Lanman is
before racking my head with Win32::Service. 

But here is the error I got if anyone is interested. :)

*
E:\>ppm
PPM interactive shell (2.1.6) - type 'help' for available commands.
PPM> set repository dave http://www.roth.net/perl/packages
PPM> set save
PPM> install win32-service
Install package 'win32-service?' (y/N): y
Installing package 'win32-service'...
Error installing package 'win32-service': Read a PPD for 'win32-service',
but it is not intended for this build of Perl (MSWin32-x86-multi-thread)
PPM> quit
Quit!
*
Thanks.

Alex


> --
> From: Timothy Johnson[SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 4:13 PM
> To:   'Yuen, Alex'; 'Perl Beginners'
> Subject:  RE: Window Services - stop/start (Newbie)...
> 
> 
> Why don't you install it via PPM?  If it's not in the Activestate
> repository, you can install it using Dave Roth's PPM repository.
> 
> PPM> set repository dave http://www.roth.net/perl/packages
> PPM> set save
> PPM> install win32-service
> 
> For Win32::Lanman (and many other useful modules), use Jenda's repository:
> http://jenda.krynicky.cz/perl
> 
> 
> -Original Message-
> From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 11:50 AM
> To: 'Perl Beginners'
> Subject: RE: Window Services - stop/start (Newbie)...
> 
> 
> Hi,
> 
> I just tried to install both modules (Win32::Service & Win32::Lanman). Get
> the message that I am using the wrong build of Perl. Both files were
> downloaded from CPAN. 
> 
> Didn't see a make.pl file, but did see an install.pl file. Ran that file
> and
> get the error message above. Do I need to create a make.pl file to install
> the module?
> 
> Or am I missing something very simple?
> 
> I am using ActiveState Perl 5.6.1 Build 633. I copied this from the
> command
> prompt...using Windows NT 4.0.
> 
> **
> **
> ***
> E:\>perl -v
> 
> This is perl, v5.6.1 built for MSWin32-x86-multi-thread
> (with 1 registered patch, see perl -V for more detail)
> 
> Copyright 1987-2001, Larry Wall
> 
> Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
> Built 21:33:05 Jun 17 2002
> 
> 
> Perl may be copied only under the terms of either the Artistic License or
> the
> GNU General Public License, which may be found in the Perl 5 source kit.
> 
> Complete documentation for Perl, including FAQ lists, should be found on
> this system using `man perl' or `perldoc perl'.  If you have access to the
> Internet, point your browser at http://www.perl.com/, the Perl Home Page.
> **
> **
> ***
> Thanks.
> 
> Alex
> 
> 
> > --
> > From:   Timothy Johnson[SMTP:[EMAIL PROTECTED]]
> > Sent:   Tuesday, September 10, 2002 4:34 PM
> > To: 'Yuen, Alex'; 'Perl Beginners'
> > Subject:RE: Window Services - stop/start (Newbie)...
> > 
> > 
> > Check out Win32::Service or Win32::Lanman.  Lanman is a whole lot to
> chew,
> > but it can do just about anything involving remote administration of
> > NT/2000/XP machines.
> > 
> > -Original Message-
> > From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, September 10, 2002 1:33 PM
> > To: 'Perl Beginners'
> > Subject: Window Services - stop/start (Newbie)...
> > 
> > 
> > Hi,
> > 
> > Does anyone know if Perl can stop or start a Service in Windows NT or
> > 2000?
> > 
> > Trying to write a script to stop the Service of an application, archive
> > the
> > log files and then restart the Service. Plus, record this transaction to
> a
> > seperate log file. Another plus, send out an e-mail notification if an
> > error
> > were to occur in any step of the Perl script.
> > 
> > Haven't decided to attach the log to the e-mail or not. But would be
> using
> > Mime::Lite for this.
> > 
> > Thanks.
> > 
> > Alex
> > 
> > -- 
> > 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]
> 

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




RE: Can my code be shortened?

2002-09-12 Thread loan tran

It works perfectly. Thanks mucho.

--- Kirby_Sarah <[EMAIL PROTECTED]> wrote:
> I didn't test it, but this should work, right?
> 
> -Original Message-
> From: loan tran [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 4:02 PM
> To: [EMAIL PROTECTED]
> Subject: Can my code be shortened?
> 
> 
> #!/usr/bin/perl -w
> 
> @col_header = ('Sybase
> Server','Function','Type','Unix
> Machine','Location');
> 
> foreach $headIt (@col_header) {
>   $headIt =~ s!(.*)!\n\t$1!;
> }
> 
> print "@col_header\n";
> 
> # out put:
> 
> 
> 
>   Sybase Server 
>   Function
>   Type 
>   Unix Machine 
>   Location
> 
> 
> Please note that there are 2 unwanted  from the
> out put. One is next to Server and one is next to
> Machine. How can I get rid of them? Can my code be
> shortened?
> 
> Thanks in advance for your help.
> 
> Loan
> 
> 
> 
> 
> 
> __
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com
> 
> -- 
> 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]
> 


__
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

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




Re: Can my code be shortened?

2002-09-12 Thread John W. Krahn

Loan Tran wrote:
> 
> #!/usr/bin/perl -w
> @col_header = ('Sybase Server','Function','Type','Unix
> Machine','Location');
> my $num_col_header = @col_header  ;
> $td0= join(' ',
> @col_header[0..($num_col_header -1)]);
> $td= ''."$td0".'';
> print "$td";
> 
> # out put:
> 
> Sybase Server Function
> Type Unix Machine Locatio
> n
> 
> Please note that there are 2 unwanted  from the
> out put. One is next to Server and one is next to
> Machine. How can I get rid of them? Can my code be
> shortened?


$ perl -e'
use CGI
qw/:standard/;  
@col_header = ("Sybase Server", "Function", "Type", "Unix Machine",
"Location");
print table( Tr( [ td( \@col_header ) ] ) );
'  
Sybase Server Function Type
Unix Machine Location


perldoc CGI



John
-- 
use Perl;
program
fulfillment

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




Re: Can my code be shortened?

2002-09-12 Thread david

try something like:

my @k = ('Sybase Server','Function','Type','Unix Machine','Location');

print '';
map { print '',$_,"\n"} @k;
print '';

david

Loan Tran wrote:

> #!/usr/bin/perl -w
> @col_header = ('Sybase Server','Function','Type','Unix
> Machine','Location');
> my $num_col_header = @col_header  ;
> $td0= join(' ',
> @col_header[0..($num_col_header -1)]);
> $td= ''."$td0".'';
> print "$td";
> 
> # out put:
> 
> Sybase Server Function
> Type Unix Machine Locatio
> n
> 
> Please note that there are 2 unwanted  from the
> out put. One is next to Server and one is next to
> Machine. How can I get rid of them? Can my code be
> shortened?
> 
> Thanks in advance for your help.
> 
> Loan
> 
> 
> 
> 
> 
> __
> Do you Yahoo!?
> Yahoo! News - Today's headlines
> http://news.yahoo.com


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




RE: Window Services - stop/start (Newbie)...

2002-09-12 Thread Timothy Johnson


Why don't you install it via PPM?  If it's not in the Activestate
repository, you can install it using Dave Roth's PPM repository.

PPM> set repository dave http://www.roth.net/perl/packages
PPM> set save
PPM> install win32-service

For Win32::Lanman (and many other useful modules), use Jenda's repository:
http://jenda.krynicky.cz/perl


-Original Message-
From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 11:50 AM
To: 'Perl Beginners'
Subject: RE: Window Services - stop/start (Newbie)...


Hi,

I just tried to install both modules (Win32::Service & Win32::Lanman). Get
the message that I am using the wrong build of Perl. Both files were
downloaded from CPAN. 

Didn't see a make.pl file, but did see an install.pl file. Ran that file and
get the error message above. Do I need to create a make.pl file to install
the module?

Or am I missing something very simple?

I am using ActiveState Perl 5.6.1 Build 633. I copied this from the command
prompt...using Windows NT 4.0.


***
E:\>perl -v

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
Built 21:33:05 Jun 17 2002


Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

***
Thanks.

Alex


> --
> From: Timothy Johnson[SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, September 10, 2002 4:34 PM
> To:   'Yuen, Alex'; 'Perl Beginners'
> Subject:  RE: Window Services - stop/start (Newbie)...
> 
> 
> Check out Win32::Service or Win32::Lanman.  Lanman is a whole lot to chew,
> but it can do just about anything involving remote administration of
> NT/2000/XP machines.
> 
> -Original Message-
> From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 10, 2002 1:33 PM
> To: 'Perl Beginners'
> Subject: Window Services - stop/start (Newbie)...
> 
> 
> Hi,
> 
> Does anyone know if Perl can stop or start a Service in Windows NT or
> 2000?
> 
> Trying to write a script to stop the Service of an application, archive
> the
> log files and then restart the Service. Plus, record this transaction to a
> seperate log file. Another plus, send out an e-mail notification if an
> error
> were to occur in any step of the Perl script.
> 
> Haven't decided to attach the log to the e-mail or not. But would be using
> Mime::Lite for this.
> 
> Thanks.
> 
> Alex
> 
> -- 
> 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]

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




RE: Can my code be shortened?

2002-09-12 Thread Kirby_Sarah

I didn't test it, but this should work, right?

-Original Message-
From: loan tran [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 4:02 PM
To: [EMAIL PROTECTED]
Subject: Can my code be shortened?


#!/usr/bin/perl -w

@col_header = ('Sybase Server','Function','Type','Unix
Machine','Location');

foreach $headIt (@col_header) {
$headIt =~ s!(.*)!\n\t$1!;
}

print "@col_header\n";

# out put:



Sybase Server 
Function
Type 
Unix Machine 
Location


Please note that there are 2 unwanted  from the
out put. One is next to Server and one is next to
Machine. How can I get rid of them? Can my code be
shortened?

Thanks in advance for your help.

Loan





__
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

-- 
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: help with commenting code..

2002-09-12 Thread Timothy Johnson


What you have here "@f[6,2..$#f]" is an array slice.  Any indexes appearing
within the brackets will be included.  If you wanted to exclude 0,1,and 6,
you could do it this way:

@f[2..5,7..$#f];

-Original Message-
From: Mike Singleton [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 11:07 AM
To: [EMAIL PROTECTED]
Subject: RE: help with commenting code..


How would I skip an index?? i.e.  I want to skip 0,1, and 6 ??

@f[6,2..$#f] ??


>>> Timothy Johnson <[EMAIL PROTECTED]> 09/12/02 09:47AM >>>

$#f stands for the last index of the array @f.  So 2..$#f means "from index
2 to the last index".  This means that the code is skipping $f[0] and $f[1].

-Original Message-
From: Mike Singleton [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, September 12, 2002 9:04 AM
To: [EMAIL PROTECTED] 
Subject: help with commenting code..



# grep each line for the declared variables
while () {
 print "parsing $_";
 if ( /$JOBSTART|$TASKSUM|$TASKDET|$TASKEND|$ERROR|$JOBEND/i )
 {

# remove spaces and replace with commas
 my @f = split /\s+/,$_,9;
 
  print OUT join (',', @f[2..$#f]) ;
---> What does this line (above) do?  I know it removes the first two
fields?

 } else {
 print "skipped: '$_'\n";
 }
}

===
Mike Singleton 
Network Analyst
(253) 272-1916  x1259
(253) 405-1968 (cellular)
[EMAIL PROTECTED] 

DaVita Inc.
___
Perl-Win32-Admin mailing list
[EMAIL PROTECTED] 
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

DaVita Inc.

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




Can my code be shortened?

2002-09-12 Thread loan tran

#!/usr/bin/perl -w
@col_header = ('Sybase Server','Function','Type','Unix
Machine','Location');
my $num_col_header = @col_header  ;
$td0= join(' ',
@col_header[0..($num_col_header -1)]);
$td= ''."$td0".'';
print "$td";

# out put:

Sybase Server Function
Type Unix Machine Locatio
n

Please note that there are 2 unwanted  from the
out put. One is next to Server and one is next to
Machine. How can I get rid of them? Can my code be
shortened?

Thanks in advance for your help.

Loan





__
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

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




Re: go to next file

2002-09-12 Thread david

Harry Putnam wrote:

>   #!/usr/local/bin/perl -w
>  
>   $regex = shift;
>   while(<>){
>  $cnt++;
>  if($cnt == 1){
>print "$ARGV\n";
>  }
>  if(/$regex/){
>printf "%-3d %s", $cnt, $_;
>  }elsif(/^$/){
>$cnt = 0;
>next;
>  }
> }

you are feeding reg directly to Perl from the user in 'if(/$regex/)' there 
is a chance that this will crash your program consider:

#!/usr/bin/perl -w
use strict;

eval{
while(){
chop;
/$_/o;
}
};

print $@ if($@);

__END__

the program crash if i supply '\':

Trailing \ in regex m/\/ at ./tmp.pl line 31,  line 2.

you should consider things like that when you taking stuff directly from the 
user. you should also consider putting a 'o' like:

if(/$regex/o)

since $regex don't change after your program start running, this will save 
you sometime to recompile the whole reg when it's encountered.

david

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




Re: I'm selling my Perl books

2002-09-12 Thread Randal L. Schwartz

> "mmaunder" == mmaunder  <[EMAIL PROTECTED]> writes:

mmaunder> Learning Perl - Schwartz and Christainsen - Oreilly (£10) 

This is definitely 2nd edition from the author list (now
deprecated, replaced by third edition in all manners of speaking)...

mmaunder> Programming Perl - Larry Wall et. al. - Oreilly (£10) 

... But you can't tell what edition this is.  Can you be more specific?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

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




RE: Window Services - stop/start (Newbie)...

2002-09-12 Thread Yuen, Alex

Hi,

I just tried to install both modules (Win32::Service & Win32::Lanman). Get
the message that I am using the wrong build of Perl. Both files were
downloaded from CPAN. 

Didn't see a make.pl file, but did see an install.pl file. Ran that file and
get the error message above. Do I need to create a make.pl file to install
the module?

Or am I missing something very simple?

I am using ActiveState Perl 5.6.1 Build 633. I copied this from the command
prompt...using Windows NT 4.0.


***
E:\>perl -v

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
Built 21:33:05 Jun 17 2002


Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

***
Thanks.

Alex


> --
> From: Timothy Johnson[SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, September 10, 2002 4:34 PM
> To:   'Yuen, Alex'; 'Perl Beginners'
> Subject:  RE: Window Services - stop/start (Newbie)...
> 
> 
> Check out Win32::Service or Win32::Lanman.  Lanman is a whole lot to chew,
> but it can do just about anything involving remote administration of
> NT/2000/XP machines.
> 
> -Original Message-
> From: Yuen, Alex [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 10, 2002 1:33 PM
> To: 'Perl Beginners'
> Subject: Window Services - stop/start (Newbie)...
> 
> 
> Hi,
> 
> Does anyone know if Perl can stop or start a Service in Windows NT or
> 2000?
> 
> Trying to write a script to stop the Service of an application, archive
> the
> log files and then restart the Service. Plus, record this transaction to a
> seperate log file. Another plus, send out an e-mail notification if an
> error
> were to occur in any step of the Perl script.
> 
> Haven't decided to attach the log to the e-mail or not. But would be using
> Mime::Lite for this.
> 
> Thanks.
> 
> Alex
> 
> -- 
> 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]




Compiling Perl 5.8 in Win 2000

2002-09-12 Thread Alan Hogue

Hello,

My appologies if this particular problem has shown up here before. I
looked around, but didn't see anything that quite addressed it.

I am trying to build perl on my windows system using gcc and dmake. The
versions are:

Win 2000 5.00.2195 SP3
Perl 5.8.0
gcc 2.95.2
dmake 4.1

I followed the README.win32 instructions pretty carefully for setting
up the makefile and everything, but when I run dmake I get the
following:

G:\Career\perl\perl-5.8.0\win32>dmake
del /f config.h
copy config_H.vc config.h
1 file(s) copied.
cl -c  -nologo -Gf -W3 -I..\lib\CORE -I.\include -I. -I.. -DWIN32
-D_CONSOLE -DN
O_STRICT  -DPERLDLL -DPERL_CORE  -MD -DNDEBUG -O1
-DPERL_IMPLICI
T_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX -Foperlglob.obj
perlglob.c
'cl' is not recognized as an internal or external command,
operable program or batch file.
dmake.exe:  Error code 1, while making 'perlglob.obj'


I previously tried building using nmake, and I got almost exactly the
same message. Can anyone tell me why 'cl' is giving the compiler (or is
it dos?) problems, or suggest at least where to start looking for the
answer? I'd really appreciate it.

Thanks,
Alan


=
"Do I repeat myself? Very well, I repeat myself; I am repetitive."

__
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com

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




RE: regular expression help....

2002-09-12 Thread david

David --- Senior Programmer Analyst --- Wgo Wagner wrote:

> Your log shows a space between the time and hyphen and hyphen and
> Micro. You dont' have that in the regex and even more so, there is no
> hyphen before Adapter log.
> 
> You might want:
> /^(\d\d-\d\d-\d{4})\s+(\d\d:\d\d:\d\d\.\d\d).+Adapter
> log\s+(opened|closed)/i
> 
> Anchor with the ^ and you will have date in $1, time in $2 and
> opened or closed in $3.
> A shot.
> Wags ;)

you can avoid putting tons of \d in your reg by using:

my($d,$t) = (split(/\s+/))[0,1];
print "$d,$t\n";

__END__

but a reg. expression should be much faster.

david

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




RE: logging data to text file help!!

2002-09-12 Thread Winchester, Derek S (Derek)



-Original Message-
From: Winchester, Derek S (Derek) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 12:22 PM
To: [EMAIL PROTECTED]
Subject: logging data to text file


I have composed this perl script and I would like the results from each
command to append a log file. Is there a way I can do this? I have seen
several examples but none of them  looks as if it would achieve what I am
trying to do here. Any help would be appreciated.



#!/usr/bin/perl -w
# file: ionex test
use Net::Telnet;
use constant HOST => '152.148.228.14';
use constant USER => 'admin';
use constant PASS => 'admin';
# loads the text file to be loaded via cli. populating the array w/text
config file
$telnet = Net::Telnet->new(HOST);
$telnet->open(HOST);
$telnet->waitfor('/[^Welcome]/');
$telnet->print ("\007");
$telnet->login(Name => USER,Password => PASS,Prompt => '/#/',Timeout => 30);
$file = select (/usr/test.txt);
$telnet->cmd ("set page disable\n");
$telnet->cmd ("router verio_gate_1\n");
$telnet->cmd ("show ip route\n");
$telnet->cmd ("show ip ospf database external\n");
$telnet->cmd ("show ip ospf database \n");
$telnet->cmd ("show ip ospf database nssa\n");
$telnet->cmd ("show ip ospf border-routers\n");
$telnet->cmd ("show ip ospf interfaces\n");
$telnet->cmd ("show ip ospf routers\n");
$telnet->cmd ("up\n");
$telnet->cmd ("show clock\n");
$telnet->cmd ("restart router verio_gate_1\n");

-- 
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: printing hash of a hash

2002-09-12 Thread david

Marija Silajev wrote:

> Hi,
> 
> I create a hash like following:
> 
> 
>  $Data{$KEYS} = { key1 => [@array1],
>  key2 => [@array2],
> };
> 
> 
> with:
> foreach $KEYS ( keys %Data){
> print "Key1 data : @{$Data{$KEYS}{key1}}\n";
> }
> 
> I manage to print the whole @array1 in one line like:
> 
> Key1 data : 4321 432 765 341
> 
> and i would like it to look like
> Key1 data :
> 
> 4321
> 432
> 765
> 341
> 
> I still didn'n manage to get it like this.
> Thanks in advance for help.
> 
> 
> Marija

try:

my %hash;
my @i = (1..5);
my @j = (6..9);

$hash{'key'} = { key1 => [@i], key2 => [@j] };

while(my($key,$value) = each %hash){
while(my($k,$v) = each %{$value}){
print "$k data:\n";
foreach my $ar (@{$v}){
print "$ar\n";
}
}
}

__END__

prints:

key1 data:
1
2
3
4
5
key2 data:
6
7
8
9

david

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




Re: Help regarding the perl safe module

2002-09-12 Thread david

Basavaraj Bendigeri wrote:
> 
> use Expect;
> use IO::Tty;
> use IO::Pty;
> use Safe;
> 
>   $Expect::Debug=1;
>   $compartment = new Safe;
>   $compartment->deny(qw(print));
>   $compartment->reval(&test_func);
> 
> This is just a sample script wherein I am trying to deny
> the print function. But the print works.
> Thanks in advance for your help
> -Basavaraj

no, it doesn't work. you see your message print out because you are doing a 
function call like:

$compartment->reval(&test_func);

the '&test_func' is simply a function call so Perl calls your function 
'test_func' and prints the message. it's like you have:

&test_func;
$compartment->reval();

which of course prints your statement and make you believe that the Safe 
module doesn't work.

david


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




RE: sleep question

2002-09-12 Thread Bob Showalter

> -Original Message-
> From: Chad Kellerman [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 12:37 PM
> To: [EMAIL PROTECTED]
> Subject: sleep question
> 
> 
> Greetings,
>  I have a script that forks 5 children.  I print to 
> screen when each
> child gets forked.  Under certain conditions in the script a child
> should sleep.  This conditions occurs at different times for 
> each child.
> 
>  I think I am noticing that when the sleep is called in a child,
> every child and the parent sleep as well.
> 
>   Am I correct in this assumption?

No. After the fork, parent and child lead separate lives. Something else is
going on.

> The OS that the script is 
> running on
> is Solaris.

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




Re: new output error

2002-09-12 Thread david

Mike Singleton wrote:

>  open IN, $_ or die "open $_: $!";
>  while () {
>   my @f = split /s+/,$_,9;
>   print OUT join (',', @f) . "\n" if
>/$JOBSTART|$CONDSTART|$JOBEND|$CONDEND|$JOBCANC|$XFER|$VOLUSED/i;
> 

'print  if(EXP)', make sure the EXP is true. otherwise, you will 
have nothing to print and your file will be empty. also, you should 
consider moving your split function inside the if() statement so only when 
the if(EXP) exp is true, you do the split:

if(EXP){
#-- split
#-- print
}

you currently have:

#-- split
print  if(EXP)

which could be doing a lot of uneccessary split. remember that split is kind 
of expensive and you will wasting a lot of time donig things that you might 
never need.

david

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




Re: Tie::File glitch trying to head a file - head.txt

2002-09-12 Thread zentara

On Thu, 12 Sep 2002 11:50:19 -0400, [EMAIL PROTECTED] (Zentara)
wrote:

>On Thu, 12 Sep 2002 09:56:41 -0400, [EMAIL PROTECTED] (Zentara)
>wrote:
>
>>Hi,
>>
>>This little glitch has caused me alot of "useless searching for why".
>>I thought I was losing my mind. :-)
>>
>>I'm trying to delete the first line of a file, using Tie::File and
>>shift.
>>
>
>My attachment wasn't sent right, sorry.
>Upon further experimentation, I've discovered
>that Tie::File is truncating all files bigger than
>8192 to 8192 when doing a shift on the array.
>
>pop array seems to do OK.

Well I got the latest version of Tie::File and it seems to
be fixed, but can I be sure enough to trust Tie::File?



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




sleep question

2002-09-12 Thread Chad Kellerman

Greetings,
 I have a script that forks 5 children.  I print to screen when each
child gets forked.  Under certain conditions in the script a child
should sleep.  This conditions occurs at different times for each child.

 I think I am noticing that when the sleep is called in a child,
every child and the parent sleep as well.

  Am I correct in this assumption?  The OS that the script is running on
is Solaris.

Thanks,
CHad

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




logging data to text file

2002-09-12 Thread Winchester, Derek S (Derek)

I have composed this perl script and I would like the results from each
command to append a log file. Is there a way I can do this? I have seen
several examples but none of them  looks as if it would achieve what I am
trying to do here. Any help would be appreciated.



#!/usr/bin/perl -w
# file: ionex test
use Net::Telnet;
use constant HOST => '152.148.228.14';
use constant USER => 'admin';
use constant PASS => 'admin';
# loads the text file to be loaded via cli. populating the array w/text
config file
$telnet = Net::Telnet->new(HOST);
$telnet->open(HOST);
$telnet->waitfor('/[^Welcome]/');
$telnet->print ("\007");
$telnet->login(Name => USER,Password => PASS,Prompt => '/#/',Timeout => 30);
$file = select (/usr/test.txt);
$telnet->cmd ("set page disable\n");
$telnet->cmd ("router verio_gate_1\n");
$telnet->cmd ("show ip route\n");
$telnet->cmd ("show ip ospf database external\n");
$telnet->cmd ("show ip ospf database \n");
$telnet->cmd ("show ip ospf database nssa\n");
$telnet->cmd ("show ip ospf border-routers\n");
$telnet->cmd ("show ip ospf interfaces\n");
$telnet->cmd ("show ip ospf routers\n");
$telnet->cmd ("up\n");
$telnet->cmd ("show clock\n");
$telnet->cmd ("restart router verio_gate_1\n");

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




Re: go to next file

2002-09-12 Thread Harry Putnam

Bob Showalter <[EMAIL PROTECTED]> writes:

[...]

>> cat test.pl
>>   #!/usr/local/bin/perl -w
>>  
>>   $regex = shift;
>>   while(<>){
>>  $cnt++;
>>  if($cnt == 1){
>>print "$ARGV\n";
>>  }
>>  if(/$regex/){
>>printf "%-3d %s", $cnt, $_;
>>  }elsif(/^$/){
>>$cnt = 0;
>
> add 'close ARGV;' right here.
>
>>next;
>>  }
>> }

Yup, that did it and its majorly faster than using the two while
loops as suggested.

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




Re: Tie::File glitch trying to head a file - head.txt

2002-09-12 Thread zentara

On Thu, 12 Sep 2002 09:56:41 -0400, [EMAIL PROTECTED] (Zentara)
wrote:

>Hi,
>
>This little glitch has caused me alot of "useless searching for why".
>I thought I was losing my mind. :-)
>
>I'm trying to delete the first line of a file, using Tie::File and
>shift.
>

My attachment wasn't sent right, sorry.
Upon further experimentation, I've discovered
that Tie::File is truncating all files bigger than
8192 to 8192 when doing a shift on the array.

pop array seems to do OK.



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




Re: copying files to diskette

2002-09-12 Thread Joseph Paish

thanks for the responses.  

still not working, but i will keep on plugging away or just use one of the 
scripts that already exist for doing backups and modify it for what i want.

joe

On Tuesday 06 August 2002 08:25, Joseph Paish wrote:
> here is a copy of the script i am working on
>
> #!/usr/bin/perl -w
> use strict ;
>
> my ($sec, $minutes, $hr, $monthdate, $month, $year, $weekday, $year_date,
> $daylight_savings) = localtime(time) ;
> my @month_names = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
> "Sep", "Oct", "Nov", "Dec") ;
>
> my $date_string = join "_", $month_names[$month], $monthdate, ($year +
> 1900) ;
>
> my @temp_array = ( "mkdir", "/mnt/floppy/$date_string" ) ;
> system (@temp_array) ;
>
> my @filenames = ("/home/jpaish/trash") ; # eventually several files
>
> use File::Copy ;
>
> foreach my $single_filename (@filenames) {
> print ( "the current filename is : $single_filename \n") ;
> copy ( "$single_filename", "/$date_string/$single_filename" ) ;
> }
>
> -
>
> a couple of questions :
>
> 1. why doesn't the copy command in the foreach loop expand the $date_string
> and $single_filename to their values? i thought that if i put it in quotes,
> it would expand out to the correct values (the print statement inside the
> foreach works ok).  there are no errors, just an empty directory.
>
> --
> 2. when i go to delete the Aug_06_2002 directory using rm -r, i am told
> that the directory is write protected, and i am asked if i want to delete
> it anyway.  i answer yes, and i am allowed to delete it with no problem. 
> this is with my own account, not as root.
>
> is the write protection a result of the way i have created the directory?
> (see code below)
>
> my @temp_array = ( "mkdir", "/mnt/floppy/$date_string" ) ;
> system (@temp_array) ;
>
> --
>
> thanks
>
> joe

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




Re: Windows /dev/null device

2002-09-12 Thread Gary Stainburn

Hi all,

On Thursday 12 Sep 2002 1:20 am, Tim Musson wrote:
> Hey Mohd,
>
> My MUA believes you used
> to write the following on Wednesday, September 11, 2002 at 4:13:56 AM.
>
>
>
> MS> Hi ,
> MS> How I can send my errors to a null device under windows
> environment(winxp). MS> I tried $myoutput= `anycommand 2>null ` , but
> always this command create a MS> file called null .
> MS> Thanks.
>
> for some reason, MS decided to implement using only one L in nul.
>
> $myoutput= `anycommand 2>nul`

This is due to an early limitation in DOS where devices could not be 3 
letters, e.g. prn, con.

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


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




Re: go to next file

2002-09-12 Thread Harry Putnam

Dharmender Rai <[EMAIL PROTECTED]> writes:

> you are not reading the files properly.
> use 2 "while loops". the outer for traversing the
> command line args while the inner for reading and
> checking the file contents. use "break" in the inner
> "while loop" when you get a blank line to go to the
> outer "while loop".

Ahh thanks, 

  
  shift;
  
  while(<@ARGV>){
$file = $_;
open(FILE,"<$file");
while(){
  do what ever
  last if(/^$/);
}
   close(FILE);
 }

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




RE: go to next file

2002-09-12 Thread Bob Showalter

> -Original Message-
> From: Harry Putnam [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 11, 2002 10:25 PM
> To: [EMAIL PROTECTED]
> Subject: go to next file 
> 
> 
> I know its possible to force perl to read the next file but have
> forgotten how to do it.
> 
> The simple script below is supposed to read message files that are on
> disk one message per file.
> 
> I want to go to the next file when the first blank line is seen.
> I don't see how $cnt can equal one more than once per file in the
> script below yet I get output that indicates it does.
> Maybe its `last' I'm looking for but trying that in place of next and
> I get one hit and the script stops.
> 
> Judging by the output below its resetting to 0 on every blank line,
> not going to the next file.
> Maybe I've been staring at this too long...
> 
> cat test.pl
>   #!/usr/local/bin/perl -w
>  
>   $regex = shift;
>   while(<>){
>  $cnt++;
>  if($cnt == 1){
>print "$ARGV\n";
>  }
>  if(/$regex/){
>printf "%-3d %s", $cnt, $_;
>  }elsif(/^$/){
>$cnt = 0;

add 'close ARGV;' right here.

>next;
>  }
> }
> 
> Run it against a directory full of 4 messages:
> 
> ../test.pl '^Date: ' ~/Mail/test/[0-9]*
> 
> /home/reader/Mail/test/1
> 40  Date: Wed, 11 Sep 2002 17:05:03 -0700
> /home/reader/Mail/test/1
> /home/reader/Mail/test/1
> /home/reader/Mail/test/1
> /home/reader/Mail/test/1
> /home/reader/Mail/test/1
> /home/reader/Mail/test/2
> 63  Date: 12 Sep 2002 01:08:31 +0100
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/2
> /home/reader/Mail/test/3
> 60  Date: Wed, 11 Sep 2002 20:24:12 -0400
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/3
> /home/reader/Mail/test/4
> 20  Date: Thu, 12 Sep 2002 01:51:34 +0100
> /home/reader/Mail/test/4
> /home/reader/Mail/test/4
> /home/reader/Mail/test/4
> 
> -- 
> 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: go to next file

2002-09-12 Thread Harry Putnam

George Schlossnagle <[EMAIL PROTECTED]> writes:

> I think you need to stop programming C.  :)
>
> 'last' is the token you want to use for breaking out of a loop in perl.

In the script I posted `last' used in place of next, doesn't work
like I wanted.  It just stops the script on the first file.

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




Tie::File glitch trying to head a file - head.txt (1/1)

2002-09-12 Thread zentara


begin 644 head.txt
M9&EE(").;R!P87-S=V]R9',@:6X@)'!A2`D:V5Y(#T@,2`K(&EN="!R86YD("1C;W5N=#L*;7D@)'!AF5D865M;VX*9&ER8V]P
M>0ID:7)S:7IE"F-H;6]D"G=R87!I;F=L;VYG;&EN97,*8F%C:W5PG1EF5R;PIA"F9I;&4*<')I;G1F:6QE7!E7-T0IN
M97=L:6YE"FAE861L:6YE"F9I;&5L871EF4*8VAM;V0*=W)A<&EN9VQO;F=L:6YE0IG7-T65X=`IZ97)O"F$*9FEL90IP0IS96%R8V@*F5D865M;VX*9&ER
M8V]P>0ID:7)S:7IE"F-H;6]D"G=R87!I;F=L;VYG;&EN97,*8F%C:W5PG1EF5R;PIA"F9I;&4*<')I;G1F:6QE7!E7-T0IN97=L:6YE"FAE861L:6YE"F9I;&5L871EF4*8VAM;V0*=W)A<&EN9VQO;F=L:6YE0IG
M7-T65X=`IZ97)O"F$*9FEL90IP0IS96%R8V@*F5D865M;VX*
M9&ER8V]P>0ID:7)S:7IE"F-H;6]D"G=R87!I;F=L;VYG;&EN97,*8F%C:W5P
MG1EF5R;PIA"F9I;&4*<')I;G1F:6QE7!E7-T0IN97=L:6YE"FAE861L:6YE"F9I;&5L871EF4*8VAM;V0*=W)A<&EN9VQO;F=L:6YE0IG7-T65X=`IZ97)O"F$*9FEL90IP0IS96%R8V@*F5D865M
M;VX*9&ER8V]P>0ID:7)S:7IE"F-H;6]D"G=R87!I;F=L;VYG;&EN97,*8F%C
M:W5PG1EF5R;PIA"F9I;&4*<')I;G1F:6QE
M7!E7-T0IN97=L:6YE"FAE861L:6YE"F9I;&5L871EF4*8VAM;V0*=W)A<&EN9VQO;F=L:6YE0IG7-T


Tie::File glitch trying to head a file - head.txt (0/1)

2002-09-12 Thread zentara

Hi,

This little glitch has caused me alot of "useless searching for why".
I thought I was losing my mind. :-)

I'm trying to delete the first line of a file, using Tie::File and
shift.

It works for all the files I have except this one. On this file,
it deletes the first line, and then truncates a large chunk
of the file. Then on subsequent executions, works properly.

I'm wondering if my Tie::File is bad, or whether the file is bad.
It is a test file, which I made by cat file >>head.txt a few times,
to build it up, so many of the lines repeat themselves.

Can someone verify this problem? I've attached 'head.txt'
because it's too big for cut-n-paste.

The head.txt file has 13140 bytes on my system, and I expect
after running the script, it should be 13108, BUT it drops to
8192.  Then repeated executions run as expected.
###
#!/usr/bin/perl
use Tie::File;
#deletes firstline of a file
my $file = 'head.txt';
tie my @raw_data, 'Tie::File', $file or die "Cannot Open $file: $!";
shift @raw_data;
untie @raw_data;
##





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




RE: Another Nubie Question

2002-09-12 Thread Bob Showalter

> -Original Message-
> From: Simopoulos [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 12, 2002 7:59 AM
> To: Perl Beginners
> Subject: Another Nubie Question
> 
> 
> Hi All,
> I have just been reading and learning so much from all of you 
> about Perl.
> I have noticed that there are many modules such as the DBD::Oracle.
> Where do you get these?  Who writes them?  How are they installed?

They are written by various Really Smart People who are kind enough to share
them with the rest of us.

All these questions (and more!) are answered at:

http://www.cpan.org/misc/cpan-faq.html

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




Weekly list FAQ posting

2002-09-12 Thread casey

NAME
beginners-faq - FAQ for the beginners mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?

Send mail to <[EMAIL PROTECTED]>

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

<[EMAIL PROTECTED]>.

  1.2 -  How do I unsubscribe?

Now, why would you want to do that? Send mail to
<[EMAIL PROTECTED]>, and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

<[EMAIL PROTECTED]>

  1.3 - There is too much traffic on this list. Is there a digest?

Yes. To subscribe to the digest version of this list send an email to:

<[EMAIL PROTECTED]>

To unsubscribe from the digest, send an email to:

<[EMAIL PROTECTED]>

This is a high traffic list (100+ messages per day), so please subscribe
in the way which is best for you.

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

http://archive.develooper.com/beginners%40perl.org/

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a week, and will be
available online in the archives, and at http://learn.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?

Send an email to <[EMAIL PROTECTED]> with your suggestion.

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who owns this list?  Who do I complain to?

Casey West owns the beginners list. You can contact him at
[EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?

Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?

Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl beginners.

  1.11 - When was this FAQ last updated?

Sept 07, 2001

2 -  Questions about the 'beginners' list.
  2.1 - What is the list for?

A list for beginning Perl programmers to ask questions in a friendly
atmosphere.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Monkeys
* Monkeys solicitating homework on non-Perl related SPAM.
  2.3 - Are there any rules?

Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun
  2.4 - What topics are allowed on this list?

Basically, if it has to do with Perl, then it is allowed. You can ask
CGI, networking, syntax, style, etc... types of questions. If your
question has nothing at all to do with Perl, it will likely be ignored.
If it has anything to do with Perl, it will likely be answered.

  2.5 - I want to help, what should I do?

Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?

We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

Please do not quote the documentation unless you have something to add
to it. It is better to direct someone to the documentation so they
hopefully will read documentation above and beyond that which answers
their question. It also helps teach them how to use the documentation.

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?

Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

"perldoc perldoc"

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

  2.8 Is this a high traffic list?

YES! You have been warned! If you don't want to get ~100 emails per day
from thi

Another Nubie Question

2002-09-12 Thread Simopoulos

Hi All,
I have just been reading and learning so much from all of you about Perl.
I have noticed that there are many modules such as the DBD::Oracle.
Where do you get these?  Who writes them?  How are they installed?
Peace,
Marsie



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


Re: Windows /dev/null device

2002-09-12 Thread Tim Musson

Hey Mohd, 

My MUA believes you used 
to write the following on Wednesday, September 11, 2002 at 4:13:56 AM.



MS> Hi ,
MS> How I can send my errors to a null device under windows environment(winxp).
MS> I tried $myoutput= `anycommand 2>null ` , but always this command create a 
MS> file called null .
MS> Thanks.

for some reason, MS decided to implement using only one L in nul.

$myoutput= `anycommand 2>nul`

-- 
[EMAIL PROTECTED]
Flying with The Bat! eMail v1.61
Windows 2000 5.0.2195 (Service Pack 2)
In a world without walls and fences, who needs Windows and Gates?


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




Re: password style text widget for perl/tk

2002-09-12 Thread zentara

On Wed, 11 Sep 2002 12:41:25 -0400, [EMAIL PROTECTED] (Jess Balint)
wrote:

>Hey all. Does anyone know how to create a password style text widget in tk?
>I have tried a few things, but can't seem to figure it out. Thanks.

I'm not an expert on Tk , but try this to get you going:

#!/usr/bin/perl -w

require Tk::LabEntry;
require Tk::DialogBox;

$mw = MainWindow->new();
$db = $mw->DialogBox(-title => 'Login', -buttons => ['Ok', 'Cancel'],
 -default_button => 'Ok');
$db->add('LabEntry', -textvariable => \$uname, -width => 20,
-label => 'Username', -labelPack => [-side => 'left'])->pack;
$db->add('LabEntry', -textvariable =>\$pw, -width => 20,
-label => 'Password', -show => '*',
-labelPack => [-side => 'left'])->pack;
$answer = $db->Show();

if ($answer eq "Ok") {
print "Username = $uname, Password = $pw\n";

}






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