Re: Easiest Way in Perl to check Whether a Disk is Mounted

2024-06-05 Thread karl
 You can check if something is mounted by comparing which device
 a specific directory is on and comparing it to its parent directory.

$ cat chk_mount.pl
#!/usr/bin/perl -w

use strict;
use Fcntl ':mode';

my $A = $ARGV[0] // "/";
my $B = $ARGV[1] // "/var";

my @Ast = stat $A;
my @Bst = stat $B;

if ( S_ISDIR($Ast[2]) && S_ISDIR($Bst[2]) ) {
if ($Ast[0] == $Bst[0]) {
print "$Ast[0], $Bst[0]: same filesystem\n";
} else {
print "$Ast[0], $Bst[0]: different filesystem\n";
}
} else {
print "not directories\n";
}

$ ./chk_mount.pl / /usr
2306, 2308: different filesystem
$ ./chk_mount.pl /usr/bin /usr
2308, 2308: same filesystem
$

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: project

2024-05-18 Thread karl
William:
> What is the need to develop a project in Perl?

Perl and some knowledge of what the project is about.

You can, at your own convenience or requirement, add some version 
control system, some editor or progremming environment, etc.

Regards,
/Karl Hammar


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: module dependency

2024-05-16 Thread karl
Netwinds:
> How do I know which other modules are required by the perl module
> (like Net::SMTPS) I am using?

You mean like go to cpan:
 https://metacpan.org/pod/Net::SMTPS
and looking at the left column under dependencies ?

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex

2024-01-24 Thread karl
Mike:
> I stand properly scolded.

I didn't want to scold anyone, it seems I expressed myself wrong.
Sorry for that.

Regards,
/Karl Hammar


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex

2024-01-23 Thread karl
Please stop using my mail address when replying, I'm on the list and
don't want two copies of the same mail (it's not about you Mike).

Mike 
> Why is my Perl not working on that command?
> 
> $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
> Unescaped left brace in regex is illegal here in regex; marked by <-- 
> HERE in m/a{ <-- HERE ,2}/ at -e line 1.
> $
> 
> But this works:
> $ perl -e 'exit(10) if "aaa"=~/a{0,2}/;'
> $
> 
> $ echo $?
> 10
> $

 On an old debian woody box I get:
$ perl -v | grep v5
This is perl, v5.6.1 built for i386-linux
$ perl -e 'exit(10) if "aaa"=~/a{,2}/;'; echo $?
0
$ perl -e 'exit(10) if "aaa"=~/a{0,2}/;'; echo $?
10

$ man perlre
...
   The following standard quantifiers are recognized:

   *  Match 0 or more times
   +  Match 1 or more times
   ?  Match 1 or 0 times
   {n}Match exactly n times
   {n,}   Match at least n times
   {n,m}  Match at least n but not more than m times
...

 So, old perl versions don't have the {,m} quantifier, check your 
documentation for that. The easy way out is to always use {0,m} instead 
of {,m}, which is the same thing in modern perl, actually there is no
need ever to use the {,m} quantifier.

I don't know why I don't get a perl error message above, maybe a bug.

///

 On a more uptodate system I get:
$ perl -v | grep v5
This is perl 5, version 34, subversion 1 (v5.34.1) built for 
x86_64-linux-thread-multi
$ perl -e 'exit(10) if "aaa"=~/a{,2}/;'; echo $?
10
$ perl -e 'exit(10) if "aaa"=~/a{0,2}/;'; echo $?
10

///

 If you are interested of the syntax rules, check under "Simple 
statements" in:

 (perl 5.6.1)
$ man perlsyn
   Any simple statement may optionally be followed by a SIN-
   GLE modifier, just before the terminating semicolon (or
   block ending).  The possible modifiers are:

   if EXPR
   unless EXPR
   while EXPR
   until EXPR
   foreach EXPR

...

 (perl 5.34.1)
$ man perlsyn
...
   Statement Modifiers
   Any simple statement may optionally be followed by a SINGLE modifier,
   just before the terminating semicolon (or block ending).  The possible
   modifiers are:

   if EXPR
   unless EXPR
   while EXPR
   until EXPR
   for LIST
   foreach LIST
   when EXPR

...

So, modern perl also have "for" and "when".

///

Also note that in a compound statement you have to ()'ize the EXPR as in

 if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK

in contrast to for the modifier you don't need to:

 STATEMENT if EXPR;

I prefer to always to use ()' around the expression, since it makes it 
easier to convert between the two forms.

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex

2024-01-22 Thread karl
Jorge Almeida:
> On Mon, 22 Jan 2024 at 13:00,  wrote:
> > Jorge Almeida:
> > > $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
...
> >   {,n}Match at most n times
...
> Yes, I read it (several times). I still don't understand it (I understand
> what you're saying, and I trust you're right, I just don't understand how
> this behaviour matches the description above--- "at most", really?)

Just think it like this:
 on the table there is three diamonds,
 can you find zero, one, or preferable two diamonds there ?
...
> Now, in
> perl -e 'print $1,"\n" if "aaa"=~/(a{,2})/;'
> $ aa
> this is understandable. More or less. Maybe the semantics of /a{,2}/ should
> be described as "match any number of consecutive 'a' whatsoever and capture
> at most 2  'a' characters...

No, it just looks at the first two a's and finds a match, there is 
still one "a" left, but who cares, you have already got your match.

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex

2024-01-22 Thread karl
Jorge Almeida:
> Please help me to understand this:
> $ perl -e 'exit(10) if "aaa"=~/a{,2}/;'
> $ echo $?
> $ 10

In man perlre, under "Regular Expressions" it says:

  {,n}Match at most n times

So /a{,2}/ matches "", "a", and "aa" and is ignorant about what 
comes before and after (basically). That "aa" is followed by a
"a" isn't something the expression prohibits. If you want that
try /^a{,2}$/ instead.

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Bash vs Perl

2023-07-14 Thread karl
Willam Torrez Corea:
> Can I mix bash with perl in a program?

Yes, both ways;
$ perl -e 'print "Hello World!\n"'
Hello World!
$ cat ls.pl
#!/usr/bin/perl -w
use strict;

print `ls @ARGV`
$ ./aa -r -t -l /usr | tail -4
drwxr-xr-x  35 root root   8192 Apr 20 21:24 lib
drwxr-xr-x   2 root root 118784 Apr 25 19:52 bin
drwxr-xr-x 548 root root  40960 Apr 25 19:52 include
drwxr-xr-x 197 root root 172032 Apr 25 19:52 lib64
$

> I want to create a program in Perl to execute the bash command.
> 
> *Basic Bash commands (echo, read, etc.)*

echo -> print()
read -> read() or readline()
etc. -> get a perl book or read an online tutorial

>- cd : Change the directory to a different location.

You can do that but that only affects the current shell, so
`cd /usr/local`; won't help you, use chdir() in perl instead.
For the same reason this doen't work either:
$ pwd
/Net
$ perl -e 'chdir("/usr/local");'
$ pwd
/Net
$

>- ls : List the contents of the current directory.

 either:
@list = `ls -1 /usr/local`;
$list = `ls -1 /usr/local`;
 you can also use
opendir(); readdir(), there is an example in man perlfunc under readdir.

>- mkdir : Create a new directory.

man perlfunc is your friend.

>- touch : Create a new file.

`touch zzz`
see example in man perlfunc under utime

>- rm : Remove a file or directory.

As in c, use unlink(), man perlfunc

>- cp : Copy a file or directory.

`cp `;

>- mv : Move or rename a file or directory.

As in c, use rename(), man perlfunc

> The program must update the package manager

Ask on one of the debian mailing lists.

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




tty functions

2023-07-02 Thread karl
 In perlfaq8 there is a question about how to open serial ports.

 Here is my take of it:
http://aspodata.se/git/openhw/bin/Tty.pm

 I use it to talk to a grbl controller, which i borrowed from a friend:
https://github.com/gnea/grbl.git
https://www.sainsmart.com/collections/genmitsu-cnc/products/sainsmart-genmitsu-cnc-router-3018-pro-diy-kit

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




UnixDate export problem

2015-11-06 Thread Karl Hakmiller

~/perlstuff$ perl hopdelta.plx
"UxixDate" is not exported by the Date::Manip module
Can't continue after import errors at hopdelta.plx line 9.
BEGIN failed--compilation aborted at hopdelta.plx line 9.
karlh@HAKS13:~/perlstuff$

I received this error trying to run a script taken from the Perl 
Cookbook (2nd Ed;Christensen & Torkington; p.107).

which begins as follows:

use Date::Manip qw (ParseDate UxixDate);

# print header;
printf "%-20.20s %-20.20s %-20.20s %s\n",
"Sender",  "Recipient", "Time",  "Delta";

$/ = '';   # Paragraph mode
$_ = <>;   # Read header
s/\n\s+/ /g;   # Join continuation lines


