Re: Searching tecknical documentation

2004-11-16 Thread Gavin Henry


Stephen Liu said:
> Hi folks,
>
> Please advise where can I find similar free
> documentation on Internet, like;
>
> programming perl (O'reilly)
> Learning Perl (Llama)
> Programming Perl (Camel)
> Perl Cookbook (Ram)

You can't that's why they charge for it ;-)


> Google search brought me tons of links which a
> beginner finds it hard to sort out
>
> TIA
>
> B.R.
> Stephen Liu
>
> --
> 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: Searching tecknical documentation

2004-11-16 Thread Gavin Henry
Randal L. Schwartz said:
>> "K-sPecial" == K-sPecial  <[EMAIL PROTECTED]> writes:
>
> K-sPecial> Damn (if I may say so), nice link.
>
> Die, pirate scum.
>
> You insult me personally by pirating my words.  How do you expect
> me to have the means to write future books?

Well said.


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


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




Formating a list into one line. Regex or Substition?

2004-11-22 Thread Gavin Henry
Hi all,

I have a log file a like this:

The following packages were available in this version but NOT upgraded:
Canna-devel-3.7p3-6.i386.rpm
GConf-devel-1.0.9-15.i386.rpm
Guppi-devel-0.40.3-21.i386.rpm
HelixPlayer-1.0.1.gold-6.i386.rpm
Maelstrom-3.0.6-6.i386.rpm
MagicPoint-1.11b-1.i386.rpm
NetworkManager-0.3.1-3.i386.rpm
NetworkManager-gnome-0.3.1-3.i386.rpm

But with many more lines. I want to create a regex or substition to get rid of 
the rpm numbering and leave only the package name, so I can feed this to apt 
or yum and install the missing rpms.

So far I have swapped all \n for spaces, which gets everything on one line 
(using perl on the command line perl -pi -e 's/\n/ /' toinstall.log)

Can I make a regex for this, (don't tell me how, I'm just not sure which way 
to go) or should I carry one with substition?

Also, could I match rpm and substitute so many characters in front of it as 
well, like match rpm + 7 chars?

Gavin.


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: Formating a list into one line. Regex or Substition?

2004-11-22 Thread Gavin Henry
Chris Devers said:
> On Mon, 22 Nov 2004, Gavin Henry wrote:
>
>> I have a log file a like this:
>>
>> The following packages were available in this version but NOT upgraded:
>> Canna-devel-3.7p3-6.i386.rpm
>> GConf-devel-1.0.9-15.i386.rpm
>> Guppi-devel-0.40.3-21.i386.rpm
>> HelixPlayer-1.0.1.gold-6.i386.rpm
>> Maelstrom-3.0.6-6.i386.rpm
>> MagicPoint-1.11b-1.i386.rpm
>> NetworkManager-0.3.1-3.i386.rpm
>> NetworkManager-gnome-0.3.1-3.i386.rpm
>
> I know it's not the fasionable way to do this, but I just like doing
> this sort of thing on the command line with shell tools.
>
> Let's say the command to get the lines out of the file is:
>
>   grep '\.rpm$' logfile
>
> (If it's not that, amend as needed.)
>
> Try something like this to get the raw list:
>
>   $ grep '\.rpm$' logfile | sed 's/\-[0-9].*//' | fmt -1000
>   Canna-devel GConf-devel Guppi-devel HelixPlayer Maelstrom MagicPoint
> NetworkManager NetworkManager-gnome
>   $

Cool, cheers.

>
> And something like this to actually install it:
>
>   $ rpm -i `grep '\.rpm$' logfile | sed 's/\-[0-9].*//' | fmt -1000`
>
> (Or whatever the `rpm` command is -- I mainly use Debian, not RedHat, so
> I forget how to use RPM these days...).

it would be apt-get, as this works on Fedora too, and yum.

>
>> Can I make a regex for this, (don't tell me how, I'm just not sure
>> which way to go) or should I carry one with substition?
>
> Yeah, you can; the `sed` command above should point you the right way.

Thanks again.

>
>> Also, could I match rpm and substitute so many characters in front of it
>> as
>> well, like match rpm + 7 chars?

That was just a guess.

>
> Sure, but why seven?
>
> $ echo MagicPoint-1.11b-1.i386.rpm
> MagicPoint-1.11b-1.i386.rpm
> $ echo MagicPoint-1.11b-1.i386.rpm | sed 's/.*\(...rpm\)/\1/'
> 1.i386.rpm
>
> Or some variant on that...

Thanks.

>
>
>
> --
> Chris Devers
>


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




Re: Formating a list into one line. Regex or Substition?

2004-11-22 Thread Gavin Henry


daggerquill said:
> On Mon, 22 Nov 2004 08:56:59 +0000, Gavin Henry <[EMAIL PROTECTED]> wrote:
>> Hi all,
>>
>> I have a log file a like this:
>>
>> The following packages were available in this version but NOT upgraded:
>> Canna-devel-3.7p3-6.i386.rpm
>> GConf-devel-1.0.9-15.i386.rpm
>> Guppi-devel-0.40.3-21.i386.rpm
>> HelixPlayer-1.0.1.gold-6.i386.rpm
>> Maelstrom-3.0.6-6.i386.rpm
>> MagicPoint-1.11b-1.i386.rpm
>> NetworkManager-0.3.1-3.i386.rpm
>> NetworkManager-gnome-0.3.1-3.i386.rpm
>>
>> But with many more lines. I want to create a regex or substition to get
>> rid of
>> the rpm numbering and leave only the package name, so I can feed this to
>> apt
>> or yum and install the missing rpms.
>>
>> So far I have swapped all \n for spaces, which gets everything on one
>> line
>> (using perl on the command line perl -pi -e 's/\n/ /' toinstall.log)
>>
>> Can I make a regex for this, (don't tell me how, I'm just not sure which
>> way
>> to go) or should I carry one with substition?
>>
>> Also, could I match rpm and substitute so many characters in front of it
>> as
>> well, like match rpm + 7 chars?
>>
>> Gavin.
>
> Gavin,
>
> Substitutions are regexes.  The question is just whether to look for
> what you want to get rid of (s///), or what you want to keep (m//).  I
> would say that in most cases, it's going to be easier to look for what
> you don't want (.+i386.rpm) than to figure out the various forms what
> you do want might take, and building the memory parenthesis
> accordingly (or using $').  I'd personally go with something like
> 's/-.+?.rpm//'.

ah, great.

>
> If you're looking at a very large file, and you know you want to strip
> a fixed number of characters from the end of every line (e.g. just
> remove the 'i386.rpm' and leave all of the version numbers), you could
> speed things up by using substr().

The file is the upgrade.log from upgrading FC2 to FC3 (Fedora Core) and is
about 55,000 lines long due to xml docs errors. But the sed/grep command
from Chris took about 1/2 a second to parse it :-)

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!


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




Re: Can perl produce a huge-sized file for download testing?

2005-01-17 Thread Gavin Henry

> On Sun, 16 Jan 2005 22:53:29 -0800 (PST), [EMAIL PROTECTED] (Harold
> Castro) wrote:
>
>>Hi,
>>   Our company is involved in internet service
>>providing, and as such, troubleshooting our partner's
>>links is one of our day to day activities. We have our
>>own network monitoring system using mrtg and other
>>stuffs. On some occasions with intermittent links, the
>>mrtg is not acting as accurate as we are specting it
>>to. We therefore need to test our links manually by
>>downloading huge files from host to host and vice
>>versa.

Sorry, but for ease, have you seen:

http://dast.nlanr.net/Projects/Iperf/#whatis

Server mode is excellent.

Gavin.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




CGI Rsync script to show backup in realtime for end user

2005-01-26 Thread Gavin Henry
Dear all,

Is it possible for me to write a perl cgi script that will echo the output 
from an rsync backup?

Thanks.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: CGI Rsync script to show backup in realtime for end user

2005-01-27 Thread Gavin Henry
On Thursday 27 Jan 2005 02:01, JupiterHost.Net wrote:
> >> Is it possible for me to write a perl cgi script that will echo the
> >> output from an rsync backup?
> >
> > Sure, why not :)
> >
> > Sorry, had to be done ;p
> >
> > More info needed, code you've tried, how you're doing rsync, etc
> >
> > Start with:
> >
> > #!/usr/bin/perl
> >
> > use strict;
> > use warnings;
> >
> > use CGI;
> >
> > print CGI::header();
> >
> > print "Starting rsync...\n";
>
> Actually probably want to change the above two lines to:
>
> $|++;
>
> print CGI::header('text/plain');
>
> print "Starting rsync...\n";
>
> > # rsync code goes here

Cool. I'll show you what I've got later.

Thanks.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: CGI Rsync script to show backup in realtime for end user

2005-01-27 Thread Gavin Henry

>>> Is it possible for me to write a perl cgi script that will echo the
>>> output from an rsync backup?
>>
>> Sure, why not :)
>>
>> Sorry, had to be done ;p
>>
>> More info needed, code you've tried, how you're doing rsync, etc
>>
>> Start with:
>>
>> #!/usr/bin/perl
>>
>> use strict;
>> use warnings;
>>
>> use CGI;
>>
>> print CGI::header();
>>
>> print "Starting rsync...\n";
>
> Actually probably want to change the above two lines to:
>
> $|++;
>
> print CGI::header('text/plain');
>
> print "Starting rsync...\n";
>
>> # rsync code goes here
>>

So far I've got this, that works fine, but there's no output on the screen
when using File::Rsync. Not sure how to grab it. Oh, I still need to put
more checks in this:

#!/usr/bin/perl
#
#  program: rsync.cgi   #
#  license: GPL #
#  author:  Gavin Henry #
#  company: Suretec Systems Ltd.#
#  url: http://www.suretecsystems.com   #
#  version: v0.1#
#   #
#  first draft : 27-01-05   #
#  last update : 28-01-05   #
#

$|++;   # stdout hot
use strict; # avoid stupid bugs
use warnings;   # Let us know what is bad
require 5;  # for follwing modules
use CGI;# Use CGI stuff for web output
use Mail::Sendmail; # For sending the e-mails
use POSIX qw(strftime); # For the date format
use File::Rsync;# Rsync Perl module

my $to  = '[EMAIL PROTECTED]';
my $from= '"Suretec Support Services" <[EMAIL PROTECTED]>';
my $time= localtime;
my $datestamp   = strftime '%d.%m.%y.%T', localtime;
my $hostname= 'ndserver';
my $page= new CGI;
my %ropts   = ( verbose => 1, delete => 1, recursive => 1 );
my %dirs= ( src => '/home/ghenry/docbook', dest => 
'/home/ghenry/docbook2');

print
$page->header(),
$page->start_html(
-title=>'Backup Progress',
-author=>'Suretec Systems Ltd.',
-style=>'/suretec.css',
);

print '

Backup starting
Please be patient
';

my $bck = File::Rsync->new(\%ropts);
$bck->exec(\%dirs) or warn 'Backup failed';

print '';
my %mails = (
To  => "$to",
From=> "$from",
Subject => "Ad-hoc backup complete on $hostname on $time",
Message => "Ad-hoc backup has been completed on $hostname"
. " on $time\n"
."Backup Solution brought to you by Suretec Systems Ltd.\n\n"
."T \+44 \(0\) 1467 624141\n"
."F \+44 \(0\) 1224 742001\n"
."E [EMAIL PROTECTED]"
."W http\:\/\/support.suretecsystems.com\n\n"
."Open Source. Open Solutions\(tm\).\n\n"
."http://www.suretecsystems.com/\n";
);
sendmail(%mails);
# Success finish message
print "\Backup complete on $time for $hostname.\"
  ."\E-mail sent to David Cullen and Suretec with details.\";


# Create a success logfile
open LOG, ">>/opt/suretec/logs/Ad-hoc-backup-$datestamp.log"
  or die "Cannot create logfile: $!";
print LOG
 "Ad-hoc backup completed on $time for $hostname\n\nAn e-mail has
been sent.\n\n"
 ."Backup Solution brought to you by Suretec Systems Ltd.\n\n"
 ."T \+44 \(0\) 1467 624141\n"
 ."F \+44 \(0\) 1224 742001\n"
 ."E [EMAIL PROTECTED]"
 ."W http\:\/\/support.suretecsystems.com\n\n"
 ."Open Source. Open Solutions\(tm\).\n\n"
 ."http://www.suretecsystems.com/\n\n";;
close LOG;
print "\Logfile also created in \/opt\/suretec\/logs\/ on $time.\n\n";

print '',
$page->end_html() ;
exit (0);




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




[OT - maybe] cgi-bin script being run three times?

2005-01-27 Thread Gavin Henry
Dear all,

my rsync.cgi script that I was taking about earlier, when run via cgi-bin,
ps- aux soshow three copies of the same command.

Does a cgi process fork 3 times, or is this an apache feature?

A bit OT I know.

-- 
Kind Regards,

Gavin Henry.
Managing Director.

T +44 (0) 1467 624141
M +44 (0) 7930 323266
F +44 (0) 1224 742001
E [EMAIL PROTECTED]

Open Source. Open Solutions(tm).

