[11851] in Perl-Users-Digest
Perl-Users Digest, Issue: 5452 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 22 11:07:32 1999
Date: Thu, 22 Apr 99 08:01:35 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 22 Apr 1999 Volume: 8 Number: 5452
Today's topics:
Q about implicit references <kgnews@olympiakos.com>
Re: Q about implicit references (Rob Sweet)
redirecting STDOUT and STDERR into a text widget <schnoz@ibm.net>
reset $. in one-liner richard_chen@my-dejanews.com
Re: Script to tidy/format a C file (Clinton Pierce)
SHAREWARE: txt2pdf v. 2.0 <sanface@sanface.com>
Re: Silicon Valley Perl Mongers Group <gregm@well.com>
Small problem, please help (regarding upload) <ours@casema.net>
Re: T-shirt with potential Perl-logo (Ran)
Telnet problems scott@sboss.net
Re: The Future of Tk? <frederic.bonnet@ciril.fr>
To trim right blanks from a field. kalash4334@my-dejanews.com
Re: To trim right blanks from a field. <tchrist@mox.perl.com>
Re: using colors in Curses <ug@suse.de>
Re: Verifying text in a string (Tad McClellan)
Re: weird difference between exec and system <Michael.Cameron@no.spam.technologist.com>
Why can't the script find the Perl binaries?. <softcomp@home.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Apr 1999 09:13:07 -0400
From: Kiriakos Georgiou <kgnews@olympiakos.com>
Subject: Q about implicit references
Message-Id: <864sm8bxy4.fsf@dev-serv.nrl.navy.mil>
Hello,
I want to have a function that can modify its argument similarly
to chop. Implicit references was the obvious choice, but for
the sample perl program attached to the end of this post causes
the interpreter to complain:
Type of arg 1 to main::times2 must be scalar (not hash elem) at
foo.pl line 11, near "})" Execution of foo.pl aborted due to
compilation errors.
Yet the chop before the times2() call works, so assuming chop is
implemented in perl there is a way to pass by reference even
hash elements.
Any elegant way of resolving this other than assigning $hash{abc}
to a scalar, than passing it to times2 and assigning the result
back to $hash{abc}? I don't understand why perl doesn't treat
the hash element as a scalar.
thanks,
Kiriakos
#! /usr/local/bin/perl
sub times2(\$){
$ref = shift;
$$ref *= 2;
}
$hash{abc} = 11;
chop($hash{abc}); # works
times2($hash{abc}); # doesn't work
# $hash{abc} should now be 2
------------------------------
Date: Thu, 22 Apr 1999 14:37:04 GMT
From: sweet@enterpriseusa.com (Rob Sweet)
Subject: Re: Q about implicit references
Message-Id: <371f32f9.26229203@news1.mi.home.net>
Note the changes....
#! /usr/local/bin/perl
sub times2($){ # <- removed backslash
$ref = \$_[0] ; # <- reference to the original parameter
$$ref *= 2 ;
}
$hash{abc} = 11;
chop($hash{abc}); # works
times2($hash{abc}); # works NOW
print $hash{abc} ;
# $hash{abc} now IS 2
---
Rob Sweet
www.enterpriseusa.com
On 22 Apr 1999 09:13:07 -0400, Kiriakos Georgiou
<kgnews@olympiakos.com> wrote:
>
>Hello,
>I want to have a function that can modify its argument similarly
>to chop. Implicit references was the obvious choice, but for
>the sample perl program attached to the end of this post causes
>the interpreter to complain:
>
> Type of arg 1 to main::times2 must be scalar (not hash elem) at
> foo.pl line 11, near "})" Execution of foo.pl aborted due to
> compilation errors.
>
>Yet the chop before the times2() call works, so assuming chop is
>implemented in perl there is a way to pass by reference even
>hash elements.
>
>Any elegant way of resolving this other than assigning $hash{abc}
>to a scalar, than passing it to times2 and assigning the result
>back to $hash{abc}? I don't understand why perl doesn't treat
>the hash element as a scalar.
>
>thanks,
>Kiriakos
>
>
>
>#! /usr/local/bin/perl
>
>sub times2(\$){
> $ref = shift;
> $$ref *= 2;
>}
>
>$hash{abc} = 11;
>
>chop($hash{abc}); # works
>times2($hash{abc}); # doesn't work
>
># $hash{abc} should now be 2
------------------------------
Date: Thu, 22 Apr 1999 08:02:38 -0400
From: Lee & James <schnoz@ibm.net>
Subject: redirecting STDOUT and STDERR into a text widget
Message-Id: <371F0FDE.A7761989@ibm.net>
I'd like to redirect STDOUT and STDERR into a text widget. The code on
page 235 of "Advanced Perl Programming" works for STDOUT alone but I
can't figure out how to do it for STDERR together with STDOUT or even
STDERR alone.
Any suggestions would be appreciated!
Thanks,
James
------------------------------
Date: Thu, 22 Apr 1999 13:56:40 GMT
From: richard_chen@my-dejanews.com
Subject: reset $. in one-liner
Message-Id: <7fn9ql$ei0$1@nnrp1.dejanews.com>
I would like to insert a line at the beginning of
many files. The following will not work
$ perl -pi -e 's|(.*)|#!/usr/bin/perl\n$1| if $.==1' *.pl
because $. does not get reset after the first file.
How can one reset $. in such a one liner? I know that
one can use eof in an elaborate while ... continue ... loop.
But that make the one liner much too complicated.
Thanks for any info.
Richard
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Apr 1999 14:02:02 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Script to tidy/format a C file
Message-Id: <372929be.1899652075@news.ford.com>
[poster cc'd in e-mail]
On Thu, 22 Apr 1999 06:34:37 GMT, Myke <myke98@my-dejanews.com> wrote:
>In article <MPG.1188385b780f533e98990a@nntp.hpl.hp.com>,
> lr@hpl.hp.com (Larry Rosler) wrote:
>
>> The command `man 1 cb` on my HP-UX system produces this:
>>
>> cb(1)
>>
>> NAME
>> cb - C program beautifier, formatter
>
>Thanks, I didn't know about 'cb' but having just gone through it, it doesn't
>exactly do what I want/hoped for.
>
> [...]
>
>Well, I wanted to allow a little more flexibility such as having
>user-definable formatting options. Examples would be whether or not opening
>braces '{' would be on the same line as the control block, or whether they
>started on a new line, and if on a new line, would they be indented or not.
>What's the indent width? Should tabs be for indenting or padded spaces?
>Should comment blocks be indented? Stuff like that.
*thwack*
For a UNIX programmer, this is the wrong way of thinking. Shame!
cb(1) knows how to parse C program files and return a fairly 'standard'
well-structured C program source file. Why should it do anything else?
Reproducing that in Perl is Not Trivial. Now in UNIX you've got:
1. A program that spews forth very rigidly-structured ASCII text
files, that happen to parse as C (cb).
2. An excellent text-file manipulation language (Perl).
It should be _trivial_ to take the output of cb(1) and re-format it
slightly to fit your tastes:
cb foo.c | my_cb_reformat_script > foo_new.c
You're sitting in front of the best programmers toolkit in the world! Use
it!
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: Thu, 22 Apr 1999 13:37:15 GMT
From: SANFACE Software <sanface@sanface.com>
Subject: SHAREWARE: txt2pdf v. 2.0
Message-Id: <7fn8ma$dd8$1@nnrp1.dejanews.com>
txt2pdf is a very flexible PERL5 program. It's a converter from text files to
PDF format files.
Why do you need txt2pdf?
Most of your documents are text files (e.g. HTML, C source, C++ source, PERL
source, ...) Inside your DBs you have textual information txt2pdf is a PERL5
script, so you can use it in every operating systems supported by PERL5 (View
the list of OS tested) txt2pdf is a native converter, you don't need to pass
through PostScript format txt2pdf is specific for text to PDF conversion, so
you can mark yellow, red, green, blue or bold, italic, bolditalic (with PERL
regular expression) words in the produced PDF files you can produce a
2-columns PDF you can add page number in every page you can add text at the
beginning and at the end of every file you can add a border to every page
every word like http://... ftp://... mailto:... will become an URL you can
use a few parse commands (e.g. [!blue]...[!/blue]) the fee for every licence
is only $25 SANFACE Software is going to give you a free licence for every
good idea or for every good modify
txt2pdf is shareware
The txt2pdf source code is our company core business.
We trust you.
You can test text2pdf and modify it.
You can't use a modify version of txt2pdf for production purpose.
You can't resell txt2pdf or a modify version of it without SANFACE Software
authorization.
You can't copy part of it to include in your source without SANFACE Software
authorization.
What's new in this version
Border line
URL support (mailto: http: ftp:)
Allowinparse option [from Matt Johnson mailto:matt@vadu.com]
At the moment the options aren't multiline
[!yellow][!/yellow]
[!red][!/red]
[!green][!/green]
[!blue][!/blue]
[!italic][!/italic]
[!bold][!/bold]
Bugfix: added support for landscape option inside configuration file
End of txt2pdf_opt support
Test txt2pdf 2.0!
You can find it in our new site http://www.sanface.com
--
SANFACE Software
http://www.sanface.com
mailto:sanface@sanface.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Apr 1999 07:44:01 -0700
From: Greg McCann <gregm@well.com>
Subject: Re: Silicon Valley Perl Mongers Group
Message-Id: <371F35B1.CAD80231@well.com>
fxia@yahoo.com wrote:
> At last! A Perl Mongers group in the heart of Silicon Valley! ...
Great! I'm looking forward to the first meeting. Do you have any dates in mind
yet?
------------------------------
Date: Thu, 22 Apr 1999 14:56:52 -0700
From: "Ours" <ours@casema.net>
Subject: Small problem, please help (regarding upload)
Message-Id: <7fn6b1$emb$1@news.casema.net>
Hi All,
Yes I have ordered CGI/COOKBOOK, but I have to wait for it.
Please help me on the following matter:
I use a webform like this:
<FORM ENCTYPE="multipart/form-data"
ACTION="mydomain/cgi-bin/upload.cgi" METHOD="POST">
<INPUT TYPE="file" Name="filename" Size=35">
<INPUT TYPE="hidden" Name="Number" Value="153698">
<INPUT TYPE="SUBMIT" VALUE="upload">
</FORM>
(the Value of "Number" is a random value generated by another cgi)
What I would like to do is the following:
Let users upload a file, renaming the file to the random value.
So: reame.txt should be uploaded and stored as for example: 153698.txt
I also need file-extension control, so they can only upload: MP3 and MP2
files.
Can someone please help me? Files should be uploaded to:
d:/directory/subdirectory on my server
Thank you very very much in advance,
MW
------------------------------
Date: Thu, 22 Apr 1999 12:56:53 GMT
From: ran@netgate.net (Ran)
Subject: Re: T-shirt with potential Perl-logo
Message-Id: <924785813.704.98@news.remarQ.com>
In <371EFF39.62198F52@datenrevision.de>, Philip Newton <Philip.Newton@datenrevision.de> writes:
>Ed Bogart wrote:
>>
>> RJRTC stands for R. J. Reynolds
>> Tobacco Co. who makes Camel cigarettes which are mostly sold in third
>> world countries.
>
>Hmm, wonder what that makes Germany [where you can buy Camels]... :)
But, can you buy the T-shirts? Let's keep our priorities straight ;-)
Perhaps, now that Joe Camel has been officially declared "The Spawn of
Satan" for being to appealing to children, we'll be able to get
merchandise with the old logo here in the States again...
Ran
------------------------------
Date: Thu, 22 Apr 1999 12:54:04 GMT
From: scott@sboss.net
Subject: Telnet problems
Message-Id: <7fn65a$avp$1@nnrp1.dejanews.com>
Hello All..
I have never had as much trouble with a perl script as I am having now with
the Net::Telnet module. I am trying to telnet to many machines, one at a
time so I can do a "health check" of the system. When I try to telnet to the
machines, (Sun E3000s, E4000s, E6000s, E10000s, SSPs (ultra 5s), HP 9000s, HP
735, HP E45s) It gets past the point of the login/password but times out
before my first command can execute. I have tried many variations of the
code, I have stolen code sniplets off Dejanews and various emails. No luck.
>From the same machine I am executing the script I can telnet to all the
machines and login without a problem. Any suggestions?
Thanks
Scott
--
Scott Boss
Atlanta Perl Mongers Fearless Leader
website: http://atlanta.pm.org
community: http://www.dejanews.com/~apm
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Apr 1999 14:10:42 +0200
From: Frederic BONNET <frederic.bonnet@ciril.fr>
Subject: Re: The Future of Tk?
Message-Id: <371F11C2.3162025@ciril.fr>
Hi,
Eugene Dragoev wrote:
[...]
> But I also found that while older versions of Tk were using lightweight
> components (Some Java terminology :) the latest version is using native
> components for things like scrollbars and buttons.
>
> I don't want to say that this is bad for Tcl users but what about all
> the other languages that use Tk? Isn't writting multiplatform GUI harder
> using native components. I think Java made big step forward in
> abandoning the native components and using lightweight ones in Swing.
>
> Is there going to be any Tk implementation that will continue using
> lightweight components?
By lightweight I guess you mean emulated in some way. I don't think that
cross-platform look&feel consistency is a good thing. As a GUI designer
I'd rather follow the principle of least astonishment: an app running on
Windows should look and feel like a Windows app. The same app running on
MacOS and X should do the same on the respective platforms. Such a
cross-platform application is not supposed to look and feel the same on
all platforms. If users want to use the same app on several platforms,
it's their problem, and I think this isn't an issue: if the same person
uses an application on both Mac and Windows, he or she is supposed to
know both platforms, so he won't be surprised if the same application
behave differently on different platforms. On the contrary he or she
would be surprised to use an application that behaves like a Mac app on
his Windows system. The current Tk implementation addresses these
problems in a transparent manner, which is good for both programmers and
users.
A short summary of menubar differences between systems:
- they are placed on top of a window on Windows and X, and on top
of the screen on Mac.
- on Mac, the mouse button must be kept pressed to open and
navigate the menu (until recently). On X, one needs to click on
each menu to open it. On Windows, one needs to click on a menu
but doesn't need to keep the button pressed.
And I don't speak about look differences.
See you, Fred
--
Fridiric BONNET frederic.bonnet@ciril.fr
---------------------------------------------------------------
"Theory may inform, but Practice convinces"
George Bain
------------------------------
Date: Thu, 22 Apr 1999 14:39:06 GMT
From: kalash4334@my-dejanews.com
Subject: To trim right blanks from a field.
Message-Id: <7fnca9$gtp$1@nnrp1.dejanews.com>
I am looking for a function to trim the right spaces from a field of one line.
i.e.
my file is like
<jsfkjsh skdhfkshflk sdjfhsjkhfsdhf sdkhfklsh lkshflksj
uyfjfhj hvhjvj jhgjg nbvvbbjkb mnbbkjbbkjj>
I used substr function to break these columns in different variables by
giving position. Now I want to remove the right spaces to make the file in
this format:
jsfkjsh skdhfkshflk sdjfhsjkhfsdhf sdkhfklsh lkshflksj
uyfjfhj hvhjvj jhgjg nbvvbbjkb mnbbkjbbkjj
I tried Trim($variable_name) but I am getting this error
Undefined subroutine &main::Trim called at a.pl line 31, <> line 2.
Can someone suggest a solution.
Thanks
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Apr 1999 08:58:07 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: To trim right blanks from a field.
Message-Id: <371f38ff@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
kalash4334@my-dejanews.com writes:
:my file is like
:<jsfkjsh skdhfkshflk sdjfhsjkhfsdhf sdkhfklsh lkshflksj
: uyfjfhj hvhjvj jhgjg nbvvbbjkb mnbbkjbbkjj>
:
:I used substr function to break these columns in different variables by
:giving position.
That's too bad. The A format in unpack might have served you better.
:Now I want to remove the right spaces to make the file in
:this format:
:
:jsfkjsh skdhfkshflk sdjfhsjkhfsdhf sdkhfklsh lkshflksj
:uyfjfhj hvhjvj jhgjg nbvvbbjkb mnbbkjbbkjj
:
:I tried Trim($variable_name) but I am getting this error
"Trim()"? What is "Trim()"? I can't find that in perlfunc.
man perlfaq4. man perlre. man perlop. grep grep grep.
--tom
--
I've got plenty of inputs and outputs. I don't need the video. --Andrew Hume
------------------------------
Date: Thu, 22 Apr 1999 16:04:25 +0200
From: Uwe Gansert <ug@suse.de>
Subject: Re: using colors in Curses
Message-Id: <371F2C69.3A3BD10@suse.de>
Hi markus
> I'm trying to get color output using Curses, but
> #!/usr/bin/perl
> initscr;
> start_color;
> if( has_colors) { addstr( 10, 10, "has_colors");
> } else { addstr( 10, 10, "no has_colors"); }
> $win = newwin(0,0,0,0);
init_pair(1, COLOR_WHITE, COLOR_RED);
attrset( COLOR_PAIR(1) );
> #attrset( COLOR_WHITE);
> addstr( 12,10,"colored output");
> refresh($win);
> getch;
> endwin();
and then everything is looks fine.
tschau , UwE
------------------------------
Date: Wed, 21 Apr 1999 19:52:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Verifying text in a string
Message-Id: <qbolf7.dr6.ln@magna.metronet.com>
Jukka Juslin (jtjuslin@cc.hut.fi) wrote:
: The answer is quite obviously \W switch, for example:
: $name =~ s/\W.*//;
\W is not a switch (a switch should be of a binary nature).
It is a Character Class.
Behavior is identical to:
$name =~ s/[^a-zA-Z0-9_].*//;
It is just a shortcut to save typing.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 22 Apr 1999 14:50:43 +0000
From: Michael Cameron <Michael.Cameron@no.spam.technologist.com>
To: eric@fruitcom.com
Subject: Re: weird difference between exec and system
Message-Id: <371F3743.D9ED3D1C@no.spam.technologist.com>
Eric Smith wrote:
> Can anyone explain why the output is different depending on the call to
> systrm or exec?
>
> [info@plum 220500]$ cat 220499.db|perl -pe 'exec "sort -u"'|wc -l
> 3551
I think you should read the documentation on the -p flag. (I think) the
above is equivalent to:
cat 220499.db|perl -e 'while (<>) {exec "sort -u" } continue { print or
die "-p destination: $!\n";}'|wc -l
which is not really what you are trying to do (is it?), same applies to
the system call below.
perldoc -f exec
perldoc -f system
explains the differences fully.
You could try:
perl -e 'exec "sort -u afile";print "Aha! So thats the difference\n"'
| grep "Aha! So thats the difference"
perl -e 'system "sort -u afile";print "Aha! So thats the difference\n"' |
grep "Aha! So thats the difference"
to give you a little clue.
Michael
>
> [info@plum 220500]$ cat 220499.db|sort -u|wc -l
> 3581
> [info@plum 220499]$ cat 220499.db|perl -pe 'system "sort -u"'|wc -l
> 3581
------------------------------
Date: Thu, 22 Apr 1999 14:15:26 GMT
From: "WF, Yee" <softcomp@home.com>
Subject: Why can't the script find the Perl binaries?.
Message-Id: <371F2DD8.DE7B22AF@home.com>
Hello All,
This is very puzzling to me and I hope someone
has an idea what's wrong. I installed perl version
5.005_02 on my Linux box last night and I noticed that
it is behaving very flaky.
When I did "which perl", I get "/usr/bin/perl".
When I did "perl -v", it reported that version
5.005_2 is installed.3
I have "#!/usr/bin/perl" as the first line of my
script but yet when I tried to execute it, I get
"No such file or directory". When I did "perl mytest" (name
of script is mytest), the script worked fine. I checked
"/usr/bin/perl" and it does exist. I am guessing
it may have to do with the shell or I messed something up
during the installation when it asked about "what is the
first lien of the script" or something to that effect.
Has anyone seen this one before?. Thanks in advance.
Wai Fai, Yee
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5452
**************************************