[19812] in Perl-Users-Digest
Perl-Users Digest, Issue: 2007 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 25 11:05:57 2001
Date: Thu, 25 Oct 2001 08:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1004022311-v10-i2007@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 25 Oct 2001 Volume: 10 Number: 2007
Today's topics:
ANN: SQL::Catalog - test, label, and retrieve SQL queri (Terrence Brannon)
ANNOUNCE PDF::API2 0.1.16_beta perl module alfredreibenschuh@yahoo.com
Announce: Printer 0.94b (Stephen Patterson)
ANNOUNCE: Spreadsheet::WriteExcel 0.34 (John McNamara)
Can't Set registry permissions (AJ Miller)
Re: CPAN.pm complaining all the time <lmoran@wtsg.com>
Debugging Perl for Unix Cobalt <horsey@hoof.com>
Re: GD::Graph plot keeps failing (adam denenberg)
getting %errorlevel% values with perl? <e_kelleher@hotmail.com>
Re: getting %errorlevel% values with perl? <darkon@one.net>
Re: how to call a sub from anywhere? <mto@kabelfoon.nl>
Re: how to call a sub from anywhere? <bernard.el-hagin@lido-tech.net>
Re: how to call a sub from anywhere? <mto@kabelfoon.nl>
Re: how to call a sub from anywhere? <bernard.el-hagin@lido-tech.net>
Re: how to call a sub from anywhere? <mto@kabelfoon.nl>
Re: how to call a sub from anywhere? <tsee@gmx.net>
https and writing files <tedapke@apkesoftware.com>
LogonAsUser Error ????? (AJ Miller)
Re: matching (Lex Thoonen)
Re: NEWBIE: double sort on a string <dtweed@acm.org>
Re: NEWBIE: double sort on a string <dtweed@acm.org>
Re: one-liner solution sought (John J. Trammell)
Perl debuggin in Unix cobalt <horsey@hoof.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Oct 2001 06:33:36 -0700
From: metaperl@mac.com (Terrence Brannon)
Subject: ANN: SQL::Catalog - test, label, and retrieve SQL queries
Message-Id: <ttg6cid4ito90e@corp.supernews.com>
NAME
SQL::Catalog - test, label, and retrieve SQL queries
SYNOPSIS
shell% cd sql_lair/city,date/weather/1/
shell% cat concrete.sql
select city, date from weather where temp_lo < 20;
shell% sql_test concrete.sql
shell% cat testexec.out # see results of prepare, execute on this
shell% cat abstract.sql
select city, date from weather where temp_lo < ?;
shell% sql_test abstract.sql 55 # send in placeholder value
shell% cat testexec.out # to see results... looks good
shell% sql_register abstract.sql basic_weather
[hi_and_low] inserted as
[select city from weather where temp_lo > ? and temp_hi > ? LIMIT 10]
... then in a Perl program (e.g. test.pl in this distribution)
my $dbh = SQL::Catalog->db_handle; # optional - get the handle as you please
my $sql = SQL::Catalog->lookup('hi_and_low');
my $sth = $dbh->prepare($sql);
$sth->execute(55);
my $rows = $sth->rows;
DESCRIPTION
Over time, it has become obvious that two things about SQL queries are
necessary. One, you want to be able to get a query by a label. Two, you
want to be able to look through old queries to see if someone else has
written one similar to what you want. Three, you want the database guru
to develop queries on his own and be able to register them for your use
without interfering with him. Four, you want to be able to answer
questions such as "what queries are doing a select on such-and-such
tables".
Well, wait no longer, for your solution has arrived.
Common Steps to Usage
Develop your concrete query in a db shell
The first step to developing a database query is to play around at the
db shell. In this case, you normally dont have any placeheld values. You
just keep mucking with the query until it gives you what you want.
When you finally get what you want, save it in a file, say
`concrete.sql' for example. Here is a concrete query:
select city, date from weather where temp_hi > 20
Abstract your query with placeholders
Now it's time to make your query more abstract. So we do the following:
select city, date from weather where temp_hi > ?
and save in a different file, say `abstract.sql'.
But let's test this query next:
sql_test abstract.sql 34
And let's cat testexec.out to see the results.
Register your query
sql_register abstract.sql city_date_via_temp_hi
and the system tells you
[city_date_via_temp_hi] saved as
[select city, date from weather where temp_hi > ?]
Use your query from DBI:
use SQL::Catalog;
my $dbh = SQL::Catalog->db_handle;
my $SQL = SQL::Catalog->lookup('city_date_via_temp_hi') or die "not found";
my $sth = $dbh->prepare($SQL, $cgi->param('degrees'));
.... etc
What you must do
* edit sub db_handle so it gets a database handle.
* copy the sql_* scripts to a place on your `$PATH'
* create a table named sql_catalog. a script for Postgresql is provided.
What SQL::Catalog does
It stores each query in a database table. I could have gone for
something more fancy in database design but wanted to maintain database
independence without requiring extra tools for schema creation and
database use.
The queries are stored in this table:
CREATE TABLE sql_catalog (
query varchar(65535) , # the actual query
tables varchar(255) , # tables used
columns varchar(255) , # fields selected
cmd varchar(40) , # SELECT, INSERT, UPDATE, etc
phold int4 # number of bind_values
);
Query field omitted for brevity. It has (wouldya guess) the SQL query.
mydb=# select label,cmd,columns,tables,phold from sql_catalog;
label | cmd | columns | tables | phold
---------------+--------+---------------------------------------------------
weather_hi | SELECT | weather.city,weather.date | weather | 1
hi_and_low | SELECT | weather.city | weather | 2
AUTHOR
T. M. Brannon, <tbone@cpan.org>
SEE ALSO
* the Class::Phrasebook::SQL manpage performs a similar function. It
stores a "phrasebook" of SQL in XML files. It doesn't support
placeholders. It also has some rather daunting satellite module
requirements.
* the DBIx::SearchProfile manpage does query labeling and also has some
convenience functions for query retrieval. It does not store the SQL in
a database or make it searchable by table, column, or number of
placeholders.
------------------------------
Date: Mon, 22 Oct 2001 11:30:46 GMT
From: alfredreibenschuh@yahoo.com
Subject: ANNOUNCE PDF::API2 0.1.16_beta perl module
Message-Id: <ttg4d4g7fah659@corp.supernews.com>
hi !
i'd like to announce the availability of version 0.1.16_beta
of PDF::API2, which comes with toe following changes:
- uncommon unicode-maps have been phased out into
a seperate archive
- now works correctly on both win32 and unix
- all examples produce valid pdfs, if properly invoked
- quick implementation of support for icc-profiles
in colorspaces
as always: it works for my appz, your milage my vary !
from the readme.txt:
----------------------------------------------------------------------
PDF::API2
There seem to be a growing plethora of Perl modules for creating and
manipulating PDF files.
This module is 'The Next Generation' of Text::PDF::API which initially
provided a nice API around the Text::PDF::* modules created by Martin
Hosken.
WARNING
Sorry but this release of PDF::API2 comes bundled
with fixed versions of Text::PDF and Font::TTF because of
the various changes in that module-distributions !!!!!
FIXES IN 0.1.x
. *TODO*
FEATURES
. Works with more than one PDF file open at once
. It presents a object-oriented API to the user
. Supports the 14 base PDF Core Fonts
. Supports TrueType fonts
. Supports Adobe-Type1 Fonts (pfb/pfa/afm)
. Supports native Embedding of bitmap images
(jpeg,ppm,png,gif)
. Supports modification of existing pdfs
and import/cloning of pages
UN-FEATURES (which will one day be fixed)
. Documentation is currently rather sparse
. This is beta code in development which works
for my apps, your milage may vary :)
REQUIREMENTS
This module set requires you to have installed the following other
perl modules:
Module Required for
------------------------------------------------------
Compress::Zlib - Compression of PDF object streams
NOTES
For Type1 font support to work correctly you have to have a postscript
font file, either binary (pfb) or ascii (pfa) format and an adobe font
metrics file (afm).
Thanks.
INSTALLATION
Installation is as per the standard module installation approach:
perl Makefile.PL
make
make install
CONTACT
There is a mailing-list available:
Post message: perl-text-pdf-modules@yahoogroups.com
Subscribe: perl-text-pdf-modules-subscribe@yahoogroups.com
Unsubscribe: perl-text-pdf-modules-unsubscribe@yahoogroups.com
List owner: perl-text-pdf-modules-owner@yahoogroups.com
URL to page: http://groups.yahoo.com/group/perl-text-pdf-modules
DOWNLOAD SITE:
Primary: http://www.penguin.at0.net/~fredo/files/
CPAN: ftp://ftp.funet.fi/pub/CPAN/authors/id/A/AR/AREIBENS/
Linked: http://freshmeat.net/projects/pdf-api2/
COPYRIGHTS & LICENSING
This module is copyrighted by Alfred Reibenschuh and can be used under
perl's "Artistic License" which has been included in this archive.
-- me, myself & I
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
N++ W+++ E--- U++++ P+++ O-- k- w++ d- s+:+ a- c++V-- PS++ PE
Y+ PGP++ t+++ 5+++ x++ R++ tv+ b+ DI D++ G e+ h--- r+++ y++**
------END GEEK CODE BLOCK------
------------------------------
Date: 25 Oct 2001 03:31:24 -0700
From: s.patterson@freeuk.com (Stephen Patterson)
Subject: Announce: Printer 0.94b
Message-Id: <ttg4ee3sje4h67@corp.supernews.com>
A low-level cross-platform interface to system
printers.
This module is intended to allow perl programs to use and query
printers on any computer system capable of running perl. The
intention of this module is for a program to be able to use the
printer without having to know which operating system is being
used.
PLATFORMS
This code has been tested on Linux, DEC-OSF, Solaris, HP/UX windows 95
and windows NT4.
Changes since 0.93
0.94b
* added documentation of the array input capabilities of the print()
method
Availabilty
on CPAN and http://perlprint.sourceforge.net/
* windows installation fixed
0.94a
* glaring typos fixed to pass a syntax check (perl -c)
0.94
* uses the first instance of the lp* commands from the user's path
* more typos fixed
* list_jobs almost entirely rewritten for linux like systems.
------------------------------
Date: Mon, 22 Oct 2001 23:56:44 GMT
From: jmcnamara@cpan.org (John McNamara)
Subject: ANNOUNCE: Spreadsheet::WriteExcel 0.34
Message-Id: <ttg4dd5t7vnn5e@corp.supernews.com>
======================================================================
ANNOUNCE
Spreadsheet::WriteExcel version 0.34 has been uploaded to CPAN.
======================================================================
NAME
Spreadsheet::WriteExcel - Write formatted text and numbers to a
cross-platform Excel binary file.
======================================================================
CHANGES
Added Spreadsheet::WriteExcel::Utility module with helper
functions for row/columns and dates.
Added write_row and write_col methods after many requests.
Added ability to insert bitmap images.
Added cell protection and formula hiding.
Added more examples.
======================================================================
DESCRIPTION
The Spreadsheet::WriteExcel module can be used create a cross-
platform Excel binary file. Multiple worksheets can be added to a
workbook and formatting can be applied to cells. Text, numbers,
formulas and hyperlinks and images can be written to the cells.
The Excel file produced by this module is compatible with Excel 5,
95, 97, 2000 and 2002.
The module will work on the majority of Windows, UNIX and
Macintosh platforms. Generated files are also compatible with the
Linux/UNIX spreadsheet applications OpenOffice, Gnumeric and XESS.
The generated files are not compatible with MS Access.
This module cannot be used to read an Excel file. See
Spreadsheet::ParseExcel or look at the main documentation for some
suggestions.
This module cannot be used to write to an existing Excel file.
======================================================================
SYNOPSIS
To write a string, a formatted string, a number and a formula to
the first worksheet in an Excel workbook called perl.xls:
use Spreadsheet::WriteExcel;
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("perl.xls");
# Add a worksheet
$worksheet = $workbook->addworksheet();
# Add and define a format
$format = $workbook->addformat(); # Add a format
$format->set_bold();
$format->set_color('red');
$format->set_align('center');
# Write a formatted and unformatted string
$col = $row = 0;
$worksheet->write($row, $col, "Hi Excel!", $format);
$worksheet->write(1, $col, "Hi Excel!");
# Write a number and a formula using A1 notation
$worksheet->write('A3', 1.2345);
$worksheet->write('A4', '=SIN(PI()/4)');
======================================================================
REQUIREMENTS
This module requires Perl 5.005 (or later) and Parse::RecDescent:
http://search.cpan.org/search?dist=Parse-RecDescent
======================================================================
AUTHOR
John McNamara (jmcnamara@cpan.org)
--
------------------------------
Date: 25 Oct 2001 07:32:24 -0700
From: ajmiller@crutchfield.com (AJ Miller)
Subject: Can't Set registry permissions
Message-Id: <f13dd2ac.0110250632.415ce80c@posting.google.com>
Here is my problem:
I am trying to add permisssions in the registry for the account "Domain
Users" to have CHANGE permission to the HKLM\Software\Crutchfield section of
the registry. It keeps saying giving me the following error: Usage:
$Obj->SetRecurse( $Path [, $Container ] )
Hre is my script:
#####################################################################
use Win32::Perms;
$Dir = 'HKEY_LOCAL_MACHINE\SOFTWARE\Crutchfield' unless( $Dir = $ARGV[0] );
$P = new Win32::Perms( $Dir );
$P->Add( $Dir, CHANGE, KEY );
$P->SetRecurse("$Dir" ) or die "Here: $!";
print "Permissions Set\n";
#####################################################################
Any thoughts anyone has would be wonderful :-)
Thanks,
AJ
------------------------------
Date: Thu, 25 Oct 2001 09:07:48 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: CPAN.pm complaining all the time
Message-Id: <2k3gttc10oaf9ilice5s0lu6ubjg43132e@4ax.com>
On Wed, 24 Oct 2001 19:28:14 BST, spam@freeuk.com (Stephen Patterson)
wrote wonderful things about sparkplugs:
SNIP
>>> but it always complains about
>>> Net::FTP but won't let me install Net::FTP!
>
>Have you tried just 'install Net::FTP'?
doesn't work. It's no big deal I guess
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Wed, 24 Oct 2001 22:03:45 -0700
From: "Mr. Ed" <horsey@hoof.com>
Subject: Debugging Perl for Unix Cobalt
Message-Id: <ttg9codshb094a@corp.supernews.com>
I'm not much in the know of server admin for Unix Cobalt, the server I'm
testing things on: how do I enable debugging for my Perl cgi scripts so that
I get an error message that tells me what line # on my script is faulty
instead of the dreaded Internal Server Error message?
Thanx
Ed
------------------------------
Date: 25 Oct 2001 06:25:12 -0700
From: adam@dberg.org (adam denenberg)
Subject: Re: GD::Graph plot keeps failing
Message-Id: <78526aa1.0110250525.45b853ec@posting.google.com>
That worked perfectly , thanks so much ..
-adam
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrn9tek4a.6ff.mgjv@verbruggen.comdyn.com.au>...
> On 24 Oct 2001 14:06:39 -0700,
> adam denenberg <adam@dberg.org> wrote:
> > Hey,
> >
> > I am using GD::Graph and I am trying to plot data from 2 stored
> > arrays, but it is failing
>
> Ignore my previous response:
>
> $my_graph->plot([@labels],[@vals]) or die $my_graph->error;
>
> tells us:
>
> Invalid data set: 0 at ./foo.pl line 27.
>
> The data set has to be a single reference to an array, which contains
> other references to arrays, _or_ a GD::Graph::Data object.
>
> This will work:
>
> $my_graph->plot([\@labels, \@vals]) or die $my_graph->error;
>
> or this, if you really want to copy the data:
>
> $my_graph->plot([ [@labels], [@vals] ]) or die $my_graph->error;
>
> But depending on how you need to build your actual data set, you might
> prefer to use a GD::Graph::Data object:
>
> use GD::Graph::Data;
> my $data = GD::Graph::Data->new();
> $data->add_point('label1', 1);
> $data->add_point('label2', 2);
>
> which is more suitable for processing od the result of database
> queries, or file contents.
>
> Martien
------------------------------
Date: Thu, 25 Oct 2001 09:51:50 -0400
From: ek <e_kelleher@hotmail.com>
Subject: getting %errorlevel% values with perl?
Message-Id: <3BD818F6.6A3841B0@hotmail.com>
I have tried catching %errorlevel% values from the command prompt
unsuccessfully using perl. It seems to be a scope problem as batch
files seem to handle it okay. If for example I type dir rubbish and
then echo %errorlevel% the return value is 1. If I put this in a perl
script as
`dir rubbish`;
$var=`echo \%errorlevel\%';
$var's value is always 0. Does anyone have any idea how to keep the
scope so perl will catch the actual %errorlevel% value?
Thanks...
------------------------------
Date: Thu, 25 Oct 2001 15:04:58 -0000
From: David Wall <darkon@one.net>
Subject: Re: getting %errorlevel% values with perl?
Message-Id: <Xns914570A6199A9darkononenet@207.126.101.97>
ek <e_kelleher@hotmail.com> wrote on 25 Oct 2001:
> I have tried catching %errorlevel% values from the command prompt
> unsuccessfully using perl. It seems to be a scope problem as batch
> files seem to handle it okay. If for example I type dir rubbish and
> then echo %errorlevel% the return value is 1. If I put this in a perl
> script as
> `dir rubbish`;
> $var=`echo \%errorlevel\%';
> $var's value is always 0. Does anyone have any idea how to keep the
> scope so perl will catch the actual %errorlevel% value?
Look in the Perl docs (perlvar) for $? or use system().
--
David Wall
darkon@one.net
------------------------------
Date: Thu, 25 Oct 2001 15:01:47 +0200
From: "MAGiC MANiAC^mTo" <mto@kabelfoon.nl>
Subject: Re: how to call a sub from anywhere?
Message-Id: <9r92nu$1f3d$1@news.kabelfoon.nl>
"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> schreef in bericht
news:slrn9tg1gl.3nk.bernard.el-hagin@gdndev25.lido-tech...
> On Thu, 25 Oct 2001 14:27:01 +0200, MAGiC MANiAC^mTo <mto@kabelfoon.nl>
wrote:
> > how can I create a sub, that I can call from anywhere?
> > example :
> > sub mysub($var){
> > print $var;
> > }
> > mysub "ITS MAGiC";
>
> I don't know what you mean "call from anywhere", but the above
> code doesn't compile. It should look more like this:
>
> sub mysub{
> my $var = shift;
> print $var;
> }
>
> or if you want the prototype:
>
> sub mysub($){
> my $var = shift;
> print $var;
> }
> mysub 'ITS MAGIC';
> Now if you can explain what you mean by "call from anywhere" perhaps
> we'll be able to help you more.
> Cheers,
> Bernard
well this is almost what I'm searched for (see below)... :)
sub mysub($){
my $var = shift;
print $var;
}
mysub 'ITS MAGIC';
But how can I do this :
mysub 'its','magic';
result: 'its magic'
thanks for your quick reply!!
MAGiC MANiAC^mTo
------------------------------
Date: 25 Oct 2001 13:13:23 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: how to call a sub from anywhere?
Message-Id: <slrn9tg3j6.3nk.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 25 Oct 2001 15:01:47 +0200, MAGiC MANiAC^mTo <mto@kabelfoon.nl> wrote:
>
> "Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> schreef in bericht
> news:slrn9tg1gl.3nk.bernard.el-hagin@gdndev25.lido-tech...
>> On Thu, 25 Oct 2001 14:27:01 +0200, MAGiC MANiAC^mTo <mto@kabelfoon.nl>
> wrote:
>> > how can I create a sub, that I can call from anywhere?
>> > example :
>> > sub mysub($var){
>> > print $var;
>> > }
>> > mysub "ITS MAGiC";
>>
>> I don't know what you mean "call from anywhere", but the above
>> code doesn't compile. It should look more like this:
>>
>> sub mysub{
>> my $var = shift;
>> print $var;
>> }
>>
>> or if you want the prototype:
>>
>> sub mysub($){
>> my $var = shift;
>> print $var;
>> }
>> mysub 'ITS MAGIC';
>> Now if you can explain what you mean by "call from anywhere" perhaps
>> we'll be able to help you more.
>> Cheers,
>> Bernard
>
>
> well this is almost what I'm searched for (see below)... :)
>
> sub mysub($){
> my $var = shift;
> print $var;
> }
> mysub 'ITS MAGIC';
>
>
> But how can I do this :
>
> mysub 'its','magic';
>
> result: 'its magic'
I still don't know what you *really* want to do, but if it's
just printing all of the arguments with a space between them
try:
sub mysub{
print join ' ', @_;
}
mysub( 'its', 'magic' ); # you must have the ()s in this case
> thanks for your quick reply!!
You're welcome.
Cheers,
Bernard
------------------------------
Date: Thu, 25 Oct 2001 15:27:52 +0200
From: "MAGiC MANiAC^mTo" <mto@kabelfoon.nl>
Subject: Re: how to call a sub from anywhere?
Message-Id: <9r948r$1gs5$1@news.kabelfoon.nl>
"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> schreef in bericht
news:slrn9tg3j6.3nk.bernard.el-hagin@gdndev25.lido-tech...
> On Thu, 25 Oct 2001 15:01:47 +0200, MAGiC MANiAC^mTo <mto@kabelfoon.nl>
wrote:
> >
> > "Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> schreef in bericht
> > news:slrn9tg1gl.3nk.bernard.el-hagin@gdndev25.lido-tech...
> >> On Thu, 25 Oct 2001 14:27:01 +0200, MAGiC MANiAC^mTo <mto@kabelfoon.nl>
> > wrote:
> >> > how can I create a sub, that I can call from anywhere?
> >> > example :
> >> > sub mysub($var){
> >> > print $var;
> >> > }
> >> > mysub "ITS MAGiC";
> >>
> >> I don't know what you mean "call from anywhere", but the above
> >> code doesn't compile. It should look more like this:
> >>
> >> sub mysub{
> >> my $var = shift;
> >> print $var;
> >> }
> >>
> >> or if you want the prototype:
> >>
> >> sub mysub($){
> >> my $var = shift;
> >> print $var;
> >> }
> >> mysub 'ITS MAGIC';
> >> Now if you can explain what you mean by "call from anywhere" perhaps
> >> we'll be able to help you more.
> >> Cheers,
> >> Bernard
> >
> >
> > well this is almost what I'm searched for (see below)... :)
> >
> > sub mysub($){
> > my $var = shift;
> > print $var;
> > }
> > mysub 'ITS MAGIC';
> >
> >
> > But how can I do this :
> >
> > mysub 'its','magic';
> >
> > result: 'its magic'
>
>
> I still don't know what you *really* want to do, but if it's
> just printing all of the arguments with a space between them
> try:
>
>
> sub mysub{
> print join ' ', @_;
> }
>
> mysub( 'its', 'magic' ); # you must have the ()s in this case
>
>
> > thanks for your quick reply!!
>
>
> You're welcome.
>
>
> Cheers,
> Bernard
Well, I hope I can explain you what I want to do...
I like to send some $strings to mysub, like for example:
mysub($var1, $var2, $var3);
mysub grab this $strings ($var1,$var2,$var3) and put them into
a print function... like this :
sub mysub($var1,$var2,$var3){
$tmp1=$var2+" / the netherlands";
print "hello $var1, your at $var2 in $var3";
}
now I can change the text quick.
let say:
mysub("MAGIC","ROTTERDAM","1 hour");
now the result will be:
"hello MAGiC, your at ROTTERDAM / the netherlands in 1 hour"
hope that you understand what I like to do...
------------------------------
Date: 25 Oct 2001 13:37:40 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: how to call a sub from anywhere?
Message-Id: <slrn9tg50n.3nk.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 25 Oct 2001 15:27:52 +0200, MAGiC MANiAC^mTo <mto@kabelfoon.nl> wrote:
[snipped previous exchange]
> Well, I hope I can explain you what I want to do...
>
> I like to send some $strings to mysub, like for example:
>
> mysub($var1, $var2, $var3);
>
> mysub grab this $strings ($var1,$var2,$var3) and put them into
> a print function... like this :
>
> sub mysub($var1,$var2,$var3){
> $tmp1=$var2+" / the netherlands";
> print "hello $var1, your at $var2 in $var3";
> }
>
> now I can change the text quick.
> let say:
>
> mysub("MAGIC","ROTTERDAM","1 hour");
>
> now the result will be:
>
> "hello MAGiC, your at ROTTERDAM / the netherlands in 1 hour"
>
> hope that you understand what I like to do...
OK. Try this:
sub mysub{
my( $var1, $var2, $var3 ) = @_;
print "hello $var1, your at $var2 in $var3";
}
mysub( 'MAGIC', 'ROTTERDAM', '1 hour' );
Cheers,
Bernard
------------------------------
Date: Thu, 25 Oct 2001 15:50:32 +0200
From: "MAGiC MANiAC^mTo" <mto@kabelfoon.nl>
Subject: Re: how to call a sub from anywhere?
Message-Id: <9r95r2$1ico$1@news.kabelfoon.nl>
"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> schreef in bericht
news:slrn9tg50n.3nk.bernard.el-hagin@gdndev25.lido-tech...
> On Thu, 25 Oct 2001 15:27:52 +0200, MAGiC MANiAC^mTo <mto@kabelfoon.nl>
wrote:
>
>
> [snipped previous exchange]
>
>
> > Well, I hope I can explain you what I want to do...
> >
> > I like to send some $strings to mysub, like for example:
> >
> > mysub($var1, $var2, $var3);
> >
> > mysub grab this $strings ($var1,$var2,$var3) and put them into
> > a print function... like this :
> >
> > sub mysub($var1,$var2,$var3){
> > $tmp1=$var2+" / the netherlands";
> > print "hello $var1, your at $var2 in $var3";
> > }
> >
> > now I can change the text quick.
> > let say:
> >
> > mysub("MAGIC","ROTTERDAM","1 hour");
> >
> > now the result will be:
> >
> > "hello MAGiC, your at ROTTERDAM / the netherlands in 1 hour"
> >
> > hope that you understand what I like to do...
>
>
> OK. Try this:
>
>
> sub mysub{
> my( $var1, $var2, $var3 ) = @_;
> print "hello $var1, your at $var2 in $var3";
> }
>
> mysub( 'MAGIC', 'ROTTERDAM', '1 hour' );
Now your talk'n... thanks!!! ;)
This is exactly what I want! perfect! :)))
Theres just one thing I should know.
What do I have to do when I want to add a string to another string?...
for example:
$tmp1=" / the netherlands";
$var2=$var2 + $tmp1;
p.s. this my last question about this sub function what I have to know...
------------------------------
Date: Thu, 25 Oct 2001 16:33:13 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: how to call a sub from anywhere?
Message-Id: <9r97o1$7cd$05$1@news.t-online.com>
"MAGiC MANiAC^mTo" <mto@kabelfoon.nl> schrieb im Newsbeitrag
news:9r95r2$1ico$1@news.kabelfoon.nl...
| Theres just one thing I should know.
| What do I have to do when I want to add a string to another string?...
|
| for example:
|
| $tmp1=" / the netherlands";
| $var2=$var2 + $tmp1;
|
| p.s. this my last question about this sub function what I have to know...
The string concatenation operator is '.', not '+'.
$var2 = $var2 . $tmp1;
You could even:
$var2 = "$var2$tmp1";
Or:
$var2 = join( '', $var2, $tmp1 );
Better yet if you want to append something to a var:
$var2 .= $tmp1;
see also perlop.
HTH,
Steffen
--
$_=q;33352987319029872958319011313364356732192639127636833335345138283712
3712336415083973397340602842912;;s;\n;;;print"\n";$o=$_;push@o,substr($o,
$_*4,4)for(0..24);pop@o;for(@o){$i++;print' 'x(26-$i).(chr$_/29-$i)."\n"}
------------------------------
Date: Thu, 25 Oct 2001 14:49:37 GMT
From: "Ted Apke" <tedapke@apkesoftware.com>
Subject: https and writing files
Message-Id: <5EVB7.20414$IR4.11759583@news1.denver1.co.home.com>
I'm having a problem writing to a file when the perl CGI script is accessed
via a secure connection. The script works fine when the connection is via
http, but when run from https it fails. I'm not 100% sure of the host
environment but I'd say it is Solaris.
I've done a number of searches, including Google groups, and found nothing
similar. I'd appreciate any suggestions.
Thanks in advance.
Ted Apke
------------------------------
Date: 25 Oct 2001 07:31:30 -0700
From: ajmiller@crutchfield.com (AJ Miller)
Subject: LogonAsUser Error ?????
Message-Id: <f13dd2ac.0110250631.654b974a@posting.google.com>
I am trying to logon as another user that has admin privileges. here is the
code, and at the bottom I have listed both the output that is generated when
I run the code, and the privileges assigned to both the logged on user, and
the user I am trying to Impersonate.
Any comments would be greatly appreciated :-)
AJ
-----------------------------Code Begins--------------------------------
use Win32::Adminmisc;
if ( $#ARGV < 0 ) {
die "Not enough arguments";
}
$Domain = "domain";
$User = "user";
$Password = "password";
$Process = $ARGV[0];
if (Win32::AdminMisc::LogonAsUser ($Domain, $User, $Password,
LOGON32_LOGON_INTERACTIVE))
{
$LogonUser = Win32::AdminMisc::GetlogonName();
print "Succesfully logged on as $LogonUser.\n";
$Result = Win32::AdminMisc::CreateProcessAsUser(
$Process,
"Flags" => CREATE_NEW_CONSOLE,
"Xsize" => 640,
"Ysize" => 400,
"X" => 200,
"Y" => 175,
"XBuffer" => 80,
"YBuffer" => 175,
"Show" => SW_MINIMIZE,
"Title" => "Title: $User" . "'s $Process program",
"Fill" => BACKGROUND_BLUE |
FOREGROUND_RED |
FOREGROUND_BLUE |
FOREGROUND_INTENSITY|
FOREGROUND_GREEN,
);
if ($Result)
{
print "Successful! The new process PID is $Result. \n";
}
else {
print "Failed.\n\tError: ", Error(), " \n ";
}
}else{
print "Failed to logon.\n\tError: ", Error(), " \n ";
}
sub Error
{
return Win32::FormatMessage(Win32::GetLastError());
}
-----------------------------Code Ends--------------------------------
---------------------Error Message------------------------------------
Failed to logon.
Error: The operation completed successfully.
----------------------------------------------------------------------
------------------------------User Privledges-------------------------
these are the user access rights that both the logged on user, and the user
I'm trying to impersonate have:
SeAssignPrimaryTokenPrivilege
SeIncreaseQuotaPrivilege
SeTcbPrivilege
SeChangeNotifyPrivilege
SeInteractiveLogonRight
SeBatchLogonRight
--------------------------------------------------------------------
------------------------------
Date: Thu, 25 Oct 2001 13:44:00 GMT
From: lex@nospam.peng.nl (Lex Thoonen)
Subject: Re: matching
Message-Id: <3bd8170d.160069211@news>
Thanks to you all!!
It works perfectly!
Lex
------------------------------
Date: Thu, 25 Oct 2001 13:46:09 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: NEWBIE: double sort on a string
Message-Id: <3BD8163C.C48DB0D0@acm.org>
"Jippie@yahoo.com" wrote:
> This is what I have done but my logic is wrong.
> sub by_string
> {
> @parts_a=split(/[|]/,$a);
> @parts_b=split(/[|]/,$b);
>
> $retval = (lc($parts_a[$sortfield])) cmp (lc($parts_b[$sortfield]));
> if( $retval == 0 && $sortfield !=1 ) # they are the same
> {
> # then sort by title next. Always nice to have the title in order
> $retval = (lc($parts_a[1])) cmp (lc($parts_b[1]));
> }
$retval; # <== add this
> }
Your logic is fine; you just need to explicitly return $retval at the
end, as shown above.
If you want to make this a lot more efficient, you should do all the
splitting outside the sort sub. Look up "Schwartzian Transform" in your
favorite search engine (also, "perldoc -q sort" mentions it).
@sorted = map {$_->[0]} sort {$a->[1] cmp $b->[1]}
map {[$_, lc join '',(split /|/)[$sortfield,1]]} @data;
-- Dave Tweed
------------------------------
Date: Thu, 25 Oct 2001 14:17:39 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: NEWBIE: double sort on a string
Message-Id: <3BD81D9F.556541BF@acm.org>
I wrote:
> @sorted = map {$_->[0]} sort {$a->[1] cmp $b->[1]}
> map {[$_, lc join '',(split /|/)[$sortfield,1]]} @data;
^^
Oops. I guess there ought to be a delimiter in there that sorts before
any character in your strings. Try ' ' instead, assuming your strings
don't contain control characters, or use "\0" to be sure.
-- Dave Tweed
------------------------------
Date: Thu, 25 Oct 2001 08:37:53 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: one-liner solution sought
Message-Id: <slrn9tg5dh.ifb.trammell@haqq.el-swifto.com>
On Thu, 25 Oct 2001 12:29:39 +0100, Kevin Brownhill wrote:
[TOFU fixed]
> <kmead@socrates.Berkeley.EDU> wrote in message
> news:9r6pen$l3r$1@agate.berkeley.edu...
> > Can someone come up with a one-line perl script which will pad out
> > the value part of a name="value" to be exactly 10 characters long?
> >
> > For example, change
> > name="value" ==> name="valuexxxxx"
> > name="" ==> name="xxxxxxxxxx"
> > name="1234567890123" ==> name="1234567890123"
> >
>
> and in one line that is:
>
> $word = substr($word . 'xxxxxxxxxx',0,10);
>
Except for the requirement:
name="1234567890123" ==> name="1234567890123"
--
I don't know what the hell is going on dude, but this suspension gives
me more time for fraggin'. Yee haw!
------------------------------
Date: Thu, 25 Oct 2001 07:53:22 -0700
From: "Mr. Ed" <horsey@hoof.com>
Subject: Perl debuggin in Unix cobalt
Message-Id: <ttg9hv52sic586@corp.supernews.com>
I need to find out how to display error messages in Perl that is set up on a
Unix cobalt server- i want to get a Line # reference to what the error will
point to on my script without having to see the dreaded"Internal Server
Error" message
Thanks
Ed
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 2007
***************************************