http://www.suretecsystems.com/



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




Re: [OT - maybe] cgi-bin script being run three times?

2005-01-27 Thread Gavin Henry

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!


> On Thu, 27 Jan 2005, Gavin Henry wrote:
>
>> my rsync.cgi script that I was taking about earlier, when run via
>> cgi-bin,
>> ps- aux soshow three copies of the same command.
>>
>> Does a cgi process fork 3 times, or is this an apache feature?
>
> No, and no.
>
> Of course, there must be a reason that it's happening in this case, but
> without seeing the source, it's hard to say why it's happening.
>

It's below. I wanted to use File::Rsync, but I couldn't figure out how to
get the output of the command.

#!/usr/bin/perl

$|++;   # stdout hot
use strict; # avoid stupid bugs
use warnings;   # Let us know what is bad
require 5;  # for follwing modules
use CGI;# Use CGI stuff for web output
use Mail::Sendmail; # For sending the e-mails
use POSIX qw(strftime); # For the date format
#use File::Rsync;   # Rsync Perl module

my $to  = '[EMAIL PROTECTED]';
my $from= '"Support Services" <[EMAIL PROTECTED]>';
my $time= localtime;
my $datestamp   = strftime '%d.%m.%y.%T', localtime;
my $hostname= 'testserver';
my $page= new CGI;
my $rsync   = '/usr/bin/rsync';
my $option1 = '-v';
my $option2 = '--delete';
my $option3 = '-r';
my $origdir = '/orig';
my $todir   = '/new';
my $logdir  = '/orig';

my @args= ( $option1, $option2, $option3, $origdir, $todir );
#my %ropts  = ( verbose => 1, delete => 1, recursive => 1 );
#my %dirs   = ( src => '/home/ghenry/docbook', dest =>
'/home/ghenry/docbook2');

print
$page->header(),
$page->start_html(
-title=>'Backup Progress',
-author=>'Support Ltd.',
-style=>'/support.css',
);

print '

Backup starting
Please be patient
';

#my $bck = File::Rsync->new(\%ropts);
#$bck->exec(\%dirs) or warn 'Backup failed';

my $bdata = `$rsync @args`;
print "$bdata";

print '';
my %mails = (
To  => "$to",
From=> "$from",
Subject => "Ad-hoc backup complete on $hostname on $time",
Message => "Ad-hoc backup has been completed on $hostname on $time,
with the command:\n\n$rsync @args\n\nOutput: \n\n$bdata\n\n"
. " The commands output was: \n\n$bdata\n\n"
."Backup Solution brought to you by Support Ltd.\n\n"
);
sendmail(%mails);

open LOG, ">>$logdir/Ad-hoc-backup-$datestamp.log"
  or die "Cannot create logfile: $!";
print LOG
"Ad-hoc backup has been completed on $time for $hostname, with the
command:\n\n$rsync @args\n\nOutput: \n\n$bdata\n\nAn e-mail has been
sent.\n\n"
 . " The commands output was: \n\n$bdata\n\n"
 ."Backup Solution brought to you by Support Ltd.\n\n";
close LOG;

# Success finish message
print "\Backup complete on $time for $hostname.\<\/h3\>"
  ."\E-mail sent to Support with details.\<\/p\>"
  ."\Logfile also created in $logdir on $time.\<\/p\>"
  ."\<\/div\>";

$page->end_html() ;
exit (0);



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




Subroutine for a scripts progress

2005-02-02 Thread Gavin Henry
Dear all,

I haven't coded anything yet, but I was wondering if it has been done, or
can be done to write a small sub that can be called to show how a script
is progressing?

Like an on the sopt 1% 2% kind of thing or a  hash progress?

A small pointer to the correct feature/doc is all I am asking.

Thanks.



-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




RE: Subroutine for a scripts progress

2005-02-02 Thread Gavin Henry

>
> you can use the perl debugger for that.
> see
> perldoc perldebug
>

Sorry, I should have been clearer, this is to show the end user how things
are progressing.

>
> -Original Message-
> From: Gavin Henry [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 02, 2005 5:36 PM
> To: beginners@perl.org
> Subject: Subroutine for a scripts progress
>
>
> Dear all,
>
> I haven't coded anything yet, but I was wondering if it has been done, or
> can be done to write a small sub that can be called to show how a script
> is progressing?
>
> Like an on the sopt 1% 2% kind of thing or a  hash progress?
>
> A small pointer to the correct feature/doc is all I am asking.
>
> Thanks.
>
>
>
> --
> Just getting into the best language ever...
> Fancy a [EMAIL PROTECTED] Just ask!!!
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
> *
> Disclaimer:
>
> This message (including any attachments) contains
> confidential information intended for a specific
> individual and purpose, and is protected by law.
> If you are not the intended recipient, you should
> delete this message and are hereby notified that
> any disclosure, copying, or distribution of this
> message, or the taking of any action based on it,
> is strictly prohibited.
>
> *
> Visit us at http://www.mahindrabt.com
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


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




Re: Subroutine for a scripts progress

2005-02-02 Thread Gavin Henry

> Dear all,
>
> I haven't coded anything yet, but I was wondering if it has been done, or
> can be done to write a small sub that can be called to show how a script
> is progressing?
>
> Like an on the sopt 1% 2% kind of thing or a  hash progress?
>
> A small pointer to the correct feature/doc is all I am asking.

Found it:

http://search.cpan.org/~fluffy/Term-ProgressBar-2.06-r1/lib/Term/ProgressBar.pm


> Thanks.
>
>
>
> --
> Just getting into the best language ever...
> Fancy a [EMAIL PROTECTED] Just ask!!!
>
> --
> 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]
 




Effective Perl Programming - Still valid, dated 1998?

2005-02-15 Thread Gavin Henry
Dear all,

I like the look of this book and I wanted to know if it is still valid for
today's Perl:

http://www.amazon.co.uk/exec/obidos/ASIN/0201419750/ref=ase_stonehengeconsul/026-0149589-0073218

I suppose certain parts of Perl, i.e. the fundamentals don't change, so it
is probably worth it.


Mr Randal L. Schwartz?

I know you read this list/group ;-)

Should I buy this?

-- 
Kind Regards,

Gavin Henry.
Managing Director.

T +44 (0) 1467 624141
M +44 (0) 7930 323266
F +44 (0) 1224 742001
E [EMAIL PROTECTED]

Open Source. Open Solutions(tm).

http://www.suretecsystems.com/



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




Re: Effective Perl Programming - Still valid, dated 1998?

2005-02-16 Thread Gavin Henry

>>>>>> "Gavin" == Gavin Henry <[EMAIL PROTECTED]> writes:
>
> Gavin> I suppose certain parts of Perl, i.e. the fundamentals don't
> Gavin> change, so it is probably worth it.
>
> There are definitely some timeless parts, but there are also
> some parts that have better solutions now.
>
> Gavin> Should I buy this?
>
> I can't answer that.  Paw through a copy somewhere, then buy it if
> you want it.

Thanks. Will do.

>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
> 0095
>  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]
> <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>




PDF Generation with PDF::API2 or similar

2005-02-17 Thread Gavin Henry
Dear Gurus,

What is the preferred way to generate PDF file?

I have never done this before and PDF::API2 seems to look good on cpan,
but I can't find any tutorials.

Anyone got any tips?


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Challenge (for me, at least)

2005-02-18 Thread Gavin Henry
On Friday 18 Feb 2005 23:16, Tyson Sommer wrote:
> Is there any way to squeeze the following into one line? (assume using
> CGI.pm and that my $q = new CGI;):

Don't hijack threads. Please start another.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: Perl waits for while to finish before printing if on the same line, why?(countdown prog)

