Where to hire good perlish Perl tutors?

2004-10-19 Thread perl perl
Can anyone recommend a site where I can hire a competent Perl Tutor? I
wish this info is readily available on perl.com but it isn't. And
searches on google and craigslist is pretty disappointing.

Anyway, I don't want to spam the board so I'd appreciate it if you
could email me directly.

I'm getting a tad frustrated with Perl tutors that self proclaims that
they are Perl Experts. Only to find that they lack that perlish coding
mentality.

Soirry for the interuption, but I think there are a lot of us Perl
students willing to pay but can't find a Randal Schwartz type out
there.

[EMAIL PROTECTED]

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




Perl versus Expect(tcl) : Specific Example

2005-02-12 Thread perl perl
Hi, I'd like to narrow the previous Expect(tcl) question so that an
answer can be extracted:
Perl vs Expect(tcl) question again.

Here is a specific Expect example:
I have a release engineering build script that performs the following:

Launch masterbuild.tcl (expect script) from WinNT server. 
This script will perform the below task:

1). Enter Solaris server, perform authentication, set the Solaris
build environment, then run GNU make to compile all C++ code, exit
Solaris.
2). Enter HPUX server, perform authentication, set the HPUX build
environment, then run GNU make to compile all c++ code, exit HPUX.
3.) Enter winXP server, perform authentication, set the XP build
variables, then run NMAKE to compile c++ code, exit XP.

Question1: 
Expect is very efficient in performing the above task. Can Perl do the
same task above?
Surely Perl can. But what are the pros and cons? PROS and CONS would
be very nice to know. Performance advantages?  Assuming you're an
skilled with both, which one is faster to set up from scratch?

Question2: :-)
How do you implement the Expect script above into Perll? Are there
several modules to choose from?

thanks,
W

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




Re: Perl versus Expect(tcl) : Specific Example

2005-02-13 Thread perl perl
Excellent info coming in, so far.  

If its true that we have to use two versions of Perl Expect.PM
(ActiveState) and Perl Expect.PM (Unix)...

 then wouldn't that pose double script maintenance issues? My
Expect(tcl) script is simplified and centralized to one file. Its
capable of switching back and forth to WinNT, WinXP, Win2000 as well
as all flavors of Unix (multiple times).

What is the solution to this? Would it work if we simply did an OS
check at the beginning of the perl script. If Win is going to be the
target, then load ActiveStateExpect.pm. If Unix, Load UnixExpect.pm
module.

More opinions of Expect(tcl) versus Perl in regards to this specific
scenario would be greatly appreciated.


On Sun, 13 Feb 2005 13:01:17 -0500, Scott Pham <[EMAIL PROTECTED]> wrote:
> Perl Expect on Windows CON:
> Expect perl module can't be used on a Windows platform.
> 
> Looks like your best bet is to use activestate TCL if it's on windows.
> 
> 
> On Sat, 12 Feb 2005 17:27:54 -0800, perl perl <[EMAIL PROTECTED]> wrote:
> > Hi, I'd like to narrow the previous Expect(tcl) question so that an
> > answer can be extracted:
> > Perl vs Expect(tcl) question again.
> >
> > Here is a specific Expect example:
> > I have a release engineering build script that performs the following:
> >
> > Launch masterbuild.tcl (expect script) from WinNT server.
> > This script will perform the below task:
> >
> > 1). Enter Solaris server, perform authentication, set the Solaris
> > build environment, then run GNU make to compile all C++ code, exit
> > Solaris.
> > 2). Enter HPUX server, perform authentication, set the HPUX build
> > environment, then run GNU make to compile all c++ code, exit HPUX.
> > 3.) Enter winXP server, perform authentication, set the XP build
> > variables, then run NMAKE to compile c++ code, exit XP.
> >
> > Question1:
> > Expect is very efficient in performing the above task. Can Perl do the
> > same task above?
> > Surely Perl can. But what are the pros and cons? PROS and CONS would
> > be very nice to know. Performance advantages?  Assuming you're an
> > skilled with both, which one is faster to set up from scratch?
> >
> > Question2: :-)
> > How do you implement the Expect script above into Perll? Are there
> > several modules to choose from?
> >
> > thanks,
> > W
> >
> > --
> > 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: I just don't get it....

2001-06-08 Thread Perl

I'm pretty much a newbie and should be reading more than contributing, but
one of my professors insisted that we troubleshoot all of our classroom
assignments by running our Perl programs from the command line.  I've
continued this practice in my post-classroom life.

Keith
Clear Lake

-Original Message-
From: Bradshaw, Brian [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 08, 2001 4:44 PM
To: [EMAIL PROTECTED]
Subject: RE: I just don't get it


I wish I new. The browser just says "There is an Internal Error. Cotact the
administrator" along with contact details and date information.

-Original Message-
From: David H. Adler [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 08, 2001 5:24 PM
To: [EMAIL PROTECTED]
Subject: Re: I just don't get it


On Fri, Jun 08, 2001 at 05:00:08PM -0400, Bradshaw, Brian wrote:
> I have the code:
> 1.$queryCat = "select project_number from prod_cat_xref where
> category_1_id=$category";
> 2.print "$queryCat \n\n";
> 3.$setCat = $wgDB->query($queryCat);
> 4.# %resultCat = $setCat->fetchhash();
> 5.while (%resultCat = $setCat->fetchhash())
> 6.{
> 7.   print "Hi Dude $resultCat{project_number} \n";
> 8.}
>
> On line 7, if I use parens () instead of curlies {}, I get an error.
> However, in an existing script on our catalog, that exact line (minus the
> "Hi Dude") with the parens works within a while loop.

What error are you getting?  As far as I can tell, that line would print

"Hi Dude (project_number) \n"

rather than give an error ($resultCat being undef).

dha

--
David H. Adler - <[EMAIL PROTECTED]> - http://www.panix.com/~dha/
Perl should only be studied as a second language.  A good first
language would be English. - Larry Wall




Re: Retaining punctuation

2001-06-17 Thread perl

you can just do this before you spell check.

{
s/./ ./g;  # Would make Test. Test .
s/,/ ,/g;  # etc. for other punctuation marks.
spellcheck
s/ ././g;  # Make Test . back to Test. after spell check
s/ ,/,/g;  # etc
}

its not very pretty but it will work no?

Ryan

On Sun, 17 Jun 2001, Lonya wrote:

> I have to remove punctuation so that I can look in a dictionary to list all possible 
>completions of the english word: "te*t".
> ie. teat teet tent test text
>
> If I leave the punctuation in, there will be no dictionary matches on "te*t,".
>
> Is that clearer now?
> Lonya
>
>
> ---
> The tagline below makes free email possible...
>
>
>




Re: Perl question

2001-06-18 Thread perl

You could do this:

$started=0;
while()
{
$started = 0 if($_ =~ "" && $started);
$started = 1 if($_ =~ "" && !$started);
print $_ if($started);   ## Will print in between the 's

}


Ryan


On Mon, 18 Jun 2001, Jack Lauman wrote:

> I wrote the following to read a daily email that is is sent in ASCII
> and contains currency exchange rates.
>
> I want to search the file and look for  and process all of the
> lines that follow it until it encounters a second .
>
> The code as it stands works, put it also processes all the garbage
> above and below the actual working area of the file.
>
> I would appreciate any help in resolving this issue as well as any
> comments on better coding practices.
>
> Regards,
>
> Jack
>
>
> #!/usr/bin/perl
> #
> # cur2sql.pl
> #
>
> use strict;
> use vars qw($proc_begin $proc_end);
> use vars qw($quote_date $cur_sym $cur_desc $usd_unit $units_usd);
> use vars qw($year $month $mday $hour $minute $second $timezone);
> use vars qw($conv_date $date $time $tz);
>
> use Date::Manip;
> use String::Strip;
>
>
> open (OUTFILE, ">", "currency.csv") || die "Can not open currency.csv
> for writing";
>
> printf STDERR "Reading currency file";
> open (INFILE, "curtest") || die "Can not open /var/spool/mail/currency
> for reading";
>
> while () {
>
>   $quote_date = substr($_,0,79);
>   ($year, $month, $mday, $hour, $minute, $second, $timezone) =
>   $quote_date = /^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+)
> (\w+) (.*)$/;
>   $year = $1;
>   $month= $2;
>   $mday = $3;
>   $hour = $4;
>   $minute   = $5;
>   $second   = $6;
>   $timezone = $7;
>
>   # Convert date from UTC (GMT) to PST and adjust adte and time
> accordingly.
>
>   $tz = &Date_TimeZone;
>   $conv_date = "$year-$month-$mday $hour:$minute:$second";
>   $conv_date = &ParseDate($conv_date);
>   $conv_date = &Date_ConvTZ($conv_date, $timezone, $tz);
>   $date = &UnixDate($conv_date,"%Y-%m-%d");
>   $time = &UnixDate($conv_date,"%H:%M:%S");
>   $tz = &UnixDate($conv_date,"%Z");
>
>   $cur_sym  = substr($_, 0, 3);
>   $cur_desc = substr($_, 4, 28);
>   StripTSpace($cur_desc);
>
>   $usd_unit = substr($_, 35, 19);
>   StripLTSpace($usd_unit);
>
>   $units_usd = substr($_, 57, 19);
>   StripLTSpace($units_usd);
>
>   printf OUTFILE "%s\,%s\,%s\,%s\,%s\,%s\,%s\n",
>   $date, $time, $tz, $cur_sym, $cur_desc, $usd_unit, $units_usd;
>
> }
>
> close(INFILE);
> close(OUTFILE);
> print STDERR "\n";
>
> 1;
>







Re: getting memory info from system

2001-06-19 Thread perl

yeah just type : 'free'

Ryan

On Tue, 19 Jun 2001, Chris Hedemark wrote:

> Howdy,
>
> I'm tearing through my O'Reilly books and the CPAN search trying to find a
> module or built-in function call that will let me get statistics back from
> the system regarding memory.  I'm trying to find:
>
> 1) real memory bytes total
> 2) real memory bytes used
> 3) real memory bytes free
>
> As a secondary interest I'd like to do the same stats but for the swap
> file(s).
>
> Can anyone here point me in the right direction please?
>
> Thanks.
>
> Chris Hedemark - Hillsborough, NC
> http://yonderway.com
>
>




Re: variable losing it's value

2001-06-19 Thread perl


When you do : foreach $line (<>){

that will print the last line in <>
rename $line in the foreach statement to something different,

RYan



On Tue, 19 Jun 2001, Bob Mangold wrote:

> I may have a bug somewhere in my code, but I can't find it. Before I look again
> though please answer this for me.
>
> If I execute:
>
>
> my ($line) = "hello";
> foreach $line (<>){
>  . whatever
> }
> print $line;
>
>
> Should it print the last line in <> or 'hello'?
>
> -Bob
>
> __
> Do You Yahoo!?
> Spot the hottest trends in music, movies, and more.
> http://buzz.yahoo.com/
>




file size

2001-06-21 Thread perl

Hi,

I would like to know if with a perl script you can get the size of a file ?
I need to get all the size of 250 files on 250 computers ...

thanx




RE: HTTP::Status status_message($rc) & LWP::Simple

2001-06-22 Thread perl

To get the status message from a http request from lwp:
my $res = $ua->request($req);
my $errorCode=$res->status_line



Economic perl programming and perl debugging  http://www.fluxcenter.com




- Original Message -
From: Me <[EMAIL PROTECTED]>
To: Drew Cohan <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, June 22, 2001 5:33 PM
Subject: Re: HTTP::Status status_message($rc) & LWP::Simple


> Do you mean use the result from such a call,
> or how to do such a call? I'm guessing doing
> the call, and a somewhat wild guess is:
>
> HTTP::Status::status_message($rc)
>
> Assuming $rc has been set to something
>
> You may need to do a:
>
> use HTTP::Status;
>
> or similar, before you make the call.
>
> And that might mean you need to install the
> HTTP::Status module.
>
> Otoh, I've never used HTTP::Status...
>
> hth.
>
> > How would I adapt the else print statement to use
> > HTTP::Status status_message($rc)?
> >
> > TIA
> >
> > drew
> > -- snip --
> > use LWP::Simple;
> >
> > while (<>){
> > if (get $_) {
> > # url is ok
> > print;
> > } else {
> > # couldn't get url
> > print "\nAn error occured with $_\n";
> > }
> > }
>
>




Logo for learn.perl.org

2001-06-24 Thread perl

I propoused thi logo for learn.perl.orgl, if you liked please
tell me so.And vote on this list.

http://perl.fluxcenter.com/images/learn_perl4.gif

The logo is the same size as the 'Download Perl'
Button, is very fast. And mathes desing of learn.perl.org
The Brown and green are are to
resemble a school Chalk Board , and the white writing
is to resemble Chalk writting. Also the expression in white
is supposed to equal 'Perl' if my reg exp do not fail me,
they were never my strongest ability, but only in unix.
But if you do like the logo I will make it faster to download,
will add definition, and make the expression equal to 'Perl'
in both Unix and Nt systems.
 tech



I need some help ...

2001-06-25 Thread perl

I want to do this :

I have a file where there are 256 servers names, one server name per line.
I want to read all lines to take the names of all servers to check the size of 
some files ...

I tried this but it's not working like I want .. :

$serveur="c:\\perl\\bin\\liste.txt";
open (SERV, "$serveur");
@serveurs = ;
close (SERV);

foreach $ligne (@serveurs)
{
$fichier="$ligne\\f\$\\cmd\\active.vbs";
$fichier2="$ligne\\f\$\\universe\\data\\exp\\upr\\upe_dsms.000";
$fichier3="$ligne\\f\$\\universe\\data\\exp\\upr\\upe_psms.000";
$fichier4="$ligne\\g\$\\common\\bin\\upecbootnt.cmd";





if (-e $fichier) 
{
$size=(stat $fichier)[7];
print RESULT"$fichier fait $size octets\n";
}
else
{
print RESULT"$fichier inexistant \n";
}

if (-e $fichier2) 
{
$size2=(stat $fichier2)[7];
print RESULT"$fichier2 fait $size2 octets\n";
}
else
{
print RESULT"$fichier2 inexistant \n";
}

if (-e $fichier3) 
{
$size3=(stat $fichier3)[7];
print RESULT"$fichier3 fait $size3 octets\n";
}
else
{
print RESULT"$fichier3 inexistant \n";
}

if (-e $fichier4) 
{
$size4=(stat $fichier4)[7];
print RESULT"$fichier4 fait $size4 octets \n";
}
else
{
print RESULT"$fichier4 inexistant \n";
}

$resultat="c:\\resultat.txt";
open (RESULT, ">>$resultat");

 }


With this i have some probleme because when i try to do store the data in the 
file c:\resultat.txt it's taking only the last server name in the list.txt 
and is not checking the size of the files ...


If someone can help me ... 

Thanx 



Re: I need some help ...

2001-06-25 Thread perl

En réponse à Aaron Craig <[EMAIL PROTECTED]>:

> I would do something like this:
> 
> use strict; # very important, and saves a lot of headache!
> 
> open (SERV, "c:\\perl\\bin\\liste.txt") || die "Could not open
> liste.txt: 
> $!"; # added error checking
> my @serveurs = ;
> close (SERV);
> open (RESULT, ">>c:\\resultat.txt") || die "Could not open resultat.txt:
> 
> $!"; # added error checking;
> foreach my $ligne (@serveurs)
>   {
>   my @fichiers =
>   (
>   "$ligne\\f\$\\cmd\\active.vbs",
>   "$ligne\\f\$\\universe\\data\\exp\\upr\\upe_dsms.000",
>   "$ligne\\f\$\\universe\\data\\exp\\upr\\upe_psms.000",
>   "$ligne\\g\$\\common\\bin\\upecbootnt.cmd",
>   );
>   # this loop does exactly what you were doing before, but is a little
> less 
> verbose, and easier to maintain.
>   #Remember, when you catch yourself copying and pasting code, it's
> probably 
> time for a loop or a function.
>   #I've taken the four files that you want to check, and stuck them in
> the 
> array above.
>   #Now we'll loop through the array and check each file.
>   #Want to check another file in the future?  Add it to the array, and 
> you're done!
>   foreach my $fichier (@fichiers)
>   {
>   my $result = (-e $fichier)? "$fichier fait (stat $fichier)[7]
> octets\n" : 
> "$fichier inexistant \n";
>   print RESULT $result;
>   }
>}
> close RESULT;
> Aaron Craig
> Programming
> iSoftitler.com
> 
> 
 It's still not checking the size .. :-(

I dont know what to do .. ?




compare the size of some files ...

2001-06-27 Thread perl

I want to do this :

- get the size of some files with stat
- compare these sizes with some variables 
- copy the "good" files if the size doesn't match ...






need some help ...

2001-07-02 Thread perl

hi,

I want to do this :

i have some servers where i want to check if some files exists and the user 
must put the all path with the name of the file ...

use strict;

#that's the file where my servers are ...


open (LISTESERVEUR, "c:\\perl\\presence\\listeserveur.txt") || die "Ne peut 
ouvrir le fichier Listeserveur.txt ! Vérifier qu'il existe sous 
c:\perl\presence:$!"; 

@serveurstab=;
Close(LISTESERVEUR);

open (RESULT,">>c:\\perl\presence\\resultat.txt");


print "Fichier recherché (sous la forme Nom_fichier.extension : \n\n";
$fichier=chop();

print "Chemin complet :\n\n";
$path=chop();


foreach $ligne (@serveurstab)
{
chop($ligne);

but how to change the path ... because the user will put 
c:\folderone\filetwo.txt but i have to write 
server\\c\$\\folderone\\filetwo.txt 

If someone can help me ...




remplace ...

2001-07-09 Thread perl

Hi,

I want to remplace all the word "html" in "php" in some web pages ...

I tried this but nothing is happening : 

open (TRANS, "c:\\test\\test.txt");

@transformation=;

foreach $ligne (@transformation)
{
chomp($ligne);
$transform=$ligne;
$transform=~s/html/php/g;
};

close (TRANS);



Summarising tables

2001-12-13 Thread Perl

Hi all,

Need a little help on summarising 2 different tables into 1, based on a particular 
field.

The 2 tables (they are actually content from a log file) look like the follow :

Table #1

1006788900 198 36
1006788600 29 35
1006788300 18 75
1006788000 19 65
1006787700 42 37
1006787400 29 26
1006787100 65 84
1006786800 6 87

Table #2

1006789500 43 47
1006789200 23 64
1006788900 198 36
1006788600 29 35
1006788300 18 75
1006788000 19 65
1006787700 42 37
1006787400 29 26

They may not be of equal length. The first field is TIME, 2nd is INPUT and 3rd is 
OUTPUT. Basically, what I want to do is to summarise the table based on the first 
field (TIME). For example, if both tables have TIME as 1006788600, INPUT and OUTPUT 
from both tables whose TIME is 1006788600 will be summed up. Meaning the script needs 
to go thru the tables to look for entries with the same TIME, and add the INPUT and 
OUTPUT together to form another summaried table.

Any easy way for me to do that other than putting the data into an array or hash 
table, and compare them entry by entry??

Any help is appreciated. Thanks in advance.




Re: Summarising tables - further question

2001-12-15 Thread Perl

Hi all,

Thanks for those who replied to my posting appreciate all the help
given. :)

Based on the code written by John (thanks a lot), I would like to ask a
further question :

John's code ==>
#!/usr/bin/perl -w
use strict;

my %data;
for my $file ( '/data/table1', '/data/table2' )
{
open IN, "< $file" or die "Cannot open
$file: $!";
while (  ) {
my ( $time, $in, $out ) = split;
$data{ $time }[0] += $in;
$data{ $time }[1] += $out;
}
close IN;
}

for ( sort keys %data ) {
print "$_ @{$data{$_}}\n";
}

The sample 2 tables (fields being TIME, IN, OUT respectively) ==>

Table #1

1006788900 198 36
1006788600 29 35
1006788300 18 75
1006788000 19 65
1006787700 42 37
1006787400 29 26
1006787100 65 84
1006786800 6 87

Table #2

1006789500 43 47
1006789200 23 64
1006788900 198 36
1006788600 29 35
1006788300 18 75
1006788000 19 65
1006787700 42 37
1006787400 29 26


Is there a way to modify the above code to summarise ONLY common values
based on TIME field?? For example, the 1st record (TIME field) in Table #2
does not appear anywhere in Table #1, so the output shouldn't contain this
record. In other words, the output from the code should only display records
whereby TIME (as a key) appears in BOTH tables, not just one.

I hope I am clear enough in my elaboration.

Thanks guys. :)