I've read the docs on the Date::Manip module and
several of its sub-modules but can find no
clarification there (which is probably because
I am a rank beginner with perl). So, assuming
there is no typo or bug in the script will someone
please point me toward a source that explains what
is (or isn't) happening here.

BTW, I'm using perl5 version 20 subversion 2 on Ubuntu 15.10

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regular expression

2011-04-28 Thread Karl Kaufman


- Original Message - 
From: Irfan Sayed irfan_sayed2...@yahoo.com

To: John W. Krahn jwkr...@shaw.ca; Perl Beginners beginners@perl.org
Sent: Thursday, April 28, 2011 9:28 AM
Subject: Re: regular expression


my logic was to just put the space character in place of comma and keep 
rest as it is


but unfortunately that does not work


Well, to be precise, your conceptual logic was fine; the implementation was 
flawed. As several have pointed out, you weren't replacing the comma with a 
_space_ *character*, but with the RegExp _whitespace_ *character class*. 



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: time format conversion

2011-04-21 Thread Karl Kaufman

Alternatives to shawn's response (w/o commenting on relative benefits)...

- Original Message - 
From: cc c...@belfordhk.com

To: beginners@perl.org
Sent: Thursday, April 21, 2011 4:37 AM
Subject: time format conversion 




Hi,

I have two strings that shows different times and I
want to find the difference in # of hours.

In PHP, there's strtotime(), but there isn't one
in Perl that I can find.


If loading additional modules is an option, the following can be of use...

Date::Manip
http://search.cpan.org/~sbeck/Date-Manip-6.23/lib/Date/Manip.pod
Date::Calc
http://search.cpan.org/~stbey/Date-Calc-6.3/lib/Date/Calc.pod

see also: The Many Dates and Times of Perl
http://www.perl.com/pub/2003/03/13/datetime.html




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: time format conversion

2011-04-21 Thread Karl Kaufman


- Original Message - 
From: Rob Dixon rob.di...@gmx.com

To: beginners@perl.org
Cc: shawn wilson ag4ve...@gmail.com
Sent: Thursday, April 21, 2011 1:14 PM
Subject: Re: time format conversion



On 21/04/2011 10:52, shawn wilson wrote:


If its always in that format, just split and define a hash and pass
it to dt. Otherwise, use dt:format:natural.


I don't understand why you are abbreviating package names when even the
capitalisation is so critical to the proper functioning of the program.

You mean:

DateTime::Format::Natural


Further, I would think that being specific, rather than using shorthand 
which assumes experience/knowledge, would conform better to the mailing 
list's stated audience. 



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-21 Thread Karl Kaufman


- Original Message - 
From: Rob Dixon rob.di...@gmx.com

To: Randal L. Schwartz mer...@stonehenge.com
Cc: beginners@perl.org
Sent: Thursday, April 21, 2011 12:21 PM
Subject: Re: Nature of this list



On 21/04/2011 17:25, Randal L. Schwartz wrote:


People come online to learn Perl.


Yes! But you have succumbed to Germanic syntax where asentence needsonly
spaces tomakesense. It is 'on line'.


'Online,' in the above context, is both proper and correct in at least one 
sizeable region. Now, if he were looking to buy Bieber tickets...



I just signed-up for this list, but had to double-check that I hadn't 
accidentally subscribed to a Python mailing. (I came here for a Perl 
education.)




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Real Beginner

2011-04-21 Thread Karl Kaufman


- Original Message - 
From: Shlomi Fish shlo...@iglu.org.il

To: beginners@perl.org
Cc: Tiago Hori tiago.h...@gmail.com
Sent: Thursday, April 21, 2011 3:01 PM
Subject: Re: Real Beginner



On Thursday 21 Apr 2011 22:03:27 Tiago Hori wrote:


print Hi $name! ;


You're missing a \n.


Naw, the original post indicates that they want all the output on a single 
line. The return comes later...


... either here:


print$lastperson!\n;


... or here:


   print You are the first here!\n;




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Real Beginner

2011-04-21 Thread Karl Kaufman



- Original Message - 
From: Tiago Hori tiago.h...@gmail.com

To: beginners@perl.org
Sent: Thursday, April 21, 2011 2:03 PM
Subject: Real Beginner


I was trying to do exercise 5 of the 5th edition of learning perl:

...

4. [10] Write a subroutine, named greet, that welcomes the person you name
by telling them the name of the last person it greeted:

...
5. [10] Modify the previous program to tell each new person the names of 
all

of the people it has previously greeted:

...

So I worked on it for a while and got something really close to what is in
the answers, but what you get as an output is grammatically incorrect, it 
is

missing the commas and such. I figured that in reality, eventually in the
real world, I would want the output to be correct or at least tab 
delimited.

So I went about trying to get commas in and I came up with this:


! /usr/bin/perl


use strict;

use 5.010;


sub greet {

state @people;

my $name = shift @_;

print Hi $name! ;

if (@people){

my @peoplec = @people;

my $lastperson = shift @peoplec;

my $beforelast = shift @peoplec;

print I've seen: ;

foreach (@peoplec){

   print $_, ;}

   print $beforelast and ;

   print$lastperson!\n;

 }

  else {

print You are the first here!\n;

}

 push @people, $name;

   }

greet (Fred);
greet (Barney);
greet (Wilma);
greet (Betty);
greet (Bamm-Bamm);

exit;

I am no perl expert, but this code looks really clunky to me, so I was 
just

looking for some input. If your input is your code sucks without any
constructive suggestion, please keep it for yourself, since I already know
that my code sucks! :P I am beginner, that's what newbies do, they suck 
(in

general, some people are brilliant and don't, not my case).



One quick alternative to the original problem would be to replace your loop 
logic with a simple print of the array as a string (@peoplec); or, if you 
want to insert commas, via the join() function.


 http://perldoc.perl.org/functions/join.html

(Though I don't know whether that would be jumping ahead, relative to where 
you are in the book.  i.e. Was the exercise intended to learn more about 
looping?)


Here are a few thoughts relative to what you have so far (again, without 
knowing what tools you are authorized to use)...


- In shift-ing the names for comparison, what if you're the 2nd visitor? 
(i.e. there has only been one other visitor but you're currently trying to 
pull two names from the visitors list) Depending on how you construct your 
conditional logic, you would really only need to pull one name from the 
list.


- Would the existing method of shift-ing the names off the @people array 
result in a report of visitors in the order desired? (see: pop() function: 
http://perldoc.perl.org/functions/pop.html)


- Rather than looping, you could simply use a join() on your @peoplec array, 
after pop()-ing off the last visitor, and then just print out the last 
visitor prefixed with  and .


- Rather than pulling and storing the names of the visitors for comparison, 
you could use available array parameters (number of elements) to index your 
way through the original @people variable, via a for loop. (There would no 
longer be a need for the second @peoplec array.)


e.g.  without over-supplying...
 for (my $inx=1; $inx = $#people; $inx++){
   if ($inx  $#people){


Moving beyond a simple blast of previous visitors, possibly taking the 
project in a direction not explored in the book, does the wording of the 
problem require you to process the list of previous visitors to remove 
duplicates, and does the problem require display of the names alpahbetically 
or in ascending/descending order of their visits?


- How to reverse the listing of previous visitors, first-to-last and 
last-to-first?


- How well formatted should the display of visitors be? Can it just be one 
long line, regardless of the number of past visitors, or should it be 
formatted to look a bit nice, with a maximum length and a continuation 
indent?


- What if you want to see a list of previous individuals without 
duplication?


- What if you want to insure that each new person is uniquely identifiable?


Stop reading here.


/  spoiler alert  //


Below are the examples I played with to refresh my memory. One a slight 
modification of the original posted, one using join, and the last using 
array indexing.



sub greet_origtweak {

   state @people;

   my $name = shift @_;

   print Hi $name! ;

   if (@people)
   {
   my @peoplec = @people;

   my $lastperson = pop @peoplec;

   print I've seen: ;
   if (@peoplec)
   {
   print shift @peoplec;
   print , $_ foreach (@peoplec);
   print  and ;
   }
   print$lastperson!\n;
   }
   else
   {
   print You are the first here!\n;
   }

   

CPAN auxiliary pages indexing

2007-11-14 Thread Karl Erisman
Hi p.b,

What conditions on a CPAN module must hold in order for cpantesters
and cpanform to create pages for that dist?  My module, App::Smbxfer,
is indexed and in the module list.  It shows up on most of the CPAN
pages (i.e. it is on the other CPAN search pages, ANNOCPAN, RT,
CPANTS, ...) but not on http://testers.cpan.org/show/App-Smbxfer.html
-OR- http://www.cpanforum.com/dist/App-Smbxfer.  Kinda curious.

Thanks.

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




Compiling and distributing Perl

2004-10-07 Thread Karl Kaufman
Ok, I have a sane compiler toolset installed on my development server, but
NOT on several servers on which I want Perl.  (Where the development and
production servers are the same architecture.)

Can I build  install Perl on my development server, and then just
distribute it as a tarball to the production servers?

What about installation of custom Perl modules?  How can these be integrated
into my custom distribution on the production servers without a compiler
toolset on the production servers?  Can they?

I hope this wasn't too vague/broad a question.  Please interrogate if more
info is needed.

Thanks..!

Karl K.


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




Re: Compiling and distributing Perl

2004-10-07 Thread Karl Kaufman
Thanks for the reply, Jenda.

(OS/arch is Solaris8/Sparc)

The difficulty will be knowing exactly which files were added by a module
install -- if I want to distribute per module.  Otherwise, I guess I can
just roll the updated site_perl directory structure.  Yes?


- Original Message - 
From: Jenda Krynicky [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, October 07, 2004 9:10 AM
Subject: Re: Compiling and distributing Perl


 From: Karl Kaufman [EMAIL PROTECTED]
  Ok, I have a sane compiler toolset installed on my development
  server, but NOT on several servers on which I want Perl.  (Where the
  development and production servers are the same architecture.)
 
  Can I build  install Perl on my development server, and then just
  distribute it as a tarball to the production servers?

 Yes. If all servers are using the same OSarchitecture you should be
 able to do that. It would be better if you told us what architecture
 it is though.

 I can confirm that this does indeed work just fine for al kinds of MS
 Windows in Intel machines.

 To keep things simple you should keep the path to the instalation the
 same on all servers. Otherwise you may have to change some paths in
 Config.pm and maybe a few other places.

  What about installation of custom Perl modules?  How can these be
  integrated into my custom distribution on the production servers
  without a compiler toolset on the production servers?  Can they?

 Again ... if the OS  architecture is the same you should be able to
 compile the modules on the dev server and then copy the results to
 the production ones.

 Jenda
 = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
 When it comes to wine, women and song, wizards are allowed
 to get drunk and croon as much as they like.
 -- Terry Pratchett in Sourcery


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




number of files in a dir

2004-04-23 Thread Karl
Hi all.

Is there a module or function which will return the number of files in a dir 
or at least have similar results as

ls -1 | wc -l

Tks
-- 
Karl


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




Re: Program close

2004-02-11 Thread Karl Hakmiller

- Original Message - 
From: Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED]
To: Anthony Vanelverdinghe [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, February 10, 2004 12:41 PM
Subject: RE: Program close


-Original Message-
From: Anthony Vanelverdinghe [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 10, 2004 09:30
To: [EMAIL PROTECTED]
Subject: Program close


When I run a very simple Perl program, it closes immediately after it has
done. So that I can't even see the output. How can I solve this?

Thanks in advance!

I created a simple sub routine which I placed in the Perl/site/lib
directory.  Then if I am not running from a shell, I place the use statement
and the simple call to the sub which basically has a display depress any
key to continue and
chomp(my $MyInput = STDIN);


Wags ;)

There is also a graceful death module for Win32 users of Perl named
Win32::Die on CPAN.
It holds the DOS command line window open (so you can read screen output) ;
it waits until you press a key before closing the DOS window.






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




How to attempt login to Windows server from Unix?

2003-02-24 Thread Karl Kaufman
Hi,

I'm trying to automate creation of login failure Security Log entries on
NT -- but want/need to be able to do so from a Unix server.   Does anyone
have suggestions on how to accomplish this (ideally using Perl)?

Thanks in advance.

Regards,
Karl K.


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



Trouble with referencing hash entry

2003-02-04 Thread Karl Kaufman
Help,please...!, I'm dead in the water trying to understand why I'm unable to 
reference hash entries in what *I consider* to be a fairly straightforward manner.  
Any help/pointer is appreciated.

The hash entries *must* exist because I can reference and print them using a literal 
key (or within a foreach loop using the internal variable):

print $device{server1} . x\n;# Works fine

However, I CANNOT reference them using a separate variable:

print $device{$_}  . x\n;# Is failing miserably!!

What's my defect?!?

Thanks in advance...!

Karl K.


EXAMPLE OUTPUT ---
  
$device{server1}: x1x
$_:   xserver1x 
Use of uninitialized value at ./devicesWIP line 198. 
$device{$_}:  xx


PORTION OF EXAMPLE CODE (please let me know if more is needed) ---

print '$device{server1}: x' . $device{server1} . x\n; 
print '$_:   x' . $_   . x\n; 
print '$device{$_}:  x' . $device{$_}  . x\n;










Re: Trouble with referencing hash entry

2003-02-04 Thread Karl Kaufman
Cupie doll for Mr. Pinyan... thanks!

Both 'length' and (/^\w+$/) indicate an unprintable character in $_.Now
to find out what it is and where it's coming from.  (*argh*)

Thanks!


- Original Message -
From: Jeff 'japhy' Pinyan [EMAIL PROTECTED]
To: Karl Kaufman [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, February 04, 2003 8:40 PM
Subject: Re: Trouble with referencing hash entry


 On Feb 4, Karl Kaufman said:

 $device{server1}: x1x
 $_:   xserver1x
 Use of uninitialized value at ./devicesWIP line 198.
 $device{$_}:  xx

 print '$device{server1}: x' . $device{server1} . x\n;
 print '$_:   x' . $_   . x\n;
 print '$device{$_}:  x' . $device{$_}  . x\n;

 I'd check the length of $_, too.  It might have an unprintable character
 in it.

 --
 Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
 RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
 stu what does y/// stand for?  tenderpuss why, yansliterate of course.
 [  I'm looking for programming work.  If you like my work, let me know.  ]




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




Re: Epoch midnight

2003-01-11 Thread Karl Kaufman
Deborah,

I'll second Todd W's response, and warn you to avoid solutions doing direct
math on the result of time(), as they disregard the effects of Daylight
Saving Time and calendar adjustments since the epoch.

Also, you can get the other midnight bookend for today, using Todd's method,
though another timelocal() call:

   $todayEnd_epoch = timelocal( 0, 0, 24, $day, $month, $year );

Regs,
Karl


- Original Message -
From: Todd W [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, January 10, 2003 8:40 PM
Subject: Re: Epoch midnight




 Deborah Scott wrote:
  I thought I understood the answer, but I need more details.
 
  What exactly would I enter if I want a program to find the epoch time
for
  midnight each night? I know how to find current time and date in both
  human time and epoch time.
 
  I want to generate a report that displays the events that are scheduled
to
  occur each day. (from midnight to midnight)
 

 [trwww@devel_rh trwww]$ perl
 use Time::Local;
 ($day, $month, $year) = ( localtime() )[3 .. 5];

 $epoch = timelocal( 0, 0, 0, $day, $month, $year );

 print( scalar( localtime( $epoch ) ), \n );
 Ctrl-D
 Fri Jan 10 00:00:00 2003

 $epoch holds the seconds between the epoch and today at midight.

 Todd W.





 --
 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: Using map

2002-10-03 Thread Karl Kaufman

I, too, am interested in this syntax.  I had to do the same juggling in order to map 
the values without affecting the original array -- and would prefer cleaner syntax if 
it's possible.  Thx!  Karl

 new_names = map { ($x = $_) =~ s/(jpg|gif)$/html/i; $x } old_names;
 
 Is there a more elegant way to accomplish this? It just doesn't seem 
 elegant assigning $_ to $x, performing the substitution on $x, and then 
 returning $x.




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]




Having problems with AppConfig::Getopt module

2002-08-26 Thread Karl Kaufman


Hello,

I'm trying to use the 'AppConfig::Getopt' module to parse my command-line arguments, 
assigning the passed values to a hash.  It's not working.  And I need help.

For example:

  # test.pl -pagerdest [EMAIL PROTECTED]

Should result in:

  %pagerdest = {
 'karl' = '[EMAIL PROTECTED]'
  };

but, instead, I end up with:

  %pagerdest = {
 '[EMAIL PROTECTED]' = undef
  };


It looks like there's a problem with how AppConfig is linking the values back from 
Getopt::Long.  Getopt::Long appears to be stripping out the key= portion of the 
hash's argument -- if the linkage reference is 'CODE' rather than 'HASH'.

The following code snippet provides an example of how AppConfig is receiving changes 
from Getopt::Long; and the example below shows the loss of the hash key from the 
arguments.

Any idea how to fix the problem?  Or where else to search for an answer?

Thanks in advance.

Regards,
Karl K.


#  code example #
use Getopt::Long;

$linkage = sub { print @_\n; };

Getopt::Long::Configure('debug');
GetOptions(pagerdest=s% = $linkage);
# end of code example ## 


Example debug output -- 

# ./test.pl -pagerdest [EMAIL PROTECTED]

GetOpt::Long 2.19 called from package main.
  GetOptionsAl $Revision: 2.20 $
  ARGV: (-pagerdest [EMAIL PROTECTED])
  autoabbrev=1,bundling=0,getopt_compat=1,order=1,
  ignorecase=1,passthrough=0,genprefix=(--|-|\+).
= link pagerdest to CODE(0xcd370)
= $opctl{pagerdest} = =s%
= option -pagerdest
= find -pagerdest, prefix=(--|-|\+)
= split -+pagerdest 
= 1 hits (pagerdest) with pagerdest out of 1
= found =s% for pagerdest 
= ref($L{pagerdest}) - CODE 
= L{pagerdest}(pagerdest, [EMAIL PROTECTED])
pagerdest [EMAIL PROTECTED]




MIME::Lite 'Datestamp' problem -- truncating timezone? (UT instead of UTC)

2002-08-26 Thread Karl Kaufman

Hello,

I'm trying to determine whether there's a problem with the MIME::Lite
module.  I've sent an email to the module's author, but haven't heard back.
Is there a bugs mailing list somewhere that I can post the following info
to, in order to get verification and facilitate a fix.

(It's my opinion that the UT timezone on line 1057 of MIME::Lite is a
typo/error.)

Thanks in advance..!
Karl K.

Details ---

I noticed that timestamps on my emails generated using MIME::Lite were off
by 5 hours, so I looked into how MIME::Lite was timestamping the messages.
I quickly noticed what appeared to be the problem:   UTC is being
truncated to just UT in the prepared message -- so the receiving system,
unable to translate the unknown timezone (i.e. 'UT'), assumes local time
instead of
UTC/GMT -- causing the 5-hour difference (since my systems are in CDT).

Here's a sample message generated by MIME::Lite..

  Content-Disposition: inline
  Content-Length: 0
  Content-Transfer-Encoding: binary
  Content-Type: text/plain
  MIME-Version: 1.0
  X-Mailer: MIME::Lite 2.117  (F2.6)
  Date: Mon, 19 Aug 2002 22:18:44 UT
  From: Wile E. Coyote [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: Mon Aug 19 17:18:44 2002

Take a look at line 1057 and 3372 of the MIME::Lite code:

  1057:   my $date = $u_wdy, $u_mdy $u_mon $u_y4 $u_time UT;
  3372: Also added automatic inclusion of a UT Date: at top level unless

Here's my test environment specifics:
- MIME::Lite v2.117 running under Perl 5.005_03 on Solaris 2.6
- Lotus Notes R5 server is receiving the message, I believe.

Is UT supposed to be considered a valid timezone?  I can definitely say
that it's not recognized on either version of Solaris in my environment.
Both UTC and UCT are acceptable (and identical) but not UT.

 ls -ilR /usr/share/lib/zoneinfo | egrep -i 'ut|uc'
100358 -rw-r--r--  11 bin  bin   56 Jul 15  1997 UCT
100358 -rw-r--r--  11 bin  bin   56 Jul 15  1997 UTC
 75316 -rw-r--r--   1 bin  bin15504 Jul 15  1997
southamerica
 82445 -rw-r--r--   1 bin  bin  785 Jul 15  1997 South
13 -rw-r--r--   1 bin  bin  823 Jul 15  1997 Aleutian




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




Re: Having problems with AppConfig::Getopt module

2002-08-26 Thread Karl Kaufman

David,

You caught my typo in my email -- the braces should have been parens.
Unfortunately, that was just a typed-in example, and the original problem
remains:  AppConfig::Getopt cannot handle hashes passed on the command-line.

Regs,
Karl K.

- Original Message -
From: david
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 5:12 PM
Subject: Re: Having problems with AppConfig::Getopt module


i have never used AppConfig::Getopt before...

Karl Kaufman wrote:

 For example:

   # test.pl -pagerdest [EMAIL PROTECTED]

 Should result in:

   %pagerdest = (
  'karl' = '[EMAIL PROTECTED]'
   );

Fixed after the fact

but are you sure you mean that? it means it should assign a hash reference
to a hash. if you have -w turn on, you should see a warning. without -w,
your %pagerdest will end up(silently) using the memeory address of the
annom. ref as it's key and undef for it's value. how are you going to
access 'karl'?


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




Re: Getopt::Long option prefix

2002-08-26 Thread Karl Kaufman

Hi David,

From what I've seen, Getopt::Long default behavior is to accept either
'--opt|-opt'.   (Tested on Solaris 2.6 w/ Perl 5.005_03)

 test.pl  
#!/usr/local/bin/perl
use strict;
use diagnostics;
use Getopt::Long;
my %pagerdest = ();
Getopt::Long::Configure('default');
GetOptions(  pagerdest=s% = \%pagerdest );
foreach my $keyname (sort keys %pagerdest)
{
print pagerdest $keyname = $pagerdest{$keyname}\n;
}
#

  ./test.pl -pagerdest a=lkfd
pagerdest a = lkfd



- Original Message -
From: david
To: [EMAIL PROTECTED]
Sent: Monday, August 26, 2002 7:03 PM
Subject: Re: Having problems with AppConfig::Getopt module


Karl Kaufman wrote:

 For example:

   # test.pl -pagerdest [EMAIL PROTECTED]

is the above another typo? should it be:

test.pl --pagerdest [EMAIL PROTECTED]

you seem to have only one '-' in front of pagerdest?
Getopt::Long uses '--' not '-'

david


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




Regular Expressions II

2002-02-19 Thread Kittler, Karl

Okay, I got the string parsing working with one exception.
 
When the A HREF... /a tag runs across two or more lines the test
fails. Any suggestions?
 
Here's what I'm using for a multiple tag search throughout the
string(condensed):
 
while ($line =~
m/[\s]*A[\s]*HREF[\s]*=[\s]*[|'|]*([\D\w\d][^'\s]*)[|'|]*[]*(.*?)
\/a[]/gi){

 $url= $1;
 $linkname = $2;
 
print FILE $url\t$linkname\n;
 
}
 
This works for tags that occur on a single line.
 
I've tried adding in \r and \n and [\r\n] but no success.
 
Thanks again.



Perl Regular Expressions

2002-02-18 Thread Kittler, Karl

Hi all,
 
I've been writing in Perl for quite some time now, however regular
expressions have eluded me. I'm not completely sure why, but they have.
Now that I need them I figure I better get some assistance soon.
 
I'm trying to extract the linked text out of an html string. I thought
that matching text between  and /a would be the best way to do
this. I came up with the following line of code:
 
$line2 = string to be parsed.
 
 ($linkname) = ($line2 =~ m/[:alpha:]*\/a[]/gi); #extract the linked
text.
 
However when I do this, the value of $linkname is always /a. I
think this means it does see a linkname in the string, but doesn't
collect what I want.
I've tried several variations on the above, changing [:alpha:] to \w
adding in \s* changing the case of those character definitions.
Thinking my resource could be wrong.
 
I've also tried several things which return errors.
 
I'm also trying to figure out how to collect both the URL and the link
name in one line of code. From what I've read, it looks like it can be
done.
 
The initial goal is to create a list, including the link name, of every
URL on my site.
 
Thanks,
Karl Kittler
 



Re: modules

2001-10-05 Thread karl

On Fri, 5 Oct 2001, TS wrote:

 I use perl 5.005_03.
 how do I find out what modules are installed ?

$perl -MCPAN -e autobundle
This will first search for all installed module. Then it will search the
cpan archive for updates...
Perhaps you need answere a few question if this is the very first time you
connect to CPAN. But it's easy. Just do it:-)

 and how do I add new modules ?(where are they
 available?).

$perl -e MCPAN -e 'install MODUL_NAME::xxx'

this will search the archive after module namedd MODUL_NAME::xxx and
install it. If this module need other modules to work ok. The installation
prossess will automatic fix this.


Karl


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




Re: Do's anyone know of a perl script which prints only sentenceline s containing either a period . question? (fwd)

2001-10-04 Thread karl



-- Forwarded message --

PST! Just a little correction...
Sorry..
Karl

Hello, JA

Sorry my very week english language. I have try to find a solution for
your problem. But I'm a beginner to. At least. This work on my Red Hat
Linux 7.1 OS

If you try this:-)
Copy and past everything between ==start== and ==stop==
Save it in a file named misc.pl (or misc.cgi)
chmod 755 misc.pl
run it like this:

perl misc /path/to/the/source_file  print_the_results

Then you can open the new file named print_the_results
and every linje with a . or ? or , will be there..
Ok?

Karl

==start==
#!/usr/bin/perl -w

use strict;
open(SOURCE);   # open the file
while(){  # loop through the file
if($_ =~ /\?|\.|\,/){   # search for your . , ?
print $_; # print the results
}   # end if statement
}   # end the while loop
close(SOURCE);  # close the file
==stop==

I try it on Linux and it open and read a file.
Find the . and ? and , in some sentence





 Hello,
 Do's anyone know of a perl script which prints only sentence lines
 containing either a period . question?
 and a , comma.

 Many Thanks:)
 Just a beginner:)
 JA






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