Re: use of modules with authorize.net

2001-06-21 Thread fliptop

Susanne wrote:
 
 does anyone have sample code that would educate me on credit card
 processing with authorize.net?  tia.

try this module from cpan:

http://search.cpan.org/search?dist=Business-OnlinePayment-AuthorizeNet



System Control

2001-06-21 Thread Thanh To

Hi All,

Does anyone know why Perl did not get back the system control after called 
the Java's Applet?  I'm using the system command:

system (java HelloJava);

And the problem is: Perl did not execute any of the following lines after 
that. I'd like to know why.

Thanks in advance!

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




Re: need code

2001-06-21 Thread Alen Sarkinovic

I only had problems with executing script from web.
It's for sure that I will blok any char ,accept numbers letters and
underline.
My problem was ,that I coudn't force script to accept variable input and
execute command  (from web).
now everything works fine,it was mestake in command syntax.

Thanks
Alen

- Original Message -
From: Curtis Poe [EMAIL PROTECTED]
To: Camilo Gonzalez [EMAIL PROTECTED]; 'Alen Sarkinovic'
[EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, June 20, 2001 9:40 PM
Subject: RE: need code


 --- Camilo Gonzalez [EMAIL PROTECTED] wrote:
  try
 
  system (/bin/somecommand $variable);
 
  or even
 
  `somecommand $variable`;
 
  -Original Message-
  From: Alen Sarkinovic [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, June 20, 2001 2:11 PM
  To: [EMAIL PROTECTED]
  Subject: need code
 
 
  Hi
  Can anybody send me code of perl that will take input from web and
execute
  Unix command ,I mean SYSTEM(/bin/somecommand $variable)
 
  I have try everything but still  not able to execute from web
,everything
  goes fine from command line :perl -T script.pl variable=blabla


 Be very, very careful about this!  It's extremely dangerous to run
arbitrary commands with
 system().  If you already know the command you want to run, try using the
multiple argument form
 of system (untested code):

 #/usr/bin/perl -wT
 use strict;
 use CGI qw/:standard/;

 my $program= '/bin/somecommand';
 my $dirty_variable = param( 'variable' );

 # untaint the variable
 # you'll need to create your own regex if \w+ does not
 # meet your needs
 my ( $variable ) = ( $dirty_variable =~ /^(\w+)$/ );

 if ( ! $variable ) { some_error_routine( $variable ) }

 my $bad_status = system( $program, $variable );

 if ( $bad_status ) { die $program returned a bad error code: $? }

 Using the multiple argument form of 'system' forces the arguments to be
passed to the program and
 not to the shell, where they could be interpreted in unexpected (and
possibly dangerous) ways.

 Absolutely do NOT use backticks unless it is critical that you capture the
output of the command.
 Backticks are extremely dangerous if you are allowing any user data near
the shell.

 Cheers,
 Curtis Poe

 =
 Senior Programmer
 Onsite! Technology (http://www.onsitetech.com/)
 Ovid on http://www.perlmonks.org/

 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail
 http://personal.mail.yahoo.com/




Re: Re: Running CGI's locally

2001-06-21 Thread Mel Matsuoka

At 12:10 PM 06/20/2001 +0200, Aaron Craig wrote:

At the office, I'm running Apache 1.3 locally on Win2000, and I don't have 
to use the shebang line, as I have Perl in my path.  However, I just 
installed Apache on my Win2000 machine at home, using the current Apache 
installation for Windows (ends with an .msi extension) found on 
www.apache.org.  Now, I need to use the shebang line, using Windows style 
paths (ie C:/perl/perl.exe).  I vaguely remember adding a registry entry by 
hand to get Apache running Perl on my Win2000 here in the office, which I 
didn't do on my computer at home.  Is that what I'm missing, or has Apache 
changed and now requires the shebang line on Windows as well.

Thw Win32 port of apache has the ScriptInterpreterSource directive which
you must uncomment in the httpd.conf file in order for it to ignore the
shebang lines and use the file associations set in the windows registry.

This is such a great convinience for developing perl scripts on a windows
box that have to be deployed on a unix box. I cant tell you how many times
I've torn my hair out, debugging and trying to figure out why my win32
developed scripts bomb out on my unix boxen...when the problem was just
that I forgot to change the shebang line to point to the unix perl path!

Aloha,
mel



__
mel matsuokaHawaiian Image Productions
Chief Executive Alphageek  (vox)1.808.531.5474
[EMAIL PROTECTED]  (fax)1.808.526.4040



RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Moon, John

Here the code (is this what you wanted ?) but from Mel's reply looks like
the problem could be the endform 


use strict;
use CGI qw(:standard :all *table);
use vars qw($dbh $REQUEST) ;# global !
use DBI;
use Cwd;
my $CGI_HOME=cwd();# get $home
# use lib /opt/common/html/actual/cgi-bin/Library;
use lib Library;
require MyConnect;
use MyCategories;
#
#   (keywd,value) for estimates are:
#   FY=30-Jun-  - The fiscal year of the Estimate
#   ACCT=varchar2(15)   - Account to Input/View
#   CUST_ID=number(10)  - Customer to View, ACCT will be undef
#   ACTION=(ACCOUNT,CUSTOMER) - What type of Action is required
#   if ACTION is by CUSTOMER then nothing to UPDATE
#   INITIAL=(NO,YES)  - If YES or exist then display blank form
#   TYPE=(SUBMIT,NEXT)  - If NEXT display ONLY - this hidden value
#   will be set by client side script
#
#   To display the initial form from the call line enter the url plus:
#   INITIAL=YES. This will display a blank form PLUS and explanation.
#   defining expected values ... will replace with submitted
#
my %REQUEST = (FY   ='',
ACCT='',
CUST_ID='',
ACTION  ='ACCOUNT',
VIEW='CATEGORY',
INITIAL ='');
my $q=new CGI;
#
my $status; # the results of request
#
#   return submitted values, replacing default if present ...
#
foreach ($q-param) {
$REQUEST{$_}=$q-param($_);
}
if ($q-param('INITIAL') eq 'YES') {
$REQUEST{INITIAL}='YES';
BuildForm();
}
else {
$REQUEST{INITIAL}='NO'; 
ProcessForm();
# my (@request,$keywd);
# @request=$main::q-param;
#   foreach $keywd (@request) {
#   print $q-header(-type=text/html),
#   $q-start_html('Dump of Estimates by TechDirect');
#   print $q-dump();
#   print 'PMy values are:BR';
#   my $keywd;
#   foreach $keywd (keys %REQUEST) {
#   print $keywd = $REQUEST{$keywd}BR;
#   }
#   print $q-end_html;
}
# ===
sub BuildForm {
use strict;
use MyYTD;
use MyEstbyCat;
my (%YTD, %EST, %CATEGORY, %PRODUCT);
my ($YTD, $EST, $CATEGORY, $PRODUCT);
my $q=new CGI;
print $q-header(text/html),
#   'HTMLHEADTITLEEstimates by TechDirect/TITLE',
#   'BASE NAME=main',
#   '/HEADBODY';
$q-start_html({-title='Estimates by TechDirect',-base='main'});
print \n;
#
#   form for navigation, initial and subsequent request to
#   see another account or customer ...
#
print $q-startform({-target=main}),
center(h3('TechDirect Estimates'));
print \n;
my ($fy,$database, @setup, %sth, $category, $ytd, $est);
my ($title,$acct,$cust_id,$status,$year,$prev_fy);
$title='';
$acct='';
$cust_id='';
#
#   Example  Explanation:
#
#   If the fiscal year being requested is 2001-2002
#   then the fiscal year of the date from the YTD Table and the previous
#   Estimate will be for fiscal year 2000-2001 (or 30-Jun-2001)
#
if ($REQUEST{INITIAL} eq 'NO') {
#
#   converting (1)-(2) to 30-Jun-(2)
$fy=Internal_FY($REQUEST{FY});
}
else {
my $year;
(undef,undef,undef,undef,undef,$year)=localtime;
$REQUEST{FY}=sprintf(%4d-%4d,1900 + $year, 1901 + $year);
$fy=Internal_FY($REQUEST{FY});
}
$prev_fy='30-Jun-' . substr($REQUEST{FY},0,4);
print center(font({-size=3},'Fiscal Year'),
$q-textfield(  -name='FY',
-default=$REQUEST{FY},
-size=9,
-maxlength=9));
print \n;
$database=MyConnect();  # returns the database handle !
@setup = MyCategory($database, 1);  #prepare and returns ref to rows,
initial
($sth{CATEGORY}, $category)=@setup;
$CATEGORY=CAT_is($category);# move results hash
if ($REQUEST{ACCT} ne ''  or $REQUEST{CUST_ID} ne '') {
#
#   IF INITIAL and/or ACCT,CUST_ID requested
#   then get data for requested Acct or Customer
#   ELSE ship out blank form
#
@setup=MyYTD($database, 1, $prev_fy, $CATEGORY-{NBR},
$REQUEST{ACCT}, $REQUEST{CUST_ID});
#
#   YTD is by Product so if REQUEST{VIEW} = CATEGORY
#   then roll up YTD
#
($sth{MyYTD},$ytd)=@setup;
$YTD=YTD_is($ytd);
@setup=MyEst_by_Cat($database, 1, $CATEGORY-{NBR},
$prev_fy,
$REQUEST{ACCT},
$REQUEST{CUST_ID});
($sth{MyEstimate},$est)=@setup;
$EST=EST_is($est);
$title=($EST-{TITLE} ne '')?$EST-{TITLE}:$YTD-{TITLE};
$cust_id=($EST-{CUST_ID} ne '')?$EST-{CUST_ID}:$YTD-{CUST_ID};
$status='Requested data displayed...';
}
#print start_table;
print table\n;
my %ids =   (   1 ={   label   ='Customer Id',
name='CUST_ID',
defa=$cust_id,
size=10,},
2 ={   label   ='Account',
name='ACCT',
defa=$acct,
size=15,},
3 ={   label   ='Title',
name

Re: How to learn Perl??

2001-06-21 Thread Dennis Waller

Twinkles, etal

I'm another newbie jumping in. 

I went to the referenced URL: 
 http://www.perl.com/pub/language/info/software.html   

I didn't see anything about MSI, I jumped to the Win32 section. That tries
to send you to ActiveStates ActivePerl, which when I tried it wouldn't go
anywhere. I went to ActiveStates and the link there to ActivePerl also came
up as a bad URL. 

Another question: If I use Perl from my Win98 machine to write progs, and
then d/l them to the sever I use for websites, is there a (good) chance the
prog will not work? 


On Thu, 21 Jun 2001 22:31:58 +1000, twinkles wrote:

  Go to the following URL to get a copy of Perl for your computer. Choose
the
  Windows version with the MSI link! MSI stands for Microsoft Installer
  (which you already have if you have WinME). This package comes with ALL
the
  documentation that you need to get started in C:\Perl\html\index.html.
  
  http://www.perl.com/pub/language/info/software.html
  
  You edit the source code using Notepad or any other PLAIN TEXT editor.
Save
  it with a *.pl extension.
  
  If you want to see hundreds of web and other Perl scripts as examples of
  how to program, go to http://www.perlarchive.com and download and learn!
  However, remember that most of these were written for UNIX computers and
  you are using Windows which has FAR less features.
  
  Having said that, your very first task is to learn about the difference
  between the two environments so as to avoid weeks of frustration
wondering
  why your scripts do not work. Specifically, read the
  C:\Perl\html\index.html file section entitled, Windows Specifics.
  
  Don't underestimate the journey you are about to embark upon! It will be
a
  very, very, very steep learning curve if you are new to computers however
  you have the distinct advantage that you are starting with a blank mind.
  
  All the best!
  
  
  At 11:39 AM 20/06/2001 +0200, Henrik Linderbäck wrote:
  Hi
  
  I don´t know anything about Perl but i will try to learn. Where kan i
find 
  information about Perl and answer to my questions??
  
  What is Perl?
  Why using Perl?
  How to start?
  
  
  Do i have to buy a book or can i find everything on internet??
  
  If there is somone how have made something with Perl i am intressted to 
  see. Please give me some links, even small thing.
  
  Thanks all
  
  //Hebbe






___
Send a cool gift with your E-Card
http://www.bluemountain.com/giftcenter/





RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Kurt Edmiston



print $q-endform, \n; # offending code maybe ? == ==
#
#   form for input of estimates, sends confirmation/results of submit
#   to toolbar ...
#


I'm not sure if this is what you want, but couldn't you just replace the 
above line of code with

print /FORM;

That will at least get rid of your hidden tag and close the form.




mail extensions

2001-06-21 Thread Cheryl Kirkpatrick

I have some simple Perl scripts that I use for several forms that have
been working correctly for several months. This week we got a new
firewall and now my forms do not work.
The user submitting the form does not see any error and believes we have
received the information inputted by the form. I receive an error
message, attachment denied by WatchGruard SMTP proxy (type text,
filename (none))

We use a Unix server that is maintained by the state government. It uses
sendmail to forward the form information to me by email. Although this
has always appeared to be a simple email message, apparently the body of
the message is actually an attachment. If I knew what extension the
program uses, I believe I can write a rule for the firewall that will
allow the message to pass through the firewall.

Does anyone know what extension(s) that sendmail uses when it complies
an email message as part of a Perl program?

Thank you!!

--
Cheryl Kirkpatrick
Web Administrator/
Information Technology Librarian
South Carolina State Library
http://www.state.sc.us/scsl/
Telephone: 803.734.5831





RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Curtis Poe

Hi John,

There are a variety of issues with this, so I'll take it from the top, but starting 
with the issue
with you are concerned.  I hope you don't take any of this personally, as it's just 
intended to be
helpful:

print $q-endform;

This does indeed print the hidden field that you are concerned with.  Here's a 
solution:

print /form; 

Frankly, I have no idea why that works, or why the hidden field is printed in the 
first place. 
I've read through much of the CGI.pm code, but this is one that I have never 
encountered.

 use CGI qw(:standard :all *table);

You're importing a bunch of functions into your namespace, but you use the object 
oriented
interface ($q-...).  You can drop the import as it's irrelevant and will slow things 
down.  Just
have use CGI;.  

However, on closer inspection, I realize that you appear to have mixed both the 
function and
object oriented interfaces.  This will merely cause confusion for maintenance 
programmers down the
road.  You should stick with one interface or the other.  From what I see with your 
code, it would
be easier to switch the function calls to object calls:

center() becomes $q-center()
b()  becomes $q-b()
h3() becomes $q-h3()

And so on...

This is an issue because CGI.pm has to do a lot of work to import those functions into 
the calling
namespace.  Since this module already has a lot of overhead, this is simply extra, 
needless work
if you are using the object oriented interface.

 foreach ($q-param) {
 $REQUEST{$_}=$q-param($_);
 }

I assume that you know your form better than I do, but are you aware that the above 
snippet will
only return the first value for a param if that param has several values?  For many 
forms, this
will not make a difference.


 sub BuildForm {
 use strict;

Two things here:

1.  It really helps if you indent the code in a sub.  Indentation gives on an 
excellent view of
how things are arranged and scoped.  Just glancing at your code, I can't tell where 
the sub ends
(or if it even ends in the snipped you sent.  Indenting is a Good Thing.

2.  use strict is not needed here.  This pragma is lexically scoped.  Thus, it will 
be in effect
in the entire scope of where it's declared.  This means that having a 'use strict' at 
the top of a
program will affect the entire file (even across package boundaries) in which it's 
present.

 center(h3('TechDirect Estimates'));

$q-center($q-h3('TechDirect Estimates'));

 print center(font({-size=3},'Fiscal Year'),

print $q-center($q-font({-size=3},'Fiscal Year'),

 #print start_table;
 print table\n;

 [snip]

 foreach (sort keys %ids) {
 print Tr(
 td({-align='RIGHT'},$ids{$_}{label},b(':')),
 td({-align='LEFT'},
 textfield(  -name=$ids{$_}{name},
 -default=$ids{$_}{defa},
 -size   =$ids{$_}{size},
 -maxlength  =$ids{$_}{size})),\n);
 }
 print /TABLE\n;

The above code for printing a table is something that I see a lot in code.  This 
happens because
of the way that that tables need to be built.  Here's a somewhat cleaner, object 
oriented method
of building it, assuming that you've already created the %ids hash:

my $table = '';
foreach (sort keys %ids) {
$table .= $q-Tr(
  $q-td({-align='RIGHT'},$ids{$_}{label},$q-b(':')),
  $q-td({-align='LEFT'},
  $q-textfield( -name  = $ids{$_}{name},
 -default   = $ids{$_}{defa},
 -size  = $ids{$_}{size},
 -maxlength = $ids{$_}{size})),\n);
}
print $q-table( $table );

There are more function orient calls, but I think this should give you a good feel for 
it.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: mail extensions

2001-06-21 Thread Curtis Poe

--- Cheryl Kirkpatrick [EMAIL PROTECTED] wrote:
 I have some simple Perl scripts that I use for several forms that have
 been working correctly for several months. This week we got a new
 firewall and now my forms do not work.
 The user submitting the form does not see any error and believes we have
 received the information inputted by the form. I receive an error
 message, attachment denied by WatchGruard SMTP proxy (type text,
 filename (none))

Cheryl,

I don't know enough about sendmail to answer your question, but I do know that many 
firewalls are
configured to disallow all attachments on email due to security concerns.  Despite 
repeated
warnings to people about not opening attachments, they do so anyway and release all 
sorts of
virii, worms, and other problems.

From your error message, it looks like a simple text attachment (text/plain?).  If 
so, I would
guess that it wouldn't be a problem.  My first thought would be to chat with your 
system
administrators or security people and explain the situation.  They might be able to 
loosen up the
rules to allow text attachments through, if the situation warrants.  Of course, they 
may also be
extrememly rigid and disallow all attachments, thus forcing you to find another 
solution.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: php - perl

2001-06-21 Thread William McKee

On 15 Jun 2001, at 10:25, Curtis Poe wrote:
  To do it manually, use the following and set $mime_type to whatever value
  you want (see W3C website for complete list):
   print Content-type: $mime_type\n;
 
 With all due respect, your print statement is why I recommend to people
 that they should not do this manually.  There should be two newlines at the
 end of that (actually a \r\n or \012\015, but usually the Web server
 catches the error and corrects for it (something I have a serious beef
 with, but that's just me (oh, and I use too many parentheses))).

I'm glad to see someone paying attention. After I sent that email, I 
realized that the snippet of code I sent was indeed in error. The two 
newlines were appended further down in my script (after a Content-
Disposition header that I was sending in order to begin a download). 
Thanks for correcting it.

William



RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread William McKee

On 21 Jun 2001, at 9:50, Curtis Poe wrote:
  foreach ($q-param) {
  $REQUEST{$_}=$q-param($_);
  }
 
 I assume that you know your form better than I do, but are you aware that
 the above snippet will only return the first value for a param if that
 param has several values? For many forms, this will not make a difference.

I am working on a script which has just this problem. My solution was 
to look for the name of the field, get an array and assign the array as 
the value in the hash. Besides knowing which fields may contain 
multiple values, is there a way to determine the number of values 
returned by $q-param(foo)?

Thanks,
William



RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Curtis Poe

--- Moon, John [EMAIL PROTECTED] wrote:
 Yes, ... it's gone ... 
 
 Thanks ...
 
 Interestingly, doesn't appear on subsequent calls to endform ... 
 
 so I'm a little concerned I don't understand what CGI (or I) am doing ...
 it would seem like it should always give the same results ...

A quick glance at the CGI docs (which I should have done in the first place!) shows 
that -nosticky
will stop CGI.pm from outputting the hidden .cgifields tags:

use CGI qw/-nosticky/;

CGI.pm uses sticky fields.  If you submit a form and CGI.pm redisplays that form 
using its HTML
shortcuts, it automatically fills in all of the form values for you if your param 
names match the
HTML shortcut attribute names.  Apparently, CGI.pm uses the hidden .cgifields tag to 
let it know
that it's processing a 'sticky' form.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Curtis Poe

--- William McKee [EMAIL PROTECTED] wrote:
 On 21 Jun 2001, at 9:50, Curtis Poe wrote:
   foreach ($q-param) {
   $REQUEST{$_}=$q-param($_);
   }
  
  I assume that you know your form better than I do, but are you aware that
  the above snippet will only return the first value for a param if that
  param has several values? For many forms, this will not make a difference.
 
 I am working on a script which has just this problem. My solution was 
 to look for the name of the field, get an array and assign the array as 
 the value in the hash. Besides knowing which fields may contain 
 multiple values, is there a way to determine the number of values 
 returned by $q-param(foo)?
 
 Thanks,
 William


Um, yes, but it looks ugly.  Generally I only use the following method if I have to 
generate a
form on the fly.  Here's one way of handling something like this:

my $foo_count = scalar @{[param('foo')]};

This will tell you how many values have been returned for foo.  Another way:

my @foo  = param('foo');
my$foo_count = scalar @foo;

What's going on is that param() uses 'wantarray' to determine if it's assigning to a 
scalar or
array.  If it's assigning to a scalar, it only returns the first value (or only value, 
if that's
all there is).  Otherwise, it's going to return a list.  What the first method does it 
the
following:

[ param('foo') ]

The square brackets force param() to be evaluated in a list context.

@{[param('foo')]}

The @{...} forces the listref to be dereferenced into an anonymous array.

scalar @{[param('foo')]};

That scalar function then forces the anonymous array to be evaluated in scalar 
context, thus
returning the number of elements.

If only one form element is returned for 'foo', param will just return a one element 
list and the
above construct returns the value '1'.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Randal L. Schwartz

 Curtis == Curtis Poe [EMAIL PROTECTED] writes:


Curtis my $foo_count = scalar @{[param('foo')]};

That's nice, but I prefer:

my $foo_count = () = param('foo');

Less typing, less work for the machine.  Less noise.  More magic,
though.  Oops, arguable on that. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Tillema, Glenn

  Curtis == Curtis Poe [EMAIL PROTECTED] writes:
 
 Curtis my $foo_count = scalar @{[param('foo')]};
 
 That's nice, but I prefer:
 
 my $foo_count = () = param('foo');
 
 Less typing, less work for the machine.  Less noise.  More magic,
 though.  Oops, arguable on that. :)
 
 -- 
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - 

Let me guess ... param('foo') is assigned to a list ... the list is assigned
to $foo_count in a scalar context so the number of elements are returned.

Right?


Glenn Tillema  [EMAIL PROTECTED]
ADC Telecommunications, Inc. 
PO Box 1101, MS 508
Minneapolis, MN  55440-1101
Learn about ADC - The Broadband Company - www.adc.com



RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Tillema, Glenn

  my $foo_count = () = param('foo');
 
 Tillema, Let me guess ... param('foo') is assigned to a list 
 Tillema,... the list is assigned
 Tillema, to $foo_count in a scalar context so the number of 
 Tillema, elements are returned.
 
 Tillema, Right?
 
 Probably simpler than that.  param is invoked in a list context,
 so it does its listy-thing, and returns a list of N elements.  This
 list attempts to be assigned to the () list, which tosses everything
 after the 0th element (that is, EVERYTHING) as unneeded.  However,
 since that list assignment op was in a scalar context, it returns
 the number of original elements (not the number of kept elements),
 and that's back to N again.  And that N goes into $foo_count.
 
 There's never a list assigned to $foo_count in a scalar context...
 the phrase doesn't even make sense to me. :) You can't assign a list
 to $foo_count.  It can never happen.  Never.  A list cannot exist in a
 scalar context... the guts of Perl mandates that.
 
 -- 
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - 

That's how it was phrased in the camel; List assignment in scalar context
returns the number of elements produced by the expression on the _right_ side
of the assignment...  Your explanation certainly goes into much more detail,
however. Thanks!


Glenn Tillema  [EMAIL PROTECTED]
ADC Telecommunications, Inc.   
PO Box 1101, MS 508
Minneapolis, MN  55440-1101
Learn about ADC - The Broadband Company - www.adc.com



RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Moon, John

Curtis,

Thank you for the suggestion ... This is for beginners and I have a lot to
learn !

... I'll use the OO format - just got lazy ... 

never used strict before because it was s strict but some guy named
Curtis (and others) kept saying to use it so  Thanks for letting me know
about the scoping...

Yes, I knew about what param returned but haven't needed to have a
multi-value token (array) returned ... so far ... and appreciate the further
discussion ... 

Thanks for the tip on $table .= ... again I needed to get out of my box
... and that why I like this forum ... I work alone (remote) and this has
been a BIG help to me ... Hope I can help others down the road ... 


In my doc (from perldoc) I don't see the pragma listed... which brings me to
the question how do I know which version of CGI I have ... I don't install
software at this shop ... and don't have root privileges ... in fact much
to my dismay they have multiple versions of Perl installed ... so when I
run perldoc which doc's am I getting ?

Althought it says loosely found as .../5.00502  ... after a lot of other
stuff ...

What is the current stable version of CGI ... ?

$ENV{MANPATH} = /usr/share/man:/usr/local/man  

 -V reports:

SUN2perl5.00502 -V|more # which is my shebang 

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  ...
where  reports:
SUN2perl -V|more
Summary of my perl5 (5.0 patchlevel 3 subversion 0) configuration:
  ...



Re: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Randal L. Schwartz

 Tillema, == Tillema, Glenn [EMAIL PROTECTED] writes:

 There's never a list assigned to $foo_count in a scalar context...
 the phrase doesn't even make sense to me. :) You can't assign a list
 to $foo_count.  It can never happen.  Never.  A list cannot exist in a
 scalar context... the guts of Perl mandates that.

Tillema, That's how it was phrased in the camel; List assignment in scalar context
Tillema, returns the number of elements produced by the expression on the _right_ side
Tillema, of the assignment...  Your explanation certainly goes into much more detail,
Tillema, however. Thanks!

Ahh, there's HUGE difference between

list assignment _in_ scalar context

and

list assigned _to_ [a scalar]

Let's draw that out.  First is:

$foo_length = () = SOME_LIST
  == list assignment in
= __ scalar context

Second might mean something like:

$foo_length = SOME_LIST # although this can't happen
  = list
=   assigned to
=== scalar

See the difference?  And the latter can't happen.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



RE: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Tillema, Glenn

 Tillema, That's how it was phrased in the camel; List 
 Tillema, assignment in scalar context
 Tillema, returns the number of elements produced by the 
 Tillema, expression on the _right_ side
 Tillema, of the assignment...  Your explanation certainly 
 Tillema, goes into much more detail,
 Tillema, however. Thanks!
 
 Ahh, there's HUGE difference between
 
 list assignment _in_ scalar context
 
 and
 
 list assigned _to_ [a scalar]
 
 Let's draw that out.  First is:
 
 $foo_length = () = SOME_LIST
   == list assignment in
 = __ scalar context
 
 Second might mean something like:
 
 $foo_length = SOME_LIST # although this can't happen
   = list
 =   assigned to
 === scalar
 
 See the difference?  And the latter can't happen.
 
 -- 
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - 

I know I've certainly tried it ... :) I see the difference, thanks!


Glenn Tillema  [EMAIL PROTECTED]
ADC Telecommunications, Inc.  
PO Box 1101, MS 508
Minneapolis, MN  55440-1101
Learn about ADC - The Broadband Company - www.adc.com



Re: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Mel Matsuoka

At 04:21 PM 06/21/2001 -0400, Timothy Kimball wrote:

Randal L. Schwartz wrote:
: ...
: Second might mean something like:
: 
: $foo_length = SOME_LIST # although this can't happen
:   = list
: =   assigned to
: === scalar
: 
: See the difference?  And the latter can't happen.

Sure it can. Well, the list itself doesn't get assigned to the scalar,
but an assignment does get made: The last element of SOME_LIST to
$foo_length. So

my $number_of_pets = ('dog','cat','iguana');

sets $number_of_pets to 'iguana'.


Methinks you actually /validated/ Randal's post, not contradicted it ;)

Randal said:
Ahh, there's HUGE difference between

list assignment _in_ scalar context

and

list assigned _to_ [a scalar]

So your example would fit in the list assignment _in_ scalar context
category...the keyword being assignMENT, and not assignED

aloha,
mel



mel matsuoka  Hawaiian Image Productions
Chief Executive Alphageek(vox)1.808.531.5474
[EMAIL PROTECTED](fax)1.808.526.4040
 



Re: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Curtis Poe


--- Timothy Kimball [EMAIL PROTECTED] wrote:
 
 Randal L. Schwartz wrote:
 : ...
 : Second might mean something like:
 : 
 : $foo_length = SOME_LIST # although this can't happen
 :   = list
 : =   assigned to
 : === scalar
 : 
 : See the difference?  And the latter can't happen.
 
 Sure it can. Well, the list itself doesn't get assigned to the scalar,
 but an assignment does get made: The last element of SOME_LIST to
 $foo_length. So
 
 my $number_of_pets = ('dog','cat','iguana');
 
 sets $number_of_pets to 'iguana'.
 
 -- tdk

Actually, you're dealing with a well-documented, but poorly understood feature.  Try 
this:

my $number_of_pets = ('dog','cat','iguana');
print $number_of_pets;

my @pets = ('dog','cat','iguana');
$number_of_pets = @pets;
print $number_of_pets;

$number_of_pets = ('dog','cat',@pets);
print $number_of_pets;

@number_of_pets = ('dog','cat',@pets);
print scalar @number_of_pets;

The first print results in 'iguana' and the second and third print statements print 3. 
 The fourth
print display a 5.

What's going on here is subtle.  Putting parens around those scalars creates a list 
literal. 
When a list literal is accessed in scalar context, it evaluates each item in scalar 
context and
returns the value of the final element.  Since, in the third example, the array is the 
third
element, it's evaluated in scalar context, as expected.

So why do the third and fourth examples have different outputs?  Because lists are not 
arrays and
do not behave as such.

Cheers,
Curtis Poe

=
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
Ovid on http://www.perlmonks.org/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Extra INPUT TYPE=hidden NAME=.cgifields VALUE=ACTION ?

2001-06-21 Thread Timothy Kimball


Mel Matsuoka wrote:
: Randal L. Schwartz wrote:
: : ...
: : Second might mean something like:
: : 
: : $foo_length = SOME_LIST # although this can't happen
: :   = list
: : =   assigned to
: : === scalar
: : 
: : See the difference?  And the latter can't happen.
: 
: Sure it can. Well, the list itself doesn't get assigned to the scalar,
: but an assignment does get made: The last element of SOME_LIST to
: $foo_length. So
: 
: my $number_of_pets = ('dog','cat','iguana');
: 
: sets $number_of_pets to 'iguana'.
: 
: 
: Methinks you actually /validated/ Randal's post, not contradicted it ;)

Actually, I was reacting in a blind fury to the words can't happen.
I hate to see that in a post about Perl. ;)

-- tdk



RE: Please remove

2001-06-21 Thread Ask Bjoern Hansen

On Wed, 20 Jun 2001 [EMAIL PROTECTED] wrote:

 I also have tried removal but I get this great little insulting remark that
 could only have been produced by a 'secret loyal order of Unix programmers'
 bit bombardier!

 Hi. This is the qmail-send program at onion.perl.org.
 I'm afraid I wasn't able to deliver your message to the following addresses.
 This is a permanent error; I've given up. Sorry it didn't work out.

 [EMAIL PROTECTED]:
 Sorry, no mailbox here by that name. (#5.1.1)

 I'm trying to work it out like a mathematician with a pencil.

In the future don't CC both lists, please. I'll have to make a
filter that rejects such mails. :-I

Anyway, your Outlook program munged the confirmation adderss from
the full long one to just [EMAIL PROTECTED] which the mail
system obviously don't know what to do with. That's why you got the
message above.


 - ask

-- 
ask bjoern hansen, http://ask.netcetera.dk/   !try; do();
more than 100M impressions per day, http://valueclick.com




Re: Please remove

2001-06-21 Thread Dave Young

D.J.B. is quite the character..  ;)


 I also have tried removal but I get this great little insulting remark that
 could only have been produced by a 'secret loyal order of Unix programmers'
 bit bombardier!

 Hi. This is the qmail-send program at onion.perl.org.
 I'm afraid I wasn't able to deliver your message to the following
 addresses. This is a permanent error; I've given up. Sorry it didn't work
 out.





Pooling of objects and session data

2001-06-21 Thread Rajeev Rumale

Hi,

I need to know if there is any easiest way to keep session data or object
accross the scripts.

Basically I would like to pool Database connections so that Parrallel
running scripts don't open multiple connection with the database.

with regards

Rajeev Rumale
- Original Message -
From: Dave Young [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, June 21, 2001 8:04 AM
Subject: Re: Please remove


 D.J.B. is quite the character..  ;)


  I also have tried removal but I get this great little insulting remark
that
  could only have been produced by a 'secret loyal order of Unix
programmers'
  bit bombardier!
 
  Hi. This is the qmail-send program at onion.perl.org.
  I'm afraid I wasn't able to deliver your message to the following
  addresses. This is a permanent error; I've given up. Sorry it didn't
work
  out.
 
 





Re: Telnet

2001-06-21 Thread Joel Divekar

Thanks Derek

Regards

Joel

At 03:01 PM 6/20/2001 +0100, Derek Harding wrote:
On Saturday 16 June 2001 07:28, Joel Divekar wrote:
  Hi
 
  Hey can we run KDE or Xwindows by telneting to Linux servers ???
 
  Regards

Not by telnet but certainly it is possible to run dumb terminals onto a
Linux server (Linux Terminal Server Project) so that 486/25 SX processors
with 8MB RAM and no hard disk will run XWindows. In fact, they boot directly
from the server so no rapscallion can change the configuration, they are
ready to log in in about 30 seconds, they can be powered off live without
effect etc.

Not so easy with SuSE but RedHat do an special server install and SuSE 7.1
has the required packages.

How about a specific preconfigured load version to select at the beginning of
yast Roger?

--
Best wishes,
Derek Harding, (BA MIAP)
ICT  Network Manager
[EMAIL PROTECTED]


--
QuantumLink Communications, Bombay, India





Re: Telnet

2001-06-21 Thread Joel Divekar

Thanks SAWMaster (Not your real name I suppose)

Will surely give it a try but I am looking for a free software

Regards

Joel


At 09:25 AM 6/20/2001 -0500, SAWMaster wrote:
Yes and no.  You cannot do it with telnet, but you can get what you want by
using an x-term client and setting up the server box to allow x connections.
One commercial example of an X-Term client for a windows box would be
X-Win32.  Do a search on the net for X-Win32 and you'll find plenty of
information.  I'm not sure if there's any public domain freeware X-Term
clients.  If anyone knows of one please let me know.


  Hi
 
  Hey can we run KDE or Xwindows by telneting to Linux servers ???
 
  Regards
 
  Joel


--
QuantumLink Communications, Bombay, India





Re: Telnet

2001-06-21 Thread Joel Divekar

Thanks Brett

Will surely download CygWin32... anyway I wanted to install it for Perl

Regards

Joel

At 10:44 AM 6/20/2001 -0400, Brett W. McCoy wrote:
On Wed, 20 Jun 2001, SAWMaster wrote:

  Yes and no.  You cannot do it with telnet, but you can get what you want by
  using an x-term client and setting up the server box to allow x 
 connections.
  One commercial example of an X-Term client for a windows box would be
  X-Win32.  Do a search on the net for X-Win32 and you'll find plenty of
  information.  I'm not sure if there's any public domain freeware X-Term
  clients.  If anyone knows of one please let me know.

XFree86 now runs under CygWin32, and is open source.  It works quite well,
although the number of window managers is supports is limited.

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

Der Horizont vieler Menschen ist ein Kreis mit Radius Null --
und das nennen sie ihren Standpunkt.


--
QuantumLink Communications, Bombay, India





fastest method to check if a URL is alive

2001-06-21 Thread Drew Cohan

Hi,

Could some kind soul please tell me why the following
prints nothing for valid URLs?  I'm trying to write a
small, tight, and very fast script that'll check to
see if a URL is alive in the least amount of time
possible (and avoid using PING).  I need to check
thousands of URLs.  It seems to me that this should be
a relatively simple affair?  Below is some code I've
tried to adapt from the cookbook (example 20.1).  I
was also intrigued by the HTML:Status class mentioned
in the perldoc, but I can't seem to figure out how to
use it without employing the seemingly overkill
LWP:UserAgent.  

thanks in advance,

Drew.

 snip 
#!/usr/bin/perl -w

$|++;

use warnings;
use strict;
use diagnostics;

use LWP::Simple;

while (){
print if (defined (my $content = get $_));
}
 end of snip 

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: compilation errors in win98

2001-06-21 Thread james crease

Thanks I had tried that already and doesn't seem to work at compile 
time:-(

In message 00e401c0f9cc$02ee7340$0901a8c0@profit, Jos I. Boumans 
[EMAIL PROTECTED] writes
try capturing the output:

perl foo.pl  outputfile.txt

all that perl spits out should be in the outputfile.txt then

regards,

Jos Boumans

- Original Message -
From: james crease [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, June 20, 2001 10:49 PM
Subject: compilation errors in win98


 I have a perl script which generates many compilation errors which
 scroll off the DOS window perl is running in. How do I capture (or
 recover) the lines that have scrolled away?
 --
 james crease



-- 
james crease
http://wocediu.org   Tel. +1 302 645 4240
http://www.codata.orgTel. +44 1608 642335



Re: xml problem

2001-06-21 Thread Morgan

This script is exelent but I need the script to read the letters åäö
and ÅÄÖ too.
Cuz this is part of my launguage (Swedish) and those letters are in the
articles.
And I need to have the word between the HIT/HIT tags in too.
Finaly I how do I enclose the article with ARTICLES/ARTICELS cuz
Chas has right there, it can be more than one article in the file and it
is not enclosed by any outher tags.



Thanks for good support and help.




Chas Owens wrote:
 
 Please, please, please, do not try to parse XML with regexps.  They only
 work in the simplest cases.  There are perfectly good XML modules
 designed to parse XML for you and they are not that hard to use.
 
 The following code parses an XML file similar to the one you described,
 but has an additional tag (ARTICLES/ARTICLES) since XML must have
 one and only one root tag.  I added this tag because I thought you have
 more than one article per file.  If this is true then the XML you
 described is not well formed.  However it would be a simple process to
 wrap this tag around the file before attempting to parse it.  If there
 is in fact only one article per file then remove the outer foreach and
 replace $articles-children with $xmlobj-children.
 
 code
 #!/usr/bin/perl -w
 
 use strict;
 use XML::Parser;   #parse XML into an internal format
 use XML::SimpleObject; #easy to use forntend to XML::Parse
 
 if (@ARGV != 2) { die Usage: $0 news.xml index.html }
 
 my $parser = new XML::Parser (ErrorContext = 2, Style = Tree);
 my $xmlobj = new XML::SimpleObject ($parser-parsefile($ARGV[0]));
 
 open HTML, $ARGV[1] or die Could not open $ARGV[1]:$!;
 select HTML;
 
 print 
 html
 head
 title
 News Articles for  . localtime() .  
 /title
 /head
 body
 table;
 
 foreach my $articles ($xmlobj-children) { #get the top tag
foreach my $article ($articles-children) { #get all articles
   my $file = $article-child('PUB')-value . '-' .
  $article-child('RUB')-value . '-' .
  $article-child('LEV')-value . '-' .
  $article-child('DAT')-value;
   $file =~ s/[^\w.-]//g; #remove anything not alphanumeric, _, -, or
 .
   open FH, $file or die Could not open $file:$!;
   print FH $article-child('BRO')-value;
   close FH;
   print
 trtd, $article-child('ORD')-value, /td/tr\n,
 trtd, $article-child('LEV')-value, /td/tr\n,
 trtd, $article-child('DAT')-value, /td/tr\n,
 trtd, $article-child('PUB')-value, /td/tr\n,
 trtda href=\$file\, $article-child('RUB')-value,
 /a/td/tr\n,trtd, $article-child('INL')-value,
 /td/tr\n,
 trtd/td/tr;
}
 }
 
 print 
 /table
 /body
 /html;
 
 close HTML;
 /code
 
 On 19 Jun 2001 13:34:03 +0100, Nigel Wetters wrote:
  I think I can give you some clues. Here's some code out of the Perl Cookbook (6.8 
Extracting a Range of Lines), which I've adapted for you. You should be able to nest 
such structures to get what you want.
 
  my $extracted_lines = '';
  while () {
  if (/BEGIN PATTERN/ .. /END PATTERN/) {
  # line falls between BEGIN and END in the
  # text, inclusive
  $extracted_lines .= $_;
  } else {
  # now, we're outside the pattern
  process($extracted_lines) if $extracted_lines;
  $extracted_lines = '';
  }
  }
  sub process
  {
  # do stuff with the extracted lines
  # maybe performing more regex's
  }
 
   Morgan [EMAIL PROTECTED] 06/19/01 01:12pm 
  Hi
 
  I'm newbee perl developer and a rookie of xml :(
 
  Is there anyone who can give me some hints or help me out with a problem
  I have?
 
  Here is the problem.
  I will recive newsarticles three times a day in xml format and I need to
  automaticly publish those articels on a web page, on the first page it
  should only show the tags down to /INL
  tag and a link to the whole page.
 
  Here is a sample of the xml format.
 
  ART
  ORDanbud/ORD
  LEV2001-06-14/LEV
  DAT14-06-01/DAT
  PUBDAGENS INDUSTRI/PUB
  RUBDragkamp om förlusttåg/RUB
  INLHere is the indroduction about the article and when the word
  anbud comes up it is enclosed in HITanbud/HIT tags.
  This is the word we use as criteria on the articels we should recive.
  /INL
  BRO
  Here comes the rest of the document, thats the whole article.
  Even her is the HITanbud/HIT and I need the word between HIT cuz thats part 
of the article.
The article ends with
  /BRO
  /ART
 
 
  Raven
 
 
 
  This e-mail and any files transmitted with it are confidential
  and solely for the use of the intended recipient.
  ONdigital plc, 346 Queenstown Road, London SW8 4DG. Reg No: 3302715.
 
 --
 Today is Setting Orange, the 24th day of Confusion in the YOLD 3167
 Wibble.



tutorial on my/our/use/package/local

2001-06-21 Thread Me

There's plenty of existing doc, but in the name of TMTOWTDI...

Asbestos suit donned. Criticisms welcome.

--

If you are wondering about things like:

use strict;
my $foo;
our $bar;
local $baz;
explicit package

then this article might be of help.

--

Before we can understand a noun, like Paris, or a verb,
like move, we need to understand the context. Does
Paris refer to the town in Texas, USA, or the city in France?

A perl script is aware of multiple namespaces and the
meaning of a word is often established by associating
it with one or other of these namespaces.

One important job you have in coding anything but the
simplest perl script is to let perl know which namespaces
should be available and which namespace should be
used for context when you use a given word.

--

In perl, namespaces are called packages.

Every perl script automatically knows of two packages,
main and MY*.

--

Unless you declare a name as being in some other
package, a name is assumed to be in the main package:

$_ = 1;

# $_ is in main.

--

In general, you should not be lazy and let your names
fall in to the default main package. Instead, you should
declare variables you create as being in MY package:

my $foo = 1;

foreach my $element (@array) {

Unless you are writing a perl one liner, make sure you
declare your variables with my. Don't be lazy or you will
get in to trouble later...

--

Beyond main and MY, the other packages you are
most likely to use are packages written by others.

Before we look at the syntax involved, a brief digression
as a motivation for learning this package stuff:

Amazingly, a huge number of high quality packages
are available publically for free in one nice big catalog
called CPAN. Some come with perl as standard.
Others need to be pulled in from the Internet. You can
browse and search CPAN using a web browser:

http://search.cpan.org/

More on this in a footnote**.

--

Apart from main and MY, all other packages have to be
given a name.

In a similar fashion to use of / (or \) in directory names
on hard drives, package names often include '::' to
separate logical levels of the package name. For
example, one package on CPAN is:

File::Copy

--

To use another package written by someone else,
you write something like:

use File::Copy;

this makes the File::Copy namespace available.
So you can write things like:

use File::Copy;

# Invoke File::Copy's move() procedure:
File::Copy::move(file1, file2);

This is very explicit. There is no room for ambiguity.

But it sure is long.

Fortunately, the 'use File::Copy' statement does more
than make the namespace available. It also imports
some names right in to your main package. So you
could write:

use File::Copy;

# Invoke File::Copy's move() procedure:
move(file1, file2);

Which names get imported in to your main package
depends on a combination of what the author of the
package decides, and what options you specify
when you use the module. For example, you can say:

use File::Copy ();

and File::Copy won't import any names in to main.

--

If you are writing more than a one liner, you should
start your scripts with:

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

Once this is done, if you don't say where a name is
from, perl will complain that you have not provided
an explicit package name. This is a good thing, as
it forces you to be careful, and this particular form
of care will save you countless hours of frustration.

As already stated, most of the names you come up
with will refer to things that are, well, yours, so you
typically write things like:

my $foo;

so that $foo now belongs in the MY package.

If you want to refer to something from another
package, you can either specify the longhand:

$Foo::bar = 1;   # set $bar from package Foo.

or introduce a shorthand version of the name
like so:

package Foo;
our $bar = 1;   # set $bar from package Foo.
our $baz = 2;   # set $baz from package Foo.

$_, @_, STDIN and other standard Perl variables
are exempt from 'use strict' complaints. Indeed,
you can't my these variables even if you wanted to.

--

If a my or our declaration is inside braces, Perl loses
all memory of that declaration when it encounters the
enclosing end brace:

#!/usr/bin/perl;

my $foo;
{
my $bar;
# MY namespace contains the names $foo and $bar.
}
# MY namespace no longer contains the name $bar.

--

My/our declarations stack variables on top of each other
(and unstack too) and hide other variables with the
same name:

#!/usr/bin/perl;

$foo = 1; $bar = 1;
# main package now contains a $foo and a $bar.

my $foo = 2;
# MY package now contains a $foo.

print $foo;
# Refers to MY foo in preference to 

Re:MANPAGE

2001-06-21 Thread Govinderjit Dhinsa

How do I get access to the manpages please 



Re: Re:MANPAGE

2001-06-21 Thread Me

 How do I get access to the manpages please

Depends on the system, and you may not be
able to get access.

One normal access method is to enter, at a shell
prompt (command line):

man foo

to access the man page for foo.

Perl has its own equivalent of manpages. To start,
enter at a shell prompt:

perldoc perl

hth




RE: PERL PROGRAM HELP!

2001-06-21 Thread Aaron Craig

At 11:35 20.06.2001 +0100, Govinderjit Dhinsa wrote:
Iv been givin this program to modify, but I can not astblish what some parts
of the program are doing.   From

printf
to
}

Can any body help please and run through it with me pls!



open iscd,$ARGV[0] or die Cannot open $ARGV[0],$!;

this opens a file that's been typed in at the command line

open sortcode,$ARGV[1];

this opens the second file that's been typed in at the command line

while($line=iscd){
 chomp $line;
 @fields=split \t,$line;

this grabs one line at a time from the first file and splits it out into an 
array -- the line is apparently a tab delimited list

 printf sortcode
\n%6.6s%8.8s%3.3s%27.27s%20.20s%35.35s%35.35s%10.10s%1.1s%1.1s%2.2s%2.2s%2.
2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%1.1s%1.1s%6.6s%35.35s%4.4s%4.4s%10.10s
%8.8s,

$fields[0],$fields[1],$fields[2],$fields[4],$fields[5],$fields[6],$fields[7]
,$fields[11],$fields[14],$fields[25],

$fields[26],$fields[27],$fields[28],$fields[29],$fields[30],$fields[31],$fie
lds[32],$fields[33],

$fields[34],$fields[35],$fields[58],$fields[60],$fields[61],$fields[64],
$fields[76],$fields[77],$fields[78],$fields[79];
}

this formats the data from the line and prints it out to the second 
file.  There's probably a cleaner and easier-to-read way to do 
this.  However, if you look at the docs for printf, and compare the input 
and output files you should be able to figure out exactly how the lines are 
getting formatted and printed.

Aaron Craig
Programming
iSoftitler.com




Re: Recursive subrutines

2001-06-21 Thread Aaron Craig

At 10:54 20.06.2001 +0200, Dalløkken, Espen wrote:
I'm trying to wirte a recursive subroutine that recives an array, does some
processing and then calls itself with a new array.
The problem is that I never get to retrive the array after the subroutine
has ran once. When it runs the second time it doesn't get the correct set of
items in the passed in array.
So I'm wondering if I'm calling the subroutine in the wrong way, or if I'm
retriving the parameters incorrectly.

---
buildBranch(@someNodes);

You don't have to use  anymore.  I'd call your routines like this:
buildBranch(@someNodes);
also, you probably want to get into the habit of passing references to 
structures instead of the structure itself.  That means you don't have to 
return the structure if you change it inside your function, and it's faster 
because you're not making copies of structures all over the place.

That said:

buildBranch(\@someNodes);  # \@ passes a reference to the array, not a copy 
of the array.  changes made inside buildBranch() will effect @someNodes.

sub buildBranch($) # I know that prototyping is controversial, so maybe 
we'll get a good thread going out of this sub declaration
 {
 my($raNodes) = @_; # if you're not using strict, the gods of Perl 
will grumble -- and besides, it's better.
 foreach my $node (@{ $raNodes }) # I'm changing your variable name 
to something a little more descriptive
 {
 if($node-getTagName() eq branch) # could this just be a 
property of node? like $node-{TagName} ?  just an idea
 {
 # fetch parameters from the XML file
 ... # this looks cool
 CreateBranch();
 # no reason to right the same code twice, so we'll 
move the child nodes stuff outside the if
 }
 my $raChildNodes = $node-GetChildNodes(); # you'll have 
to change GetChildNodes() to return an array ref instead of an array
 buildBranch($raChildNodes) if(scalar(@{ $raChildNodes })  
0); # as long as GetChildNodes() returns a proper array of child nodes, it 
should work as is.  what specific errors are you getting?
 }
 }

sub buildBranch()
{
 @numNodes = @_;
 foreach $item (@numNodes)
 {
 # if the node is a branch tag, create branch
 if ($item-getTagName() eq branch)
 {
 # fetch parameters from the XML file
 $branchName = $item-getAttribute(name);
 $vpath = $item-getAttribute(vpath);
 $comment = $item-getAttribute(comment);
 $edition = $item-getAttribute(edition);
 $owner = $item-getAttribute(owner);
 $groupForSharing =
$item-getAttribute(groupForSharing);

 createBranch();
 @childBRNodes = $item-getChildNodes();
 if (scalar(@childBRNodes)  0)
 {
 buildBranch(@childBRNodes);
 }
 }
 @childNodes = $item-getChildNodes();
 if (scalar(@childNodes)  0)
 {
 buildBranch(@childNodes);
 }
 }
}

Aaron Craig
Programming
iSoftitler.com




file size

2001-06-21 Thread perl

Hi,

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

thanx




Re: PROGRAM!

2001-06-21 Thread Me

 #!/usr/bin/perl -w
 
 use strict;

means you can't just go introducing names
willy nilly without telling perl where they come
from.

which in turn means...

 while () {
 
 @fields = split /*/;

you can't do this!. oops. should be

  my @fields = split /*/;

 for (my $i = -1; $i  -9; --$i) {
 
 print $fields[$i] . \n;
 
 }
 
 }

 Q IS this what you want me to change it to

 for (my $i = 0; $i  -3; $i  -7) {

Nope. This form of a for loop works like this:

for (start; test; change) {

do something

}

where 'start' tells perl the starting arrangement,
'test' is something perl tests each time it is at
the top of the loop, and 'change' is something
perl will do each time it reaches the bottom of
the loop. The 'change' bit had better change
something otherwise the loop will just go on
repeatedly doing the same thing.

So, the $i  -7 bit doesn't make sense because
it isn't going to change anything.

The loop I had written was going to start at index
position -1, which means the last element of an
array, then step backwards through the next 7
previous elements. I thought that was the address.

You need something more like:

print $fields[0] . \n;
print $fields[3] . \n;
for (my $i = -3; $i  -7; --$i) {
print $fields[$i] . \n;
}

 PS. not able to get access to the manpage.

That's like saying, you still can't get access to the software.

What manpage? On what operating system?




Re: file size

2001-06-21 Thread Me

-s

as in:

perl -e 'print $_:  . -s . \n for (glob (*.*))'

 Hi,

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

 thanx




Re: compilation errors in win98

2001-06-21 Thread james crease




In message [EMAIL PROTECTED], Sally 
[EMAIL PROTECTED] writes
Why don't you work on the ones you can see, then the list will shrink, and
you'll get rid of the errors eventually. I know that's not the point but it
is a solution.

This is not  I think likely to help as most of the errors are 
consequential on the original real  error, but thanks for the thought.




-Original Message-
From: james crease [mailto:[EMAIL PROTECTED]]
Sent: 21 June 2001 09:26
To: [EMAIL PROTECTED]
Subject: Re: compilation errors in win98


Thanks I had tried that already and doesn't seem to work at compile
time:-(

In message 00e401c0f9cc$02ee7340$0901a8c0@profit, Jos I. Boumans
[EMAIL PROTECTED] writes
try capturing the output:

perl foo.pl  outputfile.txt

all that perl spits out should be in the outputfile.txt then

regards,

Jos Boumans

- Original Message -
From: james crease [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, June 20, 2001 10:49 PM
Subject: compilation errors in win98


 I have a perl script which generates many compilation errors which
 scroll off the DOS window perl is running in. How do I capture (or
 recover) the lines that have scrolled away?
 --
 james crease



--
james crease
http://wocediu.org   Tel. +1 302 645 4240
http://www.codata.orgTel. +44 1608 642335

-- 
james crease
http://wocediu.org   Tel. +1 302 645 4240
http://www.codata.orgTel. +44 1608 642335



Re: file size

2001-06-21 Thread victor

use the stat command.

[EMAIL PROTECTED] wrote:

 Hi,

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

 thanx




RE: Please remove

2001-06-21 Thread John Pimentel

I'm not sure how HE tried to remove himself, but if you send an email to the
address provided in the confirmation email
[EMAIL PROTECTED] the onion.perl.org
mail server complains and sends it back.  I tried it - following the
instructions EXACTLY as they were written.  I assume the ability to
unsubscribe is just a big joke.  I sent an email to [EMAIL PROTECTED]
hoping to get an answer, nothing yet.

So, if you know of anyone who has had success unsubscribing from one of
these, please provide some details.  Following the confirmation email does
not work as written.  If it's failed for you, provide the mailer error, we
can start a how does one REALLY unsubsubscribe message.

-Original Message-
From: Mark Bergeron [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 20, 2001 7:17 PM
To: Debo Lawrence-Cornett; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Please remove


Your gonna have to remove yourself. Didn't you get a confirmation email with
the details of the what, where, why and how?

Mark Bergeron
Perl Junkie

-Original Message-
From: Debo Lawrence-Cornett[EMAIL PROTECTED]
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Date: Wed Jun 20 15:05:45 PDT 2001
Subject: Please remove

I would like to be removed from this list.  It is probably very helpful,
but
there's just too much.  Thanks.  [EMAIL PROTECTED]

Debo Lawrence-Cornett
Cornett Web Design
[EMAIL PROTECTED]

Member of the following professional Web Designer Associations:
International Webmasters Association http://iwanet.org
HTML Writers Guild http://www.hwg.org



/~_. _ | _ _  _  _ 
\_/|(_||| | |(_)| |
 _|
___
GO.com Mail
Get Your Free, Private E-mail at http://mail.go.com




Re: Detecting NT eol (^M) characters

2001-06-21 Thread Chas Owens

\n in Perl is magical.  It changes its value based on the OS.  On Unix
boxen it is equal to LF, on Macs it is equal to CR, and on DOS based
machines it is equal to CRLF.  If you are looking for the CR and only
the CR your best bet is to use \015.


On 21 Jun 2001 07:17:04 -0400, Jeanne Riley wrote:
 Hi,
 
 I am attempting to write my 1st Perl script.  I have an install of ClearCase
 4.1 which has Perl embedded in it.  I need to write a Perl script (trigger)
 that if anyone attempts to check in a file with NT eol character the check
 in will be blocked.  The Perl script needs to detect if there are any NT eol
 or ^M characters in a file.  I am cat the file and know I need to grep for
 ^M but I don't know how to do this in Perl.  I did seek assistance from
 www.perl.org and found information regarding \cIM but this does not seem
 to work.
 
 Has anyone tried to do this before?
 
 Any and all assistance will be greatly appreciated.
 Jeanne
--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
Umlaut Zebra über alles!





Re[2]: compilation errors in win98

2001-06-21 Thread Tim Musson

Hey james,

Can you change the Properties of the command window?  Right click on
the blue bar at the top, Properties, then the Layout tab.
I typically set it to:
Screen Buffer Size:
Width   100
Height  300
Window Size:
Width80
Height   50

This should work on 98.  I run Win2k, but it also worked on NT.

Thursday, June 21, 2001, 4:26:28 AM, you wrote:

jc Thanks I had tried that already and doesn't seem to work at
jc compile  time:-(

perl foo.pl  outputfile.txt

all that perl spits out should be in the outputfile.txt then

 I have a perl script which generates many compilation errors which
 scroll off the DOS window perl is running in. How do I capture (or
 recover) the lines that have scrolled away?




-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
Experience is something you don't get until just after you need it.




Re: Re[2]: if statement

2001-06-21 Thread Chas Owens

snip href=perldoc perlop
Symbolic Unary Operators

   Unary ! performs logical negation, i.e., not.  See
   also not for a lower precedence version of this.
/snip

Most of the line noise logical operators have an equivalent English
operator.  These English operators (in general) have a lower precedence
than the line noise version.  This is why

open FH, $filename || die Could not open $filename:$!;

is wrong but

open FH, $filename or die Could not open $filename:$!;

is right.


On 21 Jun 2001 08:07:38 -0400, Tim Musson wrote:
 Hey Jos,
 
 I believe you have to use ! instead of not also...
 
 Wednesday, June 20, 2001, 6:05:39 PM, you wrote:
 
 JIB i'd say, there is no 'like' operator...
 
  This isn't working for me.  Help please.  What is wrong with the second if
  statement
 
while ( ($timestamp, $report_type, $game_name, $data_name, $data_value)
 JIB =
  $ora_sth-fetchrow_array)
  {
  if (($data_name eq 'min') || ($data_name eq 'time')) {$data_value =
  $data_value * 1440}
  if (not ($report_type like  'unique'))
  {   %myvar =(   $report_type,
  $data_name,
  $data_value,
  );
  $dname{$report_type} = $data_name;
  $dvalue{$report_type} = $data_value + $dvalue{$report_type};
 
 
 
 
 -- 
 [EMAIL PROTECTED]
 Using The Bat! eMail v1.53d
 Windows NT 5.0.2195 (Service Pack 1)
 Why is it that to stop Windows 2000, you still have to click on Start?
 
 
--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
Pzat!





Re: Last page

2001-06-21 Thread Jos Boumans

Assuming you'll utilise the CGI module, this would work:

my $q = new CGI;
my $calling_page = $q-referer();

hth,

Jos Boumans

Stéphane JEAN BAPTISTE wrote:

 How can I get the URL which was calling my script (like
 document.referrer in Javascript)

 tks




Re: Detecting NT eol (^M) characters

2001-06-21 Thread Brett W. McCoy

On Thu, 21 Jun 2001, Jeanne Riley wrote:

 I am attempting to write my 1st Perl script.  I have an install of ClearCase
 4.1 which has Perl embedded in it.  I need to write a Perl script (trigger)
 that if anyone attempts to check in a file with NT eol character the check
 in will be blocked.  The Perl script needs to detect if there are any NT eol
 or ^M characters in a file.  I am cat the file and know I need to grep for
 ^M but I don't know how to do this in Perl.  I did seek assistance from
 www.perl.org and found information regarding \cIM but this does not seem
 to work.

 Has anyone tried to do this before?

you want to match your string against /\cM/g.  In fact, instead of
blocking the file, you should just filter them out with this regular
expression substitution:

$string =~ s/\Cm//g

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

sillema sillema nika su




Re: Last page - That's OK

2001-06-21 Thread Stéphane JEAN BAPTISTE

It was all I need


Thank you




Stéphane JEAN BAPTISTE a écrit :

 How can I get the URL which was calling my script (like
 document.referrer in Javascript)

 tks




SUB ?

2001-06-21 Thread EDonnelly

Hi All,

Can you tell me what this sub is. Is it sub routine ?

Regards,
Elaine.


local(@acc_fields) = @_;
 return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' );
 return(-811) if ( $acc_fields[1] eq  );
 return(-812) if ( $acc_fields[2] eq  );
 return(-813) if ( $acc_fields[7]  0 );
 $acc_fields[8] = get_date if ( $acc_fields[8] eq '' );

 return(send_ddc(tdilc5110b000,accum_cycle_count,@acc_fields));
}

sub ilc_cycle_counting
{
 # @icc_fields are:
 #0 - Cycle Counting Order
 #1 - Warehouse
 #2 - Location
 #3 - Item Code
 #4 - Container
 #   5 - Lot Code
 #   6 - Storage Unit
 #   7 - Counted Inventory
 #8 - Counting Date

 local(@icc_fields) = @_;
 return(-810) if ( $icc_fields[0] == 0 || $icc_fields[0] eq '' );
 return(-811) if ( $icc_fields[1] eq  );
 return(-812) if ( $icc_fields[2] eq  );
 return(-813) if ( $icc_fields[7]  0 );
 $icc_fields[8] = get_date if ( $icc_fields[8] eq '' );

 return(send_ddc(tdilc5110b000,ilc_cycle_counting,@icc_fields));
}

#
-
# called from ccount form to ensure wharehouse/order combination is valid
#
-

sub validate_whse_order
 {
 local($whse) = $_[0];
 local($corder) = $_[1];

 return if ($whse eq );
 return if ($corder eq );

 display_status(Checking Order...);
 $select = SQL$;VALCCORDER$;${company}$;N$;$;${corder}$;${whse};
 return(send_dc($select));
 }

sub item_loc_on_ccorder
{
 my($item,$loc,$corder) = @_;

 return if ($item eq );
 return if ($loc eq );
 return if ($corder eq );

 display_status(Checking Item/Loc...);
 $select = SQL$;ITMLOCCCORDER$;${company}$;N$;$;${corder}$;${item}$;
${loc};
 return(send_dc($select));
} # item_loc_on_ccorder

sub get_ccorder_item_date
{
 my($item,$location,$order,$warehouse,$lot) = @_;

 display_status(Checking Item/Loc...);
 $select = SQL$;CCORDERDATE$;${company}$;N$;$;${order}$;${warehouse}$;
${location}$;${item}$;${lot};
###  return(send_dc($select));
$return = send_dc($select);
($cdate) = split($;,$err_msgs[0]);
if ( $return == 1 )
{
return 0;
}
else
{
return 1;
}
} #

1;






Perl DB Question again

2001-06-21 Thread Prabhu, Vrunda P (UMC-Student)

Victor had graciously answered some of my questions earlier about using
DB_File in a perl CGI.  I am now wondering about the following:

I have the following code:


**

 $filename=./mockalias.db;
tie %ALIAS, 'DB_File', $filename, O_RDWR|O_CREAT, 0644, $DB_HASH;
my ($key, $values);
open Fin, mockalias;
while (Fin)
{
($key, $value) = split(/:/, $_);
$ALIAS{$key} = $value;
}
close Fin;
###
 If Continue is selected, new entry will be created in the
 Alias file
###
if ($recstatus eq Continue)
{
$ALIAS{$login} = $loginaddress;

 ### If update is selected
if ($recstatus eq Update)
{
$ALIAS{$login} = $loginaddress;
###HTML code...
}

### If delete is selected
if ($recstatus eq Delete)   
 {
delete $ALIAS{$firstname};
delete $ALIAS{$login};
##HTML code...
} 
 untie %ALIAS; 
*


My question is the following:  When one gives the update, delete commands,
is the file mockalias also accordingly updated?  (MY file seems to not have
any changes). Once, the hash ALIAS is untied, should one then rewrite to
the file from the hash?

Thanks in advance.  ( I am a student, as you can tell from my address above,
however, none of this is my homework.  I am doing an internship and have
been assigned two projects, but no one here is there to help me, so I truly
appreciate all your help).
Thanks again.
Vrunda





SUB ?

2001-06-21 Thread EDonnelly

If it is sub routine, What does this mean ?

- Forwarded by Elaine Donnelly/Saturn on 21/06/01 14:49 -
   
 
[EMAIL PROTECTED] 
 
rndisc.comTo: [EMAIL PROTECTED]   
 
  cc:  
 
21/06/01 15:00Subject: SUB ?   
 
   
 
   
 



Hi All,

Can you tell me what this sub is. Is it sub routine ?

Regards,
Elaine.


local(@acc_fields) = @_;
 return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' );
 return(-811) if ( $acc_fields[1] eq  );
 return(-812) if ( $acc_fields[2] eq  );
 return(-813) if ( $acc_fields[7]  0 );
 $acc_fields[8] = get_date if ( $acc_fields[8] eq '' );

 return(send_ddc(tdilc5110b000,accum_cycle_count,@acc_fields));
}

sub ilc_cycle_counting
{
 # @icc_fields are:
 #0 - Cycle Counting Order
 #1 - Warehouse
 #2 - Location
 #3 - Item Code
 #4 - Container
 #   5 - Lot Code
 #   6 - Storage Unit
 #   7 - Counted Inventory
 #8 - Counting Date

 local(@icc_fields) = @_;
 return(-810) if ( $icc_fields[0] == 0 || $icc_fields[0] eq '' );
 return(-811) if ( $icc_fields[1] eq  );
 return(-812) if ( $icc_fields[2] eq  );
 return(-813) if ( $icc_fields[7]  0 );
 $icc_fields[8] = get_date if ( $icc_fields[8] eq '' );

 return(send_ddc(tdilc5110b000,ilc_cycle_counting,@icc_fields));
}

#
-

# called from ccount form to ensure wharehouse/order combination is valid
#
-


sub validate_whse_order
 {
 local($whse) = $_[0];
 local($corder) = $_[1];

 return if ($whse eq );
 return if ($corder eq );

 display_status(Checking Order...);
 $select = SQL$;VALCCORDER$;${company}$;N$;$;${corder}$;${whse};
 return(send_dc($select));
 }

sub item_loc_on_ccorder
{
 my($item,$loc,$corder) = @_;

 return if ($item eq );
 return if ($loc eq );
 return if ($corder eq );

 display_status(Checking Item/Loc...);
 $select = SQL$;ITMLOCCCORDER$;${company}$;N$;$;${corder}$;${item}$;
${loc};
 return(send_dc($select));
} # item_loc_on_ccorder

sub get_ccorder_item_date
{
 my($item,$location,$order,$warehouse,$lot) = @_;

 display_status(Checking Item/Loc...);
 $select = SQL$;CCORDERDATE$;${company}$;N$;$;${order}$;${warehouse}$;
${location}$;${item}$;${lot};
###  return(send_dc($select));
$return = send_dc($select);
($cdate) = split($;,$err_msgs[0]);
if ( $return == 1 )
{
return 0;
}
else
{
return 1;
}
} #

1;









Re: compilation errors in win98

2001-06-21 Thread james crease

In message 993124108.25145.2.camel@cowens, Chas Owens 
[EMAIL PROTECTED] writes
The problem is that the error messages are going to stderr instead of
stdout.  The standard DOS shell (command.com or cmd.exe depending on
your system) doesn't understand how to capture stderr.  The solution is
to get a better shell.  Cygnus (now RedHat) makes cygwin a complete unix
style development enviroment for Windows boxen that includes the best
command shell available (IMHO): bash
(http://sources.redhat.com/cygwin/).  I have also heard that 4dos gives
you the ability to capture stderr, but have never used their product
myself (http://www.jpsoft.com/).  There are almost certainly other
packages out there.

Thanks to all for suggestions.
Comments- I suspect Chas above has the likely solution.
The version of DOS I have on win98SE doesn't allow for a scroll bar as 
suggested by one comment nor does it have a layout tab to set the size 
of the window although it does allow a set to a maximum of 50 lines.

If there are any other thoughts on stderr capture I'd be pleased to hear 
them :-(





On 21 Jun 2001 09:26:28 +0100, james crease wrote:
 Thanks I had tried that already and doesn't seem to work at compile
 time:-(

 In message 00e401c0f9cc$02ee7340$0901a8c0@profit, Jos I. Boumans
 [EMAIL PROTECTED] writes
 try capturing the output:
 
 perl foo.pl  outputfile.txt
 
 all that perl spits out should be in the outputfile.txt then
 
 regards,
 
 Jos Boumans
 
 - Original Message -
 From: james crease [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, June 20, 2001 10:49 PM
 Subject: compilation errors in win98
 
 
  I have a perl script which generates many compilation errors which
  scroll off the DOS window perl is running in. How do I capture (or
  recover) the lines that have scrolled away?
  --
  james crease
 
 

 --
 james crease
 http://wocediu.org   Tel. +1 302 645 4240
 http://www.codata.orgTel. +44 1608 642335

--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
Keep the Lasagna flying!



-- 
james crease
http://wocediu.org   Tel. +1 302 645 4240
http://www.codata.orgTel. +44 1608 642335



Re: SUB ?

2001-06-21 Thread Chas Owens

Which one?  I count four.

On 21 Jun 2001 15:02:52 +0100, [EMAIL PROTECTED] wrote:
 If it is sub routine, What does this mean ?
 
 - Forwarded by Elaine Donnelly/Saturn on 21/06/01 14:49 -
  
   
 [EMAIL PROTECTED]   
   
 rndisc.comTo: [EMAIL PROTECTED] 
   
   cc:
   
 21/06/01 15:00Subject: SUB ? 
   
  
   
  
   
 
 
 
 Hi All,
 
 Can you tell me what this sub is. Is it sub routine ?
 
 Regards,
 Elaine.
 
 
 local(@acc_fields) = @_;
  return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' );
  return(-811) if ( $acc_fields[1] eq  );
  return(-812) if ( $acc_fields[2] eq  );
  return(-813) if ( $acc_fields[7]  0 );
  $acc_fields[8] = get_date if ( $acc_fields[8] eq '' );
 
  return(send_ddc(tdilc5110b000,accum_cycle_count,@acc_fields));
 }
 
 sub ilc_cycle_counting
 {
  # @icc_fields are:
  #0 - Cycle Counting Order
  #1 - Warehouse
  #2 - Location
  #3 - Item Code
  #4 - Container
  #   5 - Lot Code
  #   6 - Storage Unit
  #   7 - Counted Inventory
  #8 - Counting Date
 
  local(@icc_fields) = @_;
  return(-810) if ( $icc_fields[0] == 0 || $icc_fields[0] eq '' );
  return(-811) if ( $icc_fields[1] eq  );
  return(-812) if ( $icc_fields[2] eq  );
  return(-813) if ( $icc_fields[7]  0 );
  $icc_fields[8] = get_date if ( $icc_fields[8] eq '' );
 
  return(send_ddc(tdilc5110b000,ilc_cycle_counting,@icc_fields));
 }
 
 #
 -
 
 # called from ccount form to ensure wharehouse/order combination is valid
 #
 -
 
 
 sub validate_whse_order
  {
  local($whse) = $_[0];
  local($corder) = $_[1];
 
  return if ($whse eq );
  return if ($corder eq );
 
  display_status(Checking Order...);
  $select = SQL$;VALCCORDER$;${company}$;N$;$;${corder}$;${whse};
  return(send_dc($select));
  }
 
 sub item_loc_on_ccorder
 {
  my($item,$loc,$corder) = @_;
 
  return if ($item eq );
  return if ($loc eq );
  return if ($corder eq );
 
  display_status(Checking Item/Loc...);
  $select = SQL$;ITMLOCCCORDER$;${company}$;N$;$;${corder}$;${item}$;
 ${loc};
  return(send_dc($select));
 } # item_loc_on_ccorder
 
 sub get_ccorder_item_date
 {
  my($item,$location,$order,$warehouse,$lot) = @_;
 
  display_status(Checking Item/Loc...);
  $select = SQL$;CCORDERDATE$;${company}$;N$;$;${order}$;${warehouse}$;
 ${location}$;${item}$;${lot};
 ###  return(send_dc($select));
 $return = send_dc($select);
 ($cdate) = split($;,$err_msgs[0]);
 if ( $return == 1 )
 {
 return 0;
 }
 else
 {
 return 1;
 }
 } #
 
 1;
 
 
 
 
 
 
 
--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
P'tang!





Re: to delete a file

2001-06-21 Thread victor

try the unlink command.

Stéphane JEAN BAPTISTE wrote:

 How can I delete a file ?

 thanks




RE: to delete a file

2001-06-21 Thread Yacketta, Ronald

unix:
rm filename

winblows:
del filename

oh wait, do you mean in perl ;) (wise a$$ arent I?)

perldoc -f unlink


 -Original Message-
 From: Stéphane JEAN BAPTISTE
 [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 21, 2001 10:03 AM
 To: PERL
 Subject: to delete a file
 
 
 
 
 How can I delete a file ?
 
 thanks
 
 



Re: to delete a file

2001-06-21 Thread n6tadam

Hi,

Usually, one uses the following command (from the shell prompt)

rm /path/to/file/filename

To supress the confirmation message, use:

rm -f /path/to/file/filename

To delete recursively (i.e. a directory), and make it verbose to the screen:

rm -rfv /path/to/directory

Does that help.

Of course, from a perl script, you can either use:

system(/bin/rm -f /path/to/filename);

or

`rm -f filename`

I hope that helps,
Regards,

Thomas Adam  (VI form student)
Linux Co-ordinator at the Purbeck School (Network Support)
Wareham,
Dorset,
UK
- Original Message -
From: Stéphane JEAN BAPTISTE [EMAIL PROTECTED]
To: PERL [EMAIL PROTECTED]
Sent: Thursday, June 21, 2001 3:03 PM
Subject: to delete a file




How can I delete a file ?

thanks




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: SUB ?

2001-06-21 Thread EDonnelly


Does that mean that it will run 4 different sub routines ?



   

Chas Owens 

cowens@interTo: [EMAIL PROTECTED]  

call.comcc: [EMAIL PROTECTED]

 Subject: Re: SUB ?

21/06/01   

14:55  

   

   




Which one?  I count four.

On 21 Jun 2001 15:02:52 +0100, [EMAIL PROTECTED] wrote:
 If it is sub routine, What does this mean ?

 - Forwarded by Elaine Donnelly/Saturn on 21/06/01 14:49 -


 [EMAIL PROTECTED]

 rndisc.comTo: [EMAIL PROTECTED]

   cc:

 21/06/01 15:00Subject: SUB ?








 Hi All,

 Can you tell me what this sub is. Is it sub routine ?

 Regards,
 Elaine.


 local(@acc_fields) = @_;
  return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' );
  return(-811) if ( $acc_fields[1] eq  );
  return(-812) if ( $acc_fields[2] eq  );
  return(-813) if ( $acc_fields[7]  0 );
  $acc_fields[8] = get_date if ( $acc_fields[8] eq '' );

  return(send_ddc(tdilc5110b000,accum_cycle_count,@acc_fields));
 }

 sub ilc_cycle_counting
 {
  # @icc_fields are:
  #0 - Cycle Counting Order
  #1 - Warehouse
  #2 - Location
  #3 - Item Code
  #4 - Container
  #   5 - Lot Code
  #   6 - Storage Unit
  #   7 - Counted Inventory
  #8 - Counting Date

  local(@icc_fields) = @_;
  return(-810) if ( $icc_fields[0] == 0 || $icc_fields[0] eq '' );
  return(-811) if ( $icc_fields[1] eq  );
  return(-812) if ( $icc_fields[2] eq  );
  return(-813) if ( $icc_fields[7]  0 );
  $icc_fields[8] = get_date if ( $icc_fields[8] eq '' );

  return(send_ddc(tdilc5110b000,ilc_cycle_counting,@icc_fields));
 }

 #

-


 # called from ccount form to ensure wharehouse/order combination is valid
 #

-



 sub validate_whse_order
  {
  local($whse) = $_[0];
  local($corder) = $_[1];

  return if ($whse eq );
  return if ($corder eq );

  display_status(Checking Order...);
  $select = SQL$;VALCCORDER$;${company}$;N$;$;${corder}$;${whse};
  return(send_dc($select));
  }

 sub item_loc_on_ccorder
 {
  my($item,$loc,$corder) = @_;

  return if ($item eq );
  return if ($loc eq );
  return if ($corder eq );

  display_status(Checking Item/Loc...);
  $select = SQL$;ITMLOCCCORDER$;${company}$;N$;$;${corder}$;${item}$;
 ${loc};
  return(send_dc($select));
 } # item_loc_on_ccorder

 sub get_ccorder_item_date
 {
  my($item,$location,$order,$warehouse,$lot) = @_;

  display_status(Checking Item/Loc...);
  $select = SQL$;CCORDERDATE$;${company}$;N$;$;${order}$;${warehouse}
$;
 ${location}$;${item}$;${lot};
 ###  return(send_dc($select));
 $return = send_dc($select);
 ($cdate) = split($;,$err_msgs[0]);
 if ( $return == 1 )
 {
 return 0;
 }
 else
 {
 return 1;
 }
 } #

 1;







--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
P'tang!









Re: SUB ?

2001-06-21 Thread Chris Hedemark

Yes, sub denotes a subroutine.

Syntax:

sub name {
command;
command;
command;
}

You call it like this:

name(arg1,arg2);

I highly recommend picking up a copy of Learning Perl which explains this
in great detail.

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 21, 2001 10:00 AM
Subject: SUB ?


 Hi All,

 Can you tell me what this sub is. Is it sub routine ?

 Regards,
 Elaine.


 local(@acc_fields) = @_;
  return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' );
  return(-811) if ( $acc_fields[1] eq  );
  return(-812) if ( $acc_fields[2] eq  );
  return(-813) if ( $acc_fields[7]  0 );
  $acc_fields[8] = get_date if ( $acc_fields[8] eq '' );

  return(send_ddc(tdilc5110b000,accum_cycle_count,@acc_fields));
 }

 sub ilc_cycle_counting
 {
  # @icc_fields are:
  #0 - Cycle Counting Order
  #1 - Warehouse
  #2 - Location
  #3 - Item Code
  #4 - Container
  #   5 - Lot Code
  #   6 - Storage Unit
  #   7 - Counted Inventory
  #8 - Counting Date

  local(@icc_fields) = @_;
  return(-810) if ( $icc_fields[0] == 0 || $icc_fields[0] eq '' );
  return(-811) if ( $icc_fields[1] eq  );
  return(-812) if ( $icc_fields[2] eq  );
  return(-813) if ( $icc_fields[7]  0 );
  $icc_fields[8] = get_date if ( $icc_fields[8] eq '' );

  return(send_ddc(tdilc5110b000,ilc_cycle_counting,@icc_fields));
 }

 #
 --
---
 # called from ccount form to ensure wharehouse/order combination is valid
 #
 --
---

 sub validate_whse_order
  {
  local($whse) = $_[0];
  local($corder) = $_[1];

  return if ($whse eq );
  return if ($corder eq );

  display_status(Checking Order...);
  $select = SQL$;VALCCORDER$;${company}$;N$;$;${corder}$;${whse};
  return(send_dc($select));
  }

 sub item_loc_on_ccorder
 {
  my($item,$loc,$corder) = @_;

  return if ($item eq );
  return if ($loc eq );
  return if ($corder eq );

  display_status(Checking Item/Loc...);
  $select = SQL$;ITMLOCCCORDER$;${company}$;N$;$;${corder}$;${item}$;
 ${loc};
  return(send_dc($select));
 } # item_loc_on_ccorder

 sub get_ccorder_item_date
 {
  my($item,$location,$order,$warehouse,$lot) = @_;

  display_status(Checking Item/Loc...);
  $select =
SQL$;CCORDERDATE$;${company}$;N$;$;${order}$;${warehouse}$;
 ${location}$;${item}$;${lot};
 ###  return(send_dc($select));
 $return = send_dc($select);
 ($cdate) = split($;,$err_msgs[0]);
 if ( $return == 1 )
 {
 return 0;
 }
 else
 {
 return 1;
 }
 } #

 1;







Re: to delete a file

2001-06-21 Thread Kevin Meltzer

On Thu, Jun 21, 2001 at 03:04:21PM +0100, n6tadam 
([EMAIL PROTECTED]) spew-ed forth:
 Hi,
 

[snip]

 
 Of course, from a perl script, you can either use:
 
 system(/bin/rm -f /path/to/filename);
 
 or
 
 `rm -f filename`

Don't do that. Just use unlink()

perldoc -f unlink

Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
Nuclear explosions under the Nevada desert? What the f*ck are we testing for?
We already know the sh*t blows up.
-- Frank Zappa



Re: to delete a file - That's OK

2001-06-21 Thread Stéphane JEAN BAPTISTE

It's allright!

thank you

Stéphane JEAN BAPTISTE a écrit :

 How can I delete a file ?

 thanks




Re: to delete a file

2001-06-21 Thread Nigel Wetters

To delete a file:
unlink($filename) or die can't delete $filename:$!\n;

To delete lots of files:
unlink(@filenames) == @filenames or die couldn't unlink all of @filenames: $!\n;

To delete a folder:
use File::Path;
rmtree($directory);

 Stéphane JEAN BAPTISTE [EMAIL PROTECTED] 06/21/01 
03:03pm 


How can I delete a file ?

thanks




This e-mail and any files transmitted with it are confidential 
and solely for the use of the intended recipient. 
ONdigital plc, 346 Queenstown Road, London SW8 4DG. Reg No: 3302715. 



Re: SUB ?

2001-06-21 Thread Chas Owens

No, subroutines only get run if you explictitly run them:

code
#!/usr/bin/perl -w

use strict;

runme(); #run the runme subroutine

sub runme {
print You ran me!\n;
}

sub do_not_run_me {
print Why did you run me?\n;
}
/code

Based on the fact that the file ends with 1; I am willing to bet this is
a module that another perl file is including with the use command (Like
I included strict in my example).

On 21 Jun 2001 15:16:21 +0100, [EMAIL PROTECTED] wrote:
 
 Does that mean that it will run 4 different sub routines ?
 
 
 
  
  
 Chas Owens   
  
 cowens@interTo: [EMAIL PROTECTED]
  
 call.comcc: [EMAIL PROTECTED]  
  
  Subject: Re: SUB ?  
  
 21/06/01 
  
 14:55
  
  
  
  
  
 
 
 
 Which one?  I count four.
 
 On 21 Jun 2001 15:02:52 +0100, [EMAIL PROTECTED] wrote:
  If it is sub routine, What does this mean ?
 
  - Forwarded by Elaine Donnelly/Saturn on 21/06/01 14:49 -
 
 
  [EMAIL PROTECTED]
 
  rndisc.comTo: [EMAIL PROTECTED]
 
cc:
 
  21/06/01 15:00Subject: SUB ?
 
 
 
 
 
 
 
 
  Hi All,
 
  Can you tell me what this sub is. Is it sub routine ?
 
  Regards,
  Elaine.
 
 
  local(@acc_fields) = @_;
   return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' );
   return(-811) if ( $acc_fields[1] eq  );
   return(-812) if ( $acc_fields[2] eq  );
   return(-813) if ( $acc_fields[7]  0 );
   $acc_fields[8] = get_date if ( $acc_fields[8] eq '' );
 
   return(send_ddc(tdilc5110b000,accum_cycle_count,@acc_fields));
  }
 
  sub ilc_cycle_counting
  {
   # @icc_fields are:
   #0 - Cycle Counting Order
   #1 - Warehouse
   #2 - Location
   #3 - Item Code
   #4 - Container
   #   5 - Lot Code
   #   6 - Storage Unit
   #   7 - Counted Inventory
   #8 - Counting Date
 
   local(@icc_fields) = @_;
   return(-810) if ( $icc_fields[0] == 0 || $icc_fields[0] eq '' );
   return(-811) if ( $icc_fields[1] eq  );
   return(-812) if ( $icc_fields[2] eq  );
   return(-813) if ( $icc_fields[7]  0 );
   $icc_fields[8] = get_date if ( $icc_fields[8] eq '' );
 
   return(send_ddc(tdilc5110b000,ilc_cycle_counting,@icc_fields));
  }
 
  #
 
 -
 
 
  # called from ccount form to ensure wharehouse/order combination is valid
  #
 
 -
 
 
 
  sub validate_whse_order
   {
   local($whse) = $_[0];
   local($corder) = $_[1];
 
   return if ($whse eq );
   return if ($corder eq );
 
   display_status(Checking Order...);
   $select = SQL$;VALCCORDER$;${company}$;N$;$;${corder}$;${whse};
   return(send_dc($select));
   }
 
  sub item_loc_on_ccorder
  {
   my($item,$loc,$corder) = @_;
 
   return if ($item eq );
   return if ($loc eq );
   return if ($corder eq );
 
   display_status(Checking Item/Loc...);
   $select = SQL$;ITMLOCCCORDER$;${company}$;N$;$;${corder}$;${item}$;
  ${loc};
   return(send_dc($select));
  } # item_loc_on_ccorder
 
  sub get_ccorder_item_date
  {
   my($item,$location,$order,$warehouse,$lot) = @_;
 
   display_status(Checking Item/Loc...);
   $select = SQL$;CCORDERDATE$;${company}$;N$;$;${order}$;${warehouse}
 $;
  ${location}$;${item}$;${lot};
  ###  return(send_dc($select));
  $return = send_dc($select);
  ($cdate) = split($;,$err_msgs[0]);
  if ( $return == 1 )
  {
  return 0;
  }
  else
  {
  return 1;
  }
  } #
 
  1;
 
 
 
 
 
 
 
 --
 Today is Boomtime, the 26th day of Confusion in the YOLD 3167
 P'tang!
 
 
 
 
 
 
 
--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
Hail Eris, Hack Linux!





RE: xml problem

2001-06-21 Thread Richard_Cox

Chas Owens [mailto:[EMAIL PROTECTED]] wrote:
 On 21 Jun 2001 10:38:08 +0200, Morgan wrote:
  This script is exelent but I need the script to read the 
 letters åäö
  and ÅÄÖ too.
  Cuz this is part of my launguage (Swedish) and those 
 letters are in the
  articles.
 I am working on this, I don't understand what it is doing 
 with them.  If
 I add ?xml version='1.0' encoding='ISO-8859-1'? to the start of the
 file the parser doesn't bomb any more, but it outputs Dragkamp om
 förlusttÃ¥g instead of Dragkamp om förlusttåg.  My current
 assumption is that it is doing something funky involving two-byte
 UNICODE chars (this is based on the observation that the funky chars
 appear to be doubled).  If anyone could shed some light on 
 this I would

Try
[...]encoding='ISO-8859-4'[...]

ISO-8859-1 (aka Latin-1) coveres W. Europe, ISO-8859-4 is the specific
Scandinavian character set (almost, but not quite, the same as -1).

If this does not work, have a look at using UTF-8 (but this means those
accented characters will need to be encoded appropriately).

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



Re: exec()

2001-06-21 Thread Paul


--- Yacketta, Ronald [EMAIL PROTECTED] wrote:
 I am running the following (Thanxs to Paul for his skeleton code)
 exec ( 'egrep'. -c, $lookFor, @{$LOGS[($_ -1)]} )

You're quite welcome, but why exec egrep?

Ah, I may have misled you with that code.
You probably don't need the exec at all.

Just fork a child and have *that child process* handle the grep()'ing.
Perl is certainly as good at regexes as egrep. =o)
It can parse the file however you like, and redirect it's output any
way you please.




__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



RE: xml problem

2001-06-21 Thread Chas Owens

snip /
 
 Try
   [...]encoding='ISO-8859-4'[...]
 
 ISO-8859-1 (aka Latin-1) coveres W. Europe, ISO-8859-4 is the specific
 Scandinavian character set (almost, but not quite, the same as -1).
 
 If this does not work, have a look at using UTF-8 (but this means those
 accented characters will need to be encoded appropriately).
 
 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
 

Nope, didn't help.  The characters we are talking about exist in the
Latin-1 character set (I looked them up).

I was thinking about using  XTM::XML::UTF's iso2utf8 and utf82iso
functions, but I am not sure converting the entire file is worth it
though.  More and more I am leaning towords using my ftdp ord= /
hack. 

--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
Umlaut Zebra über alles!





Re: to delete a file

2001-06-21 Thread Chris Hedemark

#!/usr/bin/perl
#
# Name:unlinkdemo.pl
# Author:  Chris Hedemark [EMAIL PROTECTED]
# Purpose: Demonstrate use of the unlink function.

if (!@ARGV) {
die No arguments!\n;
}

for ($i = 0; $i  @ARGV.; ++$i) {
if (-e $ARGV[$i]) {
 unlink ($ARGV[$i]);
}
else {
 print File $ARGV[$i] does not exist!\n;
}
}

- Original Message -
From: Stéphane JEAN BAPTISTE [EMAIL PROTECTED]
To: PERL [EMAIL PROTECTED]
Sent: Thursday, June 21, 2001 10:03 AM
Subject: to delete a file




How can I delete a file ?

thanks





RTF to HTML or text conversion

2001-06-21 Thread Jonathan Macpherson


Hi;

Im trying to write a perl script that will pull newspaper stories out of a
sybase database and post them on the web. I can connect to sybase, pull
stories, but they are in Rich Text Format. I would like to convert the RTF
to text or html. Could anyone point me in the right direction ?

Thanks
jon




Re: to delete a file

2001-06-21 Thread Chris Hedemark

This will work on UNIX but I recommend against this because it is not
portable to other platforms, and there inefficiency in this in that it is
not native perl.  I recommend using the unlink command in perl which will be
portable across platforms and for a large number of files/servers it will
run faster with less resource overhead.

- Original Message -
From: n6tadam [EMAIL PROTECTED]
To: Stéphane JEAN BAPTISTE [EMAIL PROTECTED];
PERL [EMAIL PROTECTED]
Sent: Thursday, June 21, 2001 10:04 AM
Subject: Re: to delete a file


 Hi,

 Usually, one uses the following command (from the shell prompt)

 rm /path/to/file/filename

 To supress the confirmation message, use:

 rm -f /path/to/file/filename

 To delete recursively (i.e. a directory), and make it verbose to the
screen:

 rm -rfv /path/to/directory

 Does that help.

 Of course, from a perl script, you can either use:

 system(/bin/rm -f /path/to/filename);

 or

 `rm -f filename`

 I hope that helps,
 Regards,

 Thomas Adam  (VI form student)
 Linux Co-ordinator at the Purbeck School (Network Support)
 Wareham,
 Dorset,
 UK
 - Original Message -
 From: Stéphane JEAN BAPTISTE [EMAIL PROTECTED]
 To: PERL [EMAIL PROTECTED]
 Sent: Thursday, June 21, 2001 3:03 PM
 Subject: to delete a file




 How can I delete a file ?

 thanks




 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: Last page

2001-06-21 Thread Zhe Hong

The URL which was calling your script is stored in the variable
$ENV{'HTTP_REFERER'} .
note: referrer spelt as referer and not referrer.




use of require causing name space problems?

2001-06-21 Thread Rodney Holm

I have a few functions that are common to many different
perl applications.  All of these functions live in one
file.

I have many perl programs that run from cron that make
use of these functions.  So, in each of these programs
I use require to gain access to these functions.

Example:

 doit.pl 
#!/usr/bin/perl
require '/usr/local/myperllib.pl';
@array = (one\n, two\n, three\n);
## calling WriteFile from myperllib.pl
WriteFile('/path/filename', @array);
exit;
 doit.pl 

 doit1.pl 
require '/usr/local/myperllib.pl';
@array = (four\n, five\n, six\n);
## calling WriteFile from myperllib.pl
WriteFile('/path/filename1', @array);
exit;

imagine many of these doit.pl scripts ( doit1.pl, doit2.pl ... ), all using
require, all calling WriteFile, all running at the same time.

What happens is sometimes, what should end up in one file, ends up in
another file.  I would expect:
$ cat /path/filename
one
two
three

what I sometimes get is the contents of /path/filename1 ending up in
/path/filename
$ cat /path/filename
four
five
six

How would I code my library correctly to avoid this type of namespace
pollution?

thanks
rodney




Re: RTF to HTML or text conversion

2001-06-21 Thread Me

http://search.cpan.org/

 Im trying to write a perl script that will pull newspaper stories out
of a
 sybase database and post them on the web. I can connect to sybase,
pull
 stories, but they are in Rich Text Format. I would like to convert the
RTF
 to text or html. Could anyone point me in the right direction ?

 Thanks
 jon




Terminal control on Windows NT

2001-06-21 Thread Nigel Wetters

I want to do this:

use POSIX qw(:termios_h);
$term = POSIX::Termios-new;
$term-getattr(fileno(STDIN));
# do some terminal manipulation here

However, I get the error message on Windows NT:

POSIX::termios not implemented on this architecure

I have two questions:

1. Is there _any_ way to take user input (including control sequences such as ^C) from 
Windows, and not have that input echo'd to the screen?

2. Is it possible to do this in a platform-independent manner?

--nigel




This e-mail and any files transmitted with it are confidential 
and solely for the use of the intended recipient. 
ONdigital plc, 346 Queenstown Road, London SW8 4DG. Reg No: 3302715. 



RE: Terminal control on Windows NT

2001-06-21 Thread John Edwards

use Term::ReadKey;

print Please enter password: ;
ReadMode('noecho');
$password = ReadLine(0);
ReadMode('restore');
chomp ($password);
print \n;

print $password\n;

-Original Message-
From: Nigel Wetters [mailto:[EMAIL PROTECTED]]
Sent: 21 June 2001 16:16
To: [EMAIL PROTECTED]
Subject: Terminal control on Windows NT


I want to do this:

use POSIX qw(:termios_h);
$term = POSIX::Termios-new;
$term-getattr(fileno(STDIN));
# do some terminal manipulation here

However, I get the error message on Windows NT:

POSIX::termios not implemented on this architecure

I have two questions:

1. Is there _any_ way to take user input (including control sequences such
as ^C) from Windows, and not have that input echo'd to the screen?

2. Is it possible to do this in a platform-independent manner?

--nigel




This e-mail and any files transmitted with it are confidential 
and solely for the use of the intended recipient. 
ONdigital plc, 346 Queenstown Road, London SW8 4DG. Reg No: 3302715. 


--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: tutorial on my/our/use/package/local

2001-06-21 Thread Randal L. Schwartz

 Jeff == Jeff 'japhy' Pinyan [EMAIL PROTECTED] writes:

Jeff Damian dropped the bomb at YAPC.  You'll be able to access the padlist,
Jeff using a mechanism like C$MY.foo.

Ah, that's what happens when you spend a week at sea with Tim Bunce on
a Geek Cruise (www.geekcruises.com) instead of being in Montreal. :-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re[2]: compilation errors in win98

2001-06-21 Thread Tim Musson

Hey james,

Thursday, June 21, 2001, 9:26:34 AM, you wrote:

jc The version of DOS I have on win98SE doesn't allow for a scroll
jc bar as  suggested by one comment nor does it have a layout tab to
jc set the size  of the window although it does allow a set to a
jc maximum of 50 lines.

Are you not trying to run it in a command window from the GUI then?
Just booting to DOS?

-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
What could possibly go wrong?




RE: use of require causing name space problems?

2001-06-21 Thread Rodney Holm

Does anyone know why perl behaves like this?  It seems to me
that since the scripts are running as seperate processes, there
should not be a problem.

The only information Ive found on the subject is this:

require - the file being required inserts the subroutine names
  into a package ( a namespace ) of its own choosing, not
  your package.  Second, require happens at run-time, so
  the decleration occurs to late to serve as a declaration
  in the file invoking the require.

use - performs a require at compile time, then lets you import
  declerations into your own namespace.

Would it behoove me to modify my library to be a perl module and
switch require to use?  Would this solve my problem?

thanks
rodney


 -Original Message-
 From: Me [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 21, 2001 9:23 AM
 To: Rodney Holm; [EMAIL PROTECTED]
 Subject: Re: use of require causing name space problems?
 
 
  sub WriteFile
  {
  my ($file,@lines) = @_;
  my ($line);
  
  open(FILE,$file);
 
 FILE is a problem.
 
 If you are using perl 5.6 or later, you can do:
 
 my $fh;
 
 and then use $fh where you were using FILE, eg
 
 open($fh, $file);
 
 If you aren't using 5.6, it gets more complicated
 and I'm out of, er, my depth. I'll post later if I see
 what to do, but I suggest you post again and ask.
 
  foreach $line (@lines)
 
 $line is a problem.
 
 Fixing $line is easy. I'll let you guess. :
 Ok, no I won't:
 
 foreach my $line (@lines)
 
  {
  print FILE $line; }
  }
  close(FILE);
  return(0);
  }
  open(FILE,$file);
 
 



=

2001-06-21 Thread Nick Transier

I have written some OO perl and I have a problem that I just realized, when 
you set an object = to another object, they become irreversibly linked and 
all operations on one or the other causes changes in both. If I am trying to 
simply initialize the object and not link them, how do I get around this 
problem?

Thanks,
-Nick
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




Re: use of require causing name space problems?

2001-06-21 Thread Me

Ok, I entirely retract my post to which this is a reply.
Hey, I've been up all night.

If the scripts are running as separate processes,
then, well, I don't know.

 Does anyone know why perl behaves like this?
[see earlier posts in thread]




Regex Problem

2001-06-21 Thread Jack Lauman

I get the following results when running the perl script below.  For
some reason I get (3) lines that don't match the regex criteria before
it reaches the first line that has data, and one additional line after
the script completes.  Is there a way to not write the line if the 
varaiable $cur_sym is empty?

Thanks in advance,

Jack

Output from script:

2000-12-29,16:16:19,PST
2000-12-29,16:16:19,PST
2000-12-29,16:16:19,PST
2000-12-29,16:16:19,PST,USD,United States Dollars   ,1.0,1.0
2000-12-29,16:16:19,PST,EUR,Euro   
,0.941604,1.06202
2000-12-29,16:16:19,PST,GBP,United Kingdom Pounds  
,1.49242,0.670052
2000-12-29,16:16:19,PST,CAD,Canada Dollars 
,0.666790,1.49972
2000-12-29,16:16:19,PST,DEM,Germany Deutsche Marks 
,0.481435,2.07712
2000-12-29,16:16:19,PST,FRF,France Francs  
,0.143547,6.96638
2000-12-29,16:16:19,PST,JPY,Japan Yen  
,0.00872554,114.606
2000-12-29,16:16:19,PST



#!/usr/bin/perl
#
# cur2csv.pl
#

use strict;
use vars qw($started);
use vars qw($cur_sym $cur_desc $usd_unit $units_usd);
use vars qw($year $month $mday $hour $minute $second $timezone);
use vars qw($conv_date $date $time $tz);


use Date::Manip;
use String::Strip;

use DBI;
use DBD::Pg;

open (OUTFILE, , currency.csv) || die Can not open currency.csv
for writing;

printf STDERR Reading currency file...;
open (INFILE, currency) || die Can not open /var/spool/mail/currency
for reading;

while (INFILE) {

# Extract date and time of Currency Rate Quotation

($year, $month, $mday, $hour, $minute, $second, $timezone) =
/^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+) (\w+) (.*)$/; 

# Convert date from UTC (GMT) to PST8PDT and adjust date and time
accordingly.

$tz = Date_TimeZone;   
$conv_date = $year-$month-$mday $hour:$minute:$second;
$conv_date = ParseDate($conv_date);
$conv_date = Date_ConvTZ($conv_date, $timezone, $tz);  
$date  = UnixDate($conv_date,%Y-%m-%d);
$time  = UnixDate($conv_date,%H:%M:%S);
$tz= UnixDate($conv_date,%Z);

$year and last;# If we've matched the data line, then bail out.

eof and print STDERR Didn't find the date line;

}

# Extract the ISO 4217 Code for Currencies and Funds (1995)
# Extract the Currency Description, and trim the trailing spaces
# Extract US Dollars to Units rate, and trim the leading/trailing
spaces
# Extract Units to US Dollars rate, and trim the leading/trailing
spaces

while (INFILE) {

($cur_sym, $cur_desc, $usd_unit, $units_usd) =
/^([A-Z]{3})\s+([A-Za-z()\s]{28})\s+(\d+\.\d+)\s+(\d+\.\d+)/;

# Strip the trailing spaces from $cur_desc
StripTSpace($cur_desc);

$cur_sym and $started++;

printf OUTFILE %s\,%s\,%s\,%s\,%s\,%s\,%s\n,
$date, $time, $tz, $cur_sym, $cur_desc, $usd_unit, $units_usd;

not $cur_sym and ($started and last) or next;

$started or print STDERR Didn't find a currency line;

}   


close(INFILE);
close(OUTFILE);
print STDERR \n;

1;



RE: Regex Problem

2001-06-21 Thread John Edwards

if ($cur_sym) {
printf OUTFILE %s\,%s\,%s\,%s\,%s\,%s\,%s\n,$date, $time, $tz,
$cur_sym, $cur_desc, $usd_unit, $units_usd;
}

-Original Message-
From: Jack Lauman [mailto:[EMAIL PROTECTED]]
Sent: 21 June 2001 17:15
To: [EMAIL PROTECTED]
Subject: Regex Problem


I get the following results when running the perl script below.  For
some reason I get (3) lines that don't match the regex criteria before
it reaches the first line that has data, and one additional line after
the script completes.  Is there a way to not write the line if the 
varaiable $cur_sym is empty?

Thanks in advance,

Jack

Output from script:

2000-12-29,16:16:19,PST
2000-12-29,16:16:19,PST
2000-12-29,16:16:19,PST
2000-12-29,16:16:19,PST,USD,United States Dollars   ,1.0,1.0
2000-12-29,16:16:19,PST,EUR,Euro   
,0.941604,1.06202
2000-12-29,16:16:19,PST,GBP,United Kingdom Pounds  
,1.49242,0.670052
2000-12-29,16:16:19,PST,CAD,Canada Dollars 
,0.666790,1.49972
2000-12-29,16:16:19,PST,DEM,Germany Deutsche Marks 
,0.481435,2.07712
2000-12-29,16:16:19,PST,FRF,France Francs  
,0.143547,6.96638
2000-12-29,16:16:19,PST,JPY,Japan Yen  
,0.00872554,114.606
2000-12-29,16:16:19,PST



#!/usr/bin/perl
#
# cur2csv.pl
#

use strict;
use vars qw($started);
use vars qw($cur_sym $cur_desc $usd_unit $units_usd);
use vars qw($year $month $mday $hour $minute $second $timezone);
use vars qw($conv_date $date $time $tz);


use Date::Manip;
use String::Strip;

use DBI;
use DBD::Pg;

open (OUTFILE, , currency.csv) || die Can not open currency.csv
for writing;

printf STDERR Reading currency file...;
open (INFILE, currency) || die Can not open /var/spool/mail/currency
for reading;

while (INFILE) {

# Extract date and time of Currency Rate Quotation

($year, $month, $mday, $hour, $minute, $second, $timezone) =
/^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+) (\w+) (.*)$/; 

# Convert date from UTC (GMT) to PST8PDT and adjust date and time
accordingly.

$tz = Date_TimeZone;   
$conv_date = $year-$month-$mday $hour:$minute:$second;
$conv_date = ParseDate($conv_date);
$conv_date = Date_ConvTZ($conv_date, $timezone, $tz);  
$date  = UnixDate($conv_date,%Y-%m-%d);
$time  = UnixDate($conv_date,%H:%M:%S);
$tz= UnixDate($conv_date,%Z);

$year and last;# If we've matched the data line, then bail out.

eof and print STDERR Didn't find the date line;

}

# Extract the ISO 4217 Code for Currencies and Funds (1995)
# Extract the Currency Description, and trim the trailing spaces
# Extract US Dollars to Units rate, and trim the leading/trailing
spaces
# Extract Units to US Dollars rate, and trim the leading/trailing
spaces

while (INFILE) {

($cur_sym, $cur_desc, $usd_unit, $units_usd) =
/^([A-Z]{3})\s+([A-Za-z()\s]{28})\s+(\d+\.\d+)\s+(\d+\.\d+)/;

# Strip the trailing spaces from $cur_desc
StripTSpace($cur_desc);

$cur_sym and $started++;

printf OUTFILE %s\,%s\,%s\,%s\,%s\,%s\,%s\n,
$date, $time, $tz, $cur_sym, $cur_desc, $usd_unit,
$units_usd;

not $cur_sym and ($started and last) or next;

$started or print STDERR Didn't find a currency line;

}   


close(INFILE);
close(OUTFILE);
print STDERR \n;

1;


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

2001-06-21 Thread Jeff 'japhy' Pinyan

On Jun 21, Nick Transier said:

I have written some OO perl and I have a problem that I just realized, when 
you set an object = to another object, they become irreversibly linked and 
all operations on one or the other causes changes in both. If I am trying to 
simply initialize the object and not link them, how do I get around this 
problem?

You want to make a clone of the object.

  use Storable 'dclone';  # you might need to get this from CPAN
  $new = dclone $orig;

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

2001-06-21 Thread Nick Transier

Isn't == a logical operator? I am not trying to compare the two objects.


From: Sally [EMAIL PROTECTED]
To: Nick Transier [EMAIL PROTECTED]
Subject: RE: =
Date: Thu, 21 Jun 2001 17:18:47 +0100

You should use == instead of =

-Original Message-
From: Nick Transier [mailto:[EMAIL PROTECTED]]
Sent: 21 June 2001 17:09
To: [EMAIL PROTECTED]
Subject: =


I have written some OO perl and I have a problem that I just realized, when
you set an object = to another object, they become irreversibly linked and
all operations on one or the other causes changes in both. If I am trying 
to
simply initialize the object and not link them, how do I get around this
problem?

Thanks,
-Nick
_
Get your FREE download of MSN Explorer at http://explorer.msn.com


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




Re: Perl DB Question again

2001-06-21 Thread Michael Fowler

On Thu, Jun 21, 2001 at 08:48:08AM -0500, Prabhu, Vrunda P (UMC-Student) wrote:
 I have the following code:
[snip]
 open Fin, mockalias;

Always check your open calls:
open Fin, mockalias or die(Unable to open file \mockalias\: \l$!.\n);

[snip]


 My question is the following:  When one gives the update, delete commands,
 is the file mockalias also accordingly updated?  (MY file seems to not have
 any changes).

Yes, the file should be updated as you make modifications to the hash.  How
did you go about verifying these changes weren't being made?



 Once, the hash ALIAS is untied, should one then rewrite to the file from
 the hash?

Um, no, that's the entire point of tying; any modifications of the hash are
applied to the file.


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



Re: =

2001-06-21 Thread Brett W. McCoy

On Thu, 21 Jun 2001, Nick Transier wrote:

 I have written some OO perl and I have a problem that I just realized, when
 you set an object = to another object, they become irreversibly linked and
 all operations on one or the other causes changes in both. If I am trying to
 simply initialize the object and not link them, how do I get around this
 problem?

This is an issue one confronts in a lot of OO langauges.  I think the
issue is that you are not copying objects, but making one reference to
another reference.  You need to create what is called a 'copy constructor'
-- basically, create a method in a class that returns a copy of an object
(I think Randal referred to this the other day when he was talking about
the $self = ref($proto) || $proto controversy), you can call the
constructor 'clone' or something to that effect.  In C++, you can overload
the = operator to use the copy constructor.  I don't remember if in Perl
you can overload =, but you can still do:

$newobj = $old_obj-clone #you will clone $self

or even

$newobj = Class-clone($old_obj);

where Class is the name of the class itself (and clone becomes a class --
or static -- method).

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

Presidency:  The greased pig in the field game of American politics.
-- Ambrose Bierce




Advice for Perl Class

2001-06-21 Thread dave hoover

I began learning Perl in November of 2000.  I've
learned a lot in a short amount of time and I feel
like I've got a good understanding of Perl
fundamentals (I just finished reading Effective Perl
Programming...great book).

Anyway, at my job I have the opportunity to use some
training money to learn more about whatever I want.  I
want to learn more about Perl and Networks and CGI.  I
live in the Chicago area and I need some
recommendations about where I could find some
excellent classes nearby.

TIA

=
Dave Hoover
Twice blessed is help unlooked for. --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Terminal control on Windows NT

2001-06-21 Thread Brett W. McCoy

On Thu, 21 Jun 2001, Nigel Wetters wrote:

 use POSIX qw(:termios_h);
 $term = POSIX::Termios-new;
 $term-getattr(fileno(STDIN));
 # do some terminal manipulation here

 However, I get the error message on Windows NT:

 POSIX::termios not implemented on this architecure

 I have two questions:

 1. Is there _any_ way to take user input (including control sequences
 such as ^C) from Windows, and not have that input echo'd to the
 screen?

 2. Is it possible to do this in a platform-independent manner?

Your going to have trouble doing that with the command-shell, most
definitely.  As many others have suggested, you will have to move to
CygWin (or Unix altogether) to use the POSIX based modules.

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

Never underestimate the bandwidth of a station wagon full of tapes.
-- Dr. Warren Jackson, Director, UTCS




Cloning

2001-06-21 Thread Nick Transier

Ok, so I see the way around the = problem with cloning, however, there is a 
clone module on CPAN, but I have no idea how to install it using win2k. Any 
ideas?

Thanks,
-Nick
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




Re: tutorial on my/our/use/package/local

2001-06-21 Thread Me

 Brutal critique enclosed... beware, I get right to the point. :)

Hmm, I enjoyed it, so I'm thinking I must
be more SM oriented than I thought...


 Me # $_ is in main.

 $_ is always in main, even if the current package is something else.

Yes. I spent some time considering where this was
best revealed, and wrote it in in various places as
I drafted this article along with other stuff such as that
you can't my $_. But these details ultimately bit the
digital dust.


 Me Amazingly, a huge number of high quality packages
 Me are available publically for free in one nice big catalog
 Me called CPAN. Some come with perl as standard.

 That'd be modules, not packages.

My early drafts tried to maintain the module/package
distinction. But on balance, I decided the distinction was
not merited given the kind of material I was trying to write,
especially given that I judged that the lie does little damage.

I found that the sleight of hand of focusing on packages
as against modules, and indeed on the content of a
package (its names) as against the package as a
singular entity, worked better than the alernatives I
came up with.

My intent was to say, you could go get a namespace
(set of names) by going to CPAN, and I thought that
that was a reasonable way of looking at it. Again, one
draft used 'namespace' throughout and deliberately
eschewed the terms module and package.


 Me Apart from main and MY, all other packages have to be
 Me given a name.

 main is a name!  MY is not a package.

main is the name of a namespace.

MY is my name for what is currently (perl 5) an
anonymous namespace. A package is a namespace,
and I felt that less damage was done in this article
if I also used the white lie that a namespace is a package.

I'm having second thoughts of course. Larry didn't use
the term package in connection with MY, he used the
term pseudo class. Indeed he specifically said that
one could use it to import things lexically as well as
packagely, indicating that he did not see MY as a
package, or at least not as a package.

Btw, MY was mentioned in Apocalypse II, which is where I
picked up on it. I have no idea what Damian said about it.


 Me To use another package written by someone else,
 Me you write something like:

 Me use File::Copy;

 module!

Well, unless I'm getting something really screwed up
(always possible :), I'd say both.

You have to use the module, to use the names in its
namespace, which is to say to use the namespace,
which is to say to use the package.

I do think the File::Copy wasn't the best choice to
illustrate some of these points. But I decided it was
good enough.


 Me Fortunately, the 'use File::Copy' statement does more
 Me than make the namespace available. It also imports
 Me some names right in to your main package.

 Actually, the current package.

Argh. Bad mistake. Thanks.


 Me use warnings;

 use warnings makes your program needlessly incompatible with 5.5.
 don't do that unless you're also using other 5.6 features.

A useful reminder. Thanks.


 Me my $foo;

 Me so that $foo now belongs in the MY package.

 $foo is now a lexical, not part of any package, and has a scope and
 persistence related to where it is defined, no longer a global.

Again, I think the device of fuzzing the notion of package
serves a purpose and it seemed to serve it well to me.
The truth is s much more complicated!


 Me package Foo;
 Me our $bar = 1;   # set $bar from package Foo.
 Me our $baz = 2;   # set $baz from package Foo.

 our is 5.6, again needlessly incompatible with 5.5.  use vars
qw($bar)
 is the close equivalent for all.

Oh I don't think needless is fair. I certainly wouldn't
have left our out, it's too neat. But I agree it was wrong
not to mention, in fact highlight, our's newness, as well
as to mention use vars.


 Me If you redeclare a my, you throw away the old value:

 Me my $foo = 1;
 Me my $foo;
 Me # $foo is undefined.

 This is almost certainly unintended, and merits a warning when
 warnings are enabled.

My 5.6.0 does indeed warn.


 Me Only use local if you can't do what you want with my.

 You haven't even mentioned what local is, so it doesn't even suggest
 why you'd want this.

This section barely made my final editor's cut.

I deliberately didn't say how to use it. I mentioned it
enough to say, don't do that, and what you should be
doing instead. Any more seemed inappropriate.
local doesn't have any impact on namespaces or
use of names. It's only to do with values.


 Me * In Perl 5, the package I call MY package is not often
 Me called a package and can't be accessed in the same
 Me way that other packages can be accessed. However,
 Me in Perl 6, there will be a MY package, and, imo, it is
 Me simpler to use the term package for all namespaces.

 This is news to me.

As explained above, I may be technically wrong on MY,
perhaps very wrong. I am not sure how this would impact
how I felt about the package and MY 

regex headache

2001-06-21 Thread Yacketta, Ronald

Folks,

I have been looking for a way to search for two strings in a line
at the command line I would

Communication $grepTMPFILE | grep failure | wc -l

how would this be converted into perl/regex? I have part of it right now
(Thanxs to others on the list)

foreach (@output) {
foreach my $test(@lookFor) {
$results{$test}++ if /$test/igo;
}
}

I need to add a  to the if above.. correct?

if ( $test == 'Communication' ) {
if ( /$text/igo  /failed/igo ) {  $results($test)++; }
}



Re: fastest method to check if a URL is alive

2001-06-21 Thread Bradford Ritchie

I tried your code and got it to work by inserting a chomp; in your while loop.  I 
don't understand chomp/chop well enough to figure out how to imbed it within the print 
line, though.  Give it a shot if you think it will run faster that way.

-- Brad


- Original Message - 
From: Drew Cohan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 21, 2001 3:52 AM
Subject: fastest method to check if a URL is alive


 Hi,
 
 Could some kind soul please tell me why the following
 prints nothing for valid URLs?  I'm trying to write a
 small, tight, and very fast script that'll check to
 see if a URL is alive in the least amount of time
 possible (and avoid using PING).  I need to check
 thousands of URLs.  It seems to me that this should be
 a relatively simple affair?  Below is some code I've
 tried to adapt from the cookbook (example 20.1).  I
 was also intrigued by the HTML:Status class mentioned
 in the perldoc, but I can't seem to figure out how to
 use it without employing the seemingly overkill
 LWP:UserAgent.  
 
 thanks in advance,
 
 Drew.
 
  snip 
 #!/usr/bin/perl -w
 
 $|++;
 
 use warnings;
 use strict;
 use diagnostics;
 
 use LWP::Simple;
 
 while (){
 print if (defined (my $content = get $_));
 }
  end of snip 
 
 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail
 http://personal.mail.yahoo.com/




Re: Cloning

2001-06-21 Thread Jos I. Boumans

if you have activestate's perl distro, try running 'ppm' and search for
'storable'
then just 'install storable' (or whatever it's exact name is) and you're
good to go

if you did it anyway else, you'll need to grab the tarball off cpan and
install like described in the readme

hth,

Jos Boumans

- Original Message -
From: Nick Transier [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 21, 2001 7:03 PM
Subject: Cloning


 Ok, so I see the way around the = problem with cloning, however, there is
a
 clone module on CPAN, but I have no idea how to install it using win2k.
Any
 ideas?

 Thanks,
 -Nick
 _
 Get your FREE download of MSN Explorer at http://explorer.msn.com






How do you create a Hyperlink field in an MS Access table?

2001-06-21 Thread Adam Dudsic

I'm using Perl DBI to create a table in an MS Access database.  No problem 
with that.  However, I can't figure out how to create a field in that table 
whose data type is Hyperlink.

In the course of investigating the problem, I manually created a table in 
which one of the fields was set to the Hyperlink data type, then used DBI 
type_info() to see what data type DBI interpreted that field as having.  It 
came back showing the field to be a LONGCHAR field.

So, going back to my problem, I assume that in creating a new MS Access 
table, if I want to create a field whose data type is Hyperlink, I must 
actually create a LONGCHAR field, then set some additional field 
attribute/property (dbHyperlink?) so that the contents of the field are 
treated as a Hyperlink.

But how?  Might this involve using some other module--a Win32 or some OLE 
module?

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




How do you create a Hyperlink field in an MS Access table?

2001-06-21 Thread Adam Dudsic

I'm using Perl DBI to create a table in an MS Access database.  No problem 
with that.  However, I can't figure out how to create a field in that table 
whose data type is Hyperlink.

In the course of investigating the problem, I manually created a table in 
which one of the fields was set to the Hyperlink data type, then used DBI 
type_info() to see what data type DBI interpreted that field as having.  It 
came back showing the field to be a LONGCHAR field.

So, going back to my problem, I assume that in creating a new MS Access 
table, if I want to create a field whose data type is Hyperlink, I must 
actually create a LONGCHAR field, then set some additional field 
attribute/property (dbHyperlink?) so that the contents of the field are 
treated as a Hyperlink.

But how?  Might this involve using some other module--a Win32 or some OLE 
module?

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




Re: =

2001-06-21 Thread Chas Owens

On 21 Jun 2001 12:40:07 -0400, Brett W. McCoy wrote:
snip /

In C++, you can overload the = operator to use the copy constructor.  I don't 
remember if in Perl
 you can overload =

snip /

use overload = = \clone;

Perl also does automagic operator overloading.  If you overload - it
automagicly overloads -= and -- for you.

--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
Fnord.





One last question...

2001-06-21 Thread Jack Lauman

I get the following from 'grep CAD currency.csv' created from the
script below.  If the file has more than one e-mail message in it
(this one does) how can I get it to return the correct date along
with the currency rates data (which are correct)?

2001-06-14,14:16:23,PDT,CAD,Canada Dollars,0.657776,1.52027
2001-06-14,14:16:23,PDT,CAD,Canada Dollars,0.656214,1.52389
2001-06-14,14:16:23,PDT,CAD,Canada Dollars,0.656039,1.52430
2001-06-14,14:16:23,PDT,CAD,Canada Dollars,0.651900,1.53398
2001-06-14,14:16:23,PDT,CAD,Canada Dollars,0.652010,1.53372
2001-06-14,14:16:23,PDT,CAD,Canada Dollars,0.652225,1.53321

The above dates should fall between 6/14 and 6/20.

Thanks,

Jack

#!/usr/bin/perl
#
# cur2csv.pl
#

use strict;
use vars qw($started);
use vars qw($cur_sym $cur_desc $usd_unit $units_usd);
use vars qw($year $month $mday $hour $minute $second $timezone);
use vars qw($conv_date $date $time $tz);


use Date::Manip;
use String::Strip;

use DBI;
use DBD::Pg;

open (OUTFILE, , currency.csv) || die Can not open currency.csv
for writing;

printf STDERR Reading currency file...;
open (INFILE, /var/spool/mail/currency) || die Can not open
/var/spool/mail/currency for reading;

while (INFILE) {

# Extract date and time of Currency Rate Quotation

($year, $month, $mday, $hour, $minute, $second, $timezone) =
/^Rates as of (\d+).(\d+).(\d+) (\d+):(\d+):(\d+) (\w+) (.*)$/; 

# Convert date from UTC (GMT) to PST8PDT and adjust date and time
accordingly.

$tz = Date_TimeZone;   
$conv_date = $year-$month-$mday $hour:$minute:$second;
$conv_date = ParseDate($conv_date);
$conv_date = Date_ConvTZ($conv_date, $timezone, $tz);  
$date  = UnixDate($conv_date,%Y-%m-%d);
$time  = UnixDate($conv_date,%H:%M:%S);
$tz= UnixDate($conv_date,%Z);

$year and last;# If we've matched the data line, then bail out.

eof and print STDERR Didn't find the date line;

}

# Extract the ISO 4217 Code for Currencies and Funds (1995)
# Extract the Currency Description, and trim the trailing spaces
# Extract US Dollars to Units rate, and trim the leading/trailing
spaces
# Extract Units to US Dollars rate, and trim the leading/trailing
spaces

while (INFILE) {

($cur_sym, $cur_desc, $usd_unit, $units_usd) =
/^([A-Z]{3})\s+([A-Za-z()\s]{28})\s+(\d+\.\d+)\s+(\d+\.\d+)/;

# Strip the trailing spaces from $cur_desc
StripTSpace($cur_desc);

$cur_sym and $started++;

if ($cur_sym) {
printf OUTFILE %s\,%s\,%s\,%s\,%s\,%s\,%s\n,
$date, $time, $tz, $cur_sym, $cur_desc, $usd_unit, $units_usd;
}

}   

$started or print STDERR Didn't find a currency line;

close(INFILE);
close(OUTFILE);
print STDERR \n;

1;



Re: compilation errors in win98

2001-06-21 Thread Aaron Craig

At 21:49 20.06.2001 +0100, james crease wrote:
I have a perl script which generates many compilation errors which scroll 
off the DOS window perl is running in. How do I capture (or recover) the 
lines that have scrolled away?
--
james crease


Use EditPlus2 as your editor.  You can capture perl output in an output 
window inside the program, copy and paste it, as well as double click a 
line number and get taken directly to that line in your code, among many 
other helpful features.

www.editplus.com

It's shareware that doesn't expire, though the program is really worth the 
35 bucks.
Aaron Craig
Programming
iSoftitler.com




Re: Cloning

2001-06-21 Thread Brett W. McCoy

On Thu, 21 Jun 2001, Nick Transier wrote:

 Ok, so I see the way around the = problem with cloning, however, there is a
 clone module on CPAN, but I have no idea how to install it using win2k. Any
 ideas?

If it's not available as a PPM (for ActiveState), you will need to install
as source, which may give you troubles without a C compiler (if the module
requires one).

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

I'll eat ANYTHING that's BRIGHT BLUE!!




Re: tutorial on my/our/use/package/local

2001-06-21 Thread Chas Owens

I just listened to the mp3 of it this morning, fascinating stuff.  It
almost makes me sad I started learning Perl now and not next year.

http://www.crystalflame.net/keynote.mp3

slide show:
http://www.yetanother.org/damian/Perl6/YAPC_talk.pdf

On 21 Jun 2001 08:32:49 -0700, Randal L. Schwartz wrote:
  Jeff == Jeff 'japhy' Pinyan [EMAIL PROTECTED] writes:
 
 Jeff Damian dropped the bomb at YAPC.  You'll be able to access the padlist,
 Jeff using a mechanism like C$MY.foo.
 
 Ah, that's what happens when you spend a week at sea with Tim Bunce on
 a Geek Cruise (www.geekcruises.com) instead of being in Montreal. :-)
 
 -- 
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
 See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
 
--
Today is Boomtime, the 26th day of Confusion in the YOLD 3167
You are what you see.





Re: Limiting String Length

2001-06-21 Thread Jeff 'japhy' Pinyan

On Jun 21, Chuck Ivy said:

Now, looking up the substring function, it looks like if the original 
string were less than the size of my substring, it would pad my variable 
until it was 4096 characters.

Would a regex be better? Matching for up to 4096 characters and 
replacing the string with $1?

This is NOT the place to use a regex.  Just use the substr() function to
remove all characters after the 4096th.

  substr($entry, 4096) =  if length($entry)  4096;

or

  $entry = substr($entry, 0, 4096);

I recall some programming languages treat strings as arrays of 
characters. Is there a quick perl function or variable that represents 
the length of a string? I didn't see any obvious entries in the index of 
Programming Perl, but I may have been looking in the wrong place.

Perl's strings can't be manipulated as arrays at the high-end level
(that's not to say they're not implemented as char* in the source code).

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




  1   2   >