- Original Message -
From: "John W. Krahn" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 14, 2001 5:49 PM
Subject: Re: Summarising tables


> Perl wrote:
> >
> > Need a little help on summarising 2 different tables into 1, based on a
particular field.
> >
> > The 2 tables (they are actually content from a log file) look like the
follow :
> >
> > Table #1
> > 
> > 1006788900 198 36
> > 1006788600 29 35
> > 1006788300 18 75
> > 1006788000 19 65
> > 1006787700 42 37
> > 1006787400 29 26
> > 1006787100 65 84
> > 1006786800 6 87
> >
> > Table #2
> > 
> > 1006789500 43 47
> > 1006789200 23 64
> > 1006788900 198 36
> > 1006788600 29 35
> > 1006788300 18 75
> > 1006788000 19 65
> > 1006787700 42 37
> > 1006787400 29 26
> >
> > They may not be of equal length. The first field is TIME, 2nd
> > is INPUT and 3rd is OUTPUT. Basically, what I want to do is to
> > summarise the table based on the first field (TIME). For example,
> > if both tables have TIME as 1006788600, INPUT and OUTPUT from
> > both tables whose TIME is 1006788600 will be summed up. Meaning
> > the script needs to go thru the tables to look for entries with
> > the same TIME, and add the INPUT and OUTPUT together to form
> > another summaried table.
> >
> > Any easy way for me to do that other than putting the data into
> > an array or hash table, and compare them entry by entry??
>
> The easiest way would be to use a hash:
>
> #!/usr/bin/perl -w
> use strict;
>
> my %data;
> for my $file ( '/data/table1', '/data/table2' ) {
> open IN, "< $file" or die "Cannot open $file: $!";
> while (  ) {
> my ( $time, $in, $out ) = split;
> $data{ $time }[0] += $in;
> $data{ $time }[1] += $out;
> }
> close IN;
> }
>
> for ( sort keys %data ) {
> print "$_ @{$data{$_}}\n";
> }
>
>
>
>
> John
> --
> use Perl;
> program
> fulfillment
>
> --
> 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]




Explanation on dereference

2001-12-18 Thread Perl

Hi guys,

I encountered this dereference problem on hash-of-lists tables. Although I have 
managed to solve the problem thru trial and error, I need someone to explain to me 
what was wrong exactly. I tried searching the web for some info but couldn't find any.

The problem started when I tried to assign one of the values in a hash-of-lists table 
to another hash-of-lists table something like this :

foreach my $time ( keys %hash1) {
if ($hash2{$time}[0] > 0) {
if ($hash1{$time}[0] >= $hash2{$time}[0]) {
push @{ $final_hash{$time}[0] }, $hash1{$time}[0];
}
else {
push @{ $final_hash{$time}[0] }, $hash2{$time}[0];
}
}
if ($hash2{$time}[1] > 0) {
if ($hash1{$time}[1] > $hash2{$time}[1]) {
push @{ $final_hash{$time}[1] }, $hash1{$time}[1];
}
else {
push @{ $final_hash{$time}[1] }, $hash2{$time}[1];
}
}
}


The above code has no errors. But when I tried to display the content of the hash 
table "final_hash" with the following code :

foreach my $time ( keys %final_hash) {
print "$time $final_hash{$time}[0] 
$final_hash{$time}[1]\n";
}

I get the following reply :

1006788300 ARRAY(0x80ecf44) ARRAY(0x80ecf68)
1006788600 ARRAY(0x80ed01c) ARRAY(0x80ed040)
1006787700 ARRAY(0x80ecfbc) ARRAY(0x80ecfe0)
1006788000 ARRAY(0x80ed094) ARRAY(0x80ed0b8)
1006788900 ARRAY(0x80ed0f4) ARRAY(0x80ee2bc)

That showed it was a case of dereference. After multiple tries and changes made to the 
push and print statements, I found out that my problem is solved by changing the print 
statement to the following :

foreach my $time ( keys %final_hash) {
print "$time @{$final_hash{$time}[0]} 
@{$final_hash{$time}[1]}\n";
}


Can anyone briefly explain to me on that??

Also, I believe there are other ways to solve the problem by changing the PUSH or 
PRINT statements. Can anyone point them out to me??

Thanks a lot. :)



[Fwd: ezmlm response]

2002-01-25 Thread perl

 

Hi ,,,
this my first time i write to you :)
i have the uncluder script
$file = $ENV{'QUERY_STRING'};
print "Content-type: text/html\n\n";
if($file eq "") {
print "document.writeln('
Includer Error: No File Specified.
');\n"; print "document.writeln('Script by SmartCGIs.com 
<%5C%22http://www.smartcgis.com%5C%22>

');\n";
exit;
}

open(DATA,"$file") || print "document.writeln('
Includer Error: Could not open $file ($!).
Script by SmartCGIs.com <%5C%22http://www.smartcgis.com%5C%22>

');";
@filecontent = ;
close(DATA);
foreach $line(@filecontent) {
chomp($line);
$line =~ s/\'/\\\'/g;
print "document.writeln('$line');\n";
}
when i add

its not work any help
or if there any whay to include a text file without useing SSI or IFrame
Thanks
:)




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




Match and split on array help with output

2009-04-14 Thread perl
Hi all,

I have some basic code that I want to pull out the web addresses from web pages.
Would like to keep it as basic as possible for easy reading.

The line to replace http with newline seems to work ok.
however the "match" line doesnt seem to pull out the required lines
and I'm not to sure about the split either.

I think it's this line "if ($serverlist[$index]  =~ /:\/\//)" 
that's not giving me what I want.

If I comment out the program after $serverlist[$index] =~ s/http/\n/g;
and then pipe it to grep eg

./webprog.pl |grep ://|cut -d"/" -f3
I get the desired output, to a point, but I'd like to do it all in perl

Thanks for your time.

  Alan.

#!/usr/bin/perl
#
#
# Build Initial list and put into array.
@serverlist =  `/usr/bin/wget -q -O - http://www.anyserver.com`;


