perldoc -q password
How do I ask the user for a password?
(This question has nothing to do with the web. See a different
FAQ for that.)
There's an example of this in L). First, you put
the terminal into "no echo" mode, then just read the password
normally. You may do this with an old-style i
;Jeff 'japhy'
Pinyan" To: Craig
Moynes/Markham/IBM@IBMCA
<[EMA
I have a loop, each iteration through the loop the hash %tmpEntry gets a
new set of values.
And each iteration through the loop I place this hash into another hash,
like so:
[snip]
print "Added entry.\n";
$oncall{$tmpEntry{'StartDate'}} = \%tmpEntry;
[snip]
tmpEntry is defined outside the loop
: Craig
Moynes/Markham/IBM@IBMCA
Subje
You could write a script that reads a file that contains a list of files.
Compare the modification file of each file to the current date, if the file
is at least two days old try and delete it.
Then schedule this script to run everyday, take a look at:
man crontab
Cheers,
-
@matches = $var =~ m/\w{5}$something\w{5}/g
should work I believe
-
Craig Moynes
[EMAIL PROTECTED]
As far as I know this isn't possible. Admittedly reading in an existing
Excel file and then writing it out with changes is not as elegant is it an
option ?
-
Craig Moynes
Student-On-Call
netCC Development
Tel: (905) 316-3486
[EMAIL PROTECTED]
drieux
<[EMAIL PROTECTED]To: "Akens, Anthony"
<[EMAIL PROTECTED]>
om> cc: <[EMAIL PROTECTE
<[EMAIL PROTECTED]> To: "Akens, Anthony"
<[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
cc: Craig
Moynes/Markham/IBM@IBMCA
Something like this perhaps ?:
#!/usr/bin/perl -w
use strict;
my $USER_IDLE = 40;
my @input = qx!w -l!;
shift @input;
shift @input;
foreach my $entry ( @input )
{
my ($user, $port, undef, $idle) = split('\s+', $entry);
if ( $idle =~ /^\d+$/ && $idle > 0 )
{
Ok it was my fault :)
It appears to be the sequence I use to set the title of my xterm, I guess
it is grabbing it from my .profile when it tries to execute a command.
Thanks :)
-
Craig Moynes
[EMAIL PROTECTED]
Somehow I got myself into a pickle.
I have a string being set by a command that is executing (and the command
is failing). I strip out the newline characters.
The length is returned as 21, when split into an array the size is 21. Yet
when I try:
print "!$returned!\n";
I get returned:
!!
Any id
On Mon, 2002-05-13 at 15:01, Craig Moynes/Markham/IBM wrote:
> Hi all,
> Our servers are set up with a single development box, that contains
> all the compilers and what not. All the modules I need to install have
to
> be compiled on the development box, and then install
Hi all,
Our servers are set up with a single development box, that contains
all the compilers and what not. All the modules I need to install have to
be compiled on the development box, and then installed on each server (make
install). This works for now, (thanks to nfs) but I would like t
Wags helped me with the last problem (though we are still unsure of the
reason for the behavior).
This round I have encountered another similar problem. The code sample
works for printing out the scalars, but when I attempt to print out the
arrays instead the size of the arrays are printed, cau
Hey Perl'ers,
I can't seem to print the array reference within the struct correctly
( I get a blank rather than the expected data).
I grabbed this idea Chapter 12, pg 336 of Programming Perl and it looks
like I followed their sample but something doesnt seme to be working
correctly.
Cheers,
Hi all,
I have been tasked with reading and parsing a large MIB file. I
eventually have to create the traps but that's beyond this post.
Currently I am looking for a certain line of text, and for the most part
what I have written works. Looking for lines similar to this:
dot3ChipS
perldoc -f select
$timeToSleep=0.3;
select(undef, undef, undef, $timeToSleep);
-
Craig Moynes
Internship Student
netCC Development
IBM Global Services, Canada
Tel: (905) 316-3486
[EMAIL PROTECTED]
>hello,
>is there something in perl through which i can get
>date previous to some specified days ,say 20 days befores date
>i need to know only dd-mm-yy and not time
>is there any module function for it
>thanks
>shweta
I have seen several people mention Date::Calc, I believe that is overkill
This is a small test program I wrote to test the feasibility of what I want
to do.
Basically if an element in the array exists as a package group in the
hash, the array element be replace with the elements of the package group.
A package group is a hash ( I think its actually a scalar reference
From: Jie Meng <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 10, 2001 5:02 PM
Subject: A simple question
> > Dear all,
> > I plan to write a simple remote connection script, and then "ls" the
content
> > of the current directory, input like
> > telnet hostname
> > username
> >
> Calling perl gurus,
> Hello, help please!!! Looking to delete empty directories, I have a
script
> for that but if the directories have files in them, it dies. Either can
I
> add some type of script to delete them also or can I just avoid them all
> together and just delete the empty ones. A
>Hello,
>I sent an email yesterday, but never heard anything. Maybe it was the word
>'php' in the subject, but let me just simplify and ask another way.
>Is there a way to automatically direct all STDERR output to STDOUT. A
module I
>have installed automatically creates STDERR output, but I want t
>The perldoc for getopt::std states:
>Hash keys will be x (where x is the switch name) with key
>values the value of the argument or 1 if no argument is
>specified
This is true for getopt, but not getopts.
Getopts puts the parameter in the hash table (I am working on 5.005_03
built for aix )
per
>I have to source a KORN-Shell Script, so that the environment-Variables
>created by
>KORN-Shell is available in my PERL-Script. Ho do I that
The hash %ENV stores the environment variables.
if ( $ENV{HOME} =~ /dave/ )
{
print "Good morning Dave.";
}
http://www.perldoc.com/perl5.6/pod
I noticed from the sample execution (from the cmd line that you showed) it
seemed that maybe the commands should be passed with a carriage return
after each parameter. so instead of:
>
> echo "@" >>/dev/term/a [enter]
> echo "2" >>/dev/term/a [enter]
> echo "2" >>/dev/term/a [enter]
>
do somet
>A second is quite a bit of time to wait in a program, so you may want to
use
>Time::HiRes and usleep for a few milliseconds.
Another option is to use:
select( undef, undef, undef, x )
where x can be fractions of a second:
select( undef, undef, undef, 0.26 )
select( undef, undef, undef, 0.76 )
s
Hi,
I am running several commands within my perl script (on AIX 4.3.3).
These commands include find, chmod, etc.
What I am wondering is if anyone has a sample script kicking around where
they execute the command and check the return code, grabbing any output
(stderr or stdout) and printing it
I am trying to write a simple little client server relationship.
I receive the error:
Uncaught exception from user code:
Uncaught exception from user code:
Can't locate IO/Socket/INET.pm in @INC (@INC contains:
/usr/opt/perl5/li
b/5.00503/aix /usr/opt/perl5/lib/5.00503
/usr/opt/pe
I am not sure exactly what you need help with in this question.
The appending can be handled by something like:
$line = qq[Open\n"].$line.qq["\narbitary config setting 1\n\narbitrary
config setting 2\n\n];
Where $line already contains the line from the file.
Check this out for help with the '
Please try and be more descriptive with the subject lines.
-
Craig Moynes
[EMAIL PROTECTED]
"chris
To: Craig Moynes/Markham/IBM@IBMCA
,
[EMAIL PROTECTED]
wustl.edu> Subject: Re: Beginners Traini
Programming Perl is really quite good. Tons of info about the internals
...Chapter 5 right now for me ...lots to go.
Perl in a Nutshell is a good desk side reference once you have a handle on
the language.
I hear the Cookbook is also really good.
"If your bookshelf isn't full of perl, you don'
from a newbie to another newbie something like:
[snip]
my $newfile = "newfile name" # can get from parameters if you so desire
my $line;
unless(open( FILE, ">$newfile" ) )
{
# do fail stuff
}
foreach my $file ( @files ) # Setup @files with the list of filenames you
want to open
{
# You m
HANG ON :) Brain kicked into gear after I sent the last message.
open() returns a positive value if it succeeds ...what you want is
|
|
V
unless(open(LOG,">$logfile")) {
print "Content-type: text/html\n\n";
print "Couldn't open $logfile. $!\n";
print "At $date, $ENV{'REMOTE_
Uhm what about an ending " at your file name.
if(! open(LOG, ">xxx.txt")) {
instead of :
>if(! open(LOG, ">xxx.txt)) {
> print "Content-type: text/html\n\n";
> print "Can't open xxx.txt\n";
> exit;
>}
-
Craig Moynes
Internship Student
netCC Developm
from your small code sample everything checks out.
I would be inclined to ensure that the parameter is being read in correctly
with no trailing spaces or strange characters.
If you need more help send a bigger code sample for us to peruse.
-
Craig Moynes
[
Hi all, my DNS server is down so I can't check online.
Is there anyway to sleep for less than a second using the default
installation of perl ?
And if not what CPAN module should I use when I get my internet connection
back up ?
-
Craig Moynes
Internship
I have a script that when it runs (with no parameters) I have warnings
displayed (we have all seen them but) :
>Use of uninitialized value at ./log_prune.pl line 14.
Here is the beginning of my code that gives the warning:
#!/usr/bin/perl -w
use strict;
use Getopt::Std;
use LogUtil;
#help();
#
I have the following regexp:
@matches = $params{f} =~ /(%[aAbBcCdDehHIjmMnprStTuUVwWyY%])/g;
If I have a script:
[snip]
my @matches;
my ( %params );
getopts('DRSa:f:s:d:r:b:w:n:h?', \%params);
print "$params{f}\n";
print "@matches\n";
[snip]
I am passing -f "some string" in on the command lin
This is a problem with tail that I have run into as well.
If the file size gets reset the stored location of EOF remains the same
which is a problem. As the file is written too the size is still below that
of what tail is looking at. You can add a stat check to watch filesize and
reset the coun
First I have some questions.
Why is ALIGNMENT not a hash ? It seems perfect for what you are need. If
you use ALIGNMENT as a hash, then you can do away with the ID array.
Also you are checking for existence in alignment not ALIGNMENT, this will
be causing problems.
Simplify like this:
mine:
[
Ok heres my two cents
Hi guys,
[snip]
>sub DEBUG () { 1 }; # set level of debugness.
I have never seen this before, why do you use it ?
[snip]
>open (STDERR, "/tmp/userlog.log") or die $!;
[snip]
Personally I always include the 'arrow' I am using so in this case:
open (STDERR, ">/tmp/userlog.
I looked through my book (perl nutshell) and PP has not arrived yet, so I
will ask here.
I have an number that needs to be rounded to the nearest whole number.
This is my solution:
if ( $archives_needed =~ /\.\d+/ )
{
($remainder = $archives_needed) =~
I tried using the getopts, and getopt but I can't seem to have mandatory
parameters with optional parameters.
I have something like this for my usage
perl scp_logs.pl -u username -h hostname -l local_directory [-r
remote_directory]
Any thoughts on ways to manually parse the parameteres from @ARG
I am reading in a logfile, writing the records that are to be pruned from
the top to an archived file. I then open a temp file store the
modification time of the
logfile and write the remainder of the log to the tempfile. Then I check
the current modification time of the logfile if it has chang
Some of you may remember hearing about the logfile pruning/archiving tool I
was working on (with the date parsing from the record and second
calculations etc).
I am wondering about the 'perl way' or using variables. I have created a
class for a generic 'logfile'. I then have a series of instan
, but I've used Date::Manip and can say that it is awesome.
Check it
out.
--- Craig Moynes/Markham/IBM <[EMAIL PROTECTED]> wrote:
> Continuing with the problems for my 'date formatting' script.
>
> I am reading in a complete record from a logfile. I check to
Tue, 8 May 2001, Craig Moynes/Markham/IBM wrote:
> $values =~ s/.*$self->{DF_REGEXP}.*/$replaceString/g;
Perhaps you actually want:
@values_arr = $values =~ /.*$self->{DF_REGEXP}.*/
This will give you an array of the atomized matches in your regexp, and
you don't need to fool ar
Continuing with the problems for my 'date formatting' script.
I am reading in a complete record from a logfile. I check to see if the
regexp matches to something inside the record.
Then I want to find the what each grouped mini-regexp matched up with in
the monster one at the bottom of the email
Thanks, I don't know why I was having so much trouble with that.
I was trying to use the $1, $2 etc variables but that didn't seem to work.
Have to buy a good perl book in addition to my O'Reilly Nutshell Book.
thanks again for the borrowing of your brains
--
Ok I know I know how to do this but I just can't get it out of my brain
I have a string like this:
$string1 = "[%a %H:%M:%S %c] - - etc.etc.etc";
I need to parse out all the substrings that are similar to "%x" (where x is
any letter)
I have thought about tackling this using the regexp (%\w) usi
interesting ideas. I will definitely use the self-documenting
variable creation method, extra assignments be damned :)
Would it also be wise to use the qr// ?
Such as:
my $shortDayName = qr/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/;
then for example I could do:
my $abcXYZ = qr/$shortDayNa
Stumped on this problem
my ( %self );
$self->{DF_SPEC} = {
a => '(Mon|Tue|Wed|Thu|Fri|Sat|Sun)',
A => '(Monday|Tuesday|Wednesday|Thursday|Friday)',
b => '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)',
B =>
'(January|February|March|April
First sorry for asking this, I only keep select emails from this list and
couldn't find an answer among them.
I declare my hash like this:
my ( %FS_XCPTN ); # hash table, key is mount point,
# value is FS's special case H_LIMIT and
C_LIMIT
I use it
Continuing on with my earlier Date formatting program I have run into an
'ugly' issue.
I have created a Date formatting hash table like so:
( this is the shortened version)
$self->{DF_SPEC} = {
a => '(Mon|Tue|Wed|Thu|Fri|Sat|Sun)',
A =
My task is to create a Log file pruner for multiple types of logfiles. Now
this being reality both record seperators and date formats vary from log to
log. I have already nailed the record seperator problem by allowing the
user to input a regular expression as a parameter to define when a record
Hi,
I am passing a directory into my perl program. I want to list all
files only within that directory (do not descend to sub-directories). I
have tried using the File::Find::find command but to no avail.
Here are some code snippets:
xi#!/usr/bin/perl -w
##
]
"Stephen P.
Potter" To: Craig Moynes/Markham/IBM@IBMCA
<[EMAIL PROTECTED] cc: [EMAIL PROTEC
Wanted is where you want to change this. Within the function place a
regular expression or file-test ...anything that will give you a true/false
answer that you can use.
To get a list of executable files you would change
>sub wanted {
> print "$File::Find::name\n";
>}
to:
sub wanted
A little background. I am running an scp process within a perl script and
redirecting the error to a file (scp_err). I then read in the lines of
this file and attempt to place them in an error string to log to syslog.
Code Sample:
#!/usr/bin/perl -w
open ( ERR, ";
chop $in;
pr
I cannot use a fixed library path as the script will be installed in
different directories on different systems.
the idea is it will be executed as:
/home/dbncc/perl/scripts/.pl
and the library will also be located in the same directory.
-
Craig Moyne
Hi all,
I am executing a perl script from a directory other than the one it is
located in. I have a package that the script is using located in the same
directory as the script, but the script cannot find this package because
the package is not in the include directory. I need a way to incl
63 matches
Mail list logo