2005-02-20 Thread Gavin Henry
On Monday 21 Feb 2005 04:08, Mark Jayson Alvarez wrote:
> Hi,
>   I'm new to perl and i'm trying to create a simple
> program that will act like a time bomb but will print
> a dot(something like a progress bar every second until
> the specified time arrives. Here's my code.
>
> my $countdown = 5;
> while ($countdown > 0){
> print "\.";
> sleep 1;
> $countdown--;
> }
> print "Kaboom!!"
>
> And the result..
> after waiting for 5 seconds, it displayed this line at
> once:
>
> .Kaboom!!
>
>
> Why does this happens with a while loop? I told it to
> print a single dot every 1 second. Do you know another
> way of making my progress bar program that display a
> single dot every one second on the same line until it
> reaches a given time?

See:

http://search.cpan.org/~fluffy/Term-ProgressBar-2.06-r1/lib/Term/ProgressBar.pm

>
> Thank you!
>
>
>
>
>
>
>
>
>
> __
> Do you Yahoo!?
> Yahoo! Mail - 250MB free storage. Do more. Manage less.
> http://info.mail.yahoo.com/mail_250

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: PDF Generation with PDF::API2 or similar

2005-02-22 Thread Gavin Henry

> Gavin Henry wrote:
>> Dear Gurus,
>>
>> What is the preferred way to generate PDF file?
>>
>> I have never done this before and PDF::API2 seems to look good on cpan,
>> but I can't find any tutorials.
>>
>> Anyone got any tips?
>>
>>
>
> There was a good discussion of this topic on the Chicago PM list in
> September 2004:
>
> http://mail.pm.org/pipermail/chicago-talk/2004-September/thread.html#1785
>
> There are several links in those threads of where people found examples,
> as well as how others have solved PDF problems.

Great thanks.


> Personally I haven't used it or worked with PDFs much
>
> http://danconia.org

PS. i have book marked your site, as I like the GetOpt templates. Thanks.

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




Understanding split in a while loop

2005-02-28 Thread Gavin Henry
Hi all,

Just a quickie. I think the answer is that th while loop is going through
the file twice?

--
Codes that does what I expect, i.e. prints out the 42 lines of my passwd
file, with the array spaces, due to the array in "", swapped for 
and runs on $_:

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

$" = '';

open PASSWD, "/etc/passwd"
  or die "Eh? ($!)";

while () {
my @passwds = split /:/;
print "@passwds";
}


--
This now only prints 21 lines?

I am not sure why? It misses the odd ones.


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

$" = '';

open PASSWD, "/etc/passwd"
  or die "Eh? ($!)";

while () {
my @passwds = split /:/, ;
print "@passwds";
}


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Understanding split in a while loop

2005-02-28 Thread Gavin Henry

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!


>>
>>
>>I am not sure why? It misses the odd ones.
>>
>>while () {
>>my @passwds = split /:/, ;
>>
> You are reading the file twice in each while loop. Whenever you access
> , it returns a line and moves to the next line of the file.
> So in "while () {" it returns one line of the passwd file  .
> As you are reading the line again in "my @passwds = split /:/, ;",
> you are missing out on the previous line.
>

Got ya!!

Thanks.

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




www.perldoc.com

2005-02-28 Thread Gavin Henry
Is anyone having trouble getting to this domain?

I can never get a connection.


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Understanding split in a while loop

2005-02-28 Thread Gavin Henry
On Monday 28 Feb 2005 18:34, John W. Krahn wrote:
> Gavin Henry wrote:
> > Hi all,
>
> Hello,
>
> > Just a quickie. I think the answer is that th while loop is going through
> > the file twice?
> >
> > --
> > Codes that does what I expect, i.e. prints out the 42 lines of my passwd
> > file, with the array spaces, due to the array in "", swapped for 
> > and runs on $_:
> >
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
> >
> > $" = '';
> >
> > open PASSWD, "/etc/passwd"
> >   or die "Eh? ($!)";
> >
> > while () {
> > my @passwds = split /:/;
> > print "@passwds";
> > }
>
> You could also do that with Perl's built-in functions:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> $" = '';
>
> setpwent;
> while ( my @passwds = getpwent ) {
>  print "@passwds";
>  }
> endpwent;

I'll do a:

perldoc -f setpwent 

and have a read



>
> John
> --
> use Perl;
> program
> fulfillment

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




setpwent

2005-02-28 Thread Gavin Henry
Dear all,

How come if I:

perldoc -f setpwent

I don't get the same as shown here:

http://www.perl.com/doc/manual/html/pod/perlfunc/setpwent.html

the perldoc way didn't even say:

setpwent - prepare passwd file for use

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: setpwent

2005-03-01 Thread Gavin Henry
On Tuesday 01 Mar 2005 01:08, John W. Krahn wrote:
> Gavin Henry wrote:
> > Dear all,
>
> Hello,
>
> > How come if I:
> >
> > perldoc -f setpwent
> >
> > I don't get the same as shown here:
> >
> > http://www.perl.com/doc/manual/html/pod/perlfunc/setpwent.html
> >
> > the perldoc way didn't even say:
> >
> > setpwent - prepare passwd file for use
>
> If you are on Unix/Linx/BSD there is more information in the man pages:
>
> man setpwent


Ah.


>
> John
> --
> use Perl;
> program
> fulfillment

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




code on stonehenge.com for adding line numbers to code

2005-03-01 Thread Gavin Henry
Dear all,

I remember reading how Randal puts the =1= =2= in front of each line of
code on his site, but I can't find it again.

Anyone remember?

Thanks.


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: code on stonehenge.com for adding line numbers to code

2005-03-01 Thread Gavin Henry

> is this what you are looking for?
> $count=1;
> while() {
> print OUTFILE "=$count++= $_";
> }


It was more like perl -pi -e blah

>
> On Tue, 1 Mar 2005 11:23:44 - (GMT), Gavin Henry <[EMAIL PROTECTED]>
> wrote:
>> Dear all,
>>
>> I remember reading how Randal puts the =1= =2= in front of each line of
>> code on his site, but I can't find it again.
>>
>> Anyone remember?
>>
>> Thanks.
>>
>> --
>> Just getting into the best language ever...
>> Fancy a [EMAIL PROTECTED] Just ask!!!
>>
>> --
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>>
>>
>


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




Re: code on stonehenge.com for adding line numbers to code

2005-03-01 Thread Gavin Henry

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!


> On Tue, Mar 01, 2005 at 08:51:58AM -0500, Wiggins d'Anconia wrote:
>
>>and I figure you can remove the assignment in the
>> below, but I am not sure how
>>
>> perl -p -e '$_ = "=$.= $_"' test.pl
>
> Here's one way.
>
>   perl -pe 's/^/=$.= /' test.pl

That looks familiar

>
> --
> Paul Johnson - [EMAIL PROTECTED]
> http://www.pjcj.net
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>


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




Re: code on stonehenge.com for adding line numbers to code

2005-03-02 Thread Gavin Henry

>>>>>> "Gavin" == Gavin Henry <[EMAIL PROTECTED]> writes:
>
>>> perl -pe 's/^/=$.= /' test.pl
>
> Gavin> That looks familiar
>
> Yup.
>
> From emacs:
> step 1 - highlight Perl code as region
> step 2 - ^U ESC ! expand | perl -pi 's/^/\t=$.=\t/' CR
>
> It's programmed into my fingers. :)

I knew you'd answer.

Many thanks.

>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
> 0095
>  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]
> <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>




filehandle into a hash?

2005-03-10 Thread Gavin Henry
Dear all, 

I have the following:

#!/usr/bin/perl
use strict;
use warnings;
use Mail::Sendmail;

my $from = '"Test e-mails" <[EMAIL PROTECTED]>';
my $subject = 'Testing for survey e-mail';

open LIST, ";

foreach () {
my %mails = ( 
To  => "$_",
From=> "$from",
Subject => "$subject",
Message => "$message",
);
sendmail(%mails) or die $Mail::Sendmail::error;

print "Message has been sent to $_";
};

close LIST;
close MESSAGE;
print "All e-mails sent successfully.\n\n";


1. How can I get my whole email message into Message =>
2. I think my filehanldes are messess, can you suggest anything?
3. my $message = ; only gives the first line?

Thanks,

G.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: filehandle into a hash?

2005-03-10 Thread Gavin Henry
I should have searched cpan!!

http://search.cpan.org/~jimt/Mail-Bulkmail-3.12/

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: filehandle into a hash?

2005-03-10 Thread Gavin Henry
On Thursday 10 Mar 2005 20:29, Gavin Henry wrote:
> I should have searched cpan!!
>
> http://search.cpan.org/~jimt/Mail-Bulkmail-3.12/

Nevermind, overkill.

So my question still stands.

>
> --
> Just getting into the best language ever...
> Fancy a [EMAIL PROTECTED] or something
> on http://www.perl.me.uk Just ask!!!

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: filehandle into a hash?

2005-03-10 Thread Gavin Henry
On Thursday 10 Mar 2005 20:28, Wiggins d'Anconia wrote:
> Gavin Henry wrote:
> > Dear all,
> >
> > I have the following:
> >
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
> > use Mail::Sendmail;
> >
> > my $from = '"Test e-mails" <[EMAIL PROTECTED]>';
> > my $subject = 'Testing for survey e-mail';
> >
> > open LIST, " >   or die "Cannot open mailing list: $!";
> >
> > open MESSAGE, " >   or die "Cannot open mailing list message: $!";
> >
> > my $message = ;
> >
> > foreach () {
> > my %mails = (
> > To  => "$_",
> > From=> "$from",
> > Subject => "$subject",
> > Message => "$message",
> > );
>
> For efficiency you can most of the hash outside of the loop and then
> just tack on the To address inside of the loop since it is the only
> thing that changes. You can use slurp mode as the other poster mentioned
> or you can join the lines to turn them into a single string.
>
> > sendmail(%mails) or die $Mail::Sendmail::error;
> >
> > print "Message has been sent to $_";
> > };
> >
> > close LIST;
> > close MESSAGE;
> > print "All e-mails sent successfully.\n\n";
> >
> >
> > 1. How can I get my whole email message into Message =>
> > 2. I think my filehanldes are messess, can you suggest anything?
> > 3. my $message = ; only gives the first line?
> >
> > Thanks,
> >
> > G.
>
> my @message = ;
>
> my %mails = (
>  From=> "$from",
>  Subject => "$subject",
>  Message => join "", @message,
> );
>
> foreach () {
>sendmail('To' => $_, %mails) or die $Mail::Sendmail::error;
>print "Message has been sent to $_";
> };
>
> perldoc -f join

Excellent, many thanks. I remember reading that the other day.

>
> Also note this can be somewhat dangerous since you will die anytime a
> message fails to send. The problem is, what if you have 10 messages and
> message 3 fails? 4-10 don't get sent, the problem is that 1-2 have been
> sent.  You might capture all failures to a list of failed addresses,
> etc. warning on each pass. Then print some sort of good/bad report so
> you know which ones need to be resent.  As you can tell this problem
> gets magnified very quickly as the number of addresses in your list goes
> up.

Wouldn't sendmail just have them in a queue, and I would get I message later 
on?

What if I changed die, to warn in:

or die $Mail::Sendmail::error;

and stuck that in a file?

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Determining standard perl modules

2005-03-17 Thread Gavin Henry
Dear all,

How/where do I find out the standard bundled perl modules, like:

use DirHandle;
use Cwd;
use Getopt::Std;
use File::Path;
use File::stat;
use POSIX


I am building some RPMS, and need to know if I have to explicitly define
the module requirements, as they might already come with a standard perl
install

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Determining standard perl modules

2005-03-18 Thread Gavin Henry

> On Thu, 17 Mar 2005 10:48:30 -0500, Chris Charley wrote:
>>
>> > Dear all,
>> >
>> > How/where do I find out the standard bundled perl modules
>>
>> Hello Gavin,
>>
>> perldoc perlmodlib
>>
>> and then scroll to Standard Modules
>>
>> Chris

Thanks.

>>
>
> Or on the web, see: "http://search.cpan.org/dist/perl-/",
> e.g. :
> http://search.cpan.org/dist/perl-5.8.0/
>
> For access from inside a Perl script, see Module::CoreList -
> http://search.cpan.org/dist/Module-CoreList/
>
> Hope this helps,
> --
> Offer Kaye
>
> --
> 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: First time Parsing XML

2005-04-02 Thread Gavin Henry
On Saturday 02 Apr 2005 04:29, Johnstone, Colin wrote:
> Gidday All,
>
> I would like to use xml Parser to parse this chunk of xml (below) and
> return the business unit name and id attributes for each of the elements
> where division id = '221'
>
> I have tried

Why not try:

http://search.cpan.org/~grantm/XML-Simple-2.14/lib/XML/Simple.pm

If all you want to do is grab a business unit, follow the example on the page 
above.

>
> #!/web/Interwoven/TeamSite/iw-perl/bin/iwperl
>
> use XML::XPath;
> use XML::XPath::XMLParser;
>
> my $xpath;
> my $nodeset;
> my @memberList;
> my $arg;
> my $argVal;
>
> my $fileToParse =
> qq[/web/Interwoven/TeamSite/custom/config/DET_structure.xml];
>
> $xpath   = XML::XPath->new( filename => "$fileToParse" );
> $nodeSet = $xpath->find( $xpathQuery );
> @memberList  = map { XML::XPath::XMLParser::as_string( $_ ) }
> $nodeSet->get_nodelist();
> @memberList  = map { s|^.*(?=htdocs)||; $_; } @memberList;
> @memberList  = map { s|//|/|g; $_; } @memberList;
> # %masterList  = map {  $_, 1  } @memberList;
>
> while( @memberList ){
>
>   print( $_ . '\n' );
>
> }
>
> Any help appreciated
> Cheers
> Colin
>
> 
> 
>   
>   
>   
>id="276"/>
>id="204">
>   
>   
>   
>   
>id="1022"/>
>id="221">
>   
>   
>   
>   
>id="1003"/>
>   
>   
>id="1025"/>
>   
>id="1027"/>
>   
>   
>   
>   
>   
> 
>
> **
> Colin Johnstone
> Independent Interwoven Teamsite Analyst Programmer (Contractor)
> eGovernment Delivery Team
> Department of Employment and Training
> Phone (07) 3244 6268
> Fax   (07) 3244 6265
> Email Colin.Johnstone 
> Web   www.trainandemploy.qld.gov.au
> 
> Address   417 Main Street, Kangaroo Point 4169, QLD, Australia.
> **
>
>
> ---
>- This E-Mail is intended only for the addressee. Its use is limited to
> that intended by the author at the time and it is not to be distributed
> without the author's consent. Unless otherwise stated, the State of
> Queensland accepts no liability for the contents of this E-Mail except
> where subsequently confirmed in writing. The opinions expressed in this
> E-Mail are those of the author and do not necessarily represent the views
> of the State of Queensland. This E-Mail is confidential and may be subject
> to a claim of legal privilege.
>
> If you have received this E-Mail in error, please notify the author
> and delete this message immediately.
> ---
>- !DEPTSTAMP1!

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: perl module to create pdf reports

2005-04-28 Thread Gavin Henry
On Thursday 28 Apr 2005 20:42, radhika wrote:
> Hi,
> I need to create some customized pdf reports and was wondering if there
> are any perl modules out there to help.
> I already have my perl script getting data from the db and creating a csv
> file. I understand that there is an html2ps module which I can then use to
> make a pdf. Of course before that I need the HTML page, with all the
> formatting etc.
>
> Any ideas will help. Thanks.
> Radhika
>

This was released the other day:

http://entropy.homelinux.org/PDF-ReportWriter/


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: Writing my first perl script

2005-05-06 Thread Gavin Henry

>
> Hello,
>
> I'm not sure about the login or how I should approach what I want to
> achieve. I require a script that does the following.

Here are the quick answer, which provide you some reading material:

>
> 1. Search a directory and all sub-directories for a certain file
> extension. (Ex. .txt)

If you are famliar with the Unix find command, you can use find2perl;;

http://perldoc.perl.org/find2perl.html

>
> 2. Get the results of the above search and check "inside" each file for
> a string match. (Ex. "123").

You would use a while loop,  Filehandle and some regular expressions:

http://perldoc.perl.org/perlopentut.html
http://perldoc.perl.org/perlrequick.html
http://perldoc.perl.org/perlfaq5.html


>
> 3. List the matches found into an external file for further processing.

See above.

> What features should I be looking at to achieve this? Anyone know of
> some good examples that I could pick away at?
>

See above.

>
>
>
>
>
> --
> 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: Where will I find perl scripts

2005-05-06 Thread Gavin Henry

> Tielman Koekemoer (TNE) wrote:
>> Hi All,
>>
>> I think I'm like most people learn Perl easier when examining other
>> "guru's" scripts. Where is the best place on the net to find Perl
>> scripts that do everything, from doing pattern matching in arrays to
>> making coffee?
>>
>> Right now, however, I think pattern matching in arrays is more
>> important.
>>
>> TIA
>>
>
> The Perl power tools are replications of common Unix command line
> functions written by some solid Perl programmers,
>
> http://ppt.perl.org/
>
> Good luck,
>
> http://danconia.org

Look at anything on:

http://faq.perl.org/podtoc.html

-- 
Walking the road to enlightenment... I found a penguin and a camel on the
way. Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Writing my first perl script

2005-05-06 Thread Gavin Henry
On Friday 06 May 2005 16:50, macromedia wrote:
> Something like this?
>
> #!/usr/bin/perl -w
>
> #Syntax: test.pl "" ""
>
> require 5.000;
> use strict;
>
> # Pass filename parameter
> my $path = $ARGV[0];
> my $num = $ARGV[1];
>
> while ($line = <$path*.txt>) {
> open (FILE, $line) or die "cannot open $line: $!\n";
>   while () {
>  if ($line =~ /$num/ {
>  print $line;
>   }
> }
> close FILE;
> }
>

Looks good. Does it work?

>
> -Original Message-
> From: Gavin Henry [mailto:[EMAIL PROTECTED]
> Sent: Friday, May 06, 2005 11:24 AM
> To: beginners@perl.org
> Subject: Re: Writing my first perl script
>
> 
>
> > Hello,
> >
> > I'm not sure about the login or how I should approach what I want to
> > achieve. I require a script that does the following.
>
> Here are the quick answer, which provide you some reading material:
> > 1. Search a directory and all sub-directories for a certain file
> > extension. (Ex. .txt)
>
> If you are famliar with the Unix find command, you can use find2perl;;
>
> http://perldoc.perl.org/find2perl.html
>
> > 2. Get the results of the above search and check "inside" each file
>
> for
>
> > a string match. (Ex. "123").
>
> You would use a while loop,  Filehandle and some regular expressions:
>
> http://perldoc.perl.org/perlopentut.html
> http://perldoc.perl.org/perlrequick.html
> http://perldoc.perl.org/perlfaq5.html
>
> > 3. List the matches found into an external file for further
>
> processing.
>
> See above.
>
> > What features should I be looking at to achieve this? Anyone know of
> > some good examples that I could pick away at?
>
> See above.
>
> > --
> > 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>

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] or something 
on http://www.perl.me.uk Just ask!!!

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




Re: Script critique?

2005-05-06 Thread Gavin Henry
On Friday 06 May 2005 22:41, Jason Balicki wrote:
> Hello,
>
> I have several locations with a hardware VPN device and
> I've set them up to log to a central logging server.
>
> Some of the managers of these facilities would like to
> have a report showing who's using the VPN and when.
>
> I've written a script that does that.  It works, but as
> I'm pretty new at Perl (this is only my second real
> life application) I'm sure it could be improved
> (significantly).
>
> Would some kind soul like to take a look at this
> script, make suggestions or otherwise completely
> destroy my ego?  :)
>
> Thanks in advance to anyone who takes this up...
>
> The script can be found at:
>
> http://www.zeffert.com/vpn_report

Two quickies to save you time:

1. Use File::Temp http://search.cpan.org/search?query=file%3A%3Atemp&mode=all
2. Use HERE documents to save loads of print statements eg

 To begin a here document, follow print by the "<<" operator and a label

print << EOF;
my $stuff here
EOF




My tuppence.

Gavin.

> And some fake (sanitized) data to run it against (you'll
> have to make changes to the script accordingly):
>
> http://www.zeffert.com/fake_data (60k text file, some
> gunk has been pre-filtered)
>
> HINT: you can change $date in the script to get
> more hits.
>
> Thanks again,
>
> --J(K)

-- 
Walking the road to enlightenment... I found a penguin and a camel on the 
way.
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: The last element

2005-05-07 Thread Gavin Henry
On Sunday 08 May 2005 00:13, amr wrote:
> How can I call the last element in the array?
>
> I try the pop and it does the job but I think there is another way?


Of course, TMTOWTDI (http://catb.org/~esr/jargon/html/T/TMTOWTDI.html)

$ARRAY[$#ARRAY--]

See:

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

But, if you know how many items you have in your array, you can call it:

$array[last_item]

where last item is the number/item you want minus one.

If this is unclear, just say and I will explain it a bit more.

-- 
Walking the road to enlightenment... I found a penguin and a camel on the 
way.
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: The last element

2005-05-07 Thread Gavin Henry
On Saturday 07 May 2005 20:56, John W. Krahn wrote:
> Gavin Henry wrote:
> > On Sunday 08 May 2005 00:13, amr wrote:
> >>How can I call the last element in the array?
> >>
> >>I try the pop and it does the job but I think there is another way?
> >
> > Of course, TMTOWTDI (http://catb.org/~esr/jargon/html/T/TMTOWTDI.html)
> >
> > $ARRAY[$#ARRAY--]
>
> Oh wow.  Did you try that?  You do realise that modifying $#ARRAY changes
> the size of @ARRAY?

Yes, this was my misunderstanding of the OP question. He wants to only find 
out what is the last element of the array and not modify it, but I gave the 
equivalent of the pop command, which your proof demonstrates.

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

>
> $ perl -le'
> @ARRAY = "A" .. "Z";
> print "Size: " . @ARRAY, " $ARRAY[$#ARRAY]";
> print "Size: " . @ARRAY, " $ARRAY[$#ARRAY--]";
> print "Size: " . @ARRAY, " $ARRAY[$#ARRAY--]";
> print "Size: " . @ARRAY, " $ARRAY[--$#ARRAY]";
> print "Size: " . @ARRAY, " $ARRAY[--$#ARRAY]";
> '
> Size: 26 Z
> Size: 26
> Size: 25
> Size: 24 W
> Size: 23 V
>
>
>
> John
> --
> use Perl;
> program
> fulfillment

-- 
Walking the road to enlightenment... I found a penguin and a camel on the 
way.
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: The last element

2005-05-07 Thread Gavin Henry
On Saturday 07 May 2005 23:05, Peter Rabbitson wrote:
> On Sat, May 07, 2005 at 04:13:12PM -0700, amr wrote:
> > How can I call the last element in the array?
> >
> > I try the pop and it does the job but I think there is another way?
>
> If
>   my @a = (1, 2, 3, 4);
> then:
>
>   my $last = pop @a;
> is the same as
>   my $last = $a[-1];

Doh, I completely forgot that one.

>
> and
>
>   pop @a;
>   my $third = pop @a;
> is the same as
>   my $third = $a[-2];
>
> The negative sign in front of N means go N positions towards the start of
> the array from the end.
>
> Peter

-- 
Walking the road to enlightenment... I found a penguin and a camel on the 
way.
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Ebay Sell Module

2005-06-02 Thread Gavin Henry
Dear List,

I know there is a EBay Search module on CPAN, but do you think there would
be any interest in a EBay Sell module.

Something that gives us a way to resize your photos, put them on EBay or a
site of your choice and can fill out the sell form using WWW::Mechanize

Thoughts?

Thanks.

-- 
Walking the road to enlightenment... I found a penguin and a camel on the
way. Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Ebay Sell Module

2005-06-02 Thread Gavin Henry

> Dear List,
>
> I know there is a EBay Search module on CPAN, but do you think there would
> be any interest in a EBay Sell module.
>
> Something that gives us a way to resize your photos, put them on EBay or a
> site of your choice and can fill out the sell form using WWW::Mechanize
>
> Thoughts?

Just read:

http://pages.ebay.com/help/policies/user-agreement.html

Bin that idea then.

>
> Thanks.
>
> --
> Walking the road to enlightenment... I found a penguin and a camel on the
> way. Fancy a [EMAIL PROTECTED] Just ask!!!
>
> --
> 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]
 




String Length for password length testing?

2005-08-24 Thread Gavin Henry
Dear Guys,

I am stuck at something really fundamental. I am coding a wee cgi page to
change a OpenLDAP password, for Windows users on a Samba Server/LDAP
backend.

I haven't added any Net::LDAP stuff yet, just testing the basic password
form.

Would someone be so kind as to offer a simple reason my test doesn't work?

Should the le '6', I think so, but it never catches it?

Thanks:

#!/usr/bin/perl -T

use warnings;
use strict;
use CGI::Carp qw(fatalsToBrowser);

use CGI qw/:standard/;
print header,
  start_html('Change your Windows Password'),
  h1('Change your Windows® Password:'),
  start_form,
  "Username:",
  textfield('name'),
  br,
  "Old Password:",
  password_field(
-name  => 'oldpasswd',
-size  => 10,
-maxlength => 10
  ),
  br,
  "New Password:",
  password_field(
-name  => 'newpasswd',
-size  => 10,
-maxlength => 10
  ),
  br,
  "Verify Password:",
  password_field(
-name  => 'verify_passwd',
-size  => 10,
-maxlength => 10
  ),
  br,
  submit,
  end_form,
  hr;

if ( param() ) {
my $name = param('name');
my $oldpasswd = param('oldpasswd');
my $newpasswd = param('newpasswd');
my $verify_passwd = param('verify_passwd');

if ( $name eq '') {
  print "Must have a username!!\n";
  hr;
} elsif ($oldpasswd eq '') {
  print "Please enter your existing password!\n";
  hr;
} elsif ($newpasswd eq '') {
  print "Must have a new password!\n";
  hr;
} elsif ($newpasswd le 6) {
  print "Your password must be more than or equal to 6 characters\n";
  hr;
} elsif ($newpasswd ne $verify_passwd) {
  print "Sorry, your new passwords do not match!\n";
  hr;
} elsif ($oldpasswd eq $newpasswd) {
  print "Sorry, you are trying to use your existing password!\n";
  hr;
} elsif ( ($newpasswd eq $verify_passwd) && ($oldpasswd ne $newpasswd)
) {
  print "Your new password is ", em( escapeHTML($verify_passwd) ),
  hr;
} else {
  print "Situation unexpected, please contact Suretec!\n";
}
}



-- 
Walking the road to enlightenment... I found a penguin and a camel on the
way. Fancy a [EMAIL PROTECTED] Just ask!!!
http://aberdeen.pm.org

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




Re: String Length for password length testing?

2005-08-24 Thread Gavin Henry
> Ok first of all, if you are working with numbers you use < == <= >= !and
> since you want to check the length of the password, you are
> working with numbers.
> Another thing, you must get the lenght of the string, using length();
>
> So you need to do it this way:
> if(length($newpasswd)<6) {
> # do something if the password is less then 6 characters
>  }
>
> Hope it helped ;)
>

Ah, what an idiot!! I should have just searched my Perl CD Bookshelf for
the "length keyword"

Thanks.


-- 
Walking the road to enlightenment... I found a penguin and a camel on the
way. Fancy a [EMAIL PROTECTED] Just ask!!!
http://aberdeen.pm.org

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




Re: String Length for password length testing?

2005-08-24 Thread Gavin Henry


> On Wed, Aug 24, 2005 at 11:49:14AM +0100, Gavin Henry wrote:
>
>> Would someone be so kind as to offer a simple reason my test doesn't
>> work?
>>
>> Should the le '6', I think so, but it never catches it?
>
>   } elsif (length $newpasswd < 6) {
>
> perldoc -f length
> perldoc perlop

Noted.

Many thanks.

-- 
Walking the road to enlightenment... I found a penguin and a camel on the
way. Fancy a [EMAIL PROTECTED] Just ask!!!
http://aberdeen.pm.org

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




Re: New Website for Perl Beginners: perlmeme.org

2005-10-02 Thread Gavin Henry
Randal L. Schwartz said the following on 02/10/05 13:17:
>>"Shlomi" == Shlomi Fish <[EMAIL PROTECTED]> writes:
> 
> 
> Shlomi> Hi good people,
> Shlomi> there's a new web-site for Perl beginners - perlmeme.org - 
> 
> Shlomi> http://perlmeme.org/
> 
> Unless it's hidden, I'm not finding any obvious link there to the
> defacto standard location for Perl beginners, .
> I think this represents broken integrity on your part, since you
> appear to be trying to replace learn.perl.org, not supplement it, so
> you're attempting to fracture the community, not enhance it.
> 
> If you add a prominent link to learn.perl.org, I will withdraw my
> complaint.


I agree with this, and mentioned my thoughts here:

http://perlmonks.org/?node_id=496511

Thanks,

Gavin.



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




Re: How to implement Sudoku Solver/Generator by using Perl

2006-03-02 Thread Gavin Henry

> Hi,
>
> Is this possible to build "application" which solves Sudokus puzzles and
> also generates these ? I quess that I'm not only person on this planet who
> is thinging this question ;)

See this quarters The Perl Review:

www.theperlreview.com

>
> - hannhirv -
>
>
> --
> 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: LDAP query giving no results

2006-03-16 Thread Gavin Henry

>   I attempting to pull some data, but get no errors and NO data. I am
> following Graham Barr's examples with minor mods since it did seem to be
> just right.  Here is what I have leaving out the display of the data:
>
> #!perl
>
> use strict;
> use warnings;
>
> use Net::LDAP;
>
> #INITIALIZING
> my $ldap = Net::LDAP->new ( "xxx.xxx.com" ) or die "$@";  # change to
> protect someone
>
> #BINDING
> my  $mesg = $ldap->bind ( version => 3 ) or die "$@";  # use for
> searches also tried just as bind and still no data
> my $result;
>
> # OPERATION - Generating a SEARCH
>
>  sub LDAPsearch
>  {
>my ($ldap,$searchString,$attrs,$base) = @_;
># if they don't pass a base... set it for them
>
>if (! $base ) { $base = "o=Caliber System, c=US"; }#
>
># if they don't pass an array of attributes...
># set up something for them
>if (! $attrs ) { $attrs = [ 'cn','Recipients' ]; }
>my $result = $ldap->search ( base=> "$base",
> scope   => "sub",
> filter  => "$searchString",
> attrs   =>  $attrs
>   ) or die "$@";
> }
>
>  my @Attrs = ( );   # request all available attributes
> # to be returned.
>  printf "Entering into LDAPsearch\n";
>
>  $result = LDAPsearch ( $ldap, "sn=*", [EMAIL PROTECTED] );
>
>   Again I get no errors or warnings.
>
>   If someone can point me to either more examples or what I am doing wrong
> it would be greatly appreciated.
>
> Any questions and/or problems, please let me know.

Have you tried the search with ldapsearch on the commandline first? Always
best to do it that way.

Gavin.

>
>   Thanks!
>
> Wags ;)
> WGO: x2224
>
>
>
> ***
> This message contains information that is confidential
> and proprietary to FedEx Freight or its affiliates.
> It is intended only for the recipient named and for
> the express purpose(s) described therein.
> Any other use is prohibited.
> ***
>
>
> --
> 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: LDAP query giving no results

2006-03-17 Thread Gavin Henry

>> Have you tried the search with ldapsearch on the commandline first?
>> Always best to do it that way.
>>
>> Gavin.
>>
>   Sorry, but I attempted just ldapsearch ( very new to the ldap arena and
> no real knowledge ( to say the least ) ) from a kornshell and cmd, but no
> such exe found ( under windows xp server pak 2 ) runnning as 5.8.3.
>
> Wags ;)
>>>

Ah, it's a *nix thing. Part of OpenLDAP. Should have asked you, sorry.

If you can grab Java, try my two favourite LDAP Browser GUIs:

http://www-unix.mcs.anl.gov/~gawor/ldap/ (Grab the latest beta from 2001.
Still the best IMHO)

http://jxplorer.org/ (has lot of nice LDAP Knowledge links on the right of
the page)

For any kind of Schema stuff, read through:

http://ldap.akbkhome.com/

For a general LDAP Mailing list:

http://lists.fini.net/mailman/listinfo/ldap-interop

That's as OT as we get ;-)


Gavin.

-- 
Walking the road to enlightenment... I found a penguin and a camel on the
way. Fancy a [EMAIL PROTECTED] Just ask!!!
http://perlmonks.org/?node_id=386673

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




Re: Reegexp removing everything except...

2004-08-26 Thread Gavin Henry
juman said:
> I have som strings that I want to clean up. They can contain digits,
> some special characters (white space etc) and a comma and all I want to
> keep is the digits and the comma? Any idea how I could do this?
>

>From Learning Perl Chp9:

"9.6.1. Global Replacements with /g

As you may have noticed in a previous example, s/// will make just one
replacement, even if others are possible. Of course, that's just the
default. The /g modifier tells s/// to make all possible
nonoverlapping[206] replacements:

[206]It's nonoverlapping because each new match starts looking just
beyond the latest replacement.

$_ = "home, sweet home!";
s/home/cave/g;
print "$_\n";  # "cave, sweet cave!"

A fairly common use of a global replacement is to collapse whitespace;
that is, to turn any arbitrary whitespace into a single space:

$_ = "Input  data\t may haveextra whitespace.";
s/\s+/ /g;  # Now it says "Input data may have extra whitespace."

Once we show collapsing whitespace, everyone wants to know about stripping
leading and trailing whitespace. That's easy enough, in two steps:[207]

[207]It could be done in one step, but this way is better.

s/^\s+//;  # Replace leading whitespace with nothing
s/\s+$//;  # Replace trailing whitespace with nothing"


Now you know what to use, just figure the regex ;-)

--
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




OT: VIM perl indentaton

2004-08-27 Thread Gavin Henry
Hi all,

Kind of a perl question, how do I get VIM to indent perl code?


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: OT: VIM perl indentaton

2004-08-27 Thread Gavin Henry
Ramprasad A Padmanabhan said:
> On Fri, 2004-08-27 at 17:53, Gavin Henry wrote:
>> Hi all,
>>
>> Kind of a perl question, how do I get VIM to indent perl code?
>>
>>
>> --
>> Just getting into the best language ever...
>> Fancy a [EMAIL PROTECTED] Just ask!!!
>
> Use emacs :-)
>
> Anyway on a serious note , I dont think there is any auto indent
> possible in vi. You will have to set tab value and hit tabs as many
> times you want to indent.

Oh well :-(


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




Re: OT: VIM perl indentaton

2004-08-27 Thread Gavin Henry
> Fortunately, he specifically said "VIM", not Vi.
>
> Vim is a very nice improvement over traditional Vi that can do, among a
> great many other things, syntax highlighting and automatic indentation.
>
> Gavin -- what happens if you just put
>
>  set autoindent
>
> in your ~/.vimrc ? Does that not work ?
>

Hi Chris, this is what I have in ~/.vimrc

" Turn off vi compatibility settings like limited undo
set nocompatible
" Syntax highlighting based on file extension
syntax on
" Automatically insert newlines after 80 characters
set textwidth=80
" Automatically indent
set autoindent
" Match SGML tags with %
source $VIMRUNTIME/macros/matchit.vim


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




Re: OT: VIM perl indentaton

2004-08-27 Thread Gavin Henry
Chris Devers said:
> On Fri, 27 Aug 2004, Gavin Henry wrote:
>
>> Ramprasad A Padmanabhan said:
>>>
>>> Anyway on a serious note , I dont think there is any auto indent
>>> possible in vi. You will have to set tab value and hit tabs as many
>>> times you want to indent.
>>
>> Oh well :-(
>
> This is incorrect.
>
> Straight Vi may not be able to indent, but Vim can do it perfectly well.
>
> I use it all the time, it happens automatically, and it works well.
>
> <http://vimdoc.sourceforge.net/htmldoc/options.html#'autoindent'>
>
> For more Vim questions, this isn't the right list. There is a lot of
> material at <http://vimdoc.sourceforge.net/>, and you can sign up for
> Vim related mailing lists at <http://www.vim.org/community.php>.
>

Will do.


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: OT: VIM perl indentaton

2004-08-27 Thread Gavin Henry
Last question,

Do you need to press any keys to indent?


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: OT: VIM perl indentaton

2004-08-27 Thread Gavin Henry
Craig Turner said:
> (replying to digest)
>
>> > Gavin -- what happens if you just put
>> >
>> >  set autoindent
>> >
>> > in your ~/.vimrc ? Does that not work ?
>>
>> No Doesnt work for me , I am using vim 6.2 on linux ( redhat AS 3 ).
>> Any clue ?
>
> This may be a confusion over definitions.
>
> Gavin, Ram, if you do the following, does the editor keep the indentation?
>
> Type
> while {
>   if () {   

I press i first then type, and no it doesn't

>
> with autoindent on, your cursor should return to the same level of
> indentation as 'if'. However, this is different to indenting to the
> point where it's expecting you to want to type your next character. Is
> it this functionality that you're after?
>
>   - C
>
> --
> 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: OT: VIM perl indentaton

2004-08-27 Thread Gavin Henry
On Friday 27 Aug 2004 20:00, Damon Allen Davison wrote:
> Dear Gavin,
>
> Gavin Henry wrote:
>  > Kind of a perl question, how do I get VIM to indent perl code?
>
> Have a look here:
>
> http://mamchenkov.net/blog/item/vim_for_perl_developers
>
> IIRC, it was originally posted in some form at http://www.perlmonks.org,
> but it's the same author either way.

Great. I have indenting working now, but I will read this too.

Thanks all.

>
> Best,
>
> Damon
>
>
> --
>
> Damon Allen DAVISON
> http://www.allolex.net

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Indentation when coding perl

2004-08-28 Thread Gavin Henry
On Saturday 28 Aug 2004 04:21, you wrote:
> Did you ever get things working?

Yep all is fine now. I used the link for someones vimrc.

> -Original Message-
> From: Gavin Henry [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 27, 2004 9:56 AM
> To: [EMAIL PROTECTED]
> Subject: Indentation when coding perl
>
> Hi all,
>
> First post to the list. How to I set up autoident for perl in my ~/.vimrc
> file?
>
> I have set autoident in it but it doesn't work in insert mode. Is this
> correct?
>
>
>
> --
> Just getting into the best language ever...
> Fancy a [EMAIL PROTECTED] Just ask!!!

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Could this be made shorter and cleaner?

2004-08-30 Thread Gavin Henry
Hi all,

This is my first real go at a perl script. Thoughts?

Thanks.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!


suretec-backup
Description: Perl program
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: Could this be made shorter and cleaner?

2004-08-30 Thread Gavin Henry
On Tuesday 31 Aug 2004 00:43, Chris Devers wrote:
> On Tue, 31 Aug 2004, Gavin Henry wrote:
> > This is my first real go at a perl script. Thoughts?
>
> Don't send attachments?
>
> There's no telling what an attachment contains these days; if it's just
> a plain text Perl script then please paste it inline with your message.
>
> Thanks :-)

#!/usr/bin/perl

use strict;
use warnings;
use Mail::Sendmail;
use POSIX qw(strftime);

#
#  program: suretec-backup  #
#  license: GPL     #
#  author:  Gavin Henry #
#  company: Suretec Systems Ltd.#
#  url: http://www.suretecsystems.com   #
#  version: v1.0#
#   #
#  first draft : 30-08-04   #
#  last update : 31-08-04   #
#

# Globals
my $rdiff = '/usr/bin/rdiff-backup';
my $localdir = '/home/ghenry/perl';
my $userhost = "[EMAIL PROTECTED]";
my $remotedir = '/home/slim_jim/perl';
my $args = "$localdir $userhost\:\:$remotedir";
my $to = "[EMAIL PROTECTED]";
my $from = "[EMAIL PROTECTED]";
my $time = localtime;  
my $datestamp =  strftime "%d.%m.%y.%T", localtime;


# Suretec Message
print 
"\n\n";
print "Brought to you by Suretec Systems Ltd.\n";
print 
"\n";

# Start message
print 
"\n\n";
print "Initialising remote backup synchronsation on $time.\n";
print 
"\n";

# Using system command call to give us a return code, with die after 
if{}else{} block.
my $backup = system($rdiff, $args);

# Send e-mail with a few details for success and failures
# Success
if ($backup == 0) {
my %mails = ( To => "$to",
From => "$from",
Subject => "Remote backup complete from $ENV{HOSTNAME} on $time",
Message => "The remote backup has been completed on $ENV{HOSTNAME} on $time 
with the command:\n\n $rdiff $args\n" );
sendmail(%mails);
# Success finish message
print 
"\n\n";
print "Remote backup complete on $time. E-mail sent with details.\n";
print 
"\n";

# Create a success logfile
open LOG, ">>$datestamp-suretec-backup-success.log"
  or die "Cannot create logfile: $!";
print LOG "Remote backup completed on $time, with the command:\n\n$rdiff 
$args\n\nAn e-mail has been sent.\n";
close LOG;
print "Logfile created on $time.\n\n";

# Failure
} else {
my %mailf = ( To => "$to",
From => "$from",
Subject => "Remote backup failed from $ENV{HOSTNAME} on $time",
Message => "The remote backup has failed on $ENV{HOSTNAME} on $time with the 
command:\n\n$rdiff $args\n" );
sendmail(%mailf);
# Failure finish message
print 
"\n\n";
print "Remote backup failed on $time. E-mail sent with details.\n";
print 
"\n";

# Create a failure logfile
open LOG, ">>$datestamp-suretec-backup-failed.log"
  or die "Cannot create logfile: $!";
print LOG "Remote backup failed on $time, with the command:\n\n$rdiff 
$args\n\nAn e-mail has been sent.\n";
close LOG;
print "Logfile created on $time.\n\n";
}

# Did it work?
die "Backup exited funny: $?" unless $backup == 0;

# Program complete.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Could this be made shorter and cleaner?

2004-08-30 Thread Gavin Henry
On Tuesday 31 Aug 2004 01:51, you wrote:
> Gavin Henry wrote:
> > > Hi all,
> > >
> > > This is my first real go at a perl script. Thoughts?
>
> Congrats on your first script.
>
> Suggestions:
>
> 1. Indent code inside blocks.

ok.

>
> 2. The way you're calling system() looks odd. You're using more than one
> arg, which is a signal to bypass the shell. But your second arg looks like
> it needs shell processing. Does this actually work?

Yup, out of the cookbook.

>
> 3. Why not put the die() inside the else block?

yeah.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Could this be made shorter and cleaner?

2004-08-31 Thread Gavin Henry
> It looks like 99% of the code in both blocks is exactly the same.  You
> should
> factor out duplicated code.
>
> my $msg = $backup ? 'failed' : 'completed';
>
> my %mails = (
>  To  => $to,
>  From=> $from,
>  Subject => "Remote backup $msg from $ENV{HOSTNAME} on $time",
>  Message => "The remote backup has $msg on $ENV{HOSTNAME} on $time
> with
> the command:\n\n $rdiff @args\n"
>  );
> sendmail( %mails );
> # finish message
> print "\n", $separator, "Remote backup $msg on $time. E-mail sent with
> details.\n", $separator;
>

Thanks John and Chris. Chris, I have gone for John method of using the
$seperator, as I will use that more in this script when I add more
features, thanks for the pointer on here documents though.

I have taken on board all your suggestions, but I still have two questions:

1. How does the above code get the return code from rdiff to tell if it
failed or passed? Is this the $backup ? part, i.e. failed first, then
completed second?

2. use POSIX qw(strftime); I got this from Perl Cookbook. I take it this
is calling the POSIX strftime and putting it in a list, so when I select
%T etc. it is picking it from the list? Why does it fail if I put use
POSIX; and put qw(strftime); somewhere else.


Oh, and I have the bug now :-) It's a great felling when your script works!!!

You will be seeing much more of my code in here, so hopefully I will be
learning and not pasting the same mistakes.

P.S. I am now a programmer or a scripter, I am not sure is perl is
programming or scripting? I think programming.

Gavin.

Would anyone actually like a [EMAIL PROTECTED] e-mail address?



-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Could this be made shorter and cleaner?

2004-08-31 Thread Gavin Henry
John W. Krahn said:
> Gavin Henry wrote:
>>>It looks like 99% of the code in both blocks is exactly the same.  You
>>>should
>>>factor out duplicated code.
>>>
>>>my $msg = $backup ? 'failed' : 'completed';
>>>
>>>my %mails = (
>>> To  => $to,
>>> From=> $from,
>>> Subject => "Remote backup $msg from $ENV{HOSTNAME} on $time",
>>> Message => "The remote backup has $msg on $ENV{HOSTNAME} on $time
>>>with
>>>the command:\n\n $rdiff @args\n"
>>> );
>>>sendmail( %mails );
>>># finish message
>>>print "\n", $separator, "Remote backup $msg on $time. E-mail sent with
>>>details.\n", $separator;
>>
>> Thanks John and Chris. Chris, I have gone for John method of using the
>> $seperator, as I will use that more in this script when I add more
>> features, thanks for the pointer on here documents though.
>>
>> I have taken on board all your suggestions, but I still have two
>> questions:
>>
>> 1. How does the above code get the return code from rdiff to tell if it
>> failed or passed?
>
> The same way it did before.
>
>> Is this the $backup ? part, i.e. failed first, then
>> completed second?
>
> It seems like you may be confused by the conditional operator.  The
> statement:
>
> my $msg = $backup ? 'failed' : 'completed';
>
> Is short for:
>
> my $msg;
> if ( $backup == 0 ) {
>  $msg = 'completed';
>  }
> else {
>  $msg = 'failed';
>  }

Ah, got it. Do I just expand on the failure and completed message and add
in what I had before?

>
>> 2. use POSIX qw(strftime); I got this from Perl Cookbook. I take it this
>> is calling the POSIX strftime and putting it in a list,
>
> No, this is telling perl that the only function we want to import from the
> POSIX module is 'strftime'.

Got it.

>> so when I select
>> %T etc. it is picking it from the list? Why does it fail if I put use
>> POSIX; and put qw(strftime); somewhere else.
>
> Because the list of function names must follow the module name.
>
> perldoc -f use
>

Will do.

Lastly, the scripts fails when I uncomment $options, saying verbosity
needs a number, when I have it -v5 --print-statistics. Is this the wrong
way to pass the option?

Gavin.


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




RE: Could this be made shorter and cleaner?

2004-08-31 Thread Gavin Henry
Bob Showalter said:
> Gavin Henry wrote:
>> On Tuesday 31 Aug 2004 01:51, you wrote:
>> > 2. The way you're calling system() looks odd. You're using more
>> > than one arg, which is a signal to bypass the shell. But your
>> > second arg looks like it needs shell processing. Does this actually
>> > work?
>>
>> Yup, out of the cookbook.
>
> Odd. Which cookbook?

2 and 3:

Recipe 16.2 in version ":

To avoid the shell, call system with a list of arguments:

$status = system($program, $arg1, $arg);
die "$program exited funny: $?" unless $status == 0;

The returned status value is not just the exit value: it includes the
signal number (if any) that the process died from. This is the same value
that wait sets $? to. See Recipe 16.19 to learn how to decode this value.

>
> Here's a simple illustration of what I'm talking about.
>
> Consider a simple command like
>
>head /etc/services /etc/protocols
>
> This works, as it passes the command line to the shell for processing
>
>$ perl -e 'system "head /etc/services /etc/protocols"'
>
> This also works, as I'm splitting the arguments myself:
>
>$ perl -e 'system "head", "/etc/services", "/etc/protocols"'
>
> But this (which is similar to what you're doing) doesn't work:
>
>$ perl -e 'system "head", "/etc/services /etc/protocols"'
>head: /etc/services /etc/protocols: No such file or directory
>
> Since there's more than one argument to system(), the shell is bypassed,
> and
> execve(2) sees a single file name "/etc/services /etc/protocols" instead
> of
> two separate file names. Hence, the error message.

I get you now. rdiff-backup thinks -v5 --print-statistics in one arg, not
two.

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


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




RE: Could this be made shorter and cleaner?

2004-08-31 Thread Gavin Henry
> Since there's more than one argument to system(), the shell is bypassed,
> and
> execve(2) sees a single file name "/etc/services /etc/protocols" instead
> of
> two separate file names. Hence, the error message.
>

I have split the options up tp $option1 and $option2:

http://www.perl.me.uk/downloads/rdiff-script

Is this messy?

Gavin.


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




grabbing programs output for logfile

2004-08-31 Thread Gavin Henry
Hi all,

I thought I'd start a new thread for this one:

my $backup = system( $rdiff, @args);

Could I use $backup to write to my logfile?

Gavin.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




RE: Could this be made shorter and cleaner?

2004-08-31 Thread Gavin Henry
Thanks for your time Chris.

I will do the same when I get a bit better for others.

Let me digest this and get back to you.

Gavin.

Chris Devers said:
> On Tue, 31 Aug 2004, Gavin Henry wrote:
>
>> I have split the options up tp $option1 and $option2:
>>
>> http://www.perl.me.uk/downloads/rdiff-script
>>
>> Is this messy?
>
> It's not bad, but it still has a lot of repeated code, which should be a
> warning flag: if you have a lot of code repetition, it should probably
> be moved out into a subroutine.
>
> Hence, instead of this (with adjusted whitespace):
>
>  if ($backup == 0) {
>  my %mails = (
>  To  => "$to",
>  From=> "$from",
>  Subject => "Remote backup complete from $ENV{HOSTNAME} on
> $time",
>  Message => "The remote backup has been completed on
> $ENV{HOSTNAME}"
>  . " on $time with the command:\n\n $rdiff
> @args\n"
>  );
>  sendmail(%mails);
>  # Success finish message
>  print "\n", $sep, "Remote backup complete on $time. E-mail sent
> with details.\n", $sep;
>
>
>  # Create a success logfile
>  open LOG, ">>$datestamp-rdiff-backup-success.log"
>or die "Cannot create logfile: $!";
>  print LOG "Remote backup completed on $time, with the
> command:\n\n$rdiff @args\n\nAn e-mail has been sent.\n";
>  close LOG;
>  print "Logfile created on $time.\n\n";
>
>  } else {  # Failure
>  my %mailf = (
>  To  => "$to",
>  From=> "$from",
>  Subject => "Remote backup failed from $ENV{HOSTNAME} on
> $time",
>  Message => "The remote backup has failed on $ENV{HOSTNAME}"
>  . " on $time with the command:\n\n$rdiff @args\n"
>  );
>  sendmail(%mailf);
>  # Failure finish message
>  print "\n", $sep, "Remote backup failed on $time. E-mail sent
> with details.\n", $sep;
>
>  # Create a failure logfile
>  open LOG, ">>$datestamp-rdiff-backup-failed.log"
>or die "Cannot create logfile: $!";
>  print LOG "Remote backup failed on $time, with the
> command:\n\n$rdiff @args\n\nAn e-mail has been sent.\n";
>  close LOG;
>  print "Logfile created on $time.\n\n";
>  die "Backup exited funny: $?" unless $backup == 0;
>  }
>
> Try this:
>
>  my $to   = $to;
>  my $from = $from;
>  my ( $subject, $message, $log, $logmessage, %stat );
>  if ( $backup == 0 ) {
>  # The backup worked
>  $subject= "Remote backup complete from $ENV{HOSTNAME} on
> $time";
>  $message= "The remote backup has been completed on
> $ENV{HOSTNAME}"
>  . " on $time with the command:\n\n $rdiff @args\n"
>  $log= "$datestamp-rdiff-backup-success.log";
>  $logmessage = "Remote backup completed on $time, with the
> command:\n\n"
>  . "$rdiff @args\n\nAn e-mail has been sent.\n";
>  $stat{now}  = "complete";
>  $stat{then} = "completed";
>  } else {
>  # The backup failed
>  $subject= "Remote backup failed from $ENV{HOSTNAME} on
> $time";
>  $message= ""The remote backup has failed on $ENV{HOSTNAME}"
>  . " on $time with the command:\n\n$rdiff @args\n";
>  $log= "$datestamp-rdiff-backup-failed.log";
>  $logmessage = "Remote backup failed on $time, with the
> command:\n\n"
>  . "$rdiff @args\n\nAn e-mail has been sent.\n";
>  $stat{now}  = "fail";
>  $stat{then} = "failed";
>  }
>
>  # Report status to console, send a status report, write to log
>  print "\n", $sep, $message, $sep;
>  sendmail(
>  To  => "$to",
>  From=> "$from",
>  Subject => "$subject",
>  Message => "$message"
>  );
>
>  open  LOG, ">>$log" or die "Cannot open logfile $log for writing:
> $!";
>  print LOG $logmessage;
>  close LOG;
>  print "Logfile $log creat

RE: Could this be made shorter and cleaner?

2004-08-31 Thread Gavin Henry
stat is a new one for me,  am only on Chapter 7 in Learning Perl.

I will have to come back to this script when I get a bit further.

All good though :-)




-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Could this be made shorter and cleaner?

2004-08-31 Thread Gavin Henry
Daniel Staal said:
> --As of Tuesday, August 31, 2004 10:07 AM +0100, Gavin Henry is alleged to
> have said:
>
>> P.S. I am now a programmer or a scripter, I am not sure is perl is
>> programming or scripting? I think programming.
>
> --As for the rest, it is mine.
>
> Short answer: Yes.  (It is at least one of the two.)  ;)
>
> Long answer...  You honestly don't want to get into it.  You start
> devolving into arguments over what is 'scripting' versus what is
> 'programming', and from there what is best...
>
> To me, scripting is a sub-class of programming anyway, so why should it
> matter?  ;)
>

Yeah, I'm a programmer ;-)

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




RE: grabbing programs output for logfile

2004-08-31 Thread Gavin Henry
Jim said:
>
>> -Original Message-
>> From: Gavin Henry [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, August 31, 2004 10:11 AM
>> To: [EMAIL PROTECTED]
>> Subject: grabbing programs output for logfile
>>
>> Hi all,
>>
>> I thought I'd start a new thread for this one:
>>
>> my $backup = system( $rdiff, @args);
>>
>> Could I use $backup to write to my logfile?
>>
>> Gavin.
>>
>
> I think you are asking if $backup will contain the output of your sytem
> command? It won't. It will only contain the return code. You want back
> ticks
> or the the qx operator
>
> $backup = `$cmd`;
>  or
> $info = qx(ps -ef);
>
>  perldoc -f system
>
>

Thanks. I actually shouldn't of asked this, as I should have read the docs
and the cookbook first. Sorry.

>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.745 / Virus Database: 497 - Release Date: 8/27/2004
>
>
>


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




grabbing prpgrams output for logfile

2004-08-31 Thread Gavin Henry
Hi again,

I thought I would make a new one for this:

my $backup = system( $rdiff, @args);

Could I write $backup to my logfile?

Gavin.



-- 
Kind Regards,

Gavin Henry.
Managing Director.

T +44 (0) 1467 624141
M +44 (0) 7930 323266
F +44 (0) 1224 742001
E [EMAIL PROTECTED]

Open Source. Open Solutions.

http://www.suretecsystems.com/

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




System or Backticks?

2004-09-02 Thread Gavin Henry
Hi all,

Still thinking about this one. I have:

my $backup = system($rdiff, @args);

# Send e-mail with a few details for success and failures
# Success
if ($backup == 0) {
blah
}


I want to be able to stick the ouput of the $rdiff command into a strong,
as well as get an exit code for it?

Is this a backticks one?

Gavin.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: System or Backticks? - Don't reply, searched archives :-)

2004-09-02 Thread Gavin Henry
Sorry, this has been asked a million times, as I just foun din the
archives and perlmonk.

Don't bother replying :-)

Gavin.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Encrypting an in script password and wxperl

2004-09-22 Thread Gavin Henry
Dear all,

My next program is to help out my wife. It will resize some jpg's, upload
them via ftp to a website and email her the links of where they are. She
will use these for ebay listings. I also want a wee pop up box to ask for
the file or directory of the pictures.

I might have two version of this. One which will be stuck in gnome script
folder so she can just right-click the jpg and upload it. The other will
have the gui and an icon on the desktop.

This is all done apart form 2 bits:

1. How can I encrypt an in place password? (I know it will be sent plain
text)

2. Can I use wxperl for the dialog box and how hard would this be?

Thanks,

Gavin.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Optimize Problem

2004-09-23 Thread Gavin Henry
Millhost said:
> Dear All
>
> I am using this script to get my maillog information
>
> ##
> %IP_LOG=();
> open (LOG,/var/log/maillog);
> foreach () {
> if (/Sep 20/) {
> $IP_LOG{$_}++;
> }
> }
> ##
> I found this script will take 3-4 second when my log file in 40MB
> But I try using gerp "Sep 20" /var/log/maillog in bash shell, it take 0.8
> sec only.
>
> Did any one know how to optimize the script to have better performance.


Like this from Learning Perl:

#!/usr/bin/perl -w

use strict;
while (<>) {
chomp;
if (/Sep 20/) {
print "Matched: |$`<$&>$'|\n";  # Mystery code! See the text.
} else {
  print "No match.\n";
}
}

>
> Thanks all
>
> --
>
>
> -
> "Are you still wasting your time with spam?...
> There is a solution!"
>
> Protected by GIANT Company's Spam Inspector
> The most powerful anti-spam software available.
> http://mail.spaminspector.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: Optimize Problem

2004-09-23 Thread Gavin Henry
Millhost said:
> Dear All
>
> I am using this script to get my maillog information
>
> ##
> %IP_LOG=();
> open (LOG,/var/log/maillog);
> foreach () {
> if (/Sep 20/) {
> $IP_LOG{$_}++;
> }
> }
> ##
> I found this script will take 3-4 second when my log file in 40MB
> But I try using gerp "Sep 20" /var/log/maillog in bash shell, it take 0.8
> sec only.

Try using while(<>), so it processes it straight away. I think I am
correct in saying, foreach reads in the whole file first?

>
> Did any one know how to optimize the script to have better performance.
>
> Thanks all
>
> --
>
>
> -
> "Are you still wasting your time with spam?...
> There is a solution!"
>
> Protected by GIANT Company's Spam Inspector
> The most powerful anti-spam software available.
> http://mail.spaminspector.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]
 




Help with putting a subroutine into a variable?

2004-09-24 Thread Gavin Henry
Hi all,

I have this:

-
#!/usr/bin/perl

use warnings;
use strict;

my @pics = <*.jpg>;
my $website = 'http://www.website.com/uploads';

sub links {
foreach (@pics) {
print "$website/$_\n";
}
}
-

I would normally call the subroutine like &links; but I want to put the
result into a variable in order to stick it into an e-mail. I have been
trying all day reading all my perl books and it's time to ask for help.

Thanks.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Help with putting a subroutine into a variable?

2004-09-24 Thread Gavin Henry
> Your sub breaks encapsulation because it relies on the fact that @pics
> and $website are available in the sub but have not been passed into it.
> Generally we want our subs to take arguments and return values. If you
> were to move this sub to the top of the file or to another file (such as
> a library/module) it would break. So the first thing you should correct
> is the encapsulation by making your sub accept its arguments and return
> a value.
>
> sub links {
>my ($base_url, @list) = @_;
>foreach my $element (@list) {
>print .
>}
>return;
> }
>

I have the Perl V3.0 CD Bookshelf (Much better than V4.0 IMHO) and this
makes sense now. Found this bit:



4.6. Private Variables in Subroutines

But if Perl can give us a new @_ for every invocation, can't it give us
variables for our own use as well? Of course it can.

By default, all variables in Perl are global variables; that is, they are
accessable from every part of the program. But you can create private
variables called lexical variables at any time with the my operator:

sub max {
  my($a, $b);   # new, private variables for this block
  ($a, $b) = @_;# give names to the parameters
  if ($a > $b) { $a } else { $b }
}

These variables are private (or scoped) to the enclosing block; any other
$a or $b is totally unaffected by these two. And that goes the other way,
too -- no other code can access or modify these private variables, by
accident or design.[108] So, we could drop this subroutine into any Perl
program in the world and know that we wouldn't mess up that program's $a
and $b (if any).[109]

-

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Help with putting a subroutine into a variable?

2004-09-24 Thread Gavin Henry
Wiggins d Anconia said:
>> Hi all,
>>
>> I have this:
>>
>> -
>> #!/usr/bin/perl
>>
>> use warnings;
>> use strict;
>>
>
> Good start.

Courtesy of the Lama :-)

>> my @pics = <*.jpg>;
>> my $website = 'http://www.website.com/uploads';
>>
>> sub links {
>> foreach (@pics) {
>> print "$website/$_\n";
>> }
>> }
>
> Your sub breaks encapsulation because it relies on the fact that @pics
and $website are available in the sub but have not been passed into it.
Generally we want our subs to take arguments and return values. If you
were to move this sub to the top of the file or to another file (such as
a library/module) it would break. So the first thing you should correct
is the encapsulation by making your sub accept its arguments and return
a value.
>
> sub links {
>my ($base_url, @list) = @_;
>foreach my $element (@list) {
>print .
>}
>return;
> }

Doesn't this still get the scalar and array from what I defined at the top?

Also, why do you assign them to @_, can't we use that when iterating @list?

Why wouldn't it accept it's arguments?

>> -
>>
>> I would normally call the subroutine like &links; but I want to put the
result into a variable in order to stick it into an e-mail. I have been
trying all day reading all my perl books and it's time to ask for help.
>>
>
> Note that we don't want to call C<&links> that is better written as
C.
>
> What is the result?  In your case you are printing the links, so there
is no real result.

That is what I want, but I can't figure how to but the list into the
e-mail message.

> You need to decide what the return value of the sub
> will be, maybe the list of urls?

A list of urls.

> a bool? undef for positive or an
> exception for failure?  In the case of the list you should be Cing
the values to list and then returning the list.  In this last case we
can call the sub such as,
>
> my @ahrefs = links($website, @pics);

I get this part.

> foreach my $link (@ahrefs) {
>   print "$link\n";
> }

Isn't the above the same as my subroutine?

>
> For instance.
>
>> Thanks.
>>
>
> Give it a shot, see if this helps, if not come back and ask more.

Much appreciated. I will be re-reading Ch2-4 of the Lama tonight.



-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!



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




Re: Help with putting a subroutine into a variable?

2004-09-26 Thread Gavin Henry
> # send an email with @email_list
>
> # store to a database with @db_list
>
> Now your sub is generic, it doesn't rely on the specific names, @pics
> and $website, and doesn't cause data to be printed when you might not
> want it to.  Obviously this is a contrived example but as things get
> more complex it becomes absolutely critical.
>
> HTH,
>
> http://danconia.org#

Thanks. This is one of the most complete answers I have ever had and I really 
appreciate it.

I will let you know how I get on.

Gavin.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-28 Thread Gavin Henry
I really like Perl, but lately everywhere I seem to go and talk to say I
shouldn't be learning Perl as it's old and Python is better.

Since starting to learn Perl though, every other language I started to
learn/t, C, PHP etc. seem to make more sense now, as Perl has cleared
things up.

When I look at Perl, I can understand it (it kind of looks like bash),
when I look at a Python script, ugh.

I have been also trying to do some gui work with perl using wxperl, Python
seems to be much better suited/supported (for wx) and I couldn't find very
many docs for wxperl. What else is good looking to use?

I love CPAN.

Basically, my morale is getting low and I need a boost from you guys. Perl
isn't old is it?

I am on the right path?

Be kind ;-)

Thanks all,

Gavin.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-28 Thread Gavin Henry
JupiterHost.Net said:
>
>
> Gavin Henry wrote:
>> I really like Perl, but lately everywhere I seem to go and talk to say I
>
> Me too :)
>
>> shouldn't be learning Perl as it's old and Python is better.
>
> Python is different not necessarily better.
>
>> Since starting to learn Perl though, every other language I started to
>> learn/t, C, PHP etc. seem to make more sense now, as Perl has cleared
>> things up.
>
> Because Perl rocks!

:-)

>
>> When I look at Perl, I can understand it (it kind of looks like bash),
>> when I look at a Python script, ugh.
>>
>> I have been also trying to do some gui work with perl using wxperl,
>> Python
>> seems to be much better suited/supported (for wx) and I couldn't find
>> very
>> many docs for wxperl. What else is good looking to use?
>
> have a look at tk at cpan

It's not very pretty though.

>
>> I love CPAN.
>
> Another plus over many other languages. Perl has many advantages over
> other languages.
> 1) Its readily available in most systems as its alreayd installed.
> 2) Its capable of any task any other language is
> 3) It can be run persistantly or as part of apache as needed but is not
> necessary.
> 4) If it is part of apache and you expand its functionality by adding a
> module you don't break apache half the time like another bloated
> language who name I won't say (its initials are PHP ;p)
> 5)
>
>> Basically, my morale is getting low and I need a boost from you guys.
>> Perl
>> isn't old is it?
>
> It is mature, that is one thing that makes it great, less "oh crap
> upgrade to 4.3.8 or you're server is vulnerable" like the other
> unmentionable language I hinted at earlier.
>
>> I am on the right path?
>
> Yes you are padawan. One thing that makes other languages appeal to
> people is;t anythgin to do with the language itself. Rather its the
> developers and there wise use of nice design. For example, phpbb is an
> excellent forum. There are tons of other forums that have the same
> functionality but it just looks slick so people just use it.
> Of course the point being is that its html and css that make people
> choose it, not PHP.
>
> With perl, we seem to tend toward, "here';s how you do that" and not put
> much into the presentation (IE html/css, etc) and therefore it *looks*
> clunkier on the outside.
>
> So lets all keep using Perl and make it look nice so it sells!!!
>
>> Be kind ;-)
>
> use The::Force;

Ha, thanks mate.

>
>> Thanks all,
>
> No woriies :)
>
> Lee.M - JupiterHost.Net
>
>> Gavin.
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-28 Thread Gavin Henry
Paul Kraus said:
>> I really like Perl, but lately everywhere I seem to go and talk to say I
>> shouldn't be learning Perl as it's old and Python is better.
> Lets pretend we are mechanics we have this one tool that was passed on
> down from generation to generation. It is our very very very favorite
> tool.
> No matter what we do its simply not possible to do our jobs with that one
> tool.
>
> A good programmer in my opinion does not play favorites. Best tool for
> the job and all that :)

Agreed. But you need to start your base knowledge with a good one, like
Perl :-)

>
>
>> Since starting to learn Perl though, every other language I started to
>> learn/t, C, PHP etc. seem to make more sense now, as Perl has cleared
>> things up.
> It's your first real language.From here on out everything is easier to
> learn. It all becomes a matter of learning the syntax :) Congrats :)

I am beginning to learn that.

>
>> When I look at Perl, I can understand it (it kind of looks like bash),
>> when I look at a Python script, ugh.
>> I have been also trying to do some gui work with perl using wxperl,
>> Python
>> seems to be much better suited/supported (for wx) and I couldn't find
>> very
>> many docs for wxperl. What else is good looking to use?
> Depends on what your trying to do GASP even vb.net has some uses :)
>> I love CPAN.
> CPAN IS THE BOMB. hands down its why Perl is my primary tool set.

Nothing easier than:

perl -MCPAN -e shell

>
>> I am on the right path?
> Depends on if you limit yourself to Perl since it was your first
> language. If not then you are on the right path.

Agreed. Thanks.

>
> HTH,
> Paul Kraus
>


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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-28 Thread Gavin Henry
Wiggins d Anconia said:
>> I really like Perl, but lately everywhere I seem to go and talk to say I
>> shouldn't be learning Perl as it's old and Python is better.
>>
>
> I'm impressed, come to the Midwest in the US, around here they have only
> heard of M$ and Cobol.  Ironically, Python is showing its age, just look
> at Ruby. Of course Perl 6/Parrot stands to make all of the discussion
> moot.

Yeah, that will shut them all up.

By the way, my program now works great thanks to your sub advice. I still
have some cleaning to do, like my resize sub abd incorporating file tests
etc.

You can see how bad my program is at:

http://www.perl.me.uk

It's called ebaypics

Advice from you in a new thread, would be very appreciated.

Gavin.



> 
>
> http://danconia.org
>


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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-28 Thread Gavin Henry
David Garamond said:
> Gavin Henry wrote:
>> I really like Perl, but lately everywhere I seem to go and talk to say I
>> shouldn't be learning Perl as it's old and Python is better.
>
> My Good Lord, where have you been? Python is _already_ old news. Ruby,
> baby! :-)
>
>> I am on the right path?
>
> The right path is probably to learn them all, and pick whichever
> satisfies you the most. Or use the right tool for the right job.

That famous advice. I will have enough tools under my belt soon to make
that decision.

>
> I know not everybody have the time to learn new programming languages
> every few months. But frankly I think that's the best advice I can give
> you. Learning new programming languages will make you a better
> programmer, and it will asnwer your own question on whether you should
> continue using language X, use both X and Y, or move on to Y completely.

Agreed.

>
> Here's my own experience, hopefully it can help you. I know Perl since
> 1997. It has taught me _a lot_ (about programming, about the hacking
> culture, about other languages). Then I started to be interested in
> Python around 2000. Despite 1-2 years trying to familiarize and use
> Python, it never really got to me. I guess I never enjoy programming in
> that language. Nowadays I very rarely use Python at all. I install
> Python mostly just to run BitTorrent.

Likewise, except Fedora needs it for a lot of things (I'm
http://FedoraNEWS.ORG/ghenry)

>
> Then I started to be interested in Ruby in 2001. This I like. But
> despite promising myself to replace Perl with Ruby, today I still
> program like 50% : 50% in Ruby : Perl. There are just some things that I
> can write much faster and more convenient using Perl. Especially when
> writing one liners or when I can just use one or two CPAN modules and
> get the job done.

CPAN is the best.

>
> And then there's PHP. I use (or have to use it) since 1999. Despite
> swearing several times never to use PHP again, and cursing every time I
> have to code many lines in it, today I am still stuck with PHP at times.
>
> I found that, once you learn enough Perl, you just can't let it go
> completely. Perl and CPAN are too damn useful :-)

This is another common reason I have read...people always come back to Perl.

Gavin.

>
> --
> dave
>
>


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




Re: Problem iterating over diamond (while)

2004-09-28 Thread Gavin Henry
> Can we actually loop over the 'while diamond'?
> Please kindly advice how can I overcome this problem.

I don't know if I'm skilled enough to answer this yet, but shouldn't you
be using:

my @myarray = ;

foreach (@myarray) {
do stuff
}


> Thanks so much for your time.
>
> Regards,
> Edward WIJAYA
> SINGAPORE
>
>
> __BEGIN__
> use strict;
> use warnings;
> use Getopt::Std;
>
> our $opt_f;
> getopts('f:');
>
> open INFILE, "<$opt_f" or die "$0:  Can't open file $opt_f: $!";
>
> my $trial = 2;
>
> #What's wrong with running a for loop over the 'while' here?
> for ( my $t = 1 ; $t <= $trial ; $t++ ) {
>  print "Trial ", $t, "\n";
>
>  while () {
>  print;
>  }
> }
>
> __END__
>
> --
> 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: Problem iterating over diamond (while)

2004-09-28 Thread Gavin Henry
Gavin Henry said:
>> Can we actually loop over the 'while diamond'?
>> Please kindly advice how can I overcome this problem.
>
> I don't know if I'm skilled enough to answer this yet, but shouldn't you
> be using:

Nope, sorry. It helps if I *actually* read the rest of your e-mail.

Sorry.

>
> my @myarray = ;
>
> foreach (@myarray) {
> do stuff
> }
>
>
>> Thanks so much for your time.
>>
>> Regards,
>> Edward WIJAYA
>> SINGAPORE
>>
>>
>> __BEGIN__
>> use strict;
>> use warnings;
>> use Getopt::Std;
>>
>> our $opt_f;
>> getopts('f:');
>>
>> open INFILE, "<$opt_f" or die "$0:  Can't open file $opt_f: $!";
>>
>> my $trial = 2;
>>
>> #What's wrong with running a for loop over the 'while' here?
>> for ( my $t = 1 ; $t <= $trial ; $t++ ) {
>>  print "Trial ", $t, "\n";
>>
>>  while () {
>>  print;
>>  }
>> }
>>
>> __END__
>>
>> --
>> 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>
>
>
>


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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-28 Thread Gavin Henry
On Tuesday 28 Sep 2004 22:11, John W. Krahn wrote:
> Gavin Henry wrote:
> > By the way, my program now works great thanks to your sub advice. I still
> > have some cleaning to do, like my resize sub abd incorporating file tests
> > etc.
> >
> > You can see how bad my program is at:
> >
> > http://www.perl.me.uk
> >
> > It's called ebaypics
> >
> > Advice from you in a new thread, would be very appreciated.
>
> Don't put quotes around variables.
>
> Found in /usr/lib/perl5/5.8.2/pod/perlfaq4.pod
> What's wrong with always quoting "$vars"?
>
> perldoc perldata


Thanks I will update with your comments.
>
> Don't use '&' with subroutine calls.
>
> Found in /usr/lib/perl5/5.8.2/pod/perlfaq7.pod
> What's the difference between calling a function as &foo and foo()?
>
> perldoc perlsub
>
> > # Generate weblinks
> > sub links {
> > my ($url, @list) = @_;
> > my @return;
> > foreach (@list) {
> >  push @return, "$url/$_\n";
> > }
> > return @return;
> > }
> >
> > # Put the generated weblinks from the subroutine links into an array
> > my @email_links = links($website, @thumbs);
>
> This is what map() was invented for:
>
> my @email_links = map "$website/$_\n", @thumbs;
>
>
>
> John
> --
> use Perl;
> program
> fulfillment

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-28 Thread Gavin Henry
On Wednesday 29 Sep 2004 03:19, you wrote:
> You know, I'm kinda going through a similar thing. I wrote a script to
> search for users in an LDAP directory and update an attribute at the same
> time. I decided to write it in Perl because it looked so easy. And, it was.
> Works like a champ. Being new to Perl, and this was my first script, I was
> amazed at the power in a short amount of code. I've written in C, C++,
> Java, Lisp, Ada, Modula-2, Prolog, Pascal, and none of these are as easy as
> Perl (although Java is nice).
>
> However, my co-worker, who is familiar with JSP, began writing an HTML form
> to collect input data to pass to the script. We found that JSP and Perl
> didn't mix very well. In fact, we are still having trouble getting the two
> to integrate (probably ignorance hold us back).
>
> What's the point? The point is that sometimes a language choice defines an
> architectural choice. For example, Java implies that you need a JVM to run
> on the host OS (or browser). If Windows were my primary OS and I was
> writing a commerical application, I might think twice about Java. If the
> application must be cross-OS compatible, then Java is a good choice.
>
> For my script, I wish my co-worker and I had done our research ahead of
> time. We just didn't know...in fact, we still don't. But, we can't make an
> informed decision without the facts.
>
> Probably didn't help you much but, take heart in this. CGI isn't going
> anywhere soon. Millions of web pages use CGI and every web server supports
> it right out of the box. Perl is so easy to code and CPAN offers a world of
> scripts. I have seen Perl script writers whip out code in minutes that
> takes others days. It may not be commercial grade but, who of us writes
> commerical applications all the time. 90% of the time, I'm trying to
> accomplish a simple task or test a theory. You can't beat Perl for that.

Agreed. Thanks for this. My morale is up, but it's looking like I might be 
getting paid to learn Python, which is a bonus, but my heart is with Perl.

The more the better I now say!!!

>
> Gavin Henry <[EMAIL PROTECTED]> wrote:
> I really like Perl, but lately everywhere I seem to go and talk to say I
> shouldn't be learning Perl as it's old and Python is better.
>
> Since starting to learn Perl though, every other language I started to
> learn/t, C, PHP etc. seem to make more sense now, as Perl has cleared
> things up.
>
> When I look at Perl, I can understand it (it kind of looks like bash),
> when I look at a Python script, ugh.
>
> I have been also trying to do some gui work with perl using wxperl, Python
> seems to be much better suited/supported (for wx) and I couldn't find very
> many docs for wxperl. What else is good looking to use?
>
> I love CPAN.
>
> Basically, my morale is getting low and I need a boost from you guys. Perl
> isn't old is it?
>
> I am on the right path?
>
> Be kind ;-)
>
> Thanks all,
>
> Gavin.
>
> --
> Just getting into the best language ever...
> Fancy a [EMAIL PROTECTED] Just ask!!!

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread Gavin Henry
Randal L. Schwartz said:
>>>>>> "Gavin" == Gavin Henry <[EMAIL PROTECTED]> writes:


Wow I didn't know that you read this list. I am learning from your
book and I am catching up with all the columns you have ever published on
your site.


I am actually getting paid to learn Python now, and frankly it looks
really ugly, I like the way Perl flows and I can *read* it, unlike what
many people say.

>
> Gavin> I really like Perl, but lately everywhere I seem to go and talk
> Gavin> to say I shouldn't be learning Perl as it's old and Python is
> Gavin> better.
>
> Perl is more powerful.  Python is simpler.  Python is for people
> who don't want to master a language -- just use it casually.

I have that feeling now, one person (the one paying me to learn Python)
said they tried Perl about 10 years ago and couldn't really it and
understand RE. Well, your comment kind of sums him up. I have just bought
"Mastering RE from O'reilly", so I don't get scared of them :-)

The only reason I might find Python interesting is that Fedora uses it for
all the sys-admin utils, so I can help with those. (I am
http://FedoraNEWS.ORG/ghenry so I have an interest in Fedora)

>
> However, if you're gonna spend two or more hours a day hacking code,
> Perl is definitely the right place to be.  Still.

I'm almost at that level, but I should be doing other jobs, but I can't
seem to pull myself out if Vi to do technical documentations etc ;-)

>
> Those Python weenies are all just casual programmers complaining
> that for Perl, "with great power comes great responsibility".  Let'em.

Ha. That was a very politically correct response ;-)

>
> Perl's support only grows.  I used to be able to follow the CPAN "new
> modules list" by examining the daily run at search.cpan.org/recent.
> But no more.  Look at all the new modules just in the past *seven*
> days.  (It's typically a full web page for each day!) If that doesn't
> show you an intense activity in the Perl community, I really don't
> know what else I could show you.

The fact you replied is enough.

>
> Ask your Python friends where such a similar list exists. :)

He tried to show me a page on Zope's site for modules etc., but no way
does it beat CPAN or:

perl -MCPAN -e shell

>
> Python may be newer, but Perl is more mature, and here to stay.

Yes.

>
> Remember "new coke", and how long we had that. (If you're old enough
> to remember that fiasco.)


Again, thanks for this. My morale is now completely topped up, so I am
going to shell out for Programming Perl, although I do have the CD
Bookshelf 3.0 (better than 4.0)


Lastly, I just want to say that these kind of responses are what I love
about the open source etc. communities. Everyone is friendly (give or
take) and as long as you ask sensible questions, people will chat. After
all, we are all people.

If fact, this gives me the excuse to say why I am hooked to Linux and OSS.
When I setup my Linux company: http://www.suretecsystems.com I e-mailed
Linus to ask if Tux was registered to him, as the original company name
was going to be Inventux Solutions Ltd. Lo and behold he replied, with a
kind, "Nope, go ahead".

Well, from that day I have been hooked. Would Bill Gates answer a personal
e-mail? Would he f**k...

Thanks,

Gavin.

>
> --
> 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]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread Gavin Henry
John W. Krahn said:
> Gavin Henry wrote:
>> Randal L. Schwartz said:
>>>
>>>Remember "new coke", and how long we had that. (If you're old enough
>>>to remember that fiasco.)
>>
>> Again, thanks for this. My morale is now completely topped up, so I am
>> going to shell out for Programming Perl, although I do have the CD
>> Bookshelf 3.0 (better than 4.0)
>
> You might hurt his feelings, he didn't contribute to the third edition of
> Programming Perl.  Better to buy his latest book _Learning Perl Objects,
> References & Modules_  ;-)

Quick, where's my Mastercard...

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


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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread Gavin Henry
JupiterHost.Net said:
> My what long lines you have :)
>
>> It may not be commercial grade but, who of us writes commerical
>> applications all the time.
>
> I do mostly, private corporate backends mostly among other things :)
> I use it for the quick tasks and simple scripts also of course. (the
> projects never end the same as durability and ability)
>
> And cPanel (http://cpanel.net) is mostly perl for instance.
> I'd say that's pretty commercial seeing as how many webhosts use it.
>
> An associate of mine worked for/does consulting for a nationwide
> communications provider that uses all perl for the website, and backend
> employee/customer/support/work order/materials handling/etc etc.
>
> Apple's website uses perl last I heard (the .adp extension is their
> special build of it)
>
> That's just 4 that I knew off off the top of my head.
>
> Perhaps you meant commercial grade as in you don't have to spend
> thousands of dollars on a devleopment suite (hint hint Microsoft) and
> hire a team of engineers to keep it running (hint hint PHP), in that
> case I'd agree ;p
>
> One thing my associate says that I agree with that may help with the
> language blues is be proud of perl! When you do web apps in perl, use
> .pl instead of .cgi. Show some pride man!! If you're host can't add one
> line to apache conf to be able to serve .pl files then get a new host.

I agree.

>
> [shameless plug] go to jupiterhost.net we *love* Perl [/shameless plug]
>
> I like this thread, lots of opinions + not too many flames = productive
> learning

Again, I agree.


More examples please

>
> Just my .02
>
> Lee.M - JupiterHost.Net
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>


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




Re: How Can I rename File using Perl?..

2004-09-30 Thread Gavin Henry
Roime bin Puniran said:
> How can i rename any file using PERL?...Where should i start?..Where i
can find any tutorial?

using linux:

man mv

you can use a system() call or backticks ``

>
> This e-mail and any attachments may contain confidential and
> privileged information. If you are not the intended recipient,
> please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
> information by a person other than the intended recipient is
> unauthorized and may be illegal.
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>




-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: How Can I rename File using Perl?..

2004-09-30 Thread Gavin Henry
> Moreover, rename() is a basic part of Perl, so even on Linux there is no
> need to do this with a system call to the `mv` command.

Of course, doh.

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-30 Thread Gavin Henry
On Thursday 30 Sep 2004 13:19, Randal L. Schwartz wrote:
> > "John" == John W Krahn <[EMAIL PROTECTED]> writes:
>
> John> You might hurt his feelings, he didn't contribute to the third
> edition John> of Programming Perl.
>
> Actually, it's worse than that.  I contributed to it, but wasn't credited
> for it or paid for it.

Can you reveal anymore about this, as I read it on stonehenge too.

>
> John>   Better to buy his latest book _Learning Perl
> John> Objects, References & Modules_  ;-)
>
> Yes, or Learning Perl.  Both good books, from what I hear.  I dunno,
> I write'em, not read 'em. :)

Ha, this is great.

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

-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




  1   2   >