for ($index = 0; $index <= $#serverlist; $index++) {

#replace http with newline, all .com etc should now be in 3rd field "/"
$serverlist[$index] =~ s/http/\n/g;
   
 
#pull out all lines with ://   like "grep"
# as these should contain web addresses.
if ($serverlist[$index]  =~ /:\/\//) # does not seem to do what it 
should 
{
#print $serverlist[$index];
# pull out 3rd field eg. ://my.server.com/
print ((split/\//, $serverlist[$index])[2]); # like cut -d"/" 
-f3
# should now be  my.server.com
   }

 }

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




map foreach loop into array

2010-03-21 Thread perl
I have been trying to make this thing work ..
this is not a actual code
@s = { some elemnts};
foreach my $s(@s){
# i made that $s into array something like @data1
foreach my$data(@data1)
   if( $data =~ some text){
#here i will get my data for sure
i need to get that data into a global array
}

honestly i am not that good at perl i have been exploring perl
thanks you

   


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




How to Decode UDP packets got from libpcap using Net::Pcap

2010-05-05 Thread perl
> I have used libpcap to capture data using Net::Pcap module ... and now
> ... i have been stuck with decoding... here is the code that i have
> used http://cpansearch.perl.org/src/SAPER/Net-Pcap-0.16/eg/pcapdump
> #!/usr/bin/perl use strict; use Data::Hexdumper; use File::Basename;
> use Getopt::Long qw(:config no_auto_abbrev); use Net::Pcap
> qw(:functions); use NetPacket::Ethernet qw(:types); use NetPacket::IP
> qw(:protos); use NetPacket::TCP; use Pod::Usage; use Socket
> qw(inet_ntoa); $::PROGRAM = basename($0); $::VERSION = "0.01"; #
> globals my $dumper = undef; my %icmp = ( ICMP_ECHO => "echo",
> ICMP_ECHOREPLY => "echo-reply", ICMP_IREQ => "ireq", ICMP_IREQREPLY =>
> "ireq-reply", ICMP_MASREQ => "mask", ICMP_MASKREPLY => "mask-reply",
> ICMP_PARAMPROB => "param-prob", ICMP_REDIRECT => "redirect",
> ICMP_ROUTERADVERT => "router-advert", ICMP_ROUTERSOLICIT =>
> "router-solicit", ICMP_SOURCEQUENCH => "source-quench", ICMP_TIMXCEED
> => "time-exceeded", ICMP_TSTAMP => "timestamp", ICMP_TSTAMPREPLY =>
> "timestamp-reply", ICMP_UNREACH => "unreachable", ); MAIN: { run(); }
> sub run { $|++; # get options my %options = ( count => 10, promisc =>
> 0, snaplen => 256, timeout => 10, ); GetOptions(\%options, qw{ help|h!
> version|V! count|c=i interface|i=s promisc|p! snaplen|s=i writeto|w=s
> }) or pod2usage(); pod2usage({ -verbose => 2, -exitval => 0 }) if
> $options{help}; print "$::PROGRAM v$::VERSION\n" if $options{version};
> my ($err, $net, $mask, $filter); my $dev = $options{interface} ||
> pcap_lookupdev(\$err); my $filter_str = join " ", @ARGV; # open the
> interface my $pcap = pcap_open_live($dev, @options{qw(snaplen promisc
> timeou +t)}, \$err) or die "fatal: can't open network device $dev:
> $err ", "(do you have the privileges?)\n"; if ($filter_str) { #
> compile the filter pcap_compile($pcap, \$filter, $filter_str, 1, 0) ==
> 0 or die "fatal: filter error\n"; pcap_setfilter($pcap, $filter); } if
> ($options{writeto}) { $dumper = pcap_dump_open($pcap,
> $options{writeto}) or die "fatal: can't write to file
> '$options{writeto}': $! +\n"; } # print some information about the
> interface we're currently using pcap_lookupnet($dev, \$net, \$mask,
> \$err); print "listening on $dev (", dotquad($net), "/",
> dotquad($mask), " +)", ", capture size $options{snaplen} bytes"; print
> ", filtering on $filter_str" if $filter_str; print $/; # enter the
> main loop pcap_loop($pcap, $options{count}, \&process_packet, '');
> pcap_close($pcap); } sub process_packet { my ($user_data, $header,
> $packet) = @_; my ($proto, $payload, $src_ip, $src_port, $dest_ip,
> $dest_port, $f +lags); printf "packet: len=%s, caplen=%s, tv_sec=%s,
> tv_usec=%s\n", map { $header->{$_} } qw(len caplen tv_sec tv_usec); #
> dump the packet if asked to do so pcap_dump($dumper, $header, $packet)
> if $dumper; # decode the Ethernet frame my $ethframe =
> NetPacket::Ethernet->decode($packet); if ($ethframe->{type} ==
> ETH_TYPE_IP) { # decode the IP payload my $ipframe =
> NetPacket::IP->decode($ethframe->{data}); $src_ip =
> $ipframe->{src_ip}; $dest_ip = $ipframe->{dest_ip}; if
> ($ipframe->{proto} == IP_PROTO_ICMP) { my $icmpframe =
> NetPacket::ICMP->decode($ipframe->{data}); $proto = "ICMP"; $payload =
> $icmpframe->{data}; } elsif ($ipframe->{proto} == IP_PROTO_TCP) { my
> $tcpframe = NetPacket::TCP->decode($ipframe->{data}); $proto = "TCP";
> $src_port = $tcpframe->{src_port}; $dest_port =
> $tcpframe->{dest_port}; $payload = $tcpframe->{data}; $flags =
> flags_of($tcpframe->{flags}); } elsif ($ipframe->{proto} ==
> IP_PROTO_UDP) { my $udpframe =
> NetPacket::UDP->decode($ipframe->{data}); $proto = "TCP"; $src_port =
> $udpframe->{src_port}; $dest_port = $udpframe->{dest_port}; $payload =
> $udpframe->{data}; } printf "IP:%s %s:%d -> %s:%d (%s)\n", $proto,
> $src_ip, $src_port, $dest_ip, $dest_port, $flags; print hexdump(data
> => $payload, start_position => 0) if length + $payload; print $/; } }
> sub flags_of { my ($flags) = @_; my @strarr = (); push @strarr, "urg"
> if $flags & URG; push @strarr, "ack" if $flags & ACK; push @strarr,
> "psh" if $flags & PSH; push @strarr, "fin" if $flags & FIN; push
> @strarr, "syn" if $flags & SYN; push @strarr, "rst" if $flags & RS

XML::XPath got some error creating a new parsing

2010-06-03 Thread perl
This is normally the basic when i added a xml file to the code 

Code ::

/use XML::XPath;
use XML::XPath::XMLParser;
use Data::Dumper;
# create an object to parse the file and field XPath queries
my $xpath = XML::XPath->new( filename => "test.xml" );

print Dumper ($xpath) ;/

OutPut ::

/$VAR1 = bless( {
 'path_parser' => bless( {
   'direction' => 'forward',
   'context_size' => 0,
   'context_pos' => undef,
   'vars' => {},
   'cache' => {},
   'namespaces' => {},
   'context_set' => bless( [],
'XML::XPath::NodeSet' )
 }, 'XML::XPath::Parser' ),
 '_ioref' => undef,
 '_context' => undef,
 '_xml' => undef,
 '_filename' => 'test.xml',
 '_parser' => undef
   }, 'XML::XPath' );
/

This is the OutPUt when i made changes to the code ..

 Code ::

/use XML::XPath;
use XML::XPath::XMLParser;
use Data::Dumper;
# create an object to parse the file and field XPath queries
my $xpath = XML::XPath->new( context => "test.xml" );
print Dumper ($xpath) ;/

OutPut ::

http://paste2.org/p/863311



XML::LibXML::Reader source specification error

2010-06-12 Thread perl
I tried to use LibXML .. when i never to the correct libXML read file
... when i tried to use the LWP download which is an XML .. how to use
it please help  me ...

/use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $response =
$ua->get("http://www.perlmonks.org/?displaytype=xml;node_id=3989";);
 if ($response->is_success) {
 my $string = $response->content;  # or whatever
 }
 else {
 die $response->status_line;
 }
use XML::LibXML::Reader;
  my $reader = new XML::LibXML::Reader( string => $string )
 or die "cannot read file.xml\n";
  while ($reader->read) {
processNode($reader);
  }

  sub processNode {
  $reader = shift;
  printf "%d %d %s %d\n", ($reader->depth,
   $reader->nodeType,
   $reader->name,
   $reader->isEmptyElement);
}/


how to get XML::LibXML perfect xpath query ?

2010-06-12 Thread perl
i have tried to use the LibXML modules to xpath a document but its
getting complicated ..
i have seen this example over forum here .

use XML::LibXML ;
use strict;
use warnings;
{
my $xml = <<'XML';


  
Hello world!
  

XML
my $parser = XML::LibXML->new;
my $doc= $parser->parse_string($xml);
my $result = $doc->findvalue('//lastName');
print $result;
}
{
my $xml = <<'XML';

http://tempuri.org/sdnList.xsd";>
  
Hello world!
  

XML
my $parser = XML::LibXML->new;
my $doc= $parser->parse_string($xml);
my $result = $doc->findvalue('//lastName');
print $result ;
}
 /


One of the member posted this solution ... /


use XML::LibXML;
use XML::LibXML::XPathContext;

{
my $xml = <<'XML';

http://tempuri.org/sdnList.xsd";>
  
Hello world!
  

XML
my $parser = XML::LibXML->new;
my $doc= $parser->parse_string($xml);
my $xc = XML::LibXML::XPathContext->new($doc);
$xc->registerNs('sdnList', 'http://tempuri.org/sdnList.xsd');
my $result = $xc->findvalue('//sdnList:lastName');
is( $result, "Hello world!", "Namespace" );
}


But every time we can't get same namespace ... if i add any API to the
xml input . its extremely difficult to handle it .. 

Is there any way to get nodes and attr and like that stuff in
XML::LibXML easily ??? or any other modules excpet xml::xpath..

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




cgi sqlite error not able to write data in database

2010-07-23 Thread perl
hi,
it got some error while adding data into sqlite through Perl script on
Apache ... script can able to read the file but not able to write .. I
have set the permissions of sqlite file to 666 ..

when i ran the script from local user its working fine .. its able to
write the data into db
when i rant that script on Apache its not working ..
i can't figure it out
its is a Apache error or my file permissions?
thank you.
Kanishka


Re: cgi sqlite error not able to write data in database

2010-07-23 Thread perl
On 07/24/2010 08:53 AM, Owen wrote:
>   
>> hi,
>> it got some error while adding data into sqlite through Perl script on
>> Apache ... script can able to read the file but not able to write .. I
>> have set the permissions of sqlite file to 666 ..
>>
>> when i ran the script from local user its working fine .. its able to
>> write the data into db
>> when i rant that script on Apache its not working ..
>> i can't figure it out
>> its is a Apache error or my file permissions?
>> thank you.
>> Kanishka
>> 
>
>
>
>
> You actually need to provide a little more information.
>
> Do you have this line in your cgi script? If not, put it in.
>
> use CGI::Carp qw (fatalsToBrowser);
>
> The error message from that will give you some clues.
>
>
> Do you have access to the apache(2) logs? If so, read them and see
> what they say
>   

This is the Error .. got from Apache ...
DBD::SQLite::db do failed: unable to open database file at

#!/usr/bin/perl
use strict;
use Net::OAuth;
use LWP::UserAgent;
use CGI;
use DBI;
use XML::LibXML;
use YAML;
my $xpc = XML::LibXML::XPathContext->new();
use Data::Random qw(:all);
my $cgi = CGI->new;
print $cgi->header();
my $id = $cgi->param('id');
my $count = $cgi->param('count');
my $screen = $cgi->param('screen');
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
use HTTP::Request::Common;
my $i;
my $dbh = DBI->connect("dbi:SQLite:dbname=info.sqlite","","",{AutoCommit
=> 1 })||die(print "$DBI::err $DBI::errstr \t $DBI::state 1 ");
$dbh->do("INSERT INTO list VALUES
('$id','$screen','$count')")||die(print "$DBI::err $DBI::errstr
$DBI::state 2");
$dbh->do("CREATE TABLE $screen ( created TEXT, id NUMERIC, source TEXT,
text TEXT )")||die(print "$DBI::err $DBI::errstr 3");

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




Re: cgi sqlite error not able to write data in database

2010-07-24 Thread perl
On 07/24/2010 10:48 AM, Owen wrote:
>   
>> On 07/24/2010 08:53 AM, Owen wrote:
>> 
>>>   
>>>> hi,
>>>> it got some error while adding data into sqlite through Perl script
>>>> on
>>>> Apache ... script can able to read the file but not able to write
>>>> .. I
>>>> have set the permissions of sqlite file to 666 ..
>>>>
>>>> when i ran the script from local user its working fine .. its able
>>>> to
>>>> write the data into db
>>>> when i rant that script on Apache its not working ..
>>>> i can't figure it out
>>>> its is a Apache error or my file permissions?
>>>> thank you.
>>>> Kanishka
>>>>
>>>> 
>>>
>>>
>>>
>>> You actually need to provide a little more information.
>>>
>>> Do you have this line in your cgi script? If not, put it in.
>>>
>>> use CGI::Carp qw (fatalsToBrowser);
>>>
>>> The error message from that will give you some clues.
>>>
>>>
>>> Do you have access to the apache(2) logs? If so, read them and see
>>> what they say
>>>
>>>   
>> This is the Error .. got from Apache ...
>> DBD::SQLite::db do failed: unable to open database file at
>>
>> #!/usr/bin/perl
>> use strict;
>> use Net::OAuth;
>> use LWP::UserAgent;
>> use CGI;
>> use DBI;
>> use XML::LibXML;
>> use YAML;
>> my $xpc = XML::LibXML::XPathContext->new();
>> use Data::Random qw(:all);
>> my $cgi = CGI->new;
>> print $cgi->header();
>> my $id = $cgi->param('id');
>> my $count = $cgi->param('count');
>> my $screen = $cgi->param('screen');
>> $Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A;
>> use HTTP::Request::Common;
>> my $i;
>> my $dbh =
>> DBI->connect("dbi:SQLite:dbname=info.sqlite","","",{AutoCommit
>> => 1 })||die(print "$DBI::err $DBI::errstr \t $DBI::state 1 ");
>> $dbh->do("INSERT INTO list VALUES
>> ('$id','$screen','$count')")||die(print "$DBI::err $DBI::errstr
>> $DBI::state 2");
>> $dbh->do("CREATE TABLE $screen ( created TEXT, id NUMERIC, source
>> TEXT,
>> text TEXT )")||die(print "$DBI::err $DBI::errstr 3");
>>
>> 
>
>
>
>
> Where you have DBI->connect("dbi:SQLite:dbname=info.sqlite" ... i
> would have;
>
> made a variable;
> my $db = '/full/path/to/info.sqlite'; then said
> DBI->connect("dbi:SQLite:$db" 
>
> I suspect the the server is looking for the database somewhere else
>
>   
Ahh Solved its about the permissions of the Folder not the sever fault
... i have to give write permission of the folder to WWW 
Thank's for the help
Kanishka

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




Email Purge

2009-02-24 Thread perl
Cheers and thanks in advance for you help. I have a routine intended
to purge duplicate emails from a list. The code below is not working.
I remember seeing something like... foreach $email(@emails, @emails2))
{ etc ... but I'm lost. Any help is appreciated.
sub purge
{
open (LIST, "$list") or error("$list  purge 1 email  ");
while (my $line = )
{
@emails = split(/\r?\n|\r/, $line);
@emails2 =  @emails;
}
close (LIST);
foreach $email(@emails)
{

foreach $email2(@emails2)
{
if($email ne $email2)
{
$newemail .="$email\n";
}
else{$purgecnt++; }
}
}
open (LIST, ">>$list") or error("$list  purge 2");
flock(LIST, LOCK_EX);
print LIST $newemail;
close (LIST);
&success("$list has been purged of $purgecnt duplicates");


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




Apache::Session question

2004-03-25 Thread Perl
My implementation of Apache::Session::MySQL dies along the way, and gives 
unclear warning. 
[error] Died at /usr/lib/perl5/site_perl/5.8.0/Apache/Session/Generate/MD5.pm 
line 40.

I decided to implement session as a module call Store::Session, so as to 
minimize recoding it in many script.






#
#  Program: 
#  Author: Babale Fongo#
#  Date: 01-03-2004			   	#
#  Description: Module for database connections.#
#  Copyright (c) Babale Fongo			#
#  Email: [EMAIL PROTECTED]			#
#  Web: http://www.domain name.com		#
# ===   #
#		#
#  <<< Technical information >>>>		#
# 		#
# 		#
#



#
#  Beginning of the script. #
#


package Store::Session;
use vars qw(@ISA @EXPORT);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(new getId closeSession deleteObject);

use strict;
use Apache::Session::MySQL;


#
# Start a new session  
##


sub new {

my ($dbh, $session_id) = @_;
my %session;
tie %session, "Apache::Session::MySQL", $session_id,{ 

Handle => $dbh, LockHandle => $dbh

};

return;#(\%session);

}

1;
    


















#!/usr/bin/perl -w

#
#  Program: 	
#  Author: Babale Fongo
#  Date: 				
#  Description: 
#  Copyright (c) Babale Fongo			
#  Email: [EMAIL PROTECTED]			
#  Web: http://www.domain name.com		
# ===   
#		
#  <<< Technical information >>>>		
# 		
# 		
####


use strict;
use lib qw(/data/www/perl-bin/jupiterShop/Modules);
use Store::Session;
use CGI qw(:all);
use DBConnect;
use Layout;


# Database connectivity
my $dbh = dbConnect();

# Get value of url or cookie id if any.
my $session_id = cookie("session"); #|| param("session");
my ($cookie, $session_ref);

if (defined($session_id)){

$session_ref = Store::Session->new($dbh, $session_id);
defined($session_ref) || die ("Couldn't retrieve session: Apache::Session::errstr"); 

}else {

$session_ref = Store::Session->new($dbh, undef);
defined($session_ref) || die ("Couldn't start a new session: Apache::Session::errstr");
$cookie = cookie(-name => "session",
   -value => $session_ref,
   -expires => "+3d",
   -domain => ".shop.com"
);

}




print header (-cookie => $cookie);
print header();
start_html();
   print p ("The session id is : $session_ref"); 
end_html();

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


Image editing/Creating modules

2004-05-17 Thread perl
can someone give a name of any image (JPG or GIF) editing / creating module, which 
allow to create images to display on web pages on the fly by CGI scripts.


Rakhitha M. Karunarathne
Trainee Software Developer,
IFS - R & D International,
501,Galle Road ,Cololmbo-6, SRI LANKA.
Tel +94 (011)-2-364-440 Ext 841
E-mail [EMAIL PROTECTED]
www.ifsworld.com

CONFIDENTIALITY AND DISCLAIMER NOTICE 
Please note that this message may contain confidential information. If you have 
received this message by mistake, please inform the sender of the mistake by e-mailing 
[EMAIL PROTECTED], then delete the message from your system without making, 
distributing or retaining any copies of it.
Any views or opinions presented are solely those of the sender and do not necessarily 
represent those of IFS unless otherwise specifically stated.
Although we believe that the message and any attachments are free from viruses and 
other errors that might affect the computer or IT system where it is received and 
read, the recipient opens the message at his or her own risk. We assume no 
responsibility for any loss or damage arising from the receip.


Sorting HTML tables

2004-08-04 Thread Perl
I wrote some code to identify and print HTML tables below:

use strict;

my @table;
my $logfile;
my $counter;
my $inc;
my @array;

die "You must enter an argument. \n" if $#ARGV <0;
$logfile = chomp ($ARGV);
foreach my $line(<>){

if ($line =~ /(TABLE)(.+)/) {
$inc++;

}

$table[$inc] .= $line; # append each line to the array element

$counter++;

}

# Print out each table to show that the script works.   

foreach my $lineno (0..$#table) {
print "TABLE: $lineno \n";
print $table[$lineno];
print "\n\n\n";
sleep 1;
}



The problem I am stuck with is that now I want to sort the tables based
on a Priority (which range from 1-3). There may be several tables with
the same priority numbers.   An example of a Priority 3 would be:


Priority

3

I need help in understanding the methodology in how to extract these 2
items and then sort the tables in Priority order (all the 1's, 2's and
3's). 

Thanks.

--Paul


Regex to match valid host or dns names

2004-10-13 Thread perl

Hi,

How do I best test for a valid host name? My script will read from a
file which contains IP addresses and/or dns name, so I'm trying to sort
out valid IP addresses or host name (using regex). For some reason, my
regex fails to match host names with one or more dash (-). IN the
example below, it fails to match "host-no.top-level" as a valid host
name. I modify the regex several times - but still don't get the right
outlook.


my @hosts = qw(192.168.22.1 192.168.22.18 localhost another.host.domain
host-no.top-level my.host.domain.com);
foreach (@hosts){
# Works ok
push (@ips, $_ ) if $_ =~ /^\d{1,3}\.\d{1,3}\.\d{1|3}/; 
 
# Can't match "host-no.top-level". 
push (@dns, $_) if $_ =~ /^\w+-?[\w+]?\.?[\w+.{1}]*\w+$/;
}

Thanks..


Babs

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




Re: RE: Regex to match valid host or dns names

2004-10-14 Thread perl

Your regex did not allow (w2k-server-proxy2) a valid dns name.
I now see how complex it is to match valid ips or dns names.

The more I try to modify the regex to perfection, the more I see
hopholes. So I think it is not worthwhile spending lot of time on this
regex. My script does more than pattern matching, so I will be ok with
the regex I've got so far.

Unfortunately this will also match 999.999.999.999, but I will keep it.
$_ =~ /[^0][\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.][\d]{1,3}$/; 

This matches dns to an acceptable extend.

$_ =~ /^\w+[-\w+-?\w+]*\.?\w+?\d*$/ && $_ != /^\d*$|\d{2,}/;



Thanks anyway for your help.






"K.Prabakar" <[EMAIL PROTECTED]> schrieb am 14.10.2004, 06:49:16:
> On Thu, 14 Oct 2004, K.Prabakar wrote:
> 
> > On Wed, 13 Oct 2004, Babale Fongo wrote:
> > 
> > > K.Prabakar's  suggestion looks good but also failed the test:
> > > 
> > > "$_ =~ /^\w\w*-?\w+?[\.\w\w*-?\w+?]*$/",
> > > 
> > >  It will match an invalid dns name like this (host-.domain.com) as a valid.
> > > I'm still working on it, but will welcome any other suggestion.
> > > 
> > > Babs
> > > 
>  
>  As "Randal L. Schwartz" pointed out I used character class"[]" in the 
>  above regex which is wrong. That should be "()" like 
>  
>  this--> /^\w\w*-?\w+?(\.\w\w*-?\w+?)*$/
>  Now it won't match "host-.domain.com" like names.
>  
>  Other thing is this will allow dns names starting with DEGITS.In that 
> case the worst case solution will be 
>  
>  /^[a-zA-Z]\w*-?\w+?(\.[a-zA-Z]\w*-?\w+?)*$/ .
>  
>  This will allow names like
>  "bla-3bla.bla" , "bla-bla" but won't allow "3bla.bla" and "bla.4bla"
>  To avoid underscore again the worst case will be to replace \w with 
>  [-a-zA-Z] in the above expression. That won't look good at all. 
>  
>  
> 
> -- 
> Regards,   
> K.Prabakar 
> 
> -- 
> 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]
 




module installation

2004-11-16 Thread perl
Hi,

I installed few perl module locally and I
try to install another one which depends
on the previously installed ones (locally)
but I get the warning that these modules can not
be loaded

example:

billmax:~/src/perl/XML-DOM-1.43$ perl Makefile.PL 
PREFIX=~/usr/local/lib/perl5
Checking if your kit is complete...
Looks good
Warning: prerequisite XML::Parser failed to load: Can't locate 
XML/Parser.pm in @INC (@INC contains: /home/gwes/usr/local/lib/perl5/5.6.0 
home/gwes/usr/local/lib/site_perl/5.6.0 /usr/lib/perl5/5.6.0/i386-linux 
/usr/lib/perl5/5.6.0 /usr/lib/perl5/site_perl/5.6.0/i386-linux 
/usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at (eval 7) 
line 3.

Parser.pm is installed here:

billmax:~$ pwd
/home/gwes

~/usr/local/lib/perl5/lib/site_perl/5.6.0/i386-linux/XML/Parser.pm

and I have PERL5LIB defined in my .bash_profile

export  
PERL5LIB=/home/gwes/usr/local/lib/perl5/5.6.0:home/gwes/usr/local/lib/site_perl/5.6.0


so what do I get the above warning ?

thanks.


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




Uninitialized value in unpack

2004-12-23 Thread perl

Can anyone point out what is uninitialized  in line 162?

my @resolved = ();
foreach (@dns){
 my $ip = gethostbyname($_);
 my ($a,$b,$c,$d); 
 my $x = join (".", (unpack('C4',$ip ))); # line 162
 $x ||= "";
 push (@resolved, join(" => ", $_,$x));

}

Thanks

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




Compare file modification time

2005-02-11 Thread perl

How do I best compare mtime of several files. I have a script for making
daily backups  into a given directory. Now I want to modify it to
delete old backups if the total exceed cetain number. 

The idea was to compare the mtime of all file to figure out old files to
delete, but somehow I think it shouldn't be all that complicated.
Any elegant idea on how to acomplice this? 

Thanks

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



compare file modification time

2005-02-14 Thread perl
#!/usr/bin/perl -w

use strict;
#use diagnostics;

my $dir = "testdir";
opendir (DH, "$dir") || die "Could not open $dir: $!\n";

my @files; my $keep = 7;
while (defined(my $file = readdir(DH))){
next if $file =~ /^\.+$/;
push (@files, $file);
}

# Skip the rest if number of files isn't above $keep.

chdir $dir;
if ($#files -1 > $keep){
my %file_mtime;
foreach(@files){
$file_mtime{$_} = (stat ($_))[9];
}
  #foreach my $key (keys %file_mtime){print "$key \t=> 
$file_mtime{$key}\n";}print  "\n";
  my @sorted = sort{$file_mtime{$b}<=>$file_mtime{$a}} keys %file_mtime;
  #foreach (@sorted){print "$_\n";}
  my @delete = @sorted[$keep..$#sorted];
  for (@delete){unlink $_ or warn "Couldn't delete $_: $!\n";} 
}

closedir(DH);



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




Regex against a scalar

2005-03-23 Thread Perl
Hi. 

I would like to search a scalar variable and have the output to another
scalar. For example:

$test = "This is some test data";

I want another scalar, $regex to hold the output of a regular expression
lookup against $test.

So something like this:

$regex =~ /test/ running against $test. Is this possible somehow?


can any one tell why isn't this working on HTML::Tree ??

2011-01-01 Thread perl
use strict;
use warnings;
use YAML;
use HTML::Tree;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $response =
$ua->get('http://www.raaga.com/channels/hindi/moviedetail.asp?mid=H002927');
my $content1 = $response->content;
my $tree = HTML::Tree->new();
$tree->parse($content1);
my $article = $tree->look_down(_tag=>'form',id=>'raaga');
my $table =
$article->look_down(_tag=>'table',class=>'dataTbl',width=>"450");
print Dump $table;


Can any one tell me why isn't this working ???


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




Maximum file descriptors on Solaris

2002-03-26 Thread perl

I know that under Solaris 2.6 that a process couldn't hold more than 256
file descriptors, but that restriction was lifted in Solaris 7 and Solaris
8.

Using ulimit -n 1024 and the pfiles command, I can see that the process
running this particular Perl script in question has a 1024 limit but the
256th open statement fails (as monitored using pfiles).

The actual error from the open statement is "Illegal seek" but I am not sure
if that is meaningful or not.

I've tried several versions of Perl; 5.003, 5.005_03 (which comes with
Solaris), 5.6.0 and I've just built 5.6.1 on Solaris 7 with similar results.

Is there a known Perl limit that I'm dealing with here? I am new to Perl and
this is a very complicated script which forks off child processes and
maintains communication and control via the socket. We seem to have hit the
wall at 256 but I currently need hundreds more.

I would ask the original programmer, but I believe my predecessor actually
killed him for obtuse coding pratices ( an occupational hazzard for Perl
programmers? ). Any insight would be appreciated.

Regards

Jerry





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




Re: How to thread in Perl?

2002-03-26 Thread perl

Is there a limit to the number of children in Perl?


"Ahmed Moustafa" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Tagore Smith wrote:
>
> > Ahmed Moustafa wrote:
> >
> >
> >>So, how can a new different process by forked? Or, how a function be
> >>called and the next step execute without waiting for the previous
> >>function to terminate?
> >>
> >
> >For your original question (threads) see perldoc perlthrtut.
> >
> >When you fork a child process the call to fork returns the child pid
to
> > the parent and 0 to the child. So you can write code that tests the
return
> > value and does one thing in the parent process (continue forking
children to
> > deal with the rest of your files) and another in the child process
(process
> > the current file). You can also use exec to execute another process
which is
> > not a "clone" of the parent.
> >
> >See perldoc -f fork and perldoc -f exec.
> >
> >Out of curiosity, why do you want to do this?
>
>
> The main loop looks for files which are sent via FTP. Once a file is on
> the server, it should be encrypted. The encryption process is slow so
> some files stay as plain text waiting for their turns to be found and
> encrypted.
>



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




Retrieving stock data from the web

2007-12-05 Thread Perl
Hi All.

I want  to download historical stock financial data (EPS, growth, sales revenue 
etc.) from the web. My intention is to populate a MYSQL database with these 
values and then perform a series of calculations against the database for my 
personal investing. A sample of the data I want to retrieve is here: 
http://moneycentral.msn.com/investor/invsub/results/hilite.asp?Symbol=IBM

What is the best way to do this? I'm more interested in the approach vs. 
specific code. I thought about using Finance::Quote but that doesn't appear to 
be written to retrieve the historical data I am after.
LWP also comes to mind as well.

Any suggestions would be greatly appreciated.

--Paul



Re: local and auto flush

2018-05-19 Thread perl
Many thanks for the very helpful comments from Andrew and Andy. For the first 
time, I have a clear idea of what local and auto flushing are doing for me. I 
know I’d get educated here!
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: difficulty with matching

2018-06-02 Thread perl
Very useful advice, Shlomi; thanks!


> On Jun 2, 2018, at 3:57 AM, Shlomi Fish  wrote:
> 
> On Fri, 1 Jun 2018 15:54:55 -0500
> Rick T mailto:p...@reason.net>> wrote:
> 
>> This is a newbie question, I’m sure. But I get perplexed easily!
>> 
>> The follow code segment expects to receive a $student_id consisting of a
>> surname followed by a hyphen followed by a number. The die is for testing
>> what I’m doing. 
>> 
>> If I feed it 'jones-123’ it dies with ‘jones, - , 123’ as I expected. But if
>> I feed it ‘jones-‘ omitting the number on the end, it dies with no matches at
>> all (or blanks): ‘ , , ‘ and I cannot figure out why it does not die with
>> ‘jones, -, ' and would appreciate an explanation. Many thanks!
>> 
>>$student_id = lc $student_info_hash{student_id}; # Impose lower case
>>$student_id =~ s/\s//xmsg;   # Remove whitespace
>> 
>>$student_id =~
>>m{
>>\A([a-z]+)  # match and capture leading alphabetics 
>>(-) # hyphen to separate surname from student number
>>([0-9]+\z)  # match and capture trailing digits
>> }xms;  # Perl Best Practices
>>$student_surname = $1;
>>my $hyphen   = $2;
>>$student_number  = $3;
> 
> In addition to the other comments, Instead of that, you should do:
> 
> if (my ($surname, $hyphen, $num) = $student_id =~ m{ ... }xms)
> {
>   # match successful.
> }
> else
> {
>   die "match failed ...";
> }
> 
> always check for regex match successes and use the return captures of regex
> ops. See PBP for more.
> 
>> die "$student_surname, $hyphen, $student_number”;
>> 
>> Rick Triplett
>> 
> 
> 
> 
> -- 
> -
> Shlomi Fish   http://www.shlomifish.org/ <http://www.shlomifish.org/>
> Best Introductory Programming Language - http://shlom.in/intro-lang 
> <http://shlom.in/intro-lang>
> 
> A horse! A horse! My kingdom for a horse!
>— https://en.wikiquote.org/wiki/Richard_III_%28play%29 
> <https://en.wikiquote.org/wiki/Richard_III_%28play%29>
> 
> Please reply to list if it's a mailing list post - http://shlom.in/reply 
> <http://shlom.in/reply> .
> 
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org 
> <mailto:beginners-unsubscr...@perl.org>
> For additional commands, e-mail: beginners-h...@perl.org 
> <mailto:beginners-h...@perl.org>
> http://learn.perl.org/ <http://learn.perl.org/>


Re: interpolation without double quotes

2018-07-05 Thread perl
Many thanks to Shlomi and Uri: as always, you’ve greatly boosted my 
understanding of Perl! — Rick


> On Jul 4, 2018, at 9:35 AM, Shlomi Fish  wrote:
> 
> Hi Rick,
> 
> On Wed, 4 Jul 2018 09:16:19 -0500
> Rick T  wrote:
> 
>> The following line works, even though I forgot to double quote the variable.
>> 
>> my $student_directory =  '/data/students/' . $student_id;
>> 
> 
> see http://perl-begin.org/tutorials/bad-elements/#vars_in_quotes . Perl often
> stringifies expressions even outside interpolation, such as when being
> string-concatenated.
> 
>> When I noticed this, I thought this was convenient: perl is trying to “do the
>> right thing.” But I worry that leaving them out may be bad coding practice;
>> if so, or you see other worthwhile improvements, please let me know.
>> 
>> More importantly, I wonder how perl knows to do this. Perhaps  context
>> provided by the assignment operator or the concatenation operator? If there
>> is a general rule on this, it would help me to know more widely when I can
>> omit double quotes.
>> 
>> Thanks!
>> 
>> Rick Triplett
> 
> 
> -- 
> -
> Shlomi Fish   http://www.shlomifish.org/
> First stop for Perl beginners - http://perl-begin.org/
> 
> After all is said and done, a hell of a lot more is said than done.
>— Unclear source, via fortune-mod.
> 
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
> 
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 
> 

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




Re: slurp error

2018-07-29 Thread perl
Many thanks to Andy and Uri for their helpful comments. My problem is solved, 
plus I learned a lot in the process! — Rick


> On Jul 27, 2018, at 1:56 PM, Andy Bach  wrote:
> 
> open my $fh1, '<', $file_to_convert
> or die "Can't open $file_to_convert: $!\n"; 
> $slurp = <$fh1>
> or die "Could not slurp $file_to_convert: $!";
> 
> It's just a warning (the code works) that you're using $fh1 untested. This 
> doesn't complain
> if ( open my $fh1, '<', $file_to_convert ) {
> $slurp = <$fh1>;
> close $fh1;
> } 
> else { 
> die "Can't open $file_to_convert: $!\n"; 
> }
> 
> note: the "close" has to be in the "if" block.  Good idea to close handles, 
> though, as soon as you're done with them. 
> 
> I guess it's not seeing the "or die" as a good enough test.
> 
> Uri wrote:
> > no need for xms if you aren't using those features.
> 
> Yaybut - I though D.Conway's Best Practice was to always include those, 
> unless you specifically didn't want one. Smacks of cargo cult but I'd never 
> argue with him.
> 
> On Fri, Jul 27, 2018 at 1:37 PM, Rick T  <mailto:p...@reason.net>> wrote:
> I tried to implement some advice about slurping that I read on this mailing 
> list (using local) but cannot get it to work. I get the message “Value of 
>  construct can be "0"; test with defined() at line 23” (the $slurp = 
> <$fh1> line). I’m using perl version 5.18.2 installed in 2014.
> 
> I’ve googled this error and think (ha!) I understand it, but though I’ve 
> tried many changes, I cannot make the error go away. I need the advice of 
> folks who are way ahead of me!
> 
> Rick Triplett
> 
> 
> use warnings;
> use strict;
> use DB_File; # module for Berkeley DBM w/ DB_HASH file type
> use CGI::Carp qw ( fatalsToBrowser );
> 
> # Declare some globals
> my $server = 'exploringmyself'; 
> my $file_to_convert = 'Untitled.tab'; 
> 
> chdir "/big/dom/x$server/data/courses/"
> or die "Can't chdir to /courses: $!\n";
> if (! -e "$file_to_convert") {
> die "Can't find $file_to_convert: $!\n"
> };
> 
> my $slurp;
> {
> local $/;
> open my $fh1, '<', $file_to_convert
> or die "Can't open $file_to_convert: $!\n"; 
> $slurp = <$fh1>
> or die "Could not slurp $file_to_convert: $!";
> $slurp =~ s/\r/\n/xmsg; # swap Mac's CR for LF
> $slurp =~ s/\x0b//xmsg; # swap Filemaker paragraph marker VT for html
> close $fh1;
> }
> 
> 
> 
> 
> -- 
> 
> a
> 
> Andy Bach,
> afb...@gmail.com <mailto:afb...@gmail.com>
> 608 658-1890 cell
> 608 261-5738 wk



Re: reading form values from POST

2018-09-03 Thread perl
Many thanks to Shlomi, Bill, and Uri. I always get a wealth of information when 
I post here! — Rick

> On Sep 3, 2018, at 2:37 AM, Shlomi Fish  wrote:
> 
> Hi Rick,
> 
> On Sun, 2 Sep 2018 16:04:26 -0500
> Rick T mailto:p...@reason.net>> wrote:
> 
>> I am trying to wean myself from CGI.pm, an easy task for most of you, but I
>> am a beginner. The code below works, but that does not mean it always will or
>> that it cannot be improved. I found the main part of this in CGI Programming
>> with Perl, which is 18 years old, and I’ve given up hoping that a new edition
>> of it will come out. I’ve read somewhere that servers can give the wrong
>> value for CONTENT_LENGTH, so I stuck in a second chance before bailing out;
>> and of course this may not be necessary or done well.  I look forward to any
>> and all comments. I also would appreciate any guidance on how I can learn
>> more about CGI and how to deal with it. This book has been extremely valuable
>> to me, but even I can see that some of its guidance is a bit creaky! — Rick
>> 
>> sub get_form_data {
>>my $query = q{}; # Empty string
>>my @name_value_pairs;
>>if ( read( STDIN, $query, $ENV{'CONTENT_LENGTH'} ) 
>>  == $ENV{CONTENT_LENGTH}
>>   ){
>>@name_value_pairs = split /&/, $query;
>>}elsif (! read( STDIN, $query, $ENV{'CONTENT_LENGTH'} ) # Second chance
>>== $ENV{CONTENT_LENGTH}
>>   ){
>>die "Trouble parsing POST request: $!"
>>}
>> 
> 
> please  use a module - whether CGI.pm or other. See:
> 
> * https://leejo.github.io/2016/02/22/all_software_is_legacy/ 
> <https://leejo.github.io/2016/02/22/all_software_is_legacy/>
> 
> * https://plackperl.org/ <https://plackperl.org/>
> 
> * https://metacpan.org/release/CGI-Minimal 
> <https://metacpan.org/release/CGI-Minimal> 
> 
> Thanks to Uri too.
> 
> Regards,
> 
>   Shlomi Fish
> 
>>foreach my $pair (@name_value_pairs){
>>my ($key, $value) = split /=/, $pair;
>>chomp ($key, $value);
>>$pf{$key} = $value;
>>}
>> return;
>> }
>> 
> 
> 
> 
> -- 
> -
> Shlomi Fish   http://www.shlomifish.org/ <http://www.shlomifish.org/>
> http://is.gd/i5eMQd <http://is.gd/i5eMQd> - Emma Watson’s Interview for a 
> Software Dev Job
> 
> I love being convinced that I was wrong before. That way I knew I
> improved and am now wiser. Like the Klingon warriors say when it happens:
> “What a great day it was for me to die!”.
> 
> Please reply to list if it's a mailing list post - http://shlom.in/reply 
> <http://shlom.in/reply> .
> 
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org 
> <mailto:beginners-unsubscr...@perl.org>
> For additional commands, e-mail: beginners-h...@perl.org 
> <mailto:beginners-h...@perl.org>
> http://learn.perl.org/ <http://learn.perl.org/>


Re: data structure for Template Toolkit

2018-10-29 Thread perl
Many thanks to Andrew and Mike — your suggestions worked and gave me a lot to 
think about as well!

That’s what love about this mailing list: I always learn a lot!

Rick Triplett


> I hope somebody has replied already.
> If not, in general you are reading data from DATA, 
> creating an array and a hash, and then creating an 
> html file using the Template Toolkit.
> 
> I think much of it looks good, but I see no
> use Template::Toolkit
> or anything similar.
> Do you have that?  I suspect you do.
> Maybe you should post that part too.
> 
> 
> Also, this line looks suspicious to me:
> my %list = (list => \@courses);
> 
> Maybe that is intended to be an array ref.
> 
> Perhaps right after that you should put this:
> 
> print "\%list contains this:\n\n";
> foreach my $key (sort keys %list){
> print "$key - $list{$key}\n";
> }

> On Oct 28, 2018, at 4:50 PM, Andrew Solomon  wrote:
> 
> Hi Rick,
> 
> The bug is that you're calling
> 
> my %list = (list => \@courses);
> 
> when you should be calling
> 
> my %list = (courses => \@courses);
> 
> If only there were 'strict' and 'warnings' for Template!  :-)
> 
> Andrew
> 
> On Sun, Oct 28, 2018 at 8:52 PM Rick T  <mailto:p...@reason.net>> wrote:
> As a novice in perl I realize that it’s a bit presumptuous for me to attempt 
> references and complex data structures. But I had a need and gave it a shot — 
> a failing shot. I’ve been fiddling with my failure, almost mindlessly, all 
> weekend; now I need some help.
> 
> Below is the template segment I am trying to populate with data, and 
> following it is the segment of code that attempts to call it. The output I 
> get in my browser is persistently empty, with every instance of [% %] being 
> replaced with blanks.


Re: data structure for Template Toolkit

2018-10-30 Thread perl
Looks like a good place to start. When I get the courage, I’ll plunge in! — Rick


> On Oct 30, 2018, at 12:40 PM, Shlomi Fish  wrote:
> 
> Hi Rick,
> 
> On Tue, 30 Oct 2018 07:34:11 -0500
> Rick T mailto:p...@reason.net>> wrote:
> 
>> Uri, thanks for the boatload of useful suggestions! I will am busying myself
>> with understanding and applying them.
>> 
>> Regarding Template::Simple, this module isn’t among the many that my host has
>> installed, and I have not had success trying to learn how to install stuff
>> from CPAN. Fortunately I’m beginning to get the hang of Template Toolkit, and
>> I may need it for more complex situations that come up. Switching from
>> HTML::template this year was a challenge, and I had to rewrite a lot of my
>> perl to go with it. I know that most perl people are good at using the CPAN
>> resource, but I’m just a high school teacher who dabbles in perl. And at age
>> 74 I have to be choosy about which learning curves I take on!
>> 
>> Still, if anyone can point me to a “beginners guide” to using CPAN, I’ll take
>> a look at it.
>> 
> 
> See https://perl-begin.org/topics/cpan/ <https://perl-begin.org/topics/cpan/> 
> for some guides for using CPAN.
> 
> Regards,
> 
>   Shlomi Fish


Re: data structure for Template Toolkit

2018-10-30 Thread perl
Thanks, Brandon! I’m hosted at FutureQuest.net <http://futurequest.net/>, which 
has Linux servers. So, nothing oddball or demanding about the environment. But 
my familiarty with Unix/Linux programming is almost nil, so I sweat over stuff 
that would seem clear to most programmers. — Rick


> On Oct 30, 2018, at 1:41 PM, Brandon McCaig  wrote:
> 
> On Tue, Oct 30, 2018 at 07:34:11AM -0500, Rick T wrote:
>> Still, if anyone can point me to a “beginners guide” to using
>> CPAN, I’ll take a look at it.
> 
> The easy button for CPAN, or at least the one I'm most familiar
> with, is cpanm AKA App::cpanminus. The cpan command is very
> low-level and prompts the user repeatedly, making it basically
> unusable by a human user. If it is available to you, or you're
> able to get it installed, cpanm takes away all of this pain and
> automatically fetches, builds, tests, and installs your desired
> package and all of its dependencies automatically.. You'd just
> invoke:
> 
>$ cpanm Template::Simple
> 
> And with minimal output it should install for you. If not, you
> might have to get your hands dirty reading logs to figure out
> what is wrong, and what to do about it, but for well maintained
> packages in a Unix-like environment that is rare in my
> experience..
> 
> You can read about cpanm and how to install it from the Git repo
> readme:
> https://github.com/miyagawa/cpanminus/tree/devel/App-cpanminus
> 
> I have not used hosting environments for Perl deployment so I
> cannot say whether this is likely to be an option for you.
> 
> On another note, a nice way to control your Perl environment is
> by using perlbrew, which allows you to install an up-to-date perl
> distribution within your home directory to use, and to likewise
> install your CPAN modules within your home directory too. It is
> also capable of managing many different perl environments
> side-by-side which probably isn't needed, but doesn't hurt to
> know about..
> 
> I'm not sure how difficult it would be to use a perlbrew
> environment for your hosting environment, but nevertheless it is
> a useful resource to know about. Note that if you do use perlbrew
> it has a command to install cpanm too so it might kill two birds
> with one stone.
> 
> Regards,
> 
> 
> -- 
> Brandon McCaig  
> Castopulence Software <https://www.castopulence.org/>
> Blog <http://www.bambams.ca/>
> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
> q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
> tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'
> 



Pass a value to Perl script

2005-07-12 Thread Perl
I have this perl script which is taking value from an external appliaction
and then after processing it is passing back a value to same application.
But I was not able to figure out how can I define the variablemy $path
(which is taking value from external app). what should be the syntex.
Can somebody help me to set the syntex of the variable to accept value from
app.

 use strict;
 use File::Basename;
  my $path =  Value from other app;
  my $base = basename($path);
  my $dir  = dirname($path);
  print STDOUT $base;



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




Re: Pass a value to Perl script

2005-07-13 Thread Perl
Dhanashri/ Chris

Yes!! exactly that is what I am trying to do. I am sorry for not making it
clear before.
here is the true picture. I have an APP which can run a perl script but just
before running the script I have a variable in that app which is holding a
value let say "c:\documents\test.pl"  also that value changes with every
record.
Now in my perl script I want to parse the string and just want to take the
file name which is "Test.pl" in my case and want to pass back (filename)
value of $base to that APP using STDOUT.
so far script is working fine If I am giving value to $path variable as a
constant (C:\documents\test.p) but I do not how can get the value of $path
which APP is passing to script?

Thanks



"Dhanashri Bhate" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]


-> -Original Message-
-> From: Chris Devers [mailto:[EMAIL PROTECTED]
-> Sent: Wednesday, July 13, 2005 5:44 AM
-> To: Perl
-> Cc: Perl Beginners List
-> Subject: Re: Pass a value to Perl script
->
->
-> On Tue, 12 Jul 2005, Perl wrote:
->
-> > I have this perl script which is taking value from an external
-> > appliaction and then after processing it is passing back a
-> value to
-> > same application. But I was not able to figure out how can
-> I define
-> > the variable my $path (which is taking value from external
-> app). what
-> > should be the syntex. Can somebody help me to set the
-> syntex of the
-> > variable to accept value from app.

-> Try something like this:
-> sub get_value_from_other_app {
-> my $app   = '/path/to/app';
-> my $value = system( "$app" )


"system" will give the exit status of the application execution..
to get the actual output of the appln (i.e. stdout) , run the application
putting it in back-quotes..
i.e.  my $value=`/path/to/app`

as for passing the output of the perl script back to the application, you
can pipe the output..
e.g. my-perl-script.pl | /path/to/app

but from your post, i did not get exactly what you are trying to do, by
accepting in a perl script a value from an application , and passing a value
back.. are you trying to write a perl subroutine to becalled from some
another application??


Dhanashri



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




Help Please!!! External APP passing value to Perl

2005-07-22 Thread Perl
Hello Listners,

I am totally novice in perland I need help with that script.
what can be the syntex of assigning a variable (my $path) in perl which  is
taking value (for example  c:\documents\script.txt) from an expternal APP.
The script will actually parse the my$path value (C:\documents\script.txt)
to (script.txt) and then will send parse value of my$path to STDOUT.
I am not sure how should I declare the value of my$path.

The script looks like this

\#!/usr/bin/perl
use strict;
use File::Basename;

  my $path =  Variable from external app
  my $base = basename($path);
  my $dir  = dirname($path);
  print STDOUT $base;


I will really appreciate any help/comment on it.

thanks



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




Re: Help Please!!! External APP passing value to Perl- Problem Resolved

2005-07-22 Thread Perl
Jeff,

Thanks a lot for your reply. Acutally  external APP was passing value to
command prompt so the first option did work.



"Jeff 'japhy' Pinyan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Jul 22, Perl said:
>
> > what can be the syntex of assigning a variable (my $path) in perl which
is
> > taking value (for example  c:\documents\script.txt) from an expternal
APP.
>
> How is your program getting passed this value?  On the command-line?  If
> so, then you would access the value from the @ARGV array.  $ARGV[0] holds
> the first argument, $ARGV[1] the second, and so on.
>
>my $path = $ARGV[0];
>
> If it's being sent to your program via an input stream (the other program
> is writing, and your Perl program needs to read), you'd get the value from
> .
>
>chomp(my $path = );
>
> -- 
> Jeff "japhy" Pinyan %  How can we ever be the sold short or
> RPI Acacia Brother #734 %  the cheated, we who for every service
> http://japhy.perlmonk.org/  %  have long ago been overpaid?
> http://www.perlmonks.org/   %-- Meister Eckhart



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




Please Help!!! Newbie question

2005-08-31 Thread Perl
I am new to perl so I need some help from the list with this script. It
takes a value from command line and then returns afters processing.
For example, If value is "c:\projects\test 2005.txt" the script will returns
it as "test" (actually omitts any space in the directory or file name) while
I want the full name of the file regardless of any space in the directory or
filename.
how can I get the value "test 2005.txt"?

  #!/usr/bin/perl
  # file: basename.pl
  use strict;
  use File::Basename;
  my $path = $ARGV[0];
  my $base = basename($path);
  my $dir  = dirname($path);
  print STDOUT $base;


any help will be greatly appreciated.

Thanks in advance.





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




Please Help!!! Newbie Question

2005-09-01 Thread Perl
Hi List,

I have this script which actually returns the value of the filename with
extension but If the file name is something like "c:\projects\text 009.txt"
(having a space in filename which is common in windows).
This script only returns "text" instead of returning full name of file.
Here is the script

  #!/usr/bin/perl
  # file: basename.pl
  use strict;
  use File::Basename;
  my $path = $ARGV[0];
  my $base = basename($path);
  my $dir  = dirname($path);
  print STDOUT $base;

Any help/suggestion will be appreicated.

Thanks a lot.



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




Retrieve lsit of computers using net::ldap

2006-03-02 Thread perl
Hi,

I'm trying to retrieve a list of computer names using net::ldap, but my script 
returns no values. It's my first time working with the  protocol, so I can't 
figure out why it doesn't work. I checked the docs several times, but the ldap 
filter usage is still not clear.

Can anyone point out how use the ldap search object to get a list of computers 
in an OU?

Thanks

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




Re: Automatically scheduling the execution of a sub-routine

2006-04-04 Thread perl
On Tue, 2006-04-04 at 12:52 +1000, James Turnbull wrote:
> James Turnbull wrote:
> > Hi
> >
> > Anyone know of a way to create a loop (or something similar) that 
> > automatically schedules the execution of a sub-routine periodically 
> > from within a program, for example execute check() every 600 seconds 
> > or the like?  The program would be running as a daemon on the host.
> >
> Sorry - probably didn't make that clear:
> 
> The mainline program is monitoring something - every x seconds I wish to 
> execute a subroutine from within the mainline and return to the mainline 
> after executing the subroutine to continue the monitoring. 
> 
> Regards
> 
> James Turnbull
> 
> 
You might try Event.pm.
http://search.cpan.org/~jprit/Event-1.06/lib/Event.pod



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




only one of two hash keys

2006-04-04 Thread perl
Is there a nice clean perl way to test to see if only one key of a hash
has data?

%some_hash = ( key1 => 1, key2 => 2 ); should fail the test
%some_hash = ( key2 => 2 ); should pass the test
%some_hash = ( key1 => 1 ); should pass the test

Thank you


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




Re: only one of two hash keys

2006-04-04 Thread perl
On Wed, 2006-04-05 at 09:35 +0800, Jeff Pang wrote:
> Hello,
> 
> [EMAIL PROTECTED] ~/app]$ perl -le '%some_hash=(aa=>'bb');scalar keys 
> %some_hash == 1 ? print "true" : print "false"'
> true
> [EMAIL PROTECTED] ~/app]$ perl -le '%some_hash=(aa=>'bb',cc=>'dd');scalar 
> keys %some_hash == 1 ? print "true" : print "false"'
> false
> 
> Is it useful for you?
Thank you for the quick response.

That is a nice solution to the problem I stated.

But I should have said ... 

Is there a nice clean perl way to test to see if only one key of a hash
has data?

%some_hash = ( key1 => 1, key2 => 2 ); should fail the test
%some_hash = ( key2 => 2 ); should pass the test
%some_hash = ( key1 => 1 ); should pass the test
%some_hash = ( key1 => 1, key2 => 2, key3 => 3 ); should fail the test
%some_hash = ( key2 => 2 ); should pass the test
%some_hash = ( key1 => 1 ); should pass the test
%some_hash = ( key2 => 2, key3 => 3 ); should pass the test
%some_hash = ( key1 => 1, key3 => 3 ); should pass the test

Basically I can many more keys in the hash but two of the keys have to
be exclusive.

Thanks

> >Thank you
> >
> >
> >-- 


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




How to redefine an autoload sub.

2006-04-13 Thread perl
#!/usr/local/bin/perl

write_function1("first");
print auto_function(), "\n";
# This will print:
# auto_function first

write_function1("second");
# How would I undefine the autoloaded version of auto_function?
print auto_function(), "\n";
# This will print:
# auto_function first
# But I would like it to print
# auto_function second




sub AUTOLOAD {
my $attr = $AUTOLOAD;
$attr =~ s/.*:://;
if ( -e $attr ) {
require $attr;
} else {
die "oops";
}
warn $@ if $@;
$attr->("z") if -e $attr;
}

sub write_function1 {
my $thing = shift;
unlink "auto_function";
open "FILE", ">", "auto_function";
print FILE <http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: hosting suggestion?

2023-07-03 Thread perl
Thanks, Mike. A2 was high on my list; I’ll give them a close look. — Rick

> On Jul 3, 2023, at 3:44 AM, Mike  wrote:
> 
> 
> I used HostGator for more than 10 years, but they lost
> much of their expertise during Covid.  I am on A2-hosting
> now.  I think they are expensive, but pretty good.
> 
> 
> 
> Mike
> 
> 
> On 7/1/23 13:49, Rick T wrote:
>> My web hosting company is closing business, and I less than two weeks to 
>> move my five sites to another host. All of these use perl. If you have 
>> experience with a host that supports perl, I’d appreciate any and all 
>> suggestions. I’m less concerned with cost than with service quality and 
>> support because I’m a high school teacher rather than a web professional!
>> 
>> Thanks in advance!
>> 
>> Rick Triplett
> 


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




Re: configuring Net::SMTP

2023-07-08 Thread perl
Thanks, Andinus. This is useful information. — Rick  

> On Jul 8, 2023, at 10:11 AM, Andinus  wrote:
> 
> 
> Hello Rick,
> 
> Hostgator might be able to provide you more information regarding why
> the email delivery is failing. I'm not very familiar with mail stuff.
> 
> You can also try NET::SMTP->new(Debug => 1) and send an email, it might
> provide useful info.
> 
> Maybe this answer on stackoverflow might be helpful
> https://stackoverflow.com/a/10008814
> 
> Have a good day!
> 
> Rick T @ 2023-07-08 08:37 -07:
> 
>> I have two subroutines (below) in a program that uses Net::SMTP. I’ve
>> recently moved my site from FutureQuest.net <http://futurequest.net/>
>> to Hostgator.com <http://hostgator.com/>, and this part of my program
>> has stopped working. The first routine sends an analysis of a test to
>> me at Reason.net <http://reason.net/>, and the second send a score to
>> several addresses associated with the student. On my new host at
>> Hostgator both fail to do this. (One of the “technicians” at Hostgator
>> said he found my email, so one or both likely arrived at
>> webmas...@hostgator.com <mailto:webmas...@hostgator.com>.)
>> 
>> I am not trained in computer tech; I’m just a 78 year old high school
>> teacher who bought a few books on perl, so I don’t really understand
>> how to fill in the many variable assignments that make up most of
>> these two routines. Instead I took guesses and tried stuff to see
>> what would happen. If any of you have suggestions or corrections, I’d
>> be grateful!
>> 
>> Rick Triplett
>> 
>> FIRST SUBROUTINE:
>> 
>> sub email_analysis {# to LibertyLearning for score posting and analysis
>>my $n_max = shift;
>>my @analysis = define_analysis($n_max);
>> 
>>my $subject_line
>>= "$pf{percent_correct_final} $pf{name_full} $course_file\n";
>> 
>># Send administration an email of statistical analysis
>>my $to= 'socra...@reason.net';
>>my $from  = 'webmas...@libertylearning.com';
>>my $site  = 'libertylearning.com';
>>my $smtp_host = 'mail.libertylearning.com';
>> 
>>my $smtp  = Net::SMTP->new( $smtp_host, Hello => $site );
>>$smtp->mail($from);
>>$smtp->to($to);
>>$smtp->data();
>>$smtp->datasend("From: webmaster\@LibertyLearning.com\n");
>>$smtp->datasend("To: $to\n");
>>$smtp->datasend("Date: $pf{ date_ended }\n");
>>$smtp->datasend("Subject: $subject_line\n");
>>$smtp->datasend("\n");
>>$smtp->datasend("$student_id\n");
>>$smtp->datasend("$pf{percent_correct_final}\n");
>>$smtp->datasend("squandered: $pf{percent_squandered}\%\n");
>>$smtp->datasend("if tried: $pf{if_tried}\%\n");
>>$smtp->datasend("string_of_wrongs: $pf{string_of_wrongs}\n");
>>foreach (@analysis) {$smtp->datasend("$_\n")};
>>$smtp->dataend();
>>$smtp->quit;
>>return;
>> }
>> 
>> SECOND SUBRUTINE:
>> 
>> sub email_mentors {
>>my $message   = shift;
>>my $to= 'socra...@reason.net'; #was my $to = shift;
>>my $from  = 'webmas...@libertylearning.com';
>>my $site  = 'libertylearning.com';
>>my $smtp_host = 'mail.LibertyLearning.com';
>> 
>>my $smtp  = Net::SMTP->new( $smtp_host, Hello => $site );
>>$smtp->mail($from);
>>$smtp->to($to);
>>$smtp->data();
>>$smtp->datasend("From: no_reply\@LibertyLearning.com\n");
>>$smtp->datasend("To: $to\n");
>>$smtp->datasend("Date: $pf{ date_ended }\n");
>>$smtp->datasend("Subject: Test Results\n");
>>$smtp->datasend("\n");
>>$smtp->datasend("$message\n");
>>$smtp->dataend();
>>$smtp->quit;
>> 
>>return;
>> }


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




Re: configuring Net::SMTP

2023-07-15 Thread perl
Many thanks to Bob, Olivier, Claude, and Andinus. I learned from all your 
comments, and I got the Net::SMTP working! 

Rick

> On Jul 9, 2023, at 8:03 AM, Bob Kardell  wrote:
> 
> One thing to check from experience - make sure hostgator does not block 
> outbound SMTP ports.  Many do to prevent spam.  I spent hours trying to 
> configure Net::SMTP on a different host only to discover the code was working 
> but the email was being blocked.   If hostgator received it it may be because 
> it was only a mailbox inside of hostgator.
> 
> Just a thought,
> 
> Bob 
> 
>> On Jul 8, 2023, at 8:52 PM, Claude Brown via beginners  
>> wrote:
>> 
>> Hi Rick,
>> 
>> We use Net::SMTP to send emails via SendGrid.  They require a user/pass 
>> authentication over SSL and I wonder if that is what is going wrong in your 
>> case.  The other thing worth doing is checking the return-value of each SMTP 
>> call as something may be going wrong silently.
>> 
>> Below is a fragment of our code that does (a) authentication and (b) checks 
>> each value.  I hope it assists.
>> 
>> Cheers,
>> 
>> Claude.
>> 
>> use strict;
>> use Carp;
>> use Net::SMTP;
>> 
>> use constant SMTP_HOST => 'smtp.sendgrid.net';
>> use constant SMTP_PORT => 465;
>> use constant SMTP_USER => 'the-username';
>> use constant SMTP_PASS => 'the-password';
>> use constant SMTP_TIMEOUT => 15;
>> use constant SMTP_DEBUG => 0;
>> 
>> my $smtp = Net::SMTP->new(
>>   Host => SMTP_HOST,
>>   Port => SMTP_PORT,
>>   Timeout => SMTP_TIMEOUT,
>>   SSL => 1,
>>   Debug => SMTP_DEBUG);
>> 
>> my $fromAddr = 'whowe...@somehwere.com';
>> my $toAddr = 'whoe...@somewhere.com';
>> my $theBody = 'the mail headers and body of the email';
>> 
>> $smtp->auth(SMTP_USER, SMTP_PASS) or confess "SMTP auth: " . 
>> $smtp->message();
>> $smtp->mail($fromAddr)or confess "SMTP mail: " . 
>> $smtp->message();
>> $smtp->to($toAddr)or confess "SMTP to: " . $smtp->message();
>> $smtp->data()     or confess "SMTP data: " . 
>> $smtp->message();
>> $smtp->datasend($theBody) or confess "SMTP datasend: " . 
>> $smtp->message();
>> $smtp->dataend()  or confess "SMTP dataend: " . 
>> $smtp->message();
>> $smtp->quit() or confess "SMTP quit: " . 
>> $smtp->message(); 
>> --
>> Claude.
>> 
>> 
>> -Original Message-
>> From: p...@reason.net  
>> Sent: Sunday, July 9, 2023 10:41 AM
>> To: Perl Beginners 
>> Subject: Re: configuring Net::SMTP
>> 
>> CAUTION: This email originated from outside of the organization. Do not 
>> click links or open attachments unless you recognize the sender and know the 
>> content is safe.
>> 
>> Thanks, Andinus. This is useful information. — Rick
>> 
>>> On Jul 8, 2023, at 10:11 AM, Andinus  wrote:
>>> 
>>> 
>>> Hello Rick,
>>> 
>>> Hostgator might be able to provide you more information regarding why
>>> the email delivery is failing. I'm not very familiar with mail stuff.
>>> 
>>> You can also try NET::SMTP->new(Debug => 1) and send an email, it might
>>> provide useful info.
>>> 
>>> Maybe this answer on stackoverflow might be helpful
>>> https://stackoverflow.com/a/10008814
>>> 
>>> Have a good day!
>>> 
>>> Rick T @ 2023-07-08 08:37 -07:
>>> 
>>>> I have two subroutines (below) in a program that uses Net::SMTP. I’ve
>>>> recently moved my site from FutureQuest.net <http://futurequest.net/>
>>>> to Hostgator.com <http://hostgator.com/>, and this part of my program
>>>> has stopped working. The first routine sends an analysis of a test to
>>>> me at Reason.net <http://reason.net/>, and the second send a score to
>>>> several addresses associated with the student. On my new host at
>>>> Hostgator both fail to do this. (One of the “technicians” at Hostgator
>>>> said he found my email, so one or both likely arrived at
>>>> webmas...@hostgator.com <mailto:webmas...@hostgator.com>.)
>>>> 
>>>> I am not trained in computer tech; I’m just a 78 year old high school
>>>> teacher who b

how do I pass null arguement?

2003-10-09 Thread perl
How do I pass a null variable as an argument? Sometime I may want a
wrapper sub as below:

Example,
...
sub procName
{ my $fname = $_[0];
  my $lname = $_[1]];
}

my procByLastName{ mySubA(null, "doe"); }
...

This is the error message:
Bareword "null" not allowed while "strict subs" in use

thanks,
-rkl



-
eMail solutions by 
http://www.swanmail.com

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



Re: how do I pass null arguement?

2003-10-09 Thread perl
thanks. it works!
-rkl

> Try 'undef'.
>
> eg. my procByLastName{ mySubA(undef, "doe"); }
>
> On Fri, 2003-10-10 at 16:39, [EMAIL PROTECTED] wrote:
>> How do I pass a null variable as an argument? Sometime I may want a
>> wrapper sub as below:
>>
>> Example,
>> ...
>> sub procName
>> { my $fname = $_[0];
>>   my $lname = $_[1]];
>> }
>>
>> my procByLastName{ mySubA(null, "doe"); }
>> ...
>>
>> This is the error message:
>> Bareword "null" not allowed while "strict subs" in use
>>
>> thanks,
>> -rkl
>>
>>
>>
>> -
>> eMail solutions by
>> http://www.swanmail.com
>
>



-
eMail solutions by 
http://www.swanmail.com

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



regex require a period

2003-10-09 Thread perl
here's the rules:
starts with alphanumeric
4 chars long
require one period

/^[a-zA-Z][\w\-\.]{3,}$/

I think my regex is not doing the required period.

thanks,
-rkl


-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
> /^[a-zA-Z][\w\-\.]{3,}$/ && /\./

Matches more than 1 period. I MUST have 1 and ONLY 1 period. Also, can I
fit it on one line? I couldn't doit.

sub isValidDomain
{ return shift =~ /^[a-zA-Z0-9][\w\-\.]{3,}$/ }


---
> How about something like:
>
> /^[a-zA-Z][\w\-\.]{3,}$/ && /\./
>
> On Fri, 2003-10-10 at 16:58, [EMAIL PROTECTED] wrote:
>> here's the rules:
>> starts with alphanumeric
>> 4 chars long
>> require one period
>>
>> /^[a-zA-Z][\w\-\.]{3,}$/
>>
>> I think my regex is not doing the required period.
>>
>> thanks,
>> -rkl
>>
>>
>> -
>> eMail solutions by
>> http://www.swanmail.com
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
I couldn't get it to work. Will the sub run as is? Is the :alpha: suppose
to be there or replace it?


> On Thu, Oct 09, 2003 at 11:58:31PM -0700, [EMAIL PROTECTED] wrote:
>> here's the rules:
>> starts with alphanumeric
>> 4 chars long
>> require one period
>>
>> /^[a-zA-Z][\w\-\.]{3,}$/
>
> I wouldn't try to do it with one regex.  You can probably come
> up with one, but the next time you have to read this code, you'll
> wish you'd spelled out the three conditions individually.
>
>   sub validate {
> local $_ = shift;
> return length == 4  # 4 chars long
>and tr/.// == 1  # require one period
>and /^[[:alpha:]]/   # starts with a letter
>   }
>
> --
> Steve
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
This is not working as I expected:

if(validate('abc.com'))
{ print "true"; }
else
{ print "false"; }

-rkl

> On Fri, Oct 10, 2003 at 12:49:51AM -0700, [EMAIL PROTECTED] wrote:
>> I couldn't get it to work.
>
> Whoops -->
>
>   sub validate {
> local $_ = shift;
> return( length == 4 and
> tr/.// == 1 and
> /^[[:alpha:]]/ )
>   }
>
> --
> Steve
>



-
eMail solutions by 
http://www.swanmail.com

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



RE: how do I pass null arguement?

2003-10-10 Thread perl
Good info.

thanks,
-rkl

> Hi,
>
> [EMAIL PROTECTED] wrote:
>> How do I pass a null variable as an argument? Sometime I may want a
>> wrapper sub as below:
>>
>> Example,
>> ...
>> sub procName
>> { my $fname = $_[0];
>>   my $lname = $_[1]];
>> }
>
> Alternatively, you could write either
>
>   my $fname = shift;
>   my $lname = shift;
>
> or even
>
>   my( $fname, $lname ) = @_;
>
>>
>> my procByLastName{ mySubA(null, "doe"); }
>> ...
>>
>> This is the error message:
>> Bareword "null" not allowed while "strict subs" in use
>
> Perl's notion of NULL would be undef, i.e. not defined.
> As such, it's distinct from an empty string or zero as
> a numeric value.
>
> The function defined() helps you to test wether a value
> is undef or not.
>
> BTW, since you ask about argument passing and undef,
> a nice way to handle setting defaults for arguments
> is using this syntax:
>
> my $var = shift || "default";
>
> Works great if your expected arguments are always
> defined and true. It would set $var to "default"
> if you pass in an empty string or the number 0,
> though.
>
> HTH,
> Thomas
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
> /^[a-zA-Z][\w\-\.]{3,}$/ && /\./

The above matches more than 1 period.

I MUST have 1 and ONLY 1 period. Also, can I
 fit it on one line?

this doesn't work either
 sub isValidDomain
 { return shift =~ /^[a-zA-Z0-9][\w\-\.]{3,}$/ }

thanks

 ---
> How about something like:
>
> /^[a-zA-Z][\w\-\.]{3,}$/ && /\./
>
> On Fri, 2003-10-10 at 16:58, [EMAIL PROTECTED] wrote:
> here's the rules:
> starts with alphanumeric
> 4 chars long
> require one period
>
>> /^[a-zA-Z][\w\-\.]{3,}$/
>>
>> I think my regex is not doing the required period.
>>
>> thanks,
>> -rkl
>>
>>
>> -
>> eMail solutions by
>> http://www.swanmail.com
>
>



 -
 eMail solutions by
 http://www.swanmail.com




-
eMail solutions by 
http://www.swanmail.com

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



Declaring sub at top or bottom matter?

2003-10-10 Thread perl
Does declaring at the top or the bottom matter?

thanks


-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
Ok - I got it to work by changing the line to length >= 3

If I could push the rule a little further, a new rule added is that an
alpha char a-Z MUST be after the period.

thanks



> On Fri, Oct 10, 2003 at 03:11:52PM -0700, [EMAIL PROTECTED] wrote:
>> This is not working as I expected:
>>
>> if(validate('abc.com'))
>> { print "true"; }
>> else
>> { print "false"; }
>
> It prints "false" (because the length is > 4).
>
>> >   sub validate {
>> > local $_ = shift;
>> > return( length == 4 and
>> > tr/.// == 1 and
>> > /^[[:alpha:]]/ )
>> >   }
>
> What did you expect it to do?
>
> --
> Steve
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
rules:
starts with alphanumeric
3 chars long
require ONLY one period
require alpha after the period

/^[a-zA-Z0-9][\w-].[a-zA-z]/ #but now working

sub validate {
local $_ = shift;
return( length >= 3 and
tr/.// == 1 and
/^[[:alpha:]]/ and
   /[a-zA-Z0-9].[a-zA-Z]/ ); #added here still not working
}

expecting results:

a.com - true
1.com - true
a_.com - true
a-.com - true

abc   - false
a.b.c - false
a.1   - false
a.-   - false
a._   - false
_a.c  - false
-a.c  - false

I think this covers it all?
thanks
> On Fri, Oct 10, 2003 at 03:56:43PM -0700, [EMAIL PROTECTED] wrote:
>> Ok - I got it to work by changing the line to length >= 3
>
> Good.
>
>> If I could push the rule a little further, a new rule added
>> is that an alpha char a-Z MUST be after the period.
>
> Well now you have four rules.  Again, I think I'd do this
> in four steps (of which you already have solutions for three).
>
> What have you tried for the new requirement?
>
> --
> Steve
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
The regex below is working for after the period. The part in fron is not
working. It is requiring atleast 2 chars before the period which is not my
rule. the rule for the front part:

start with [a-zA-Z0-9]
chars following is [\w-] BUT IS OPTIONAL

/^[a-zA-Z0-9][\w-]\.[a-zA-z]+$/

I think the regex is not doing the option \w part.

thanks

> --On Friday, October 10, 2003 16:43 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> rules:
>> starts with alphanumeric
>> 3 chars long
>
> Note, so we are not confused: you mean _at least_ 3 chars long.  (Not
> _only_ 3 chars long.)
>
>> require ONLY one period
>> require alpha after the period
>
> Ok, what exactly do you mean here?  Is this:
> a. Require _only_ alpha after the period?
> b. Require _the next char_ to be alpha?
>
> Either one is possible from your description, and could be a big
> difference.
>
>> /^[a-zA-Z0-9][\w-].[a-zA-z]/ #but now working
>>
>> sub validate {
>> local $_ = shift;
>> return( length >= 3 and
>> tr/.// == 1 and
>> /^[[:alpha:]]/ and
>>/[a-zA-Z0-9].[a-zA-Z]/ ); #added here still not working
>> }
>
> That last line says: Match one character (alpha or numeric only) then
> any character, then a single alpha character.
>
> If you want the _next_ character to be alpha, the following should
> work:
> /\.[[:alpha:]]/
>
> If you want _only_ (and at least one) alpha after the period, you
> need this:
> /\.[[:alpha:]]+$/
>
> Hope this helps.
>
> Daniel T. Staal
>
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
The regex below is working for after the period. The part in fron is not
working. It is requiring atleast 2 chars before the period which is not my
rule. the rule for the front part:

start with [a-zA-Z0-9]
chars following is [\w-] BUT IS OPTIONAL

/^[a-zA-Z0-9][\w-]\.[a-zA-z]+$/

I think the regex is not doing the option \w part.

Example, a.c is failing. it's suppose to be true.

thanks



> --On Friday, October 10, 2003 16:43 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> rules:
>> starts with alphanumeric
>> 3 chars long
>
> Note, so we are not confused: you mean _at least_ 3 chars long.  (Not
> _only_ 3 chars long.)
>
>> require ONLY one period
>> require alpha after the period
>
> Ok, what exactly do you mean here?  Is this:
> a. Require _only_ alpha after the period?
> b. Require _the next char_ to be alpha?
>
> Either one is possible from your description, and could be a big
> difference.
>
>> /^[a-zA-Z0-9][\w-].[a-zA-z]/ #but now working
>>
>> sub validate {
>> local $_ = shift;
>> return( length >= 3 and
>> tr/.// == 1 and
>> /^[[:alpha:]]/ and
>>/[a-zA-Z0-9].[a-zA-Z]/ ); #added here still not working
>> }
>
> That last line says: Match one character (alpha or numeric only) then
> any character, then a single alpha character.
>
> If you want the _next_ character to be alpha, the following should
> work:
> /\.[[:alpha:]]/
>
> If you want _only_ (and at least one) alpha after the period, you
> need this:
> /\.[[:alpha:]]+$/
>
> Hope this helps.
>
> Daniel T. Staal
>
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
So, would this be it for the optional?

/^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/

thanks

> --On Friday, October 10, 2003 17:45 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> start with [a-zA-Z0-9]
>> chars following is [\w-] BUT IS OPTIONAL
>>
>> /^[a-zA-Z0-9][\w-]\.[a-zA-z]+$/
>>
>> I think the regex is not doing the option \w part.
>
> Correct, it isn't.  You haven't asked it to...  To make it optional
> you need to follow the [\w-] with a count which says it is optional.
> The count would be in this form: {$min,$max}, where $min and $max are
> the minimum and maximum counts, respectively.  You can leave out $max
> if there is no maximum count.  (But you still need the comma; without
> it you have an _exact_ count.)  So for zero or more times you need
> the quantifier: {0,}.
>
> There are also three shortcut quantifiers: '*', '+', '?'.  (Without
> the quotes.)  Their meanings are:
> * = {0,}
> + = {1,}
> ? = {0,1}
>
> Note that all the quantifiers are 'greedy'[1]: they match the longest
> string of characters they possibly can.
>
> Ok, now that we've got that over with, why aren't you using the
> 'validate' sub?  It is likely to be faster than the above regrex...
>
> Daniel T. Staal
>
> [1] Well, there is a way around this.  But that's another lesson.
>
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: regex require a period

2003-10-10 Thread perl
Great! Final verification question. Atleast for now :)

Do I need to use delimiter for a hyphen?

/^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/
or
/^[a-zA-Z0-9][\w\-]*\.[a-zA-z]+$/

thanks

> --On Friday, October 10, 2003 18:21 -0700 "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>
>> So, would this be it for the optional?
>>
>> /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/
>>
>> thanks
>
> Yep, that should work for you.
>
> Daniel T. Staal
>
> (By the way: Don't reply to me *and* the list.  I've set up my email
> client so that replying to me (when I'm sending to this list) sets my
> reply address as the list.  Adding the list again just sends a dupe.
> Some people like off-list replies.  I don't.)
>
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



behavior of semicolon on return line

2003-10-10 Thread perl
Does the semicolon behave any differently for a return test statement?

Example,

sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/ }

or

sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/; }

thanks


-
eMail solutions by 
http://www.swanmail.com

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



RE: working on time

2003-10-11 Thread perl
It's fair enough to use 86,400 sec in a day. But what about adding days or
months?

That is, rolling past 28,29,30 or 31 days in a particular month.

thanks
-rkl
---
> I thought of that right after hitting send...
>
> This may be better if he wants to do a lot of date manipulation down the
> road:
>
> #!/usr/bin/perl -w
>
> use Date::Manip;
>
> my ($day, $mnth, $yr);
> my $date = DateCalc("today","- 1day");
> ($yr, $mnth, $day) = ($date =~ /(\d\d\d\d)(\d\d)(\d\d)/);
> print "Yesterday was $mnth/$day/$yr\n";
>
>
>
>>>> Bob Showalter <[EMAIL PROTECTED]> 10/10/03 12:20PM >>>
> Bill Akins wrote:
>> ...
>> Try this:
>> #!/usr/bin/perl -w
>>
>> my @now = localtime;
>> my $sec = ( $now[0] );
>> my $min = ( $now[1] );
>> my $hr  = ( $now[2] );
>> my $day = ( $now[3] );
>> my $mth = ( $now[4] + 1 );
>> my $yr  = ( $now[5] + 1900 );
>>
>> $day = ($day -1);
>> print "Yesterday was $mth/$day/$yr\nor if on the other side
>> of the pond, $day/$mth/$yr\n";
>
> What if today is the first of the month?
>
> Better to use something like:
>
>($d, $m, $y) = (localtime(time - 86_400))[3..5];
>$m++;
>$y += 1900;
>
> IOW, have the system calculate local time for current epoch - 86,400
> seconds (# of seconds in a day).
>
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Help w/Class::Date Date.xs

2003-10-13 Thread perl
Can someone help me with where to put the Date.xs file?

I just downloaded the Class-Date-1.1.7.tar.gz.

I figured out where to put the 2 files in /usr/lib/perl5/5.8.0/Class:
- Class::Date.pm
- Class::Date::Const.pm

- Date.xs -where shoud it go?

I ran th test in the t directory which look like a couple of test script.
It says ok but can't find the xs part:

"Cannot find the XS part of Class::Date,
   using strftime, tzset and tzname from POSIX module."

thanks,
-rkl


-
eMail solutions by 
http://www.swanmail.com

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



help float to string

2003-10-14 Thread perl
Can someone help me with retaining the precisions when they are zero?

ie -

$f = 9.00
$z = $f;
print $z; #result in 9 - bad I want 9.00

$fx = 9.25
$z = $fx;
print $z; #result in 9.25 - good

I can but don't want to use a sub like itoa. Is there a better way to
convert to string?

$z=itoa($f);
print $z   #result 9.00
$z=itoa($fx);
print $z   #result 9.25

sub itoa { return sprintf("%.2f", $_[0]); }



-
eMail solutions by 
http://www.swanmail.com

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



Which action button clicked?

2003-10-14 Thread perl
Can someone show me how to determine which button the user clicked?

use CGI;

$cgi->param did not contain the action parameter.
I want to determine if the user click the LEFT or RIGHT button:

...


...

thanks
-rkl


-
eMail solutions by 
http://www.swanmail.com

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



Re: Which action button clicked?

2003-10-14 Thread perl
thanks

> On Tue, 14 Oct 2003 02:35:02 -0700, perl wrote:
>> Can someone show me how to determine which button the user clicked?
>
> This hasn't all that much to do with Perl, really.
>
>> 
>> 
>
> Name your input fields.  For example something like this:
>
>   
>   
>
> Now, in your script:
>
>   my $direction = $cgi->param( 'direction' ) || '';
>
>
> --
> Tore Aursand <[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: Help w/Class::Date Date.xs

2003-10-14 Thread perl
I downloaded the tar file. But I couldn't find out how to install it from
the README. From the various info in the readme I was able to install the
.pm files but not the xs. The Date class look like it's working but it
keeps showing the message about the XS part warning. The Date.xs is
sitting in my tmp dir. I looks like a C type of file.

So, please tell me how to install it.

fyi, I've never installed a cpan or any perl package, if there is such a
thing.

thanks,

> [EMAIL PROTECTED] wrote:
>
>> Can someone help me with where to put the Date.xs file?
>>
>> I just downloaded the Class-Date-1.1.7.tar.gz.
>>
>> I figured out where to put the 2 files in /usr/lib/perl5/5.8.0/Class:
>> - Class::Date.pm
>> - Class::Date::Const.pm
>>
>> - Date.xs -where shoud it go?
>>
>> I ran th test in the t directory which look like a couple of test
>> script.
>> It says ok but can't find the xs part:
>>
>> "Cannot find the XS part of Class::Date,
>>using strftime, tzset and tzname from POSIX module."
>>
>
> what are you trying to do??? did you download a module from CPAN and then
> trying to install it? what do you mean by where to put the files?
>
> david
> --
> $_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$";
> map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#,
>
> goto=>print+eval
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



clean up sub?

2003-10-14 Thread perl
Can someone shorten this upper routine?

sub toUpper
{ my $z = shift;
 $z =~ tr/a-z/A-Z/;
 return $z;
}

Also in a slightly different scenario, how can i change the value of the
parameter itself with a sub.

$a="ca";
toUpper($a);  #change the $a value itself
print $a;  #I want it to print "CA"


-
eMail solutions by 
http://www.swanmail.com

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



Re: clean up sub?

2003-10-14 Thread perl
I like that - lc() and uc()
Hmm... I wonder why it is not in the orielly book?

thanks,
-rkl

> On Tuesday, October 14, 2003, at 05:59  PM, [EMAIL PROTECTED] wrote:
>
>> Can someone shorten this upper routine?
>>
>> sub toUpper
>> { my $z = shift;
>>  $z =~ tr/a-z/A-Z/;
>>  return $z;
>> }
>
> Yes, I can.  Replace wall calls of toUpper() with uc().  ;)
>
> James
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: clean up sub?

2003-10-14 Thread perl
Great stuff  everyone!

Some of it is still greek to me ;)

here's what I got to work for me:
#!/usr/bin/perl

my $a="aBe";
my $b="bOb";
my $c="cAb";

aUpper($a);
bUpper($b);
cUpper($c);

print $a . " " . $b . " " . $c . "\n";

#results
#These sub below are good:
sub aUpper { return $_[0] = uc($_[0]); }
sub bUpper { return $_[0] = "\U$_[0]"; }

#These did NOT work for me:
sub cUpper { return $$_[0] = "\U$$_[0]"; }
#sub cUpper { return $_->[0] = "\U$_->[0]"; }


--
> Daniel Staal wrote:
>>
>> --On Tuesday, October 14, 2003 15:59 -0700 "[EMAIL PROTECTED]"
>> <[EMAIL PROTECTED]> wrote:
>> >
>> > Also in a slightly different scenario, how can i change the value
>> > of the parameter itself with a sub.
>> >
>> > $a="ca";
>> > toUpper($a);  #change the $a value itself
>> > print $a;  #I want it to print "CA"
>>
>> Ok, I'll assume this is a made-up example...  (Since it would just be
>> easy to write 'print toUpper($a);', using the return value.)
>>
>> The way to do this would be to pass references to the parameters.
>> You would have to pass the references, and work with them.
>
> There is no need to use references because the values of @_ are aliased
> to the variables passed to the sub so modifying the values in @_ will
> also modify the values of the variables.
>
>> So, the function call would become:
>>
>> toUpper(\$a);
>>
>> The sub would be:
>>
>> sub toUpper { return "\U$$_[0]"; }  # (Hey, we have linenoise!)
>
> That still doesn't modify the value in $a.  You would have to write it
> like:
>
> sub toUpper { return $$_[0] = "\U$$_[0]"; }
>
> Or:
>
> sub toUpper { return $_->[0] = "\U$_->[0]"; }
>
>
>
> John
> --
> use Perl;
> program
> fulfillment
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



RE: Help w/Class::Date Date.xs

2003-10-14 Thread perl
THanks alot for the install info. But I would like your opinion for the
following questions:

1 - Do you think that it will work without installing the XS? It seems to
be working fine but it is giving me a warning message all the time.

2 - DO I need to worry about it messing anything (kernel/perl
installation) if I were to compile and install this module?

thanks,
-rkl

> Hi,
>
> I just took a look at this.  After downloading and unbundling
> Class-Datge-1.1.7.tar.gz I found the Date.xs file that you mentioned.
> There was no INSTALL file so I did the following:
>
>  perl Makefile.PL # builds Makefile in which Date.xs is referenced
>  make
>  make install # no "test" target in this Makefile
>
> The make ran the following command that shows Date.xs is used to build
> Date.c  out the following that gives a clue about Date.xs:
>
> /usr/bin/perl.exe /usr/lib/perl5/5.8.0/ExtUtils/xsubpp  -typemap
> /usr/lib/perl5/5.8.0/ExtUtils/typemap  Date.xs > Date.xsc && mv Date.xsc
> Date.c
> Please specify prototyping behavior for Date.xs (see perlxs manual)
>
> After this, Date.c is compiled into Date.o by gcc:
>
> gcc -c   -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -DUSEIMPORTLIB -O3
> -DVERSION=\"1.1.7\" -DXS_VERSION=\"1.1.7\"
> "-I/usr/lib/perl5/5.8.0/cygwin-multi-64int/CORE"   Date.c
>
> Then Date.o is loaded into Date.dll:
>
> LD_RUN_PATH="" ld2  -s -L/usr/local/lib Date.o  -o
> blib/arch/auto/Class/Date/Date.dll
> /usr/lib/perl5/5.8.0/cygwin-multi-64int/CORE/libperl.dll.a
>
> And converted into a shared ar archive name libDate.dll.a:
>
> gcc -shared -o  Date.dll -Wl,--out-implib=libDate.dll.a
> -Wl,--export-all-symbols  -Wl,--enable-auto-import -Wl,--stack,8388608
> -s -L/usr/local/lib Date.o
> /usr/lib/perl5/5.8.0/cygwin-multi-64int/CORE/libperl.dll.a
>
> Running "make install" installs Date.dll and libDate.dll.a into
>
> /usr/lib/perl5/site_perl/5.8.0/cygwin-multi-64int/auto/Class/Date/
>
> And
>
> /usr/lib/perl5/site_perl/5.8.0/cygwin-multi-64int/auto/Class/
>
> Running "man perlxs" says that XS is an interface format for creating
> extensions of perl in C and C libraries.
>
> Based on this and looking inside Date.xs, it seem that the latter is
> where the data types and structures and functions of Class::Date are
> defined in a format that is used to generate C code that is compiled
> into dynamic libs that are loaded into perl at runtime  to implement the
> funtionality of this module.
>
> -tristram
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 14, 2003 12:30 AM
> To: [EMAIL PROTECTED]
> Subject: Help w/Class::Date Date.xs
>
>
> Can someone help me with where to put the Date.xs file?
>
> I just downloaded the Class-Date-1.1.7.tar.gz.
>
> I figured out where to put the 2 files in /usr/lib/perl5/5.8.0/Class:
> - Class::Date.pm
> - Class::Date::Const.pm
>
> - Date.xs -where shoud it go?
>
> I ran th test in the t directory which look like a couple of test
> script. It says ok but can't find the xs part:
>
> "Cannot find the XS part of Class::Date,
>using strftime, tzset and tzname from POSIX module."
>
> thanks,
> -rkl
>
>
> -
> eMail solutions by
> http://www.swanmail.com
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Another sub clean up

2003-10-14 Thread perl
Can someone hlpe me clean up this trim?

Rule: remove all trailing blanks and newline/LF

Do I need a chomp here somewhere?

sub trim
{ my $z = $_[0];

  $z =~ s/^\s+//;
  $z =~ s/\s+$//;

  return $z;
}

thanks,
-rkl


-
eMail solutions by 
http://www.swanmail.com

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



RE: Help w/Class::Date Date.xs

2003-10-14 Thread perl
fyi, I'm on the redhat linux. Well ths this the first I saw about
Date::Calc. In any case, I have a pretty straight forward requirements and
will ask you or anyone familiar dates for recommendation. Taking into
consideration my requirements, what is the best date modules available
that you can recommend?

Requirements:

- increment date by sec,min,hour,day,month and year
- I'd would use the localtime if I can figure out how to calculate
incrementing by days and handling 28,29,30,31 days of the month.
- the ability to access and format the output as in localtime.

thanks,
-rkl

> Hi,
>
> I suggest always taking a glance at the documentation that comes with
> the module.  Most of that should be in the perldoc, so for Class::Date
> you can run "perldoc Class::Date".  Sometimes it is useful also to look
> in the source directory at the README and INSTALL files and examples if
> any.  I paged through the perldoc Class::Date and found several
> interesting pieces of information near the end.  It shows how to turn
> off warnings about the missing XS part and some other interesting info
> including where to get a binary version for Win32 -- see below.  There
> should be no problem installing the module from sources since it will be
> installed in a way that does not conflict with any other modules, and
> loading its lib will only add uniquely identified functions to the
> runtime perl process so they won't be mistaken for or overlap with
> anything else.  Note also that there is a special mail group dedicated
> to Date::Calc and the author has provided his email address.  If you're
> really concerned about the Date::Calc installation messing things up,
> you can make a backup copy of /usr/lib/perl5/ beforehand for later
> regression if desired.
>
> -tristram
>
> WORKING WITHOUT A C COMPILER
> ...
>  You can use the $WARNINGS switch to switch off the complains about the
>  missing XS part from your perl program:
>
> BEGIN { $Class::Date::WARNINGS=0; }
> use Class::Date;
> ...
>
> SPEED ISSUES
> ...
> In general, if you really need fast date and datetime calculation,
> don't
> use this module. As you see in the previous section, the focus of
> development is not the speed in 1.0. For fast date and datetime
> calculations, use Date::Calc module instead.
>
> BUGS AND LIMITATIONS
> *   I cannot manage to get the timezone code working properly on
> ActivePerl 5.8.0 on win XP and earlier versions possibly have
> this
> problem also
>
> SUPPORT
> Class::Date is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.
>
> If you have questions, you can send it to the Class::Date mailing
> list:
>
>   [EMAIL PROTECTED]
>
> You can subscribe to this list by a web-interface:
>
>   http://lists.dlux.hu/wws/info/class-date
>
> WIN32 notes
> You can get a binary win32 version of Class::Date from Chris
> Winters'
> .ppd repository with the following commands...
>
> AUTHOR
>   dLux <[EMAIL PROTECTED]>
>
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: Help w/Class::Date Date.xs

2003-10-14 Thread perl
Your response is great!

Being new to the environment, simple and fundamental things can be
frustrating.  Your step-by-step instruction not only made it possible to
install but it gave me a clue into understanding how the perl/cpan are
structured/organized.

I just have a follow-up question. Is this the best date module or are
there more popular one?

thanks,
-rkl

> [EMAIL PROTECTED] wrote:
>
>> I downloaded the tar file. But I couldn't find out how to install it
>> from
>> the README. From the various info in the readme I was able to install
>> the
>> .pm files but not the xs. The Date class look like it's working but it
>> keeps showing the message about the XS part warning. The Date.xs is
>> sitting in my tmp dir. I looks like a C type of file.
>>
>> So, please tell me how to install it.
>>
>> fyi, I've never installed a cpan or any perl package, if there is such a
>> thing.
>>
>
> if a module does not came with its own installation procedures,
> try (as root):
>
> [panda]$ mv date-class.tar.gz /tmp
> [panda]$ cp /tmp
> [panda]$ tar -zxf date-class.tar.gz
> [panda]$ perl Makefile.PL
> [panda]$ make
> [panda]$ make test
> [panda]$ make install
> [panda]$ make clean
> [panda]$ perl -MDate::Class -le 'print $INC{"Date/Class.pm"}'
> [panda]$
>
> large number of CPAN modules (Class::Date happen to be one of those) are
> packed/distributed by creating make file with MakeMaker which can be
> installed by the above procedures.
>
> perldoc -q install
>
> david
> --
> $_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$";
> map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#,
>
> goto=>print+eval
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: Help w/Class::Date Date.xs

2003-10-14 Thread perl
> [panda]$ perl -MDate::Class -le 'print $INC{"Date/Class.pm"}'

Do you think you meant this?

> [panda]$ perl -MClass::Date -le 'print $INC{"Class/Date.pm"}'

thanks
---


> [EMAIL PROTECTED] wrote:
>
>> I downloaded the tar file. But I couldn't find out how to install it
>> from
>> the README. From the various info in the readme I was able to install
>> the
>> .pm files but not the xs. The Date class look like it's working but it
>> keeps showing the message about the XS part warning. The Date.xs is
>> sitting in my tmp dir. I looks like a C type of file.
>>
>> So, please tell me how to install it.
>>
>> fyi, I've never installed a cpan or any perl package, if there is such a
>> thing.
>>
>
> if a module does not came with its own installation procedures,
> try (as root):
>
> [panda]$ mv date-class.tar.gz /tmp
> [panda]$ cp /tmp
> [panda]$ tar -zxf date-class.tar.gz
> [panda]$ perl Makefile.PL
> [panda]$ make
> [panda]$ make test
> [panda]$ make install
> [panda]$ make clean
> [panda]$ perl -MDate::Class -le 'print $INC{"Date/Class.pm"}'
> [panda]$
>
> large number of CPAN modules (Class::Date happen to be one of those) are
> packed/distributed by creating make file with MakeMaker which can be
> installed by the above procedures.
>
> perldoc -q install
>
> david
> --
> $_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$";
> map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#,
>
> goto=>print+eval
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: Another sub clean up

2003-10-15 Thread perl
> On Tue, 14 Oct 2003 19:26:50 -0700, perl wrote:
>> Can someone hlpe me clean up this trim?
>
> What do you actually mean by "clean up"?  Make the code shorter and,
> maybe, more obfuscated?  Why?
--
 - more shorter - Yes
 - more obfuscated - hhmm... nice to know shortcut

--
>
>> Rule: remove all trailing blanks and newline/LF
>
>   sub trim {
>   my $string = shift;
>
>   chomp( $string );
>   $string =~ s,^\s+,,;
>   $string =~ s,\s+$,,;
>
>   return $string;
>   }
>
> This is clean _to me_, but I have no idea if you really need that chomp()
> thing.  Never tested the code above.
>
>
> --
> Tore Aursand <[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-
eMail solutions by 
http://www.swanmail.com

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



making a variable execute

2003-10-17 Thread perl
Can someone show me how to make this compute?

my $a=2;
my $b=3;
my $oper="+";

my $c = $a $oper $b;

where $c would have a value of 5.

thanks,
-rkl


-
eMail solutions by 
http://www.swanmail.com

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



RE: making a variable execute

2003-10-17 Thread perl
thanks


>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Sent: Friday, October 17, 2003 3:54 PM
>> To: [EMAIL PROTECTED]
>> Subject: making a variable execute
>>
>>
>> Can someone show me how to make this compute?
>>
>> my $a=2;
>> my $b=3;
>> my $oper="+";
>>
>> my $c = $a $oper $b;
>>
>> where $c would have a value of 5.
>>
>
> my $c = eval("$a $oper $b");
> print "$c\n";
>
> -Mark
>



-
eMail solutions by 
http://www.swanmail.com

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



what is time?

2003-10-17 Thread perl
How can I convert it to a readable date?

$now=time;

print $now return 1066442632

I had tied perldoc time but it says:
 No documentation found for "time".

thanks,


-
eMail solutions by 
http://www.swanmail.com

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



  1   2   3   4   5   6   7   >