[21832] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4036 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 28 06:06:27 2002

Date: Mon, 28 Oct 2002 03:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 28 Oct 2002     Volume: 10 Number: 4036

Today's topics:
        8 byte key's for blowfish (chris rush)
    Re: AUTOLOAD and multiple inheritance <heather710101@yahoo.com>
    Re: backticks/system command <stokerm@getnet.net>
        Can package names be supplied on-the-fly? <jkeen@concentric.net>
    Re: Can package names be supplied on-the-fly? <nospam@nospam.com>
    Re: Can package names be supplied on-the-fly? <usenet@tinita.de>
    Re: Capture Error Messages <billy@arnis-bsl.com>
    Re: DBI select with memo fields <dgardiner@houston.rr.com>
    Re: deleting a file... kill ??? (ebchang)
    Re: How can I make a set of objects? <garry@ifr.zvolve.net>
    Re: How can I make a set of objects? (tî'pô)
    Re: How can I make a set of objects? (tî'pô)
    Re: HTML:Parser <gisle@ashn89ty262h.bc.hsia.telus.net>
    Re: HTML:Parser <gisle@ashn89ty262h.bc.hsia.telus.net>
    Re: HTML:Parser (Andrew Gatt)
        Newbie Q:Help! (Perl Networking) <rshringa@austin.ibm.com>
        Perl - Error Handling <member@mainframeforum.com>
        Printing formatted text to a non-PostScript Printer <stokerm@getnet.net>
    Re: Sendmail Bcc doesn't work (Serge)
    Re: Sendmail Bcc doesn't work (Serge)
        Serial Port <oracle@sympac.com.au>
    Re: Serial Port <nospam@nospam.com>
    Re: setreuid on AIX 5.1 with perl 5.6.1 (Villy Kruse)
        significance of 42 for perl, any?!? <bik.mido@tiscalinet.it>
    Re: significance of 42 for perl, any?!? (tî'pô)
    Re: usemymalloc: Whose malloc is that? <nospam@nospam.com>
        Value in array with loop <reggie_nospam@reggieband.com>
    Re: Value in array with loop <reggie_nospam@reggieband.com>
    Re: Wow (ebchang)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 28 Oct 2002 02:56:05 -0800
From: chrisr@ilutra.com (chris rush)
Subject: 8 byte key's for blowfish
Message-Id: <40f49f69.0210280256.50227c19@posting.google.com>

has anyone got any suggestions of tools for generating random keys of
a specific byte length. I need an 8 byte one for use with blowfish. I
tried using openssl genrsa setting the byte length to 8 but it doesn't
seem to work with lengths less than 30. much appreciated


------------------------------

Date: Mon, 28 Oct 2002 04:59:21 +0000 (UTC)
From: Da Witch <heather710101@yahoo.com>
Subject: Re: AUTOLOAD and multiple inheritance
Message-Id: <apig79$rql$1@reader1.panix.com>

In <3DBB6EBB.64FFB865@earthlink.net> Benjamin Goldberg <goldbb2@earthlink.net> writes:
>Actually, it would be safer to do:

>sub AUTOLOAD {
>   # stuff
>   require NEXT; # from CPAN
>   return shift()->NEXT::ACTUAL::AUTOLOAD( @_ );
>}

>Which should work even if class A is inherited by things other than C.

NEXT is a useful module.  Thanks for pointing it out.

There's something in the docs for NEXT that I don't follow:

  ...a call to $self-NEXT::m()> resumes the depth-first, left-to-right
  search of $self's class hierarchy that resulted in the original call
  to m.
  
  Note that this is not the same thing as $self-SUPER::m()>, which 
  begins a new dispatch that is restricted to searching the ancestors
  of the current class.  $self-NEXT::m()> can backtrack
  past the current class -- to look for a suitable method in other
  ancestors of $self -- whereas $self-SUPER::m()> cannot.

I've read this last paragraph several times, but I still can't
visualize this difference between NEXT and SUPER.  Any clarification
or example would be much appreciated.

TIA,

hk



------------------------------

Date: Sun, 27 Oct 2002 23:53:16 -0700
From: Matt Stoker <stokerm@getnet.net>
Subject: Re: backticks/system command
Message-Id: <3DBCDEDC.C639B3E3@getnet.net>

Gary Hodges wrote:
> 
> I'm missing something basic.  I've distilled my problem down to the
> following code:
> #---------------
> use strict;
> my $file = "any.doc";
> my $cmd ="D:\\Program Files\\Microsoft Office\\Office\\WINWORD.EXE";
> `\"$cmd\" \"$file\"`;
> 
> #system "\"$cmd\" \"$file\"";
> #system ("\"$cmd\" \"$file\"");
> #system (qq|\"$cmd\" \"$file\"|);
> #system qq|\"$cmd\" \"$file\"|;
> #system qq|"$cmd" "$file"|;
> #---------------
> 
> When I run this using the backticks line or any of the system lines I
> get a complaint that
> 'D:\Program'
> is not a known command.  The short question is "What I missing here?"
> What do I need to do to get the full command with spaces executed?

Your sample code worked fine for me, so I'm not sure if this will help,
but if the problem is due to Windows or Perl mishandling the spaces in
the paths, you could try converting $cmd and $file to the "short path
names", which do not have spaces.  Do this as follows:

use Win32;
use strict;
my $file = "any.doc";
my $cmd ="D:\\Program Files\\Microsoft Office\\Office\\WINWORD.EXE";
$file = Win32::GetShortPathName($file);
$cmd = Win32::GetShortPathName($cmd);

`\"$cmd\" \"$file\"`;

In this case "any.doc" must be an existing file or
Win32::GetShortPathName will return undef.


------------------------------

Date: 28 Oct 2002 03:24:41 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Can package names be supplied on-the-fly?
Message-Id: <apialp$ko7@dispatch.concentric.net>

The following code is adapted from the Camel book's discussion of symbol
tables (p 293).

    package DataPresenter::Schedule;
    use strict;
    use warnings;

    my %reprocess_subs = ();

    foreach (sort keys %DataPresenter::Schedule::) {
        local *sym = $DataPresenter::Schedule::{$_};
        $reprocess_subs{$_}++ if (defined &sym and $_ =~ /^reprocess_/);
    }

The objective is to make sure that subroutines whose names begin with
"reprocess_" are defined in package DataPresenter::Schedule before they are
called.

Now suppose that I wanted to use code like the above in a number of
different packages, e.g., package DataPresenter::Foo, package
DataPresenter::Bar, and so forth.  In that case I would want to avoid
hard-coding "DataPresenter::[some_package]".  I'd prefer to have the name of
the package supplied on the fly.

Can this be done?

I know that you can say:

    my $pkg = __PACKAGE__;

and have it return "DataPresenter::[some_package]", but I haven't been able
to get it to work as I would like to:

    no strict 'refs';
    foreach (sort keys %$pkg::) {
        local *sym = $$pkg::{$_};

Suggestions?




------------------------------

Date: Sun, 27 Oct 2002 21:43:25 -0800
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: Can package names be supplied on-the-fly?
Message-Id: <3dbccdec$1_2@nopics.sjc>


"James E Keenan" <jkeen@concentric.net> wrote in message
news:apialp$ko7@dispatch.concentric.net...
> The following code is adapted from the Camel book's discussion of symbol
> tables (p 293).
>
>     package DataPresenter::Schedule;
>     use strict;
>     use warnings;
>
>     my %reprocess_subs = ();
>
>     foreach (sort keys %DataPresenter::Schedule::) {
>         local *sym = $DataPresenter::Schedule::{$_};
>         $reprocess_subs{$_}++ if (defined &sym and $_ =~ /^reprocess_/);
>     }
>
> The objective is to make sure that subroutines whose names begin with
> "reprocess_" are defined in package DataPresenter::Schedule before they
are
> called.
>
> Now suppose that I wanted to use code like the above in a number of
> different packages, e.g., package DataPresenter::Foo, package
> DataPresenter::Bar, and so forth.  In that case I would want to avoid
> hard-coding "DataPresenter::[some_package]".  I'd prefer to have the name
of
> the package supplied on the fly.
>
> Can this be done?
>
> I know that you can say:
>
>     my $pkg = __PACKAGE__;
>
> and have it return "DataPresenter::[some_package]", but I haven't been
able
> to get it to work as I would like to:
>
>     no strict 'refs';
>     foreach (sort keys %$pkg::) {
>         local *sym = $$pkg::{$_};
>
> Suggestions?
Are you brave enough to use "eval"?
local *sym = eval '$$pkg::{$_}';





------------------------------

Date: 28 Oct 2002 09:05:57 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Can package names be supplied on-the-fly?
Message-Id: <apiull$1t1ek$1@fu-berlin.de>

James E Keenan <jkeen@concentric.net> wrote:

>     foreach (sort keys %DataPresenter::Schedule::) {


> Now suppose that I wanted to use code like the above in a number of
> different packages, e.g., package DataPresenter::Foo, package
> DataPresenter::Bar, and so forth.  In that case I would want to avoid
> hard-coding "DataPresenter::[some_package]".  I'd prefer to have the name of
> the package supplied on the fly.

> Can this be done?

> I know that you can say:

>     my $pkg = __PACKAGE__;

> and have it return "DataPresenter::[some_package]", but I haven't been able
> to get it to work as I would like to:

>     no strict 'refs';
>     foreach (sort keys %$pkg::) {
>         local *sym = $$pkg::{$_};

no strict 'refs';
my $pkg = __PACKAGE__ . "::";
foreach sort keys %{$pkg} {
 local *sym = ${$pkg.$_};
 ...
}
# untested

hth, tina

-- 
http://www.tinita.de/        \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/      \     / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/   \    \ _,_\ __/\ __/_| /__/ perception


------------------------------

Date: Mon, 28 Oct 2002 12:19:24 +0200
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: Capture Error Messages
Message-Id: <apivee$1s7mk$1@ID-33095.news.dfncis.de>

jaya prakash wrote:

> Hi,
> 
> The following code snippet is is not writing to the STDRR.
> 
> #!/usr/local/bin/perl -w
> die "THIS IS AN ERROR MESSAGE";
> 
> I was trying to capture the error messages from the command prompt in
> the follwoing way. I am suprised to know that it is not directing
> STDERR to "err" file.
> 
> $./error 2>err
> THIS IS AN ERROR MESSAGE

This one should work with bash/ksh/sh shells.
However, AFAIK this will not work under csh.
That's not a perl problem (die() really
prints to stderr anyway), it's a question
about your shell's syntax and capabilities.

So please check what your shell is and consult
it's man page to see if 2>... style redirects
are supported.

If you are really using csh, the following 
should help, IMHO:

% (./program >program.stdout) >&program.stderr

You'll get both stdout and stderr captured in
two separate files.

HTH

Ilja.



------------------------------

Date: Mon, 28 Oct 2002 06:53:26 GMT
From: "Doug" <dgardiner@houston.rr.com>
Subject: Re: DBI select with memo fields
Message-Id: <G95v9.217575$8o3.6334298@twister.austin.rr.com>


"Doug" <dgardiner@houston.rr.com> wrote in message
news:Nb_u9.227857$121.6417516@twister.austin.rr.com...
> Does anyone have any suggestions on selecting rows from a database that
> include memo fields.
>
> I have a select statement which works if the size of the contents from the
> memo field are below 255.  Is there a hidden switch or something to
retrieve
> the information?
>
> The result has been, if I leave the field in the database for one row
> untouched, the fetch returns nothing saying that it couldn't find anything
> that matched the index ID of the row that I want.  If I change the
contents
> of the memo field to something below 255 characters it returns fine.
>
> I'm using Access at the moment for this, for testing purposes and for
> development reasons.  IS it something particular to the DBI module that
only
> accepts fields smaller than 255 characters?
>
> $database_run=$dbh->prepare("SELECT * FROM PROJECT_LIST WHERE Project_ID=
> ?");
> database_check() || debugger("prepare select project by project
> id","passed");
> $database_run->execute("$project_id");
> database_check() || debugger("execute select project by project
> id","passed");
>
>
> This seems to work fine when the memo field is below 255 characters.
>
> For reference, the database_check sub routine does the error checking and
> depending on whether the debugger sub is enabled prints the error directly
> to browser/and or the database log file.  No errors show up in the
database
> log file, and nothing shows up in the trace log for the database either.
>
> It just returns zero results from the search.
>
> Since it isn't returning any errors I'm not sure if this is a constraint
of
> the DBI module or the ODBC interface.  I would love to have an actual
error
> to look at.
>
>
Figures a few more hours later, a switch is revealed.  Actually 2 of them
for long objects.

LongReadLen switch and TruncLongOk switch apparently have to be specified
just before the preparation of the select statement, and is only required
for the select statement, if my documentation reads correctly.




------------------------------

Date: Mon, 28 Oct 2002 01:56:26 GMT
From: echang@netstorm.net (ebchang)
Subject: Re: deleting a file... kill ???
Message-Id: <Xns92B4D51E461DBechangnetstormnet@207.106.92.86>

"G.Doucet" <gldouce@nbnet.nb.ca> wrote in <3DB55928.B980AE2E@nbnet.nb.ca>:

>I was updating a perl script that I wrote last year. The Perl script
>reads and writes to a few database files which are just simple text
>files. At one point, the perl script deletes an old file which goes
>something like this:
>
>  if(-e "$obidfil"){kill $obidfil;}
>
>I wanted to know if I could tell whether the command was able to delete
>the file, or whether there would be an error. So I decided to read up on
>the kill function in my old Perl book "Using Perl 5 for web
>programming". 

[snip]

>I just want to make sure that I am using the correct function to delete
>a file.

The function you want is unlink, not kill.  You can test success by checking 
the return value; it returns the number of files successfully deleted.  See 
the documentation (perldoc -f unlink or look it up at perldoc.com) for more.

--
EBC


------------------------------

Date: Mon, 28 Oct 2002 06:19:08 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: How can I make a set of objects?
Message-Id: <slrnarplen.81r.garry@zfw.zvolve.net>

On Sun, 27 Oct 2002 18:41:27 +0200, Teh (tî'pô) <teh@mindless.com> wrote:
> How can I make a set of objects AKA How can I use a reference as a
> hash key?
> Yes I know this is a FAQ but still...
> 
> I want to have a set of objects and the newbie that I am I started
> coding this as a hash but even as I wrote it I realized that hash keys
> are stringified. A google and a perldoc later I come to you with a set
> of questions.
> 
> What are the drawbacks of having a hash with the key being the
> stringified version of a reference to an object and the value being
> the reference itself?

Why not use ref $obj as the key and store a list of $obj values?  

-- 
Garry Williams


------------------------------

Date: Mon, 28 Oct 2002 09:24:50 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: How can I make a set of objects?
Message-Id: <1fpprucgh4ol02jk6er7klkl8cpte19jvr@4ax.com>

Garry Williams bravely attempted to attach 18 electrodes of knowledge
to the nipples of comp.lang.perl.misc by saying:
>On Sun, 27 Oct 2002 18:41:27 +0200, Teh (tî'pô) <teh@mindless.com> wrote:
>> How can I make a set of objects AKA How can I use a reference as a
>> hash key?
>> Yes I know this is a FAQ but still...
>> 
>> I want to have a set of objects and the newbie that I am I started
>> coding this as a hash but even as I wrote it I realized that hash keys
>> are stringified. A google and a perldoc later I come to you with a set
>> of questions.
>> 
>> What are the drawbacks of having a hash with the key being the
>> stringified version of a reference to an object and the value being
>> the reference itself?
>
>Why not use ref $obj as the key and store a list of $obj values?  

That way I'll have one hash entry per class and I have to search a
list of objects every time losing almost all the advantages of a hash.


------------------------------

Date: Mon, 28 Oct 2002 10:10:17 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: How can I make a set of objects?
Message-Id: <i1sprugsv1ngr0d4iq5s8mh5isgh5hoeko@4ax.com>

I (eye) bravely attempted to attach 76 electrodes of knowledge to the
nipples of comp.lang.perl.misc by saying:
>What advantages does Tie::RefHash have over said implementation (if
>any) if I'm only interested in having a set and not assigning values
>for keys?

OK, I've read Tie/RefHash.pm and saw something I wouldn't have thought
of... RefHash keeps separate hashes for references and for
non-refereces so that a reference and its stringified value have
distinct values!

Cool, maybe there is a reason to use modules after all... ;o)


------------------------------

Date: Sun, 27 Oct 2002 23:30:34 GMT
From: Gisle Aas <gisle@ashn89ty262h.bc.hsia.telus.net>
Subject: Re: HTML:Parser
Message-Id: <m33cqrv4rq.fsf@ashn89ty262h.bc.hsia.telus.net>

sailordwarf@hotmail.com (Andrew Gatt) writes:

> Am i right in thinking there is some way to filter (HTML:Filter??)
> these javascript functions out. Something like, ignore everything
> between script tags. If there is could someone point me in the right
> direction.

If $p is you parser object, then try:

  $p->ignore_elements('script');

But you probably want to skip 'style' elements too, so make it:

  $p->ignore_elements(qw(script style));

-- 
Gisle Aas


------------------------------

Date: Sun, 27 Oct 2002 23:37:31 GMT
From: Gisle Aas <gisle@ashn89ty262h.bc.hsia.telus.net>
Subject: Re: HTML:Parser
Message-Id: <m3y98jtpvq.fsf@ashn89ty262h.bc.hsia.telus.net>

Bart Lateur <bart.lateur@pandora.be> writes:

> The thing is, recent incarnations of HTML::Parser treat whatever is
> between "<script>" and "</script>" tags, as CDATA, i.e. special "text"
> with reduced parsing. (There must be at least one more tag that does the
> same, but I forgot which that is.).

The elements parsed this way are:

   <script>...</script>
   <style>...</style>
   <xmp>...</xmp>
   <textarea>...</textarea>

> That's good. The event it triggers, is the ordinary "text" event,
> which now has an extra argument. That's not so good. So check that
> new third argument in the text event, a flag, and you can make the
> distinction.

Seems better to make the distinction based on what element you are within.

-- 
Gisle Aas


------------------------------

Date: 28 Oct 2002 00:51:23 -0800
From: sailordwarf@hotmail.com (Andrew Gatt)
Subject: Re: HTML:Parser
Message-Id: <6f904ea5.0210280051.484de672@posting.google.com>

Thanks for everyones help, in the end i've opted for the exclusion line:

$p->ignore_elements(qw(script style));

as suggested which seems to be working fine.

Andrew


------------------------------

Date: Mon, 28 Oct 2002 15:34:07 +0530
From: Rahul <rshringa@austin.ibm.com>
Subject: Newbie Q:Help! (Perl Networking)
Message-Id: <3DBD0B97.E7BD0435@austin.ibm.com>

I am new to Perl....I have tried perldoc...but don't see any of that doc
helping me.

I think, I am missing something here...though I haven't been able to
find out. I am writing a simple Client/Server program using Perl.
everything works out fine until I try sending back data from the Server
to the Client. Data send from the Client to the Server reaches the
Server just fine. From the Server and Client o/p that I have put in this
message, it looks like, the Client has been successful in sending data
to the Server, what the problem is, is that the Server is not able to
write back to the Client.

Can some one enlighten me as  to what is happening here?
BTW, for now, I have been trying out these combinations for machines:
Client on DHCP -> Server on machine with DNS entry.
Client on DHCP -> Server on DHCP

Here are the code snippets,
The Server:
------------
[SNIP]
# Make the socket.
socket(Server, PF_INET, SOCK_STREAM, getprotobyname('tcp'));

# Build my socket address
$my_addr = sockaddr_in($server_port,INADDR_ANY);
bind(Server,$my_addr) || die "Couldn't listen on port $server_port.\n";

# Establish a queue for incoming connections.
listen(Server,SOMAXCONN) || die "Couldn't listen on port
$server_port.\n";

print "Waiting for client to connect...\n";
REQUEST:
while ($paddr=accept(Client, Server)) {
print "Spawning child....\n";
 if (!defined($child_pid = fork)) {
  die "Cannot fork: $!"
 } elsif ($child_pid) {
  # Parent code....
  # Closing client connection for parent.
  close(Client);
  next REQUEST;
 } else {
  # Child code.....
  # Check the CMVC ID for this user, setuid to it, and
  # start working.
  close(Server);
my($port,$iaddr)=sockaddr_in($paddr);
my $name=gethostbyaddr($iaddr,AF_INET);
print "Connection from $name.\n";
print "Starting to communicate....\n";
  #open(STDIN, "<<&Client") || die "Can't dup client conn.IN";
  #open(STDOUT, ">&Client") || die "Can't dup client conn.OUT";
  #open(STDERR, ">&STDOUT") || die "Can't dup STDERR.";
  $username = <Client>;
print STDOUT "data received from client ..$username." || die "Can't
print to client:$!"; #temporary comment
print Client "$username.\n" || die "Can't print to client:$!";
#temporary comment
print STDOUT "data in username is $username.\n";
exit 0; # For debugging, will not execute further.
[SNIP]

The Client:
-----------
[SNIP]
chomp($remote);
$port = 8231;
$iaddr = inet_aton($remote) || die "inet_aton failed:$!";
$paddr = sockaddr_in($port,$iaddr);
$proto = getprotobyname('tcp');
print "Creating socket...\n";
socket(SOCK, PF_INET,SOCK_STREAM,$proto);
print "Created socket...\n";
connect(SOCK,$paddr) || die "connect unsuccessful:$!";
print "Connection made!\n";

#while(defined($line = <SOCK>)) {
#while(1) {
 $line = "rahul\n";
 print "Value of buffer...$line";
print "Sending line....\n";
 print SOCK $line;
print "Sent line.\n";
print "Awaiting response.\n";
 $line = <SOCK>;
 print "Value of buffer after receive...$line";
#}
[SNIP]

I have been using these print statements to see where these programs
have reached execution.
So the Server o/p is:
---------------------
$ ./RP2_Server.pl
Waiting for client to connect...
Spawning child....
Connection from RSHRINGA.
Starting to communicate....
data received from client ..rahul
 .data in username is rahul
 .

The Client o/p is:
-----------------
$ ./RP2_Client.pl rshringa.in.ibm.com
Creating socket...
Created socket...
Connection made!
Value of buffer...rahul
Sending line....
Sent line.
Awaiting response.
Value of buffer after receive...$

--

Thanks & Regards,
Rahul

Change  :
---------------
Observe constantly that all things take place by change,
and accustom thyself to consider that the nature of the
Universe loves nothing so much as to change the things
which are, and to make new things like them.
        - Marcus Aurelius(121-80 AD), Roman Emperor




------------------------------

Date: 28 Oct 2002 00:35:15 -0500
From: Srikanth <member@mainframeforum.com>
Subject: Perl - Error Handling
Message-Id: <3dbccc93$1_1@news.onlynews.com>

 wrote:
  > Can't find label ProcessCitationEnd at NewRef.pm line 1816, <INFILE>
  > line 2496.

Hi,

I've a collection of sub routines for manipulating string. At some time,
an error occurs(for eg., "Unmatched (") and the program aborts. I just
want to trap an error, and when it catches, it should do anyone of the
following whichever is practically possible:

1. If an error occurs, the program should automatically end the current
   subroutine, and should process the remaining lines.

2. If an error occurs, the program should goto a particular label, which
   may be present in another sub routine.

I indeed dont know how to do the 1st one. But, I tried the 2nd one.
[PHP]$SIG{__DIE__} = sub { goto FunctionEnd; };[/PHP] But, this is also
not working. The following error is getting displayed:


If you could able to get the answer of either of the abovesaid 2 points,
please post me. Otherwise, if you could give the better soultion of the
foresaid error handling issue, please provide me.

Thanks, Srik



--
www.MainFrameForum.com - USENET Gateway


------------------------------

Date: Sun, 27 Oct 2002 23:05:19 -0700
From: Matt Stoker <stokerm@getnet.net>
Subject: Printing formatted text to a non-PostScript Printer
Message-Id: <3DBCD39F.5A8DFD66@getnet.net>

I have a perl script that generates a text-based report.  I would like
to print out (on a printer) the report with some simple formatting.
Ideally, I would like to be able to control the font and font-size, as
well as specify bold or italic print.  In addition I would like some
capability for positioning the text, so as to enable me to generate
tables.

For the case of PostScript printers, PostScript::Simple appears adequate
for my needs.  However, several locations where I would like to use the
script do not have access to a PostScript printer.  What are my options
for a non-PostScript solution?  

I believe all the printers I'm working with support PCL, however the
only PCL module I could find: PCL::Simple doesn't really meet my
requirements.  Are there any other Perl tools for working with PCL? 

Finally, I'll be working primarily on Windows98 systems and I understand
that there may be some API's in the OS that are useful in printing
formatted text.  If this is so, can anyone point me to where I might
find information about the API's and how to access them from perl?

Thanks in advance.


------------------------------

Date: 27 Oct 2002 19:08:53 -0800
From: pulsar10@email.com (Serge)
Subject: Re: Sendmail Bcc doesn't work
Message-Id: <2481ff4b.0210271908.393b0403@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message 
> 
> Distinguishing between what is code and what is data is pretty
> fundamental. It this your first foray into programming?

I just use perl most of the time. I use Java servlets when they are 
available, but on the server I am doing this for, there is no Java Web
Server installed.

> 
> What happened when you tried it?

When I tried it, it did not work. The "to" email was sent, the "bcc"
was not (with no backslash). Thanks for your help.


------------------------------

Date: 27 Oct 2002 19:11:49 -0800
From: pulsar10@email.com (Serge)
Subject: Re: Sendmail Bcc doesn't work
Message-Id: <2481ff4b.0210271911.55a1140b@posting.google.com>

> Distinguishing between what is code and what is data is pretty
> fundamental. It this your first foray into programming?

I meant to a put a "don't" before "use" in the last post. Sorry.


------------------------------

Date: Mon, 28 Oct 2002 12:53:48 +1100
From: oracle <oracle@sympac.com.au>
Subject: Serial Port
Message-Id: <api58k$ali$1@perki.connect.com.au>

Hi all

Am planning a program to talk to a weather station via the serial port on an 
intel box and cannot find out how to talk to the serial port.

Its gotta be easy but i can't find it. Any body help ?

Just need the setup of the port, and how to send receive data from the port.

Thanks
oracle


------------------------------

Date: Sun, 27 Oct 2002 21:46:03 -0800
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: Serial Port
Message-Id: <3dbcce8a$1_3@nopics.sjc>


"oracle" <oracle@sympac.com.au> wrote in message
news:api58k$ali$1@perki.connect.com.au...
> Hi all
>
> Am planning a program to talk to a weather station via the serial port on
an
> intel box and cannot find out how to talk to the serial port.
>
> Its gotta be easy but i can't find it. Any body help ?
>
> Just need the setup of the port, and how to send receive data from the
port.
>
> Thanks
> oracle

sockets don't work for you? Are transfered data in binary format?




------------------------------

Date: 28 Oct 2002 07:47:55 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: setreuid on AIX 5.1 with perl 5.6.1
Message-Id: <slrnarpqtb.39g.vek@station02.ohout.pharmapartners.nl>

On Sat, 26 Oct 2002 05:23:47 GMT,
    techcog@acme.N3T <techcog@acme.N3T> wrote:


>
>uid of capncrunch = 12345
>
>as root I can do a setreuid(12345,12345)
>and it does what I need; sets REAL_USER_ID = 12345
>
>What's the problem?  It's certainly not AIX.
>


Translated into ($<, $>) = (12345, 12345);
That sometimes works, sometimes it leaves the saved user id,
which may or may not be a problem.  This all depends on the OS
in question.



>> 
>> The perl view if the set?uid() function doesn't fit very well
>> to this behaviour; that is, I havent found a perl construct
>> that would reliable do the same as setuid(newuid) does in a
>
>What about an ifdef for AIX ???
>
>
>> C program.  The POSIX::setuid on perl 5.005 isn't even close to
>> the behaviour of the corresponding C function of the same name .
>
>POSIX::setuid doesn't work either.
>
>


The perl manual for the POSIX package states that POSIX::setuid will
change the real user id, which a lot of kernels, especially of the
SystemV ilk, won't cooperate with.

Nowhere does the manual claim that POSIX::setuid would do the same as 
the C function setuid().


Villy


------------------------------

Date: Mon, 28 Oct 2002 10:02:20 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: significance of 42 for perl, any?!?
Message-Id: <5nspru8r8t9fodp8gnv32p1eshr4h9lbgl@4ax.com>

I noticed that Benjamin Goldberg's japh sig uses the number 42 at some
point, while it could have been anything else. Now, even if I can't
find any example at the moment, I seem to recall that 42 arises
frequently in such contexts... is there any particular significance of
42 for perl or is it just my impression?


Michele
-- 
Liberta' va cercando, ch'e' si' cara,
Come sa chi per lei vita rifiuta.
           [Dante Alighieri, Purg. I, 71-72]

I am my own country - United States Confederate of Me!
           [Pennywise, "My own country"]


------------------------------

Date: Mon, 28 Oct 2002 11:09:28 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: significance of 42 for perl, any?!?
Message-Id: <mivpruo39uglbcv5nhs2h8lfhlns0tv5ib@4ax.com>

Michele Dondi bravely attempted to attach 15 electrodes of knowledge
to the nipples of comp.lang.perl.misc by saying:
>I noticed that Benjamin Goldberg's japh sig uses the number 42 at some
>point, while it could have been anything else. Now, even if I can't
>find any example at the moment, I seem to recall that 42 arises
>frequently in such contexts... is there any particular significance of
>42 for perl or is it just my impression?

No special significance for perl, a special significance for Life The
Universe and Everything.

You may want to check out Douglas Adams' "Hitch Hiker Guide to the
Galaxy" trilogy.



------------------------------

Date: Sun, 27 Oct 2002 21:56:05 -0800
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: usemymalloc: Whose malloc is that?
Message-Id: <3dbcd0e4$1_3@nopics.sjc>


"supernews" <arthur@excalibur-internet.net> wrote in message
news:urlk2cmrpttf5f@news.supernews.com...
> When compiling perl, does the config variable 'usemymalloc' when set to
'n'
> use perl's malloc or the system malloc.
It means using system malloc.

> My confusion is over what the 'my' refers to: perl or the system. I've
read
> the INSTALL doc that comes with the perl 5.6.1 source tarball, but I'm
still
> not sure.
>
> Does anyone know which malloc is preferred on a FreeBSD system, or does it
> matter?
A while back, people did some benchmark on Linux and reported that Perl
malloc was faster
than that of the underline system. It's also much easier for debugging
problematic Perl code.
Not sure if that also applies to FreeBSD.


> Thanks in advance for clearing this up for me.
>
> Art
>
>
>




------------------------------

Date: Mon, 28 Oct 2002 08:09:45 GMT
From: "reggie" <reggie_nospam@reggieband.com>
Subject: Value in array with loop
Message-Id: <dh6v9.618963$Ag2.23820374@news2.calgary.shaw.ca>

I need to find whether a value exists inside an array.
Please, before you refer me to an FAQ consider the whole problem.

I am getting the contents of a url then regexp for urls.  I then add these
urls to an array to keep a loop going (to loop through all values).  I need
to make sure the value is not inside the array before I try and add it (so
the same page does not get searched more than once).

Problem is, if I do it with a hash, it only loops through values existant in
the hash when the for loop is entered.

e.g.)

use strict;
use LWP::Simple;       # for get url

my $base = 'http://www.server.com'; # base site
my @new_uris;          # newly found urls
my $content;           # body of HTTP result
my %uris;

$uris{'index.php'} = 1;

foreach (keys %uris) {

 print '$_ = ' . $_ . "\n"; # testing only - shows

 $content = get ($base . $_);    # get is from LWP::Simple

 @new_uris = ($content =~ /<a href=['"](.*?)['"]/g);

 # add uris (unless already there)
 for (@new_uris) {
  $uris{$_} = 1 unless ($uris{$_});
 }
}

above does not work - I assume (but cannot find corroborating docs) that
keys %uris is evaluated once (the first time it goes through) and then never
again (even when new values are added to the hash).  If I output %uris I
find that new values have indeed been added (but not looped through).

I had a working script which used an array.  After each unique new_uri was
added to the array, I would rebuild a hash to check for subsequent uri's.
This seemed wasteful to me.  However, the loop did 'expand' to accomodate
new uris.

Any ideas on an eloquent solution?

regards,
reggie.




------------------------------

Date: Mon, 28 Oct 2002 08:21:23 GMT
From: "reggie" <reggie_nospam@reggieband.com>
Subject: Re: Value in array with loop
Message-Id: <7s6v9.596380$v53.25193908@news3.calgary.shaw.ca>

"reggie" <reggie_nospam@reggieband.com> wrote in message
news:dh6v9.618963$Ag2.23820374@news2.calgary.shaw.ca...
> I had a working script which used an array.  After each unique new_uri was
> added to the array, I would rebuild a hash to check for subsequent uri's.
> This seemed wasteful to me.  However, the loop did 'expand' to accomodate
> new uris.

Here is the example of the working script:

#!/usr/bin/perl -w

use strict;
use LWP::Simple;       # for get url

my $base = "http://www.someserver.com/"; # base site
my @new_uris;          # newly found urls
my $content;           # body of HTTP result
my @uris;              # array of urls to search
my %uris;              # hash of unique urls

# add index as first page to search
push @uris, 'index.php';

for (@uris) {

 $content = get ($base . $_);    # get is from LWP::Simple

 @new_uris = ($content =~ /<a href=['"](.*?)['"]/g);

 # add uris (unless already there)
 for (@new_uris) {
  #################################
  ## These next to lines I consider
  ## wasetful (bu necessary to
  ## avoid duplicates)
  undef %uris;
  for (@uris) { $uris{$_} = 1; }

  push @uris, $_ unless $uris{$_};
 }
}

regards,
reggie.




------------------------------

Date: Mon, 28 Oct 2002 03:21:19 GMT
From: echang@netstorm.net (ebchang)
Subject: Re: Wow
Message-Id: <Xns92B4E38E267E8echangnetstormnet@207.106.92.86>

"Brian" <fatcat01010@yahoo.co.uk> wrote in
<aphjsb$k0f$1@knossos.btinternet.com>: 

>Sorry.
>I was refering to a posting on the 25th "Before I buy this book"  Would
>have helped if I replied ti the corect thread.
>Oh well

Effective quoting, especially not top-posting, is important too - see 
http://www.geocities.com/ResearchTriangle/Lab/6882/nquote.html for a start.

>"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
>news:dpUu9.9827$FS5.4110@nwrddc04.gnilink.net...
>> Brian wrote:
>>> I'm new to this news group and new to Perl.  I'm hoping to learn a
>>> bit from you guys while I'm here.  Just read this thread.
>> 
>> Which thread? Your posting does not link to any other thread.




------------------------------

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


home help back first fref pref prev next nref lref last post