Re: Special Variable for name of the running script

2001-06-14 Thread Hasanuddin Tamir

On Fri, 15 Jun 2001, Charles Lu <[EMAIL PROTECTED]> wrote,

> My question is is there perl special variable that stores the name of the
> actualy script that is running?  In other words, which variable, if any
> holds the value "myscript.pl"?

$0

perldoc perlvar


__END__
-- 
s::a::n->http(www.trabas.com)




Re: Beginer...Any free resources for Learning Perl

2001-06-14 Thread Dave Cross

On Wed, Jun 13, 2001 at 07:12:45PM +0200, Evgeny Goldin (aka Genie) 
([EMAIL PROTECTED]) wrote:
> 
> Check up my catalog at :
> [url removed]
> 
> It's only a catalog but I upload titles from it upon request.

He does, indeed, happily distribute pirate copies of Perl (and other) books
to anyone who asks. A few weeks ago I found a complete copy of my book on
his website (thanks to Google now indexing PDF files). Manning asked him to
remove it, which he did, but a few days later he was happy to email me a 
copy when I asked him to.

I'm not the only Perl author on this list. How do the others feel? Am I 
the only one that gets really angry when some idiot from Israel decides
he has the right to give away the fruits of your labour?

To the people that might be interested in Genie's treasure trove - many
Perl authors give a lot of time free to support the Perl community. If
they want to make a little (and it's really not very much) money back by 
writing books then you should support their efforts and not rip them off
by getting pirate copies like these.

Dave...
[this really _is_ a hot topic recently. this is the third place I've
has this dicussion in the last three weeks]

-- 

  Drugs are just bad m'kay




RE: Special Variable for name of the running script

2001-06-14 Thread Andrew Nelson

Sure. Try $0. :)

-Original Message-
From: Charles Lu [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 15, 2001 2:31 AM
To: [EMAIL PROTECTED]
Subject: Special Variable for name of the running script


When you run a perl script from command line, you can often retrieve the 
arguments through the special variable @ARGV.

If you type the following:

perl myscript.pl input.txt output.txt

on a commandline, the value of $ARGV[0] will be input.txt,
$ARGV[1] will be output.txt.


My question is is there perl special variable that stores the name of the 
actualy script that is running?  In other words, which variable, if any 
holds the value "myscript.pl"?

thanks
_
Get your FREE download of MSN Explorer at http://explorer.msn.com



Special Variable for name of the running script

2001-06-14 Thread Charles Lu

When you run a perl script from command line, you can often retrieve the 
arguments through the special variable @ARGV.

If you type the following:

perl myscript.pl input.txt output.txt

on a commandline, the value of $ARGV[0] will be input.txt,
$ARGV[1] will be output.txt.


My question is is there perl special variable that stores the name of the 
actualy script that is running?  In other words, which variable, if any 
holds the value "myscript.pl"?

thanks
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




Re: Credit Protocol

2001-06-14 Thread Me

> What is the credit protocol if... [it isn't explicitly documented]?

Ask the author.




Re: nested checks

2001-06-14 Thread Michael Fowler

On Thu, Jun 14, 2001 at 11:10:43PM -0500, [EMAIL PROTECTED] wrote:
> > Format to taste, of course.  Your checks on $add_alias, $add_destination,
> > and $selection should also probably be checks for defined'ness, not truth.
> > 0 is false, but, according to your definition of what $add_alias should
> > contain, is also a valid value.
> 
>   i am not sure what you mean here. i am trying to check whether
>   or not anything was filled in for these fields. i am grabbing
>   $add_alias from the hash parsed by a form parsing subroutine.
>   (the data is coming from a web page form)

When you say:

if ($add_alias) { ... }

You are testing to see if $add_alias is true.  If $add_alias = 0, the block
won't be executed.  0 may be a valid value for $add_alias to have.  If this
is the case, you probably should be testing to make sure $add_alias is
defined, meaning it has some value other than the special undef value.  You
test for this using the defined operator, perldoc -f defined.


> > Also, in your current code you don't do any checks on your calls, such as
> > your open and rename calls.  You should always check open, and usually check
> > rename.
> 
>   i am not certain what you mean by 'checks on calls' either.
>   point me in the right direction?

Both open and rename return true on success, false on failure.  The typical
idiom is:

open(FILE, $filename) || die("Unable to open filename \"$filename\": $!\n");

What this means is that, if the file couldn't be opened, the script dies
with an appropriate error message.  Review perldoc -f open, perldoc
perlopentut, and perldoc perlvar (for $!).


The above descriptions of truth, definedness, and checking open should have
been covered in your learning material.  You do have learning material, yes? 
If you don't, or if you do and it didn't cover these topics, consider
purchasing _Learning Perl_ by Randal Schwartz, or _Beginning Perl_ by Simon
Cozens.


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



Re: nested checks

2001-06-14 Thread charles

> If this is really what your code looks like, with unused blocks and all,
> it's better written as:
>
> if (   $add_alias && $add_destination && !$selection
> && $add_alias   !~ /[^\w\.\-]/]
> && $add_destination !~ /\@/
> ) {
> # ... code goes here ...
> }

no, actually the unused blocks were just there to make the
reading a bit easier on the eyes. each if statement does have
*something* in its block statement.

>
> Format to taste, of course.  Your checks on $add_alias, $add_destination,
> and $selection should also probably be checks for defined'ness, not truth.
> 0 is false, but, according to your definition of what $add_alias should
> contain, is also a valid value.
>

i am not sure what you mean here. i am trying to check whether
or not anything was filled in for these fields. i am grabbing
$add_alias from the hash parsed by a form parsing subroutine.
(the data is coming from a web page form)

>
> Also, in your current code you don't do any checks on your calls, such as
> your open and rename calls.  You should always check open, and usually check
> rename.
>

i am not certain what you mean by 'checks on calls' either.
point me in the right direction?

thanks! -cjm




Credit Protocol

2001-06-14 Thread Teresa Raymond

What is the credit protocol if I only want to use one piece (to me a 
significant piece) of someone's free program?  Where do I display the 
credit in the top of the cgi script or where the piece of code that I 
used is, and also in the html page accessing the script?



*** Teresa Raymond
*** http://www.mariposanet.com
*** [EMAIL PROTECTED]



Re: Net::Telnet

2001-06-14 Thread Paul Dean

Hya,

At 03:56 AM 15/06/2001 +0100, Kris G Findlay wrote:
>i have written this script .. just supposed to log into computer on network
>and start a forwarded gnome session to my Nt machine !
>
>problem is i cant get the prompt to match.
>
>#perl script 
>
>  #!e:\perl\bin\perl
>
>  use Net::Telnet;
>
>  $telnet = Net::Telnet->new
>   (
> Timeout => 90,
>#   Prompt => '/[\$%#>] $/',
> Prompt => '/[\$\%\#\>] $/', # these are metacharacters they 
> must be escaped "\"
> Host => '192.168.0.2'
>);
>
>  $telnet->login('kris', 'password');
>
>  $telnet->cmd('DISPLAY=192.168.0.10:0');
>
>  $telnet->cmd("export DISPLAY");
>
>  $telnet->cmd("gnome-session");
>
>  $telnet->close;
>
>exit;
>
>### end of script #
>
>[--]
>  Kris G Findlay
>  [EMAIL PROTECTED]
>[--]


Regards

Paul Dean
IT Support Officer
Canning College
Computing Centre
Ph: 9350 5430
Mob: 0408 902 206
[EMAIL PROTECTED]




Net::Telnet

2001-06-14 Thread Kris G Findlay

i have written this script .. just supposed to log into computer on network 
and start a forwarded gnome session to my Nt machine ! 

problem is i cant get the prompt to match.

#perl script 

 #!e:\perl\bin\perl

 use Net::Telnet;

 $telnet = Net::Telnet->new  
  (
Timeout => 90,
Prompt => '/[\$%#>] $/',
Host => '192.168.0.2'
   );

 $telnet->login('kris', 'password');

 $telnet->cmd('DISPLAY=192.168.0.10:0');

 $telnet->cmd("export DISPLAY"); 

 $telnet->cmd("gnome-session"); 

 $telnet->close; 

exit;

### end of script #

[--]
 Kris G Findlay
 [EMAIL PROTECTED]
[--]



Re: major "I have no clue" here

2001-06-14 Thread Me

> [analog] looks nice, but I am not sure it is suited for my needs
> [because the logs I'm parsing aren't web logs]

Sorry, my brain must have slipped out of gear
while I wasn't looking.

Forget analog.

The file count doesn't seem that much. I suggest
you use opendir and cousins to process files one
at a time.

Will you significantly benefit from running multiple
scripts simultaneously? Using 3 cpus for N seconds
rather than 1 cpu for 3N seconds?

I think you are best off putting your effort into creating
a single threaded version of the task, then profiling
and tweaking that. (I think it will probably boil down to
making the regexes more efficient.)

I suggest you search the archives of this group for
help on using opendir, and on profiling, and references
for making regexes go faster.




Re: major "I have no clue" here

2001-06-14 Thread Me

> I have been tasked to parse ~1500 log files summing a total of ~100mb
> cleanly, effectively and with little impact on the system.

I'd use http://www.analog.cx unless you really have to use perl.
It would do the whole lot in a few seconds.




Re: Can't understand Reference interpretation

2001-06-14 Thread Peter Scott

At 06:04 PM 6/14/01 -0500, [EMAIL PROTECTED] wrote:
>Gurus,

Grasshopper,

> The Camel, ( 3rd Ed. ), says,
>-
>$listref->[2][2] = "hello";# pretty clear
>$$listref[2][2] = "hello"; # A bit confusing
>
>This second of these statements may disconcert the C programmer, who is
>accustomed
>to using *a[i] to mean "what's pointed to by the ith element of a". But in
>Perl, the five characters ($ @ * % &) effectively bind more tightly than
>braces or brackets. Therefore, it is $$listref and not $listref[2] that is
>taken to be a reference to an array.
>-
>
>Now, here is how I understand the first LHS is interpreted by perl:
>Rewriting, the first,
>$listref->[2]->[2] = "hello";# Adding the redundant arrow ( for
>understanding )
>
>listref   --- is a scalar which is a reference to some array's 3rd
>elem

Nope, that there is a bareword that has no meaning in that code.

>listref->[2]---  is a   scalar which is a reference to some
>array's 3rd elem
>$listref->[2]->[2]  --- is a scalar lvalue which is assigned  string
>"hello".

Try this instead:

$listref - is a scalar which is a reference to an array.
$listref->[2] --- is the third element of that array.  It also happens 
to be a reference to another array.
$listref->[2]->[2] --- is the third element of that other array.  The 
second arrow can be omitted through syntactic sugaring.

>Now, the second LHS:
>
>$$listref[2]->[2] = "hello";  # Adding the redundant arrow ( for
>understanding )
>
>$$listref[2] is interpreted as "$listref" is a reference to an array **
>and ** $$listref[2] is
>   $ { $listref } [2]
>( i.e. given some array @k, and $refk = \@k, then $$refk[i] is $k[i].
>"Literal k always replaceable by $refk". )
>
>Why does the text say "$$listref" is a reference???

This is somewhat poorly worded.  $$listref is not a reference to an array, 
because for $$listref to mean something $listref would have to be a 
reference to a scalar.  It's saying that you shouldn't think that it's 
interpreted as

 ${$listref[2]}[2]

because it isn't.  But IMHO it would make more sense if it said $listref 
instead of $$listref in the text there.

>One reference is
>"$listref" and the second is "$$listref[2]" ( equivalently  $ { $listref }
>[2] ).
>
>I feel there is some gap in my understanding.

You seem to have it down.

There are two rules for understanding dereferencing (aside from the arrow 
operator):

1. The name portion of a variable (the "word" if you want, that comes after 
the initial punctuation sigil and before any more characters like [ or { 
that signify an element) may be replaced by a simple scalar variable ($x, 
not $x{foo} or $x[42], just $x, for some word x) which must contain a 
reference to the way the variable is being used, e.g.

 $$x - $x must contain reference to scalar
 $$x[2] - $x must contain reference to array

2. The name portion may be replaced by a block yielding the appropriate 
type of reference.  This is for when you don't have a simple scalar 
containing your reference.  So, eg:

 ${func(42)} - func(42) must return reference to scalar
 ${$hash{ish}}{urp} - $hash{ish} must return reference to hash



--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Re: counting regex matches

2001-06-14 Thread Michael Fowler

On Thu, Jun 14, 2001 at 05:08:30PM -0400, Carl Rogers wrote:
> 
> >
> >$string =~ /a/g; # match on all 'a' in $string
> >
> >Now how do I know how many times it actually matched?
> 
> Try:
> $result = $string =~ /a/g;
> The value will be in $result

> perl -wle '$str = "abcabcabc"; $cnt = $str =~ /a/g; print $cnt;'
1


What you really meant was:

> perl -wle '$str = "abcabcabc"; $cnt = () = $str =~ /a/g; print $cnt;'
3

Which forces the /a/g to be evaluated in list context, the return value of
which is then evaluated in scalar context.  The weird thing is it's
evaluated not as most lists in scalar context, which evaluate to the last
element, but as if it were an array, resulting in the count of elements.


But, if you're counting a single character:

> perl -wle '$str = "abcabcabc"; $cnt = $str =~ tr/a/a/; print $cnt;'
3


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



Re: nested checks

2001-06-14 Thread Michael Fowler

On Thu, Jun 14, 2001 at 01:51:29PM -0500, [EMAIL PROTECTED] wrote:
> i am running through a series of if/elsif checks on a variable:
> 
> if (($add_alias) && ($add_destination) && (!$selection)) {
> 
>if ( $add_alias =~ /[^\w\.\-]/ ) {
> 
>} elsif ( $add_destination !~ /\@/ ) {
> 
>} else {
[snip, code omitted]
>}
> }

If this is really what your code looks like, with unused blocks and all,
it's better written as:

if (   $add_alias && $add_destination && !$selection
&& $add_alias   !~ /[^\w\.\-]/]
&& $add_destination !~ /\@/
) {
# ... code goes here ...
}

Format to taste, of course.  Your checks on $add_alias, $add_destination,
and $selection should also probably be checks for defined'ness, not truth. 
0 is false, but, according to your definition of what $add_alias should
contain, is also a valid value.


 
> i'd now like to insert a test that will check to see if $add_alias is
> already included in $filename.
> 
> open(MATCH, $filename);
>   while () {
> @existing = split(/\@/, $_);
> if ( $add_alias eq $existing[0] ) {
>   print "That alias already exists!";
>   $error=1;
> }
>   }
> close(MATCH);
> 
> since my if statement is within a while statement, i am not certain how to
> include this within my existing checks and ensure that the script will not
> execute any of the other actions if a match is found.

Regardless of how you decide to do block your code, this is how your new
code should probably be inserted:

 open(MATCH, $filename);
   while () {
 @existing = split(/\@/, $_);
 if ( $add_alias eq $existing[0] ) {
   print "That alias already exists!";
   $error=1;
 }
   }
 close(MATCH);

   unless ($error) {
 # ... open FILE, print to it, etc. ...
   }

There are other ways of doing this, such as using subroutines, goto, etc.,
but to me this would be the cleanest.


Also, in your current code you don't do any checks on your calls, such as
your open and rename calls.  You should always check open, and usually check
rename.


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



Can't understand Reference interpretation

2001-06-14 Thread Atul_Khot

Gurus,
The Camel, ( 3rd Ed. ), says,
-
$listref->[2][2] = "hello";# pretty clear
$$listref[2][2] = "hello"; # A bit confusing 

This second of these statements may disconcert the C programmer, who is 
accustomed 
to using *a[i] to mean "what's pointed to by the ith element of a". But in 
Perl, the five characters ($ @ * % &) effectively bind more tightly than 
braces or brackets. Therefore, it is $$listref and not $listref[2] that is 
taken to be a reference to an array. 
-

Now, here is how I understand the first LHS is interpreted by perl: 
Rewriting, the first,
$listref->[2]->[2] = "hello";# Adding the redundant arrow ( for 
understanding )

listref   --- is a scalar which is a reference to some array's 3rd 
elem 
listref->[2]---  is a   scalar which is a reference to some 
array's 3rd elem 
$listref->[2]->[2]  --- is a scalar lvalue which is assigned  string 
"hello".

Now, the second LHS:

$$listref[2]->[2] = "hello";  # Adding the redundant arrow ( for 
understanding )

$$listref[2] is interpreted as "$listref" is a reference to an array ** 
and ** $$listref[2] is 
  $ { $listref } [2]
( i.e. given some array @k, and $refk = \@k, then $$refk[i] is $k[i]. 
"Literal k always replaceable by $refk". )

Why does the text say "$$listref" is a reference??? One reference is 
"$listref" and the second is "$$listref[2]" ( equivalently  $ { $listref } 
[2] ). 

I feel there is some gap in my understanding. 

-- Regards,
Atul







major "I have no clue" here

2001-06-14 Thread Ronald J. Yacketta

I have been tasked to parse ~1500 log files summing a total of ~100mb
cleanly, effectively and with little impact on the system.

The current process uses a korn shell and greps ALL ~1500 files or certain
patterns and sends the output to another file were later in the script it is
greped again! WOW talk about ugly! timex on this process during SLT (System
Load Tests) had it jumping from ~0.30 to ~15.32!! holy be Jesus!

I want to redo this in perl, maybe thread it? maybe parse #logs / 3 at a
time? thus throwing the 3 greps on 3 different cpus, hopefully reducing
overhead etc..

What are some recommendations? I am a novice at best at perl. If you have a
recommendation could you possible post some starter code? I can handle the
regex and parsing.. just not sure how to handle the HUGE number and SIZE of
the files cleanly, effectively and with minimal system impact

Regards,
Ron




Question about submit buttons

2001-06-14 Thread Ward, Stefan

Below I want to take the value they select form a list and place it into the
where clause of the SQL statement.  How do I get there from here?  I know I
need a submit button, where does that go in the structure of the print
$query???  

if ($guess eq "") { 
print header;
print $query->scrolling_list(-name=>'name_list',
-values=>['total_games','total_units'],
-default=>[' total_games ',' total_units '],
-size=>5,
-multiple=>'true',
-labels=>\%labels);
}   
print $query->end_html;
   print "\n";

elsif (guess ne "") {

$ora_sth = $ora_dbh->prepare ( q
{
select
timestamp,
report_type,
data_name,
data_value
from
dwhs.mainstream_games_reports
where
report_type = $guess and
timestamp >= sysdate - 7
}  )  || die "Can't prepare statement: $DBI::errstr";


Stefan Ward
Data Warehouse Eng
Sony Online Entertainment
www.station.sony.com  
858-577-3074



Re: counting regex matches

2001-06-14 Thread Sean O'Leary

Oops!  Sorry!  Wrong section of the documentation.  I meant to grab the 
paragraph a little further down.  Still in perlop, still in the Regexp 
Quote-Like Operators section:



The /g modifier specifies global pattern matching--that is, matching as 
many times as possible within the string. How it behaves depends on the 
context. In list context, it returns a list of the substrings matched by 
any capturing parentheses in the regular expression. If there are no 
parentheses, it returns a list of all the matched strings, as if there were 
parentheses around the whole pattern.

In scalar context, each execution of m//g finds the next match, returning 
true if it matches, and false if there is no further match. The position 
after the last match can be read or set using the pos() function; see pos 
in the perlfunc manpage. A failed match normally resets the search position 
to the beginning of the string, but you can avoid that by adding the /c 
modifier (e.g. m//gc). Modifying the target string also resets the search 
position.



So, to modify my reasoning a little (isn't post-rationalization great?!?) 
that empty list I talked about gets populated with the matched strings (a 
bunch of "a"'s in this case) and then that list is evaluated in scalar 
context, yielding it's length.  That length being the number of strings 
matched.

Sorry about that, folks.  I should post a "Cutting and Pasting Considered 
Harmful."  : )

Later,

Sean.




Re: counting regex matches

2001-06-14 Thread Sean O'Leary

At 05:08 PM 6/14/2001, you wrote:
>Try:
>$result = $string =~ /a/g;
>The value will be in $result
>
>Carl

Close.  You have to force list context for the result of the pattern match 
to make it work.  Like this:

$result = () = $string =~ /a/g;

(Thanks to Mark-Jason Dominus)

Check out perlop for a note about why the first example won't work:
(in the section called 'Binding Operators':


Binary ``=~'' binds a scalar expression to a pattern match.

When used in scalar context, the return value generally indicates the 
success of the operation. Behavior in list context depends on the 
particular operator. See Regexp Quote-Like Operators for details.



And, if we follow the pointer we read:



If the /g option is not used, m// in list context returns a list consisting 
of the subexpressions matched by the parentheses in the pattern, i.e., ($1, 
$2, $3...). (Note that here $1 etc. are also set, and that this differs 
from Perl 4's behavior.) When there are no parentheses in the pattern, the 
return value is the list (1) for success. With or without parentheses, an 
empty list is returned upon failure.



So, looking back at the solution:

$result = () = $string =~ /a/g;

We're getting the result of globally matching the pattern against the 
string, in list context (the () is an empty list, which we are populating 
with the 1's that are returned by =~ as the matching is done) then we 
evaulate that list in scalar context, which yields the number of elements 
in it.  The empty list there is important, otherwise the results of =~ are 
evaluated in scalar context, yielding only a 1 or 0 for success or failure.

Check it out:

$string = 'a';

$result1 = () = $string =~ /a/g;
$result2 = $string =~ /a/g;

print "$result1\n$result2";

Later,

Sean.




Re: PARSING A FILE

2001-06-14 Thread Chas Owens

The following code does no checking to insure the format is correct.
This is left as an excerise for the reader.


#!/usr/bin/perl -w

use strict; #make me behave

my $first = 1;
my $line;

while (<>) { #read lines from stdin or files listed
 #on cmd line
chomp;   #remove \n
if (s/^>//) {#replace leading >, this has a side effect
 #of telling us that is a name
unless ($first) {#unless this is the first line
chop $line;  #remove trailing .
print "$line\n"; #done with this name
}
$first = 0;  #make sure we know that this is no longer
 #the first line
$line = "$_\t";  #set name followed by tab
} else { #if this is a line line
$line .= "$_.";  #append line (note we need to remove the
 #last . at the end, see line 13
}
}
chop $line;  #remove trailing .
print "$line\n"; #last line needs printing


On 14 Jun 2001 16:54:11 -0400, Pedro A Reche Gallardo wrote:
> Hi to everyone, I have a file that it looks like this
> 
> >name1
> line 1
> line 2
> >name2
> line a
> line b
> 
> 
> and I want it to look this way
> 
> name1  line1.line2
> name2  linea.lineb
> 
> 
> Anyone help welcomed
> Greetings,
> 
> Pedro
> 
> 
> 
> --
> 
> ***
> PEDRO a. RECHE gallardo, pHDTL: 617 632
> 3824
> Scientist, Mol.Immnunol.Foundation, FX: 617 632 3351
> Dana-Farber Cancer Institute,   EM:
> [EMAIL PROTECTED]
> Harvard Medical School, URL: http://www.reche.org
> 44 Binney Street, D610C,
> Boston, MA 02115
> 
> ***
> 
> 
--
Today is Setting Orange, the 19th day of Confusion in the YOLD 3167
Grudnuk demand sustenance!





RE: counting regex matches

2001-06-14 Thread Wagner-David

  I only get a one when doing it that way. I had to do the following:

my $string = 'abcadebavdacde';
my $MyCount = 0;
while ( $string =~ /a/g ) { $MyCount++};

printf "String:\n%-s\nCount: %4d\n", $string, $MyCount;

Output:

String:
abcadebavdacde
Count:4

Wags ;)

-Original Message-
From: Carl Rogers [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 14:09
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: counting regex matches



>
>$string =~ /a/g; # match on all 'a' in $string
>
>Now how do I know how many times it actually matched?

Try:
$result = $string =~ /a/g;
The value will be in $result

Carl



RE: PARSING A FILE

2001-06-14 Thread Wagner-David

Major assumptions: format you stated (ie name, line 1, line 2) 
  No checking at this point, other than the first read should be > . Also
assumed from your input that you wanted ALL white space removed. Untested,
but a starting point. Also assumed you will setup the open for input and
output accordingly.

my $MyName ;
my $MyLine1;
my $MyLine2;

while(  ){
   chomp;
   if ( /^>(.+)$/ ) {
  $MyName = $1;
  chomp($MyLine1 =);
  chomp($MyLine2 =);
  $MyLine1 =~ s/\s+//g;
$MyLine2 =~ s/\s+//g;
printf FILEOUT "%-20s\t%-s.%-s\n", $MyName, $MyLine1, $MyLine2;
}else {
  # error since expecting in format of namex,line1,line2
}
 }

Wags ;)
-Original Message-
From: Pedro A Reche Gallardo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 13:54
To: [EMAIL PROTECTED]
Subject: PARSING A FILE


Hi to everyone, I have a file that it looks like this

>name1
line 1
line 2
>name2
line a
line b


and I want it to look this way

name1  line1.line2
name2  linea.lineb


Anyone help welcomed
Greetings,

Pedro



--
***
PEDRO a. RECHE gallardo, pHDTL: 617 632
3824
Scientist, Mol.Immnunol.Foundation, FX: 617 632 3351
Dana-Farber Cancer Institute,   EM:
[EMAIL PROTECTED]
Harvard Medical School, URL: http://www.reche.org
44 Binney Street, D610C,
Boston, MA 02115
***





Re: counting regex matches

2001-06-14 Thread Carl Rogers


>
>$string =~ /a/g; # match on all 'a' in $string
>
>Now how do I know how many times it actually matched?

Try:
$result = $string =~ /a/g;
The value will be in $result

Carl




Re[2]: regex matching

2001-06-14 Thread Evgeny Goldin (aka Genie)


PS> It's simply a matter of how pedantic you wish to be.  The example you
PS> pasted is not a valid IP address (maximum component value is 255).

You didn't read my words carefully, it was "I think it's better to match
the IP first, split /\./ it to four digits and check if their combination is
legal"
The complete test logic will be extremely difficult to express using regex.





counting regex matches

2001-06-14 Thread Bob Mangold

Is there a simple way to know how many times a regex matches.
Say for example:

$string =~ /a/g; # match on all 'a' in $string

Now how do I know how many times it actually matched?

-Bob

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



PARSING A FILE

2001-06-14 Thread Pedro A Reche Gallardo

Hi to everyone, I have a file that it looks like this

>name1
line 1
line 2
>name2
line a
line b


and I want it to look this way

name1  line1.line2
name2  linea.lineb


Anyone help welcomed
Greetings,

Pedro



--
***
PEDRO a. RECHE gallardo, pHDTL: 617 632
3824
Scientist, Mol.Immnunol.Foundation, FX: 617 632 3351
Dana-Farber Cancer Institute,   EM:
[EMAIL PROTECTED]
Harvard Medical School, URL: http://www.reche.org
44 Binney Street, D610C,
Boston, MA 02115
***





RE: Sort hash by values

2001-06-14 Thread Wagner-David

Sorry, but as soon as I saw the input coming back I knew it was really
untested.
 Should be sort {lc($a->[1]) cmp lc($b->[1])} and NOT sort {lc($a) cmp
lc($b)}

Wags ;)

-Original Message-
From: Wagner-David 
Sent: Thursday, June 14, 2001 13:21
To: 'David Gilden'; [EMAIL PROTECTED]
Subject: RE: Sort hash by values


  Use of keys, map and sort (untested)
foreach my $subject (sort {lc($a) cmp lc($b)} map {[ $_, $subjects{$_}]}
keys %subjects){
   printf "%-40s: %-s\n", $subjects{$subject->[0]}, $subject->[0];
 }

Wags ;)
-Original Message-
From: David Gilden [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 12:10
To: [EMAIL PROTECTED]
Subject: Sort hash by values


Hello, 

Stuck here, 

The first sort block works like a charm!

if ($sort_order == 1) {

# sort by name
# $key is really the filename with out the path and '.html'
foreach my $key (sort {lc($a) cmp lc($b)} keys %subjects){
my $name;
  ($name = $key ) =~ s/_(\d+)$//;
  $name =~ tr/_/ /;
 &print_table_rows($key,$name,$subjects{$key}," ");
}
}


However, this one has be stuck, I want to sort  (case insensitive) the
values
in the hash  %subjects,  and I need to get keys of the hash as well -- 
the key of the hash has data I need to pass along to my sub,

 elsif  ($sort_order == 2) {

# sort by subject 

foreach my $subject (sort {lc($a) cmp lc($b)} values %subjects){




##
need the key here...
my $name;
($name = $key ) =~ s/_\d+$//;
 $name =~ tr/_/ /;
##

   &print_table_rows($key,$name,$subject," ");

}

Looking for Web Talent, You found it!
portfolio: www.coraconnection.com/web/
email: [EMAIL PROTECTED]
tel/fax: (860) 231-9988




RE: Sort hash by values

2001-06-14 Thread Wagner-David

  Use of keys, map and sort (untested)
foreach my $subject (sort {lc($a) cmp lc($b)} map {[ $_, $subjects{$_}]}
keys %subjects){
   printf "%-40s: %-s\n", $subjects{$subject->[0]}, $subject->[0];
 }

Wags ;)
-Original Message-
From: David Gilden [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 12:10
To: [EMAIL PROTECTED]
Subject: Sort hash by values


Hello, 

Stuck here, 

The first sort block works like a charm!

if ($sort_order == 1) {

# sort by name
# $key is really the filename with out the path and '.html'
foreach my $key (sort {lc($a) cmp lc($b)} keys %subjects){
my $name;
  ($name = $key ) =~ s/_(\d+)$//;
  $name =~ tr/_/ /;
 &print_table_rows($key,$name,$subjects{$key}," ");
}
}


However, this one has be stuck, I want to sort  (case insensitive) the
values
in the hash  %subjects,  and I need to get keys of the hash as well -- 
the key of the hash has data I need to pass along to my sub,

 elsif  ($sort_order == 2) {

# sort by subject 

foreach my $subject (sort {lc($a) cmp lc($b)} values %subjects){




##
need the key here...
my $name;
($name = $key ) =~ s/_\d+$//;
 $name =~ tr/_/ /;
##

   &print_table_rows($key,$name,$subject," ");

}

Looking for Web Talent, You found it!
portfolio: www.coraconnection.com/web/
email: [EMAIL PROTECTED]
tel/fax: (860) 231-9988




RE: regex matching

2001-06-14 Thread Jason C. Lamb

I got this out of the Komodo help file:

IP addresses are difficult to match using a simple regular expression,
because the regular expression must verify that the IP address against which
it is matching is valid. A simple expression such as
/\d{3}\.\d{3}\.\d{3}\.\d{3}/  will incorrectly match strings such as
789.23.2.900, which is outside the range of valid IP addresses (i.e.,
0.0.0.0 to 255.255.255.255). Damian Conway's Regexp::Common
(http://velocity.activestate.com/code/search?query='Regexp::Common') module
provides a very effective regular expression which matches only valid IP
addresses.

Usage

#!/bin/perl
use Regexp::Common;

while() {
  if(/$RE{net}{IPv4}{dec}{-keep}/) {
print "IP Address: $1\n";
  }
}

__DATA__
24.113.50.245
0.42.523.2
255.242.52.4
2.5.3

 -Original Message-
From:   Peter Scott [mailto:[EMAIL PROTECTED]]
Sent:   Thursday, June 14, 2001 3:54 PM
To: Evgeny Goldin (aka Genie); [EMAIL PROTECTED]
Subject:Re: regex matching

At 09:59 PM 6/14/01 +0200, Evgeny Goldin (aka Genie) wrote:

> > /(\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?)/;
>
> >
>
/([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-
> > 4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])/)
>
>Wou ! Looks like too many symbols .. Does matching a legal IP worth
>a regex 1km long ? I think it's better to match the IP first,
>split /\./ it to four digits and check if their combination is legal -
>this will allow any sophisticated tests ( for 127.0.0.1 and the like ).
>
>Here's a regex which looks much shorter and flexible to me :
>
>C:\>perl -w
>my $line = 'here is a sample with 123.456.123.456 in the middle';
>my ($ip) = $line =~ m@((?:\d{1,3}\.){3}\d{1,3})@;
>print "[$ip]\n";
>^Z
>[123.456.123.456]

It's simply a matter of how pedantic you wish to be.  The example you
pasted is not a valid IP address (maximum component value is 255).

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com





Re: regex matching

2001-06-14 Thread Peter Scott

At 09:59 PM 6/14/01 +0200, Evgeny Goldin (aka Genie) wrote:

> > /(\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?)/;
>
> > 
> /([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-
> > 4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])/)
>
>Wou ! Looks like too many symbols .. Does matching a legal IP worth
>a regex 1km long ? I think it's better to match the IP first,
>split /\./ it to four digits and check if their combination is legal -
>this will allow any sophisticated tests ( for 127.0.0.1 and the like ).
>
>Here's a regex which looks much shorter and flexible to me :
>
>C:\>perl -w
>my $line = 'here is a sample with 123.456.123.456 in the middle';
>my ($ip) = $line =~ m@((?:\d{1,3}\.){3}\d{1,3})@;
>print "[$ip]\n";
>^Z
>[123.456.123.456]

It's simply a matter of how pedantic you wish to be.  The example you 
pasted is not a valid IP address (maximum component value is 255).

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Re: Perl UNIX commands

2001-06-14 Thread Peter Scott

At 11:33 AM 6/14/01 -0500, John Joseph Roets wrote:
>I found a site a while back which detailed a pursuit to develop Perl
>commands to replace universal UNIX commands.
>Thus, providing advanced benefits/features, such as more full regex matching
>abilities, etc.
>My problem:
>I cannot now find this site.  I can't even remember how I came across it.
>Might anyone here be aware of this site/group?  Please?

You're talking about the PMTools started by Tom Christiansen.  Once again, 
I just just cut-and-paste from a recent message of Elaine Ashton :-)

Try http://language.perl.com/misc/pmtools-1.00.tar.gz
That URL, last I knew, gave me a corrupted file. If it still does, try
http://history.perl.org/src/pmtools-1.00.tar.gz


--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




Sort hash by values

2001-06-14 Thread David Gilden

Hello, 

Stuck here, 

The first sort block works like a charm!

if ($sort_order == 1) {

# sort by name
# $key is really the filename with out the path and '.html'
foreach my $key (sort {lc($a) cmp lc($b)} keys %subjects){
my $name;
  ($name = $key ) =~ s/_(\d+)$//;
  $name =~ tr/_/ /;
 &print_table_rows($key,$name,$subjects{$key}," ");
}
}


However, this one has be stuck, I want to sort  (case insensitive) the values
in the hash  %subjects,  and I need to get keys of the hash as well -- 
the key of the hash has data I need to pass along to my sub,

 elsif  ($sort_order == 2) {

# sort by subject 

foreach my $subject (sort {lc($a) cmp lc($b)} values %subjects){




##
need the key here...
my $name;
($name = $key ) =~ s/_\d+$//;
 $name =~ tr/_/ /;
##

   &print_table_rows($key,$name,$subject," ");

}

Looking for Web Talent, You found it!
portfolio: www.coraconnection.com/web/
email: [EMAIL PROTECTED]
tel/fax: (860) 231-9988




Re: Collapsing Duplicates

2001-06-14 Thread Me

> I'm having a very hard time figuring this out. Does
> anyone have any suggestions or pointers for the best
> way to go about this?

Go buy the Perl Cookbook. A truly superb book that
gives highly distilled, highly productive answers to
hundreds of standard things you will want to do like
this in a categorized problem/solutions format. It gives
5 ways to do this, the best pick being dependent on
circumstances.

One is:

%seen = ();
foreach $item (@list) {
push (@uniq, $item) unless $seen{$item}++;
}






Re: regex matching

2001-06-14 Thread Evgeny Goldin (aka Genie)


> /(\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?)/;

> /([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-
> 4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])/)

Wou ! Looks like too many symbols .. Does matching a legal IP worth
a regex 1km long ? I think it's better to match the IP first,
split /\./ it to four digits and check if their combination is legal -
this will allow any sophisticated tests ( for 127.0.0.1 and the like ).

Here's a regex which looks much shorter and flexible to me :

C:\>perl -w
my $line = 'here is a sample with 123.456.123.456 in the middle';
my ($ip) = $line =~ m@((?:\d{1,3}\.){3}\d{1,3})@;
print "[$ip]\n";
^Z
[123.456.123.456]

C:\>



 Regards,
  Evgeny
http://geniek.net
---
"and 224.0.1.2 is for SGI's (Silicon Graphics) dogfight application"
   TCP/IP Illustrated, 12.4 Multicasting





Re: stdout/stderr

2001-06-14 Thread Evgeny Goldin (aka Genie)


> I had another idea, but that is revert back to stupidity ;)
> using system and sending the output to a file then open the file ;)

Why not ? That's just fine





nested checks

2001-06-14 Thread charles

i am running through a series of if/elsif checks on a variable:

if (($add_alias) && ($add_destination) && (!$selection)) {

   if ( $add_alias =~ /[^\w\.\-]/ ) {

   } elsif ( $add_destination !~ /\@/ ) {

   } else {
  open(FILE, ">>$filename");
print FILE "$add_alias\@$domain\t$add_destination\n";
  close(FILE);
  open(FILE, "$filename");
@entries = ;
  close(FILE);
  @entries = sort(@entries);
  open(NEWFILE, ">>$tmpfile");
foreach $item(@entries) {
  print NEWFILE "$item";
}
  close(NEWFILE);
  rename($tmpfile, $filename);
   }
}

this script takes input from a user and adds it into $filename after
sorting it and checking to verify that $add_alias has only valid a-z A-Z
0-9 . - and _ characters and $add_destination has an @ symbol included.

i'd now like to insert a test that will check to see if $add_alias is
already included in $filename.

open(MATCH, $filename);
  while () {
@existing = split(/\@/, $_);
if ( $add_alias eq $existing[0] ) {
  print "That alias already exists!";
  $error=1;
}
  }
close(MATCH);

since my if statement is within a while statement, i am not certain how to
include this within my existing checks and ensure that the script will not
execute any of the other actions if a match is found.




Collapsing Duplicates

2001-06-14 Thread E. Alan Hogue

Hello,

I'm trying to write a script that takes a list of
company names, their corresponding URLS, and their
office locations, makes the names into html links, and
puts it all into a web page.

The problem is that the list I'm working from
sometimes has two entries for the same company. The
name and URL are the same, but the locations are
different.

I need to put them together so that there is only one
link per company, but I need to dump all the
non-duplicated locations from the second one into the
first so that no information is lost.

I'm having a very hard time figuring this out. Does
anyone have any suggestions or pointers for the best
way to go about this?

Thanks,
Alan Hogue

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/



Re: Help needed with setting up a SMTP connection

2001-06-14 Thread Michael Fowler

On Thu, Jun 14, 2001 at 11:25:51AM +0200, Adrienne Kotze wrote:
> Michael Fowler wrote:
> > 
> > On Thu, Jun 14, 2001 at 08:30:14AM +0200, Adrienne Kotze wrote:
> > > $mailer = Mail::Mailer->new ("smtp", "smtp.mydomain.com") ;
> > 
> > This should be:
> > 
> > $mailer = Mail::Mailer->new("smtp", Server => "smtp.mydomain.com");
> 
> Thanx, this works great. So it would appear that the Cookbook has got a
> typo.

It could be an example from an older version of Mail::Mailer.


> Just one last thing: If I move my code to ActiveState on NT, I get the
> following:
> 
> Invalid argument at lib/Mail/Mailer.pm line 270.

Line 270 in Mail::Mailer v1.20 is:

(defined($exe) && open($self,"|-"))

That particular form of open is not supported in Windows.  You could try
different versions of Mail::Mailer, or you may have to move to something
else.


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



Weekly list FAQ posting

2001-06-14 Thread casey

NAME
beginners-faq - FAQ for the beginners mailing list

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

Send mail to <[EMAIL PROTECTED]>

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

<[EMAIL PROTECTED]>.

  1.2 -  How do I unsubscribe?

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

<[EMAIL PROTECTED]>

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

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

<[EMAIL PROTECTED]>

To unsubscribe from the digest, send an email to:

<[EMAIL PROTECTED]>

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

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

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

  1.5 - How can I get this FAQ?

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

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

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

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

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

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

  1.9 - Who currently maintains the FAQ?

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

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

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

  1.11 - When was this FAQ last updated?

June 10, 2001

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

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

  2.2 - What is this list _not_ for?

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

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

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

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

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

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

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

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

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

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

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

`perldoc perldoc'

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

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

3 - Other Resources
  3.1 - What other websites may be useful to a beginner ?

* Perl Home Page - http://www.perl.c

Re: Where to begin??!!??

2001-06-14 Thread Morbus Iff

 >The point:
 >I need to take this text file and format each entry (separated by hard
 >returns) so that the user info (name address, etc) are all in their own
 >columns still and then for each number they chose (up to 271 out of 271) it
 >creates a new entry with their contact info and one number in the last
 >column.

Here's some untested pseudo code to help you:

  # for each line of the DAT file:
  while () {

 # split each line on the pipe, and throw into matching
 # variable entries - note that bingo numbers are all
 # thrown into a single array.
 my ($date, $time, $name, $street, $city, $state,
 $town, $zip, $country, $email, $phone, @subscriptions) =
 split (/|/, $_);

 # now, loop through the subscriptions array and
 # create a new line for each bingo number.
 foreach my $subscription (@subscriptions) {

$new_data .= "$name|$street|$city|$state|$country|
  $zip|$phone|$email|$subscription|\n";

 }

  }

Once the entire DAT file has been looped through, you'll have your 
completed data in $new_data to do whatever you want. NOTE that this is 
untested code. Don't sue me if I birth your child.


Morbus Iff
.sig on other machine.
http://www.disobey.com/
http://www.gamegrene.com/




Where to begin??!!??

2001-06-14 Thread Crystal Gruetzmacher

Hi all,

I have a problem and I need to know where to begin. At the magazine I work
for we have what are called "bingo cards" in the magazine that people can
fill out and send back to us to get information on whatever of 271 topics,
stores, resorts, etc. of their choice. They can also fill this out online.
What we end up with is a DAT file with each users stuff as one entry in a
pipe-delimited file with hard returns at the end of each entry. Of course we
could bring this into Excel or Access or some other DB, but the problem then
becomes that there are 283 fields. Not many  DB's support that many.

The point:
I need to take this text file and format each entry (separated by hard
returns) so that the user info (name address, etc) are all in their own
columns still and then for each number they chose (up to 271 out of 271) it
creates a new entry with their contact info and one number in the last
column.

For example: Joe Smith|123 Main
St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|1|2||8||10|11| would
then become:
Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|1|
Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|2|
Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|8|
Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|10|
Joe Smith|123 Main St.|Yourtown|US|83124|888-555-1212|[EMAIL PROTECTED]|11|

Here is a sample entry from the DAT file.

|6/12/2001|13:05:34|Closet Geek|456 Flibity Jibet Way|My
Town|CA|90450|US|[EMAIL PROTECTED]|760-555-1212||1|2|3|4|5|6|7|8|9|10
|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|
36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|6
1|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86
|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|
109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|
128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|
147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|
166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|
185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|
204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|
223|224|225|226|227|228|229|230|231|232||234|235|236|237|238|239|240|241|242
|243|244|245|246|247|248|249|250|251|252|253|254|255|256|257|258|259|260|261
|262|263|264|265|266|267|268|269|270|271|
|6/12/2001|13:14:42|closetgeek|456 Flibity Jibet Way|Yucca
Valley|California|5|yugoslavia|[EMAIL PROTECTED]|760-555-1212|Submit||
|||53|58
78|||89||95||97|
||168||178186|||197|
|207|||230||

I really need to know where to begin. Should I put everything between the
first 12 pipes (including the pipes) into a variable and then run a loop on
the remainder? 

Closet Geek >^..^<



Re: Help needed with setting up a SMTP connection

2001-06-14 Thread Me

> So it would appear that the Cookbook has got a typo.

Sorta. You might want to read in the deja thread I referred you to.

[A thread from 1999. And I didn't find a correction in the
Cookbook's errata (though that could be because the
searching process is tedious and I wasn't motivated to
keep at it for long).]

> Just one last thing: If I move my code to ActiveState on NT,
> I get the following:
> 
> Invalid argument at lib/Mail/Mailer.pm line 270.
> 
> Any ideas ?

The deja thread would suggest you try the Cookbook syntax.




Re: Perl UNIX commands

2001-06-14 Thread iain truskett

* John Joseph Roets ([EMAIL PROTECTED]) [14 Jun 2001 16:34]:
> I found a site a while back which detailed a pursuit to develop Perl
> commands to replace universal UNIX commands. Thus, providing advanced
> benefits/features, such as more full regex matching abilities, etc.

> My problem:

> I cannot now find this site. I can't even remember how I came across
> it. Might anyone here be aware of this site/group? Please?

Sounds like "Perl Power Tools: The Unix Reconstruction Project"

Check out:  http://language.perl.com/ppt/


cheers,
-- 
iain.  



Perl UNIX commands

2001-06-14 Thread John Joseph Roets

I found a site a while back which detailed a pursuit to develop Perl
commands to replace universal UNIX commands.
Thus, providing advanced benefits/features, such as more full regex matching
abilities, etc.
My problem:
I cannot now find this site.  I can't even remember how I came across it.
Might anyone here be aware of this site/group?  Please?

Thank you greatly indeed.

/**
 * John Joseph Roets
 * Metro Information Services
 * [EMAIL PROTECTED]
 * ph:816.283.3223 x.3246
 * tf:800.990.2468 x.3246
 * fx:816.221.3428
 */




RE: Help with File Exists

2001-06-14 Thread John Edwards

try !-e instead of -!e. You need to negate the result of the -e operator. By
putting a ! in the middle of the -e operator, perl no longer knows what it
is.

-Original Message-
From: Maynard, Garth [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 17:05
To: [EMAIL PROTECTED]
Subject: Help with File Exists


I am iterating through a long hash list, and I want to be able to pause the
script. To do this, I have put a while (-!e $go) loop inside of the while
(keys (%hash)) loop, but the script is looking for $go within %hash, rather
than the predefined location. The error I am getting is:

"Can't call method "e" without a package or object reference at filename.pl
line 81,  line 4.

How do I get the $go loop to look where I told it?

use Sys::Hostname; 

$host = hostname();
$ip = &IP($host);
$go = "server\\share\\go\.script";
$ChipFile2 = "server\\share\\listfile.txt";

open LIST, "< $ChipFile2" || die "$ChipFile2 cannot find file to open $!;
$^E";

# Read the list
%list = ();
while () {
($server, $parent) = split;
$list{$server} = $parent;
}

foreach $server (keys %list){


while (-!e $go) {
# In order to pause the script during times of network
congestion, the script looks for
# a file
sleep 5;
}

if ($parent eq $host | $ip){

# ...do other stuff
}   
}
}

Thanks,

Garth


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.





Re: Noobie question

2001-06-14 Thread Michael D . Risser

On Thursday 14 June 2001 08:04 am, you wrote:
> OK I give up
>
> TMTOWTDI?
>

There's More Than One Way To Do It



Help with File Exists

2001-06-14 Thread Maynard, Garth

I am iterating through a long hash list, and I want to be able to pause the
script. To do this, I have put a while (-!e $go) loop inside of the while
(keys (%hash)) loop, but the script is looking for $go within %hash, rather
than the predefined location. The error I am getting is:

"Can't call method "e" without a package or object reference at filename.pl
line 81,  line 4.

How do I get the $go loop to look where I told it?

use Sys::Hostname; 

$host = hostname();
$ip = &IP($host);
$go = "server\\share\\go\.script";
$ChipFile2 = "server\\share\\listfile.txt";

open LIST, "< $ChipFile2" || die "$ChipFile2 cannot find file to open $!;
$^E";

# Read the list
%list = ();
while () {
($server, $parent) = split;
$list{$server} = $parent;
}

foreach $server (keys %list){


while (-!e $go) {
# In order to pause the script during times of network
congestion, the script looks for
# a file
sleep 5;
}

if ($parent eq $host | $ip){

# ...do other stuff
}   
}
}

Thanks,

Garth




Re: regex matching

2001-06-14 Thread Ken

Ok, strike my previous comments.

My apologies for wasting your time.


- Original Message -
From: "Ken" <[EMAIL PROTECTED]>
To: "John Edwards" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:45 AM
Subject: Re: regex matching


> Doesn't {1,3} mean minimum of 1 and maximum of 3 of whatever character
comes
> before the {}'s?
>
> I ran this code with the following ip:
> 192.168.0.34
> It works fine.
>
> - Original Message -
> From: "John Edwards" <[EMAIL PROTECTED]>
> To: "'Ken'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Thursday, June 14, 2001 9:40 AM
> Subject: RE: regex matching
>
>
> > "To just make sure what you have is an ip (and only an ip) is:
> > m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;"
> >
> > Not true. An IP can only consist of numbers ranging from 0 to 255. Your
> > example will match an 'IP' that looks like this;
> >
> > 311.497.999.587
> >
> > for instance.
> >
> > The example I gave isn't perfect (and I nicked the essentials of it from
> the
> > Perl Cookbook) but it will at least not match on completely wrong IPs.
> >
> > John
> >
> > -Original Message-
> > From: Ken [mailto:[EMAIL PROTECTED]]
> > Sent: 14 June 2001 16:32
> > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Subject: Re: regex matching
> >
> >
> > \d only matches one digithere's a way to extract each number from an
> ip:
> > use strict;
> > my( $ip );
> > print "Enter a string with an IP:";
> > $ip = ;
> > $ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
> > print "$1\n";
> > print "$2\n";
> > print "$3\n";
> > print "$4\n";
> >
> > Or if you just want the ip from the line:
> > use strict;
> > my( $ip );
> > print "Enter a string with an IP:";
> > $ip = ;
> > $ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
> > print "The ip is: $1\n";
> >
> > To just make sure what you have is an ip (and only an ip) is:
> > m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
> >
> >
> >
> > - Original Message -
> > From: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Thursday, June 14, 2001 9:12 AM
> > Subject: regex matching
> >
> >
> > > i have a basic knowledge of regex but i want to know if there is a
> > > simpler way to pull patterns out of a line.
> > >
> > > if i have a line like:
> > >
> > >   here is a sample with 123.456.123.456 in the middle.
> > >
> > > m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> > > get only the ip address?
> > >
> > > thanks..
> > >
> > > Brian T. Wallace
> > > Engineer
> > >
> > >
> >
> >
> > --Confidentiality--.
> > This E-mail is confidential.  It should not be read, copied, disclosed
or
> > used by any person other than the intended recipient.  Unauthorised use,
> > disclosure or copying by whatever medium is strictly prohibited and may
be
> > unlawful.  If you have received this E-mail in error please contact the
> > sender immediately and delete the E-mail from your system.
> >
> >
> >
>
>




Re: Lazy lists in Perl ?

2001-06-14 Thread Peter Scott

At 01:32 PM 6/14/01 +0200, Evgeny Goldin (aka Genie) wrote:

>   Hi,
>
>Is there any module implementing lazy lists ? ( similar to "infinite
>lists" of Scheme or "sequences" of ML )

In addition to ways of doing it in Perl 5, this has been mooted as a native 
capability for Perl 6: http://dev.perl.org/rfc/24.pod.

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




RE: regex matching

2001-06-14 Thread John Edwards

Well it would.

Run it with an 'IP' of 123.456.789.0. Still matches, right? But that's not a
valid IP.

It's a valid number if your looking for four groups of numbers, each no more
than 3 digits in length, seperated by a . (which is what your code does).
But it's not a test for a valid IP address.

John

-Original Message-
From: Ken [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 16:46
To: John Edwards; [EMAIL PROTECTED]
Subject: Re: regex matching


Doesn't {1,3} mean minimum of 1 and maximum of 3 of whatever character comes
before the {}'s?

I ran this code with the following ip:
192.168.0.34
It works fine.

- Original Message -
From: "John Edwards" <[EMAIL PROTECTED]>
To: "'Ken'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:40 AM
Subject: RE: regex matching


> "To just make sure what you have is an ip (and only an ip) is:
> m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;"
>
> Not true. An IP can only consist of numbers ranging from 0 to 255. Your
> example will match an 'IP' that looks like this;
>
> 311.497.999.587
>
> for instance.
>
> The example I gave isn't perfect (and I nicked the essentials of it from
the
> Perl Cookbook) but it will at least not match on completely wrong IPs.
>
> John
>
> -Original Message-
> From: Ken [mailto:[EMAIL PROTECTED]]
> Sent: 14 June 2001 16:32
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: regex matching
>
>
> \d only matches one digithere's a way to extract each number from an
ip:
> use strict;
> my( $ip );
> print "Enter a string with an IP:";
> $ip = ;
> $ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
> print "$1\n";
> print "$2\n";
> print "$3\n";
> print "$4\n";
>
> Or if you just want the ip from the line:
> use strict;
> my( $ip );
> print "Enter a string with an IP:";
> $ip = ;
> $ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
> print "The ip is: $1\n";
>
> To just make sure what you have is an ip (and only an ip) is:
> m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
>
>
>
> - Original Message -
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, June 14, 2001 9:12 AM
> Subject: regex matching
>
>
> > i have a basic knowledge of regex but i want to know if there is a
> > simpler way to pull patterns out of a line.
> >
> > if i have a line like:
> >
> >   here is a sample with 123.456.123.456 in the middle.
> >
> > m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> > get only the ip address?
> >
> > thanks..
> >
> > Brian T. Wallace
> > Engineer
> >
> >
>
>
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
>
>
>


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.





Re: Slicing and dicing

2001-06-14 Thread Paul


--- David Gilden <[EMAIL PROTECTED]> wrote:
> Is one style better then the other here?

> 
> sub print_table_rows {
> my $name = shift;
> my $key = shift;
> my $date = shift;

> --- alt
> sub print_table_rows {
> my ($name,$key,$date) = @_[0..2]

I'd just say 

  my ($name,$key,$date) = @_;

That leaves them in @_ in case you decide to edit the code later and
wish they were still there, assigns them for use, and cuts out the
unecessary line-noise of the [0..2].

The more important issue, however, is: does it make sense to you?
When you come back to edit it in 6 months, will it make sense to you?


__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/



RE: regex matching

2001-06-14 Thread Jason C. Lamb

Ken,

Your code will match any valid ip address, plus a bunch of addresses that
are not valid,
Try it with: 111.222.333.444

But I think that keeping in Brian's original question, it doesn't matter.
He is probably parsing the output of some program that is giving him a valid
ip, so you code will work just fine.

Jason

 -Original Message-
From:   Ken [mailto:[EMAIL PROTECTED]]
Sent:   Thursday, June 14, 2001 11:46 AM
To: John Edwards; [EMAIL PROTECTED]
Subject:Re: regex matching

Doesn't {1,3} mean minimum of 1 and maximum of 3 of whatever character comes
before the {}'s?

I ran this code with the following ip:
192.168.0.34
It works fine.

- Original Message -
From: "John Edwards" <[EMAIL PROTECTED]>
To: "'Ken'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:40 AM
Subject: RE: regex matching


> "To just make sure what you have is an ip (and only an ip) is:
> m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;"
>
> Not true. An IP can only consist of numbers ranging from 0 to 255. Your
> example will match an 'IP' that looks like this;
>
> 311.497.999.587
>
> for instance.
>
> The example I gave isn't perfect (and I nicked the essentials of it from
the
> Perl Cookbook) but it will at least not match on completely wrong IPs.
>
> John
>
> -Original Message-
> From: Ken [mailto:[EMAIL PROTECTED]]
> Sent: 14 June 2001 16:32
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: regex matching
>
>
> \d only matches one digithere's a way to extract each number from an
ip:
> use strict;
> my( $ip );
> print "Enter a string with an IP:";
> $ip = ;
> $ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
> print "$1\n";
> print "$2\n";
> print "$3\n";
> print "$4\n";
>
> Or if you just want the ip from the line:
> use strict;
> my( $ip );
> print "Enter a string with an IP:";
> $ip = ;
> $ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
> print "The ip is: $1\n";
>
> To just make sure what you have is an ip (and only an ip) is:
> m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
>
>
>
> - Original Message -
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, June 14, 2001 9:12 AM
> Subject: regex matching
>
>
> > i have a basic knowledge of regex but i want to know if there is a
> > simpler way to pull patterns out of a line.
> >
> > if i have a line like:
> >
> >   here is a sample with 123.456.123.456 in the middle.
> >
> > m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> > get only the ip address?
> >
> > thanks..
> >
> > Brian T. Wallace
> > Engineer
> >
> >
>
>
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
>
>
>





Re: regex matching

2001-06-14 Thread Ken

Doesn't {1,3} mean minimum of 1 and maximum of 3 of whatever character comes
before the {}'s?

I ran this code with the following ip:
192.168.0.34
It works fine.

- Original Message -
From: "John Edwards" <[EMAIL PROTECTED]>
To: "'Ken'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:40 AM
Subject: RE: regex matching


> "To just make sure what you have is an ip (and only an ip) is:
> m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;"
>
> Not true. An IP can only consist of numbers ranging from 0 to 255. Your
> example will match an 'IP' that looks like this;
>
> 311.497.999.587
>
> for instance.
>
> The example I gave isn't perfect (and I nicked the essentials of it from
the
> Perl Cookbook) but it will at least not match on completely wrong IPs.
>
> John
>
> -Original Message-
> From: Ken [mailto:[EMAIL PROTECTED]]
> Sent: 14 June 2001 16:32
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: regex matching
>
>
> \d only matches one digithere's a way to extract each number from an
ip:
> use strict;
> my( $ip );
> print "Enter a string with an IP:";
> $ip = ;
> $ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
> print "$1\n";
> print "$2\n";
> print "$3\n";
> print "$4\n";
>
> Or if you just want the ip from the line:
> use strict;
> my( $ip );
> print "Enter a string with an IP:";
> $ip = ;
> $ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
> print "The ip is: $1\n";
>
> To just make sure what you have is an ip (and only an ip) is:
> m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
>
>
>
> - Original Message -
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, June 14, 2001 9:12 AM
> Subject: regex matching
>
>
> > i have a basic knowledge of regex but i want to know if there is a
> > simpler way to pull patterns out of a line.
> >
> > if i have a line like:
> >
> >   here is a sample with 123.456.123.456 in the middle.
> >
> > m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> > get only the ip address?
> >
> > thanks..
> >
> > Brian T. Wallace
> > Engineer
> >
> >
>
>
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
>
>
>




RE: regex matching

2001-06-14 Thread John Edwards

"To just make sure what you have is an ip (and only an ip) is:
m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;"

Not true. An IP can only consist of numbers ranging from 0 to 255. Your
example will match an 'IP' that looks like this;

311.497.999.587

for instance.

The example I gave isn't perfect (and I nicked the essentials of it from the
Perl Cookbook) but it will at least not match on completely wrong IPs.

John

-Original Message-
From: Ken [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 16:32
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: regex matching


\d only matches one digithere's a way to extract each number from an ip:
use strict;
my( $ip );
print "Enter a string with an IP:";
$ip = ;
$ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
print "$1\n";
print "$2\n";
print "$3\n";
print "$4\n";

Or if you just want the ip from the line:
use strict;
my( $ip );
print "Enter a string with an IP:";
$ip = ;
$ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
print "The ip is: $1\n";

To just make sure what you have is an ip (and only an ip) is:
m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;



- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:12 AM
Subject: regex matching


> i have a basic knowledge of regex but i want to know if there is a
> simpler way to pull patterns out of a line.
> 
> if i have a line like:
> 
>   here is a sample with 123.456.123.456 in the middle.
> 
> m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> get only the ip address?
> 
> thanks..
> 
> Brian T. Wallace
> Engineer
> 
> 


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.





RE: A Term::ReadKey question -- keep cursor put!

2001-06-14 Thread Dave Newton

> He'd never seen the spinny cursor and was quite impressed - quite sad
really!

*grin*

I'll admit they're cute :)

Great story though; I'll have to remember that as an easy way to impress
people.

Dave




Re: regex matching

2001-06-14 Thread Ken

\d only matches one digithere's a way to extract each number from an ip:
use strict;
my( $ip );
print "Enter a string with an IP:";
$ip = ;
$ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
print "$1\n";
print "$2\n";
print "$3\n";
print "$4\n";

Or if you just want the ip from the line:
use strict;
my( $ip );
print "Enter a string with an IP:";
$ip = ;
$ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
print "The ip is: $1\n";

To just make sure what you have is an ip (and only an ip) is:
m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;



- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:12 AM
Subject: regex matching


> i have a basic knowledge of regex but i want to know if there is a
> simpler way to pull patterns out of a line.
> 
> if i have a line like:
> 
>   here is a sample with 123.456.123.456 in the middle.
> 
> m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> get only the ip address?
> 
> thanks..
> 
> Brian T. Wallace
> Engineer
> 
> 




Re: avoiding duplicates

2001-06-14 Thread Jeff 'japhy' Pinyan

On Jun 14, David Gilden said:

>sub choseColor{
>return int (rand ($#colors + 1));
>}
>
># $#colors + 1 --> better written as  int (rand @colors);
># is this ok, using an @array as in a loop to 
># like:  while ($i < @array) {... do something...; $i++} 

Yes, it's fine.  An array in SCALAR CONTEXT returns its length -- the
number of elements it contains.

># never happens ?!?
>
> print "###dup###\n" if ($color_dup == $color_choice);

It never happens because "#hello" and "#goodbye" have the same NUMERIC
value, 0.  You want to use string comparison here:

  print "dup\n" if $color_dup eq $color_choice;

If you were using warnings (via the -w switch, or the 'use warnings'
pragma in Perl 5.6) you'd be told you were using a string in numerical
context.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




RE: use of split command - concession

2001-06-14 Thread Dave Newton

> OK, I had to try the two ways again to see how much difference it made. I
> created a random contents fixed field file 14500 lines long X 80 columns
> wide, and tried processing the lines (using substr($_,)to
> break lines up into 4 sections, substitute based on a few patterns, and
change a
> couple of columns like I had given in my previous real life example) to
see
> if loading the entire file into an array made as much performance
difference as I had
> thought previously. The difference on a file that size was so small as to
> not be worth mentioning. Either way, it processed the 14,500 line file in
> less than three seconds and wrote the new contents to the new
> file. Granted, I am using a different OS than when I did that test before,
but still, the
> difference was virtually indiscernible. Therefore, I'll concede my point
> about a significant performance difference.

See, the thing is that files are (generally) buffered, so large portions of
the file are being read into memory anyway-your perl program sees it a line
at a time, but the OS doesn't.

Performance will vary depending on how files are implemented in a) that
version
of perl (not having seen the source since... well, waaay too long ago... I
don't
know how abstracted things like that are) and b) the underlying OS.

Dave




RE: regex matching

2001-06-14 Thread John Edwards



This will give you the IP only if valid. I've attached as a file too in case
the code gets mangled.

---
$string = "here is a sample with 123.456.123.456 in the middle.";

if ($string =~
/([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-
4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])/) {

print "String <$string> contains a valid IP <$&>\n";
} else {
print "String <$string> contains no valid IP\n";
}

$string2 = "here is a sample with 123.156.123.156 in the middle.";


if ($string2 =~
/([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-
4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])/) {
print "String2 <$string2> contains a valid IP <$&>\n";
} else {
print "String2 <$string2> contains no valid IP\n";
}
---

John

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 16:12
To: [EMAIL PROTECTED]
Subject: regex matching


i have a basic knowledge of regex but i want to know if there is a
simpler way to pull patterns out of a line.

if i have a line like:

  here is a sample with 123.456.123.456 in the middle.

m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
get only the ip address?

thanks..

Brian T. Wallace
Engineer



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.


 <>  

 test.zip


Re: Slicing and dicing

2001-06-14 Thread Jeff 'japhy' Pinyan

On Jun 14, David Gilden said:

>my ($name,$key,$date) = @_[0..2]

You needn't even use an explicit slice.

  my ($name, $key, $date) = @_;

works fine here, and is generally preferred over large amounts of
shift()s.

If you do need to be destructive to @_, then you might want to
splice() it, instead of shift() it forever.

  my ($name, $key, $date) = splice @_, 0, 3;  # 3 is LENGTH of splice

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Slicing and dicing

2001-06-14 Thread David Gilden

Is one style better then the other here?
Thanks,
Dave
-

sub print_table_rows {
my $name = shift;
my $key = shift;
my $date = shift;
print <

$thread{$key}
$name$date

data


--- alt



sub print_table_rows {
my ($name,$key,$date) = @_[0..2]
print <

$thread{$key}
$name$date

data





Re: regex matching

2001-06-14 Thread Paul


--- [EMAIL PROTECTED] wrote:
> i have a basic knowledge of regex but i want to know if there is a
> simpler way to pull patterns out of a line.
> 
> if i have a line like:
> 
>   here is a sample with 123.456.123.456 in the middle.
> 
> m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> get only the ip address?

m/\d\.\d\.\d\.\d/ won't match on this line at all.
try something like:
   
   my($ip) = $line =~ /(\d\d?\d?\.\d\d?\d?\.\d\d?\d?\.\d\d?\d?)/;

that allows for 1,2,or 3 digit segments, dot seperated.

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/



avoiding duplicates

2001-06-14 Thread David Gilden

Greetings, 

a couple of questions here,
---


# Text colors
@colors = qw[
#F0F8FF #00 #7FFFD4 #F0 #F5F5DC #FFE4C4
#00 #FF #8A2BE2 #A52A2A #5F9EA0 #7FFF00
#FF7F50 #DC143C #00 #8B #008B8B #B8860B  
#FA8072 #F4A460 #2E8B57 #A0522D #6A5ACD #00FF7F 
#4682B4 #D2B48C #008080 #FF6347 #EE82EE #00 
#D2691E
];


# choose a color!
# avoid the same color twice in a row!

sub choseColor{
return int (rand ($#colors + 1));
}

# $#colors + 1 --> better written as  int (rand @colors);
# is this ok, using an @array as in a loop to 
# like:  while ($i < @array) {... do something...; $i++} 


# print out some values

while ($i < 1000 ){

$color_choice = &choseColor;

# never happens ?!?

 print "###dup###\n" if ($color_dup == $color_choice);


print "$color_dup  $color_choice\n";

$color_dup = $color_choice;

$i++;
}

# print some html
print qq|some text\n|;

Looking for Web Talent, You found it!
portfolio: www.coraconnection.com/web/
email: [EMAIL PROTECTED]
tel/fax: (860) 231-9988




RE: This is odd to me - Perl & XML resources

2001-06-14 Thread KURTZ

You shouldn't feel too bad - my company sent me to Perl training and my
instructor (okay, he was a sub) couldn't give me a good definition of
regular expressions!

I think the reason why you see so many different types of discussions here
is that many of us probably work as developers in other languages and are
just learning Perl. From the way things seem to be heading though, learning
XML probably wouldn't be a complete waste of your time. The only book I can
recommend on XML is the little O'Reilly XML Pocket Reference, but there's a
great web site at http://www.w3schools.com/ where you can learn all kinds of
web skills for free including XML (and XSL and SOAP...) and they even give
book reviews at the site. (Nothing on Perl, unfortunately.)

But regarding books on Perl, if you don't mind your books on CD, The Perl CD
Bookshelf from O'Reilly is the best value I've found. You get the complete
text of 6 O'Reilly Perl books on a single CD for $59.95 (US):

Learning Perl, Programming Perl, Perl in a Nutshell, Perl Cookbook, Advanced
Perl Programming, and Learning Perl on Win32 Systems.

You even get the print copy of Perl in a Nutshell which seems to be a pretty
good desk reference. The downside is that you have to be at your computer to
read them and my copy still has the 2nd edition of both Learning Perl &
Programming Perl. But the really nice thing about it is that it's formatted
in HTML and you can search ALL 6 BOOKS in a single shot and take your pick
of what you want to read.

Bob

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 13, 2001 5:32 PM
To: [EMAIL PROTECTED]
Subject: This is odd to me


I read Learn Perl in 24 Hours.  I did the exercises in the book, and I wrote
a couple web pages where you could submit a text file that would be posted
onto the web (i.e. joke of the day sites).  I've written scripts that have
taken
files of lists of labels, compared them, then built a list of the ones that
were
in one an not the other file.  I thought that qualified me as a beginner.
Then
I join this group, and I get discussions of regexes and XML, etc.  I have
no idea what a regex is!  What books have you guys (who I assume are
beginners too, since that's the name of this board) been reading?  Turn
me into a beginner too!

Kirk



RE: Please help me!

2001-06-14 Thread John Edwards

Suggestions.

Don't use a variable called $newvar, call it $form_input or $phone_number or
somthing. Make it descriptive of the value it holds, either the source of
the data or the expected content. It'll make life easier in the long run.

Use a module to inferface with Sendmail. Let it do the hard work of
formatting and interfacing with sendmail, that's what it's there for.

http://www.tneoh.zoneit.com/perl/SendMail/

Where's the code that accepts the input from the form? How are you passing
that data, via POST or GET?

Why use a substr to strip the leading 0? What if there is no leading 0? Try

---
$phone_number = "012345012345";
print "$phone_number\n";

# Next line is all you need
$phone_number =~ s/^0//;

print $phone_number;
---

This strips only a 0, only one of them and only if it's at the very start of
the string.

John

-Original Message-
From: Euan [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 15:54
To: [EMAIL PROTECTED]
Subject: Please help me!


I have been trying to write a script .
a mobile number is entered into a form which is sent to the script,

The script removes the leading 0 then 
adds a +44 in front  and
tacks a @domain.com onto the end.

Then it saves this new number/email to a txt file and automatically sends
out
an e-mail to the +44 (some number)@domain.com e-mail address.

Here is as far as i have got.. Any ideas or help appreciated.

#!/usr/bin/perl -w

$newvar = substr($variable, offset);
$newvar = "+44" . $variable . "\@domain.com";

unless (open(MAIL, "|/path/to/sendmail -t")) {
die(" Failed to talk to sendmail\n");}
print MAIL <<"MAIL1";
To: $recipient
From: $sender
Subject: $subject

$message
MAIL1



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.





regex matching

2001-06-14 Thread Brian . T . Wallace

i have a basic knowledge of regex but i want to know if there is a
simpler way to pull patterns out of a line.

if i have a line like:

  here is a sample with 123.456.123.456 in the middle.

m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
get only the ip address?

thanks..

Brian T. Wallace
Engineer




Please help me!

2001-06-14 Thread Euan

I have been trying to write a script .
a mobile number is entered into a form which is sent to the script,

The script removes the leading 0 then 
adds a +44 in front  and
tacks a @domain.com onto the end.

Then it saves this new number/email to a txt file and automatically sends out
an e-mail to the +44 (some number)@domain.com e-mail address.

Here is as far as i have got.. Any ideas or help appreciated.

#!/usr/bin/perl -w

$newvar = substr($variable, offset);
$newvar = "+44" . $variable . "\@domain.com";

unless (open(MAIL, "|/path/to/sendmail -t")) {
die(" Failed to talk to sendmail\n");}
print MAIL <<"MAIL1";
To: $recipient
From: $sender
Subject: $subject

$message
MAIL1





RE:Telnet

2001-06-14 Thread Fco. Javier Valladolid Hdez.

Hi.

Telnet is a Character based terminal program, you can accessed a remote
terminal from your PC with your IP, ...

I'm believe that Telnet is now defunct , best use SSH, is a similar program,
but it is encrypted, as it provides best security...

Excuse, my english is not very good!

- Original Message -
From: Sally <[EMAIL PROTECTED]>
To: perlcgi <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 7:52 AM
Subject: Telnet


> I've seen lots of references to telnet, but I can't find an explanation of
> what it actually is. Is it similar to FTP?


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




Re: mystery

2001-06-14 Thread Paul


--- Sally <[EMAIL PROTECTED]> wrote:
> I got the following code from a tutorial.

Are you sure you got all of it?
I see a lot of bare HTML, which should send the Perl parser into
predictable spasms even *without* strict (but use strict!!!).

> When I uploaded (FTP) it as a perl
> file I got more errors than you could shake a stick at. When I
> uploaded it
> as an html file it sort of worked, ie it printed out the "Hello
> world" but
> it printed out everything else too. I think I understand why it
> worked as
> html, but I don't understand why it didn't work as perl. Any
> suggestions
> would be appreciated, and if you were the one who wrote this code on
> the
> tutorial, please can you offer suggestions as to why code may fail.
> 
> #!/usr/bin/perl -wT
> 
> use strict;
> 
> &error;

Reading the code below, this is as far as the program would get even if
it *weren't* for the bare HTML!

Where did you get this? =o)

(And Taint checking, too.)
 
> #hellocgi
> 
> print "Content-type: text/html\n\n";
> 
> &error;
> 
> 
> 
> &error;
> 
> 
> Hello, world!
> 
> 
> &error;
> 
> 
> Hello, world!
> 
> 
> &error;
> 
> 
> 
> 
> sub error {
> my( $q, $error_message ) = @_;
> 
> print $q->header( "text/html" ),
>   $q->start_html( "Error" ),
>   $q->h1( "Error" ),
>   $q->p( "Sorry, the following error has occurred: " );
>   $q->p( $q->i( $error_message ) ),
>   $q->end_html;
> exit;
> }
> 


=
print "Just another Perl Hacker\n"; # edited for readability =o)
=
Real friends are those whom, when you inconvenience them, are bothered less by it than 
you are. -- me. =o) 
=
"There are trivial truths and there are great Truths.
 The opposite of a trival truth is obviously false.
 The opposite of a great Truth is also true."  -- Neils Bohr

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/



Re: Huge hash ... running out of memory without warning???

2001-06-14 Thread Brett W. McCoy

On Thu, 14 Jun 2001, Paul wrote:

> dbm's are *wonderful* for some data, but not for dynamically accessing
> complex data structures. This only stores the top level, which *points*
> to actual data further down the chain at the time of the program run. :o/

Right.  In a later message, I suggested he use MLDBM, which is better at
handling more complex data structures.

-- Brett
   http://www.chapelperilous.net/btfwk/

Generic Fortune.




Re: Huge hash ... running out of memory without warning???

2001-06-14 Thread Paul


--- "Brett W. McCoy" <[EMAIL PROTECTED]> wrote:
> On Wed, 13 Jun 2001, Bryan Gmyrek wrote:
> 
> > I have just written a program that makes an array of hashes of
> hashes of
> > hashes.  It reads all kind of information in from a bunch of files
> and
> > then later I access the elements of this thing in a convienient way
> > because it's kind of like a little database.  Anyways, I end up
> printing
> > everything out into a very big html table.  I noticed that
> *sometimes*
> > nothing is printed  when I say 'print this part of that array...'
> > Thought it was a bug in the code, but then I ran the program on a
> > machine with more memory and *now* the elements that were missing
> > previously are printed, but some 'further on down the line' are
> not.  It
> > seems that the computer is running out of memory and at some point
> no
> > data really gets added to this monster of a list of lists...  What
> the
> > heck should I do so that I can perform these functions, but not run
> into
> > this problem of running out of memory?
> 
> You might want to look into using DB_File -- your hash will use your
> disk
> as a sort of 'virtual memory', plus your hash will be persistent
> between
> calls of your script:
> 
> use DB_File;
> tie %myhash, "DB_File", $filename or die "Can't open $filename$!\n";
> #do stuff to gather data
> $myhash{$somekey} = $somevalue;
> #do more stuff with your data
> untie %myhash;

dbm's are *wonderful* for some data, but not for dynamically accessing
complex data structures. This only stores the top level, which *points*
to actual data further down the chain at the time of the program run. :o/

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/



Re: map question

2001-06-14 Thread Paul


--- [EMAIL PROTECTED] wrote:
> context". How do you evaluate a block in scalar context? Any light on
> this  ( or a pointer ) maybe?

  print { *STDOUT } "foo\n";

This is looking at the block to return the filehandle to which the
output should go. Surely that argument is in a scalar context, seperate
from the printables?

If not, I'd love to see an example myself.
Wouldn't any block tend to fall back to the context in which it was
called? They're just usually void because nobody cares what they're
context is, or list because they're in a grep/map/split/etc. which
works on lists.

Comments?
Edification?

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/



RE: Problem printing a system value to a filehandle (windows)

2001-06-14 Thread JColwell

And add 1 to the month value.

The months are returned 0 to 11 (Jan to Dec).

Jeff Colwell
Senior Software Engineer
No electrons were harmed in making this e-mail message.


-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 9:12 AM
To: Mark Folse
Cc: Craig S Monroe; [EMAIL PROTECTED]
Subject: Re: Problem printing a system value to a filehandle (windows)


On Thu, 14 Jun 2001, Mark Folse wrote:

> I started out doing the same thing on my NT box many moons ago, and
> found this more reliable and easier to manage:
>
> ($day,$month,$date,$time,$year)=split (/ /,localtime);

localtime can also be used directly in a list context, for more
flexibility:

my ($day, $month, $year) = (localtime)[3,4,5];

You just have to remember to add 1900 to the year value!

-- Brett
   http://www.chapelperilous.net/btfwk/

He knows not how to know who knows not also how to unknow.
-- Sir Richard Burton




Re: Problem printing a system value to a filehandle (windows)

2001-06-14 Thread Brett W. McCoy

On Thu, 14 Jun 2001, Mark Folse wrote:

> I started out doing the same thing on my NT box many moons ago, and
> found this more reliable and easier to manage:
>
> ($day,$month,$date,$time,$year)=split (/ /,localtime);

localtime can also be used directly in a list context, for more
flexibility:

my ($day, $month, $year) = (localtime)[3,4,5];

You just have to remember to add 1900 to the year value!

-- Brett
   http://www.chapelperilous.net/btfwk/

He knows not how to know who knows not also how to unknow.
-- Sir Richard Burton





Re: Problem printing a system value to a filehandle (windows)

2001-06-14 Thread Mark Folse

I started out doing the same thing on my NT box many moons ago, and
found this more reliable and easier to manage:

($day,$month,$date,$time,$year)=split (/ /,localtime);

--- Craig S Monroe <[EMAIL PROTECTED]> wrote:
> I decided that I wanted to time stamp each of
> the entries
> 
> >  $time =~ system('TIME \/T');
>  $date =~ system('DATE \/T');
>  print DATAFILE "\n$time $date";
> 


=

-
Notice: This e-mail is protected by the U.S. Constitution and the U.N. Declaration of 
Human Rights. Unauthorized interception by any public or private agency is an ugly 
sort of work to be in. Does your mother know you spend your days reading other 
people's mail? Would she be proud of you?

-
Please visit: http://clubs.yahoo.com/clubs/district41democrats

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/



RE: Telnet

2001-06-14 Thread Doug Johnson

Telnet is a method used to communicate to another machine. You use telnet to
access a terminal window on a remote machine. It is as if you were sitting
at the console of that machine (character based).  You cannot however
transfer files through telnet. You would use ftp to do that with. It is
somewhat basic but very widely used. 

If you are using a Windows machine open up a dos window and type telnet and
press enter. This invokes the telnet application and from there you can do a
help and topics to find a vary basic description of its operation.  If you
are on a UNIX or Linux machine it becomes very powerful. Do a "man telnet"
or "info telnet" and see all of the options. It will give you a little more
detail of its use.

But basically it is just an access window to a remote machine. 

Best Regards,
Doug


 -Original Message-
From:   Sally [mailto:[EMAIL PROTECTED]] 
Sent:   Thursday, June 14, 2001 9:18 AM
To: perl
Subject:FW: Telnet



-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 13:53
To: perlcgi
Subject: Telnet


I've seen lots of references to telnet, but I can't find an explanation of
what it actually is. Is it similar to FTP?



RE: Telnet

2001-06-14 Thread Sally

Thanks guys, that's exactly what I needed to know (the lack of technical
terms was fab!!!)

-Original Message-
From: n6tadam [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 14:21
To: Sally; perl
Subject: Re: Telnet


Hi,

Telnet, gives you the ability to access a remote machine across a network,
however, I would advise against using telnet. Instead, I recommend using SSH
(Secure SHell), which is much more secure.

Regards,

Thomas Adam

- Original Message -
From: Sally <[EMAIL PROTECTED]>
To: perl <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 2:17 PM
Subject: FW: Telnet


>
>
> -Original Message-
> From: Sally [mailto:[EMAIL PROTECTED]]
> Sent: 14 June 2001 13:53
> To: perlcgi
> Subject: Telnet
>
>
> I've seen lots of references to telnet, but I can't find an explanation of
> what it actually is. Is it similar to FTP?
>
>
>


Please note that the content of this message is confidential between the
original sender and the intended recipient(s) of the message. If you are not
an intended recipient and/or have received this message in error, kindly
disregard the content of the message and return it to the original sender.

If you have any complaints about this message please reply to:
   [EMAIL PROTECTED]

The Purbeck School E-Mail server running:
   users.purbeck.dorset.sch.uk




Re: Telnet

2001-06-14 Thread EDonnelly


Net Term is quite good.



   
  
"n6tadam"  
  
<[EMAIL PROTECTED]To: "Sally" 
<[EMAIL PROTECTED]>, "perl" <[EMAIL PROTECTED]> 
et.sch.uk> cc: 
  
   Subject: Re: Telnet 
  
14/06/01 14:21 
  
   
  
   
  



Hi,

Telnet, gives you the ability to access a remote machine across a network,
however, I would advise against using telnet. Instead, I recommend using
SSH
(Secure SHell), which is much more secure.

Regards,

Thomas Adam

- Original Message -
From: Sally <[EMAIL PROTECTED]>
To: perl <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 2:17 PM
Subject: FW: Telnet


>
>
> -Original Message-
> From: Sally [mailto:[EMAIL PROTECTED]]
> Sent: 14 June 2001 13:53
> To: perlcgi
> Subject: Telnet
>
>
> I've seen lots of references to telnet, but I can't find an explanation
of
> what it actually is. Is it similar to FTP?
>
>
>


Please note that the content of this message is confidential between the
original sender and the intended recipient(s) of the message. If you are
not an intended recipient and/or have received this message in error,
kindly disregard the content of the message and return it to the original
sender.

If you have any complaints about this message please reply to:
   [EMAIL PROTECTED]

The Purbeck School E-Mail server running:
   users.purbeck.dorset.sch.uk








Re: Telnet

2001-06-14 Thread n6tadam

Hi,

Telnet, gives you the ability to access a remote machine across a network,
however, I would advise against using telnet. Instead, I recommend using SSH
(Secure SHell), which is much more secure.

Regards,

Thomas Adam

- Original Message -
From: Sally <[EMAIL PROTECTED]>
To: perl <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 2:17 PM
Subject: FW: Telnet


>
>
> -Original Message-
> From: Sally [mailto:[EMAIL PROTECTED]]
> Sent: 14 June 2001 13:53
> To: perlcgi
> Subject: Telnet
>
>
> I've seen lots of references to telnet, but I can't find an explanation of
> what it actually is. Is it similar to FTP?
>
>
>


Please note that the content of this message is confidential between the original 
sender and the intended recipient(s) of the message. If you are not an intended 
recipient and/or have received this message in error, kindly disregard the content of 
the message and return it to the original sender.

If you have any complaints about this message please reply to:
   [EMAIL PROTECTED]

The Purbeck School E-Mail server running:
   users.purbeck.dorset.sch.uk




FW: Telnet

2001-06-14 Thread Sally



-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 13:53
To: perlcgi
Subject: Telnet


I've seen lots of references to telnet, but I can't find an explanation of
what it actually is. Is it similar to FTP?




Re: Lazy lists in Perl ?

2001-06-14 Thread Jeff 'japhy' Pinyan

On Jun 14, Evgeny Goldin (aka Genie) said:

>Is there any module implementing lazy lists ? ( similar to "infinite
>lists" of Scheme or "sequences" of ML )
>
>I've coded a small prototype of this thing using tied array, so
>it's good time to stop or dig into further development ..

It sounds like what you want is a self-generating list.  Mark-Jason
Dominus just mentioned this technique in a talk he did yesterday at YAPC,
so it's fresh in my mind.

You probably want to make some sort of iterator.  It will return a value,
and then use the generator function to get its next value for the next
time you call it.

This is going to be using closures, so you might want to read up on some
documentation (start at perldoc -q closure, and work from there).

  sub make_stream {
my ($val, $generate) = @_;
$generate ||= sub { $val + 1 };
return sub {
  my $x = $val;
  $val = $generate->();
  return $x;
};
  }

Now you can make streams.  The default stream is to just keep adding 1 to
the previous value.

  $counter = make_stream(1);  # integers starting at 1
  $rand_ints = make_stream(   # random integers from 1 to 10
1 + int rand 10,
sub { 1 + int rand 10 },
  );
  # and so on

Then to use them, you can just do:

  while (1) {
$next_val = $counter->();
# ...
  }

Hope this helps! :)

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




RE: mystery

2001-06-14 Thread Sally

Forgot to say "thanks for your time"

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:58
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


Sorry guys still no luck, I'm gonna knock this one on the head, and abandon
that tutorial.

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:47
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


No. Using the print <


Hello, world!



Hello, world!




HERE_DOC

--- Cut here ---

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:32
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


This is what I uploaded and it still didn't work

#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print "<";

print"";
print"Hello, world!";
print"";

print"";
print"Hello, world!";
print"";

print"";

print"HERE_DOC";

Thanks for the print ""; tip, I just wish whoever wrote the tutorial had
said that.

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:15
To: 'Sally'; John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


OK. I think I see it now. Your script has errors in it.

Try the following:


--- Cut here ---
#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print <


Hello, world!



Hello, world!




HERE_DOC

--- Cut here ---


The web server is parsing the file as a perl script. You have syntax errors
in your Perl script (All the HTML tags, for Perl to parse them in the way
you intend you need to write them as
print "";

and
print "<\/HTML";

etc

By entering the HTML in your code as a "here" document in the perl script,
it's printed out by Perl as is.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:05
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


Yeah it's right, it's the one I've got from our hosts

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:04
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Is the path the the perl exe correct? Note, copy the list in on your mails.

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:00
To: John Edwards
Subject: RE: mystery


It has recognised .pl scripts in the past (i.e. last week), I do have access
to the error log, unfortunatly it only seems to update itself a couple of
times a day as opposed to everytime it encounters an error

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:58
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you

RE: mystery

2001-06-14 Thread Sally

Sorry guys still no luck, I'm gonna knock this one on the head, and abandon
that tutorial.

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:47
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


No. Using the print <


Hello, world!



Hello, world!




HERE_DOC

--- Cut here ---

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:32
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


This is what I uploaded and it still didn't work

#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print "<";

print"";
print"Hello, world!";
print"";

print"";
print"Hello, world!";
print"";

print"";

print"HERE_DOC";

Thanks for the print ""; tip, I just wish whoever wrote the tutorial had
said that.

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:15
To: 'Sally'; John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


OK. I think I see it now. Your script has errors in it.

Try the following:


--- Cut here ---
#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print <


Hello, world!



Hello, world!




HERE_DOC

--- Cut here ---


The web server is parsing the file as a perl script. You have syntax errors
in your Perl script (All the HTML tags, for Perl to parse them in the way
you intend you need to write them as
print "";

and
print "<\/HTML";

etc

By entering the HTML in your code as a "here" document in the perl script,
it's printed out by Perl as is.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:05
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


Yeah it's right, it's the one I've got from our hosts

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:04
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Is the path the the perl exe correct? Note, copy the list in on your mails.

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:00
To: John Edwards
Subject: RE: mystery


It has recognised .pl scripts in the past (i.e. last week), I do have access
to the error log, unfortunatly it only seems to update itself a couple of
times a day as opposed to everytime it encounters an error

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:58
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, wor

RE: mystery

2001-06-14 Thread John Edwards

Hmm not sure what that is. Others on the list may have a better idea.

My suggestion is to learn about the CGI.pm module. If you are going to be
doing a lot of web and cgi perl coding, this module is a must.

You can find more details here.

http://www.wiley.com/legacy/compbooks/stein/

I stongly suggest you buy the book that Lincoln Stein (the authour of the
CGI.pm module) wrote. It's well written and full of good examples to get you
using the module effectively, even if you have no previous CGI experience.

http://www.whsmith.co.uk/WHS/Go.asp?isbn=0471247448&DB=220
http://www.bookpool.com/.x/mq8xcmafmm/ss/1?qs=cgi.pm

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:45
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery



Since using your suggestion, my list of errors has significantly reduced to:

[Thu Jun 14 05:27:55 2001] [error] [client 213.123.194.47] Premature end of
script headers: xyz./xyzxyz.../../cgihello.pl
failed to open log file
fopen: Permission denied


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.





RE: mystery

2001-06-14 Thread John Edwards

No. Using the print <


Hello, world!



Hello, world!




HERE_DOC

--- Cut here ---

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:32
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


This is what I uploaded and it still didn't work

#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print "<";

print"";
print"Hello, world!";
print"";

print"";
print"Hello, world!";
print"";

print"";

print"HERE_DOC";

Thanks for the print ""; tip, I just wish whoever wrote the tutorial had
said that.

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:15
To: 'Sally'; John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


OK. I think I see it now. Your script has errors in it.

Try the following:


--- Cut here ---
#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print <


Hello, world!



Hello, world!




HERE_DOC

--- Cut here ---


The web server is parsing the file as a perl script. You have syntax errors
in your Perl script (All the HTML tags, for Perl to parse them in the way
you intend you need to write them as
print "";

and
print "<\/HTML";

etc

By entering the HTML in your code as a "here" document in the perl script,
it's printed out by Perl as is.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:05
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


Yeah it's right, it's the one I've got from our hosts

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:04
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Is the path the the perl exe correct? Note, copy the list in on your mails.

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:00
To: John Edwards
Subject: RE: mystery


It has recognised .pl scripts in the past (i.e. last week), I do have access
to the error log, unfortunatly it only seems to update itself a couple of
times a day as opposed to everytime it encounters an error

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:58
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, world!


&error;




sub error {
my( $q, $error_message ) = @_;

print $q->header( "text/html" ),
  $q->start_html( "Error" ),
  $q->h1( "Error" ),
  $q->p( "Sorry, the following error has occurred: " );
  $q->p( 

RE: mystery

2001-06-14 Thread Sally


Since using your suggestion, my list of errors has significantly reduced to:

[Thu Jun 14 05:27:55 2001] [error] [client 213.123.194.47] Premature end of
script headers: xyz./xyzxyz.../../cgihello.pl
failed to open log file
fopen: Permission denied




RE: mystery

2001-06-14 Thread Richard_Cox

John Edwards [mailto:[EMAIL PROTECTED]] wrote:
> 
> OK. I think I see it now. Your script has errors in it.

Beat me to it... :-)

but...

> The web server is parsing the file as a perl script. You have 
> syntax errors
> in your Perl script (All the HTML tags, for Perl to parse 
> them in the way
> you intend you need to write them as 
>   print "";
> 
> and 
>   print "<\/HTML";

Shouldn't that be

print '';

There's no need to escape slashes (I assume the missing '>' was a typo), and
using single quotes avoids most processing of the content of the string.



Richard Cox
Senior Software Developer
Dell Technology Online
All opinions and statements mine and do not in any way (unless expressly
stated) imply anything at all on behalf of my employer



Lazy lists in Perl ?

2001-06-14 Thread Evgeny Goldin (aka Genie)


  Hi,

Is there any module implementing lazy lists ? ( similar to "infinite
lists" of Scheme or "sequences" of ML )

I've coded a small prototype of this thing using tied array, so
it's good time to stop or dig into further development ..

 Thank you !





Reading Messages.tbb

2001-06-14 Thread Evgeny Goldin (aka Genie)


  Hi,

 As I saw some of you are using "TheBat!" mail client, me too.
 I'd like to be able to read it's messages from the script - for that
 I have to know the binary format of "Messages.tbb" files where it keeps
 them.
 Those files are partially plain text, partially binary data.
 It's tempting to read them as plain text but I have a strong feeling
 that it's a bad way ..
 So, is there any module dealing with this format out there ?





RE: mystery

2001-06-14 Thread Sally

This is what I uploaded and it still didn't work

#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print "<";

print"";
print"Hello, world!";
print"";

print"";
print"Hello, world!";
print"";

print"";

print"HERE_DOC";

Thanks for the print ""; tip, I just wish whoever wrote the tutorial had
said that.

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:15
To: 'Sally'; John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


OK. I think I see it now. Your script has errors in it.

Try the following:


--- Cut here ---
#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print <


Hello, world!



Hello, world!




HERE_DOC

--- Cut here ---


The web server is parsing the file as a perl script. You have syntax errors
in your Perl script (All the HTML tags, for Perl to parse them in the way
you intend you need to write them as
print "";

and
print "<\/HTML";

etc

By entering the HTML in your code as a "here" document in the perl script,
it's printed out by Perl as is.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:05
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


Yeah it's right, it's the one I've got from our hosts

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:04
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Is the path the the perl exe correct? Note, copy the list in on your mails.

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:00
To: John Edwards
Subject: RE: mystery


It has recognised .pl scripts in the past (i.e. last week), I do have access
to the error log, unfortunatly it only seems to update itself a couple of
times a day as opposed to everytime it encounters an error

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:58
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, world!


&error;




sub error {
my( $q, $error_message ) = @_;

print $q->header( "text/html" ),
  $q->start_html( "Error" ),
  $q->h1( "Error" ),
  $q->p( "Sorry, the following error has occurred: " );
  $q->p( $q->i( $error_message ) ),
  $q->end_html;
exit;
}


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the i

RE: mystery

2001-06-14 Thread John Edwards

OK. I think I see it now. Your script has errors in it.

Try the following:


--- Cut here ---
#!/usr/bin/perl -wT

use strict;

#hellocgi

print "Content-type: text/html\n\n";

print <


Hello, world!



Hello, world!




HERE_DOC

--- Cut here ---


The web server is parsing the file as a perl script. You have syntax errors
in your Perl script (All the HTML tags, for Perl to parse them in the way
you intend you need to write them as 
print "";

and 
print "<\/HTML";

etc

By entering the HTML in your code as a "here" document in the perl script,
it's printed out by Perl as is.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:05
To: John Edwards; Perl Beginners (E-mail)
Subject: RE: mystery


Yeah it's right, it's the one I've got from our hosts

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:04
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Is the path the the perl exe correct? Note, copy the list in on your mails.

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:00
To: John Edwards
Subject: RE: mystery


It has recognised .pl scripts in the past (i.e. last week), I do have access
to the error log, unfortunatly it only seems to update itself a couple of
times a day as opposed to everytime it encounters an error

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:58
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, world!


&error;




sub error {
my( $q, $error_message ) = @_;

print $q->header( "text/html" ),
  $q->start_html( "Error" ),
  $q->h1( "Error" ),
  $q->p( "Sorry, the following error has occurred: " );
  $q->p( $q->i( $error_message ) ),
  $q->end_html;
exit;
}


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictl

Re: php -> perl

2001-06-14 Thread Hasanuddin Tamir

On Wed, 13 Jun 2001, Michael Cartwright <[EMAIL PROTECTED]> wrote,

> However, I need it in Perl. Could someone help me with what would this look
> like in Perl?
>
> Thanks,
> Michael
>
>   $FileName=$HTTP_GET_VARS["FileName"];
>
>  if(!$FileName)
>  {
>   $FileName="example";
>  }
>  $FileName.=".opx";
>  header("Content-type: application/x-opx");
>  readfile($FileName);
> ?>

#!/usr/bin/perl -w

use strict;
use CGI ':standard';

my $file = param('FileName') || 'example';
$file .= '.opx';

if (open OPX, $file) {
print header(type => 'application/x-opx');
print ;
close OPX;
}
else {
print
header,
start_html('Error'),
b('Sorry, got problem when showing the content'),
end_html;
print STDERR "failed to read $file: $!\n"; # goes to error log
}

__END__

-- 
s::a::n->http(www.trabas.com)




RE: mystery

2001-06-14 Thread Sally

Yeah it's right, it's the one I've got from our hosts

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:04
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Is the path the the perl exe correct? Note, copy the list in on your mails.

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:00
To: John Edwards
Subject: RE: mystery


It has recognised .pl scripts in the past (i.e. last week), I do have access
to the error log, unfortunatly it only seems to update itself a couple of
times a day as opposed to everytime it encounters an error

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:58
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, world!


&error;




sub error {
my( $q, $error_message ) = @_;

print $q->header( "text/html" ),
  $q->start_html( "Error" ),
  $q->h1( "Error" ),
  $q->p( "Sorry, the following error has occurred: " );
  $q->p( $q->i( $error_message ) ),
  $q->end_html;
exit;
}


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the

RE: mystery

2001-06-14 Thread Sally



-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:58
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, world!


&error;




sub error {
my( $q, $error_message ) = @_;

print $q->header( "text/html" ),
  $q->start_html( "Error" ),
  $q->h1( "Error" ),
  $q->p( "Sorry, the following error has occurred: " );
  $q->p( $q->i( $error_message ) ),
  $q->end_html;
exit;
}


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.





RE: mystery

2001-06-14 Thread John Edwards

Is the path the the perl exe correct? Note, copy the list in on your mails.

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 11:00
To: John Edwards
Subject: RE: mystery


It has recognised .pl scripts in the past (i.e. last week), I do have access
to the error log, unfortunatly it only seems to update itself a couple of
times a day as opposed to everytime it encounters an error

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:58
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, world!


&error;




sub error {
my( $q, $error_message ) = @_;

print $q->header( "text/html" ),
  $q->start_html( "Error" ),
  $q->h1( "Error" ),
  $q->p( "Sorry, the following error has occurred: " );
  $q->p( $q->i( $error_message ) ),
  $q->end_html;
exit;
}


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and del

RE: mystery

2001-06-14 Thread John Edwards

OK. Do you have access to the server logs? Have you tried naming the file
hellocgi.cgi (The web server may be configured to recognise CGI scripts only
if they have the .cgi extension)

Does your webserver support running CGI scripts?

John

P.S Please cc the mailing list when you reply. There may be others following
this thread who also have the same problem or input on a solution.

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:54
To: John Edwards
Subject: RE: mystery


the perl one is www.servon.uk.com/cgi-bin/hellocgi.pl
the html one is ..hellocgi.html

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:50
To: 'Sally'; Perl Beginners (E-mail)
Subject: RE: mystery


Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, world!


&error;




sub error {
my( $q, $error_message ) = @_;

print $q->header( "text/html" ),
  $q->start_html( "Error" ),
  $q->h1( "Error" ),
  $q->p( "Sorry, the following error has occurred: " );
  $q->p( $q->i( $error_message ) ),
  $q->end_html;
exit;
}


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.





Re: Help needed with setting up a SMTP connection

2001-06-14 Thread Adrienne Kotze

Michael Fowler wrote:
> 
> On Thu, Jun 14, 2001 at 08:30:14AM +0200, Adrienne Kotze wrote:
> > $mailer = Mail::Mailer->new ("smtp", "smtp.mydomain.com") ;
> 
> This should be:
> 
> $mailer = Mail::Mailer->new("smtp", Server => "smtp.mydomain.com");

Thanx, this works great. So it would appear that the Cookbook has got a typo.

Just one last thing: If I move my code to ActiveState on NT, I get the
following:

Invalid argument at lib/Mail/Mailer.pm line 270.

Any ideas ?
-- 
Adrienne Kotze -  Technical Consultant - Sintrex Integration Service
Mobile: +27 83 269 6725 - Facsimile: +27 83 8 269 6725
mailto:[EMAIL PROTECTED]




RE: mystery

2001-06-14 Thread John Edwards

Can you give me the URL of this file?

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:41
To: John Edwards
Subject: RE: mystery


That has all been done, and the file was uploaded in ascii mode and not
binary

-Original Message-
From: John Edwards [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 10:19
To: 'Sally'; perl
Subject: RE: mystery


What operating system does the webserver run? If it's Unix or similar you
need to set the properties of the file so that all user can execute the
file. Normally you'll want to chmod the file to a value of 755.

See this for some more details http://www.waferthin.com/manual/manual5.html

The server also needs to be configured to run CGI scripts. Normally you'll
have to place your file in the cgi-bin directory of your site and give it an
extension of .cgi or .pl

HTH

John

-Original Message-
From: Sally [mailto:[EMAIL PROTECTED]]
Sent: 14 June 2001 09:54
To: perl
Subject: mystery


I got the following code from a tutorial. When I uploaded (FTP) it as a perl
file I got more errors than you could shake a stick at. When I uploaded it
as an html file it sort of worked, ie it printed out the "Hello world" but
it printed out everything else too. I think I understand why it worked as
html, but I don't understand why it didn't work as perl. Any suggestions
would be appreciated, and if you were the one who wrote this code on the
tutorial, please can you offer suggestions as to why code may fail.

#!/usr/bin/perl -wT

use strict;

&error;

#hellocgi

print "Content-type: text/html\n\n";

&error;



&error;


Hello, world!


&error;


Hello, world!


&error;




sub error {
my( $q, $error_message ) = @_;

print $q->header( "text/html" ),
  $q->start_html( "Error" ),
  $q->h1( "Error" ),
  $q->p( "Sorry, the following error has occurred: " );
  $q->p( $q->i( $error_message ) ),
  $q->end_html;
exit;
}


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.





RE: A Term::ReadKey question -- keep cursor put!

2001-06-14 Thread Pate Mark-marpate1

What, you don't find spinny cursors interesting anymore?

Strange that you should bring this up, only last week I was using the spinny
cursor concept to explain to a colleague how to continually auto-scoll text
in a browser window using the technique similar to

my @windmill=("\\", "\|", "\/", "\-");   # Not sure if I need to escape all
of these
printf "%s\r",$windmill[$_ & 3] for (0..1);

He'd never seen the spinny cursor and was quite impressed - quite sad
really!

Mark
--
GPRS Core Network Lead Engineer

-Original Message-
From: Dave Newton [mailto:[EMAIL PROTECTED]]
Sent: 13 June 2001 19:33
To: [EMAIL PROTECTED]
Subject: RE: A Term::ReadKey question -- keep cursor put!


Bear in mind that without any sort of delay it's unlikely
you'll be able to see any of this occuring.

Ah, the good old days, where a 300-baud modem was fast
and little spinny cursors were still interesting. *sigh*

Dave

--
Dave Newton, [EMAIL PROTECTED]



  1   2   >