[8040] in Perl-Users-Digest
Perl-Users Digest, Issue: 1665 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 18 09:06:36 1998
Date: Sun, 18 Jan 98 06:01:02 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 18 Jan 1998 Volume: 8 Number: 1665
Today's topics:
Re: Access Log <joseph@5sigma.com>
Building indexes in Perl (FRIHA Lamia)
Changing Case <brad.grove@b131.aone.net.au>
Delete a file with Net::FTP <tor@kmd.dk>
Re: Delete a file with Net::FTP <tor@kmd.dk>
Re: get machine name from IP? (Martin Vorlaender)
Re: get machine name from IP? <joseph@5sigma.com>
Re: How do I allow input to be retrieved from multiple <joseph@5sigma.com>
Re: How do I allow input to be retrieved from multiple <rra@stanford.edu>
Mail::Tools Question <webmaster@fccj.cc.fl.us>
Re: module to calculate dates? (Dean Burdick)
Re: module to calculate dates? <corky@ultranet.com>
Re: module to calculate dates? (Hans-Georg Rist)
Re: novice question: ranking array elements <joseph@5sigma.com>
Re: Parsing HTML tag parameters (Abigail)
Re: Parsing HTML tag parameters nobody@nowhere
Re: Parsing HTML tag parameters (Abigail)
Re: Perl dies with segmentation fault and leaves a core <joseph@5sigma.com>
Re: perl module question <joseph@5sigma.com>
qc(foo,bar,bletch) [Re: perl module question] <joseph@5sigma.com>
Re: Socket ? <lwp@flenser.att.net>
Re: Sort question <joseph@5sigma.com>
Re: source into binary code <danboo@negia.net>
Re: source into binary code (Abigail)
Re: Substituting characters (Odie Deth)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 18 Jan 1998 04:28:59 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Access Log
Message-Id: <34C1E741.2D77262F@5sigma.com>
Speak for yourself ...
{joseph}:205% ls -l foobar
-rw-rw-r-- 1 joseph 0 Jan 18 04:24 foobar
{joseph}:206% perl -e 'open FOOBAR, "> foobar" or die $!'
{joseph}:207% whoami
joseph
-joseph
http://www.effectiveperl.com
Geurt Schimmel wrote:
>
> In fact, you'r trying open(best,"> $logfile") - and that won't work if you're
> not root.
------------------------------
Date: 18 Jan 1998 10:04:57 GMT
From: friha@cui.unige.ch (FRIHA Lamia)
Subject: Building indexes in Perl
Message-Id: <69sk49$lgt@uni2f.unige.ch>
Hi,
I a beginner in Perl and have to build different indexes on a set of ASCII files, describing different
products. Each file contains different informations on the product (+errors of syntax...etc). What is the best way to do that?
Thanks in advance,
Lamia Friha
--
Lamia FRIHA mailto:friha@cui.unige.ch
CUI-Geneva University http://cuiwww.unige.ch/AI-group/home.html
24 Rue General Dufour 1211 Geneva 4, Switzerland
-Tel:(022) 705.7637----Sec:(022) 705.7660----Fax:(022) 705.77.80
------------------------------
Date: Sun, 18 Jan 1998 19:55:13 +1100
From: "Brad Grove" <brad.grove@b131.aone.net.au>
Subject: Changing Case
Message-Id: <69sjj0$m5v$1@news.mel.aone.net.au>
Hi
I have only just recently started writing in Perl and am still finding my
way. How can I change a string to Upper and Lower Case. It is easy to change
to either lower case or upper case but how can I change a string so that the
first letter of every word is upper case and the rest is in lower case.
Thanks in advance
Brad Grove
------------------------------
Date: Sun, 18 Jan 1998 12:05:37 +0100
From: "Torfinn Keringen" <tor@kmd.dk>
Subject: Delete a file with Net::FTP
Message-Id: <69snnl$7gb@news1.tele.dk>
Hi
I'm trying to make a small perl scripts that retrievs a file from a host,
and then deletes it on the host.
When I try to delete (or rename) the file via ftp it gives me this message:
Can't locate object method "delete" via package "ftp" at ftpclient.plx line
50.
put, get, pwd and cwd works fine, what am I doing wrong.
I'm running version 5.004_02.
Torfinn Keringen --> tor@kmd.dk
some of my code
use Net::FTP;
use File::Listing qw(parse_dir);
.....
sub getfiles {
$ftp->cwd($getpath) or die "Cannot change directory ($host):";
@ls = $ftp->ls('-l');
$ftp->binary();
foreach $file (parse_dir(\@ls)) {
my($name, $type, $size, $mtime, $mode) = @$file;
$local_file = $ftp->get($name) or warn "Could not get '$name',
skipped: $!";
if($local_file) {
ftp->delete($name);
}
}
}
Net::FTP=GLOB(0xa144e8)>>> NLST -l
Net::FTP=GLOB(0xa144e8)<<< 150 Opening data connection for /bin/ls.
Net::FTP=GLOB(0xa144e8)<<< 226 Transfer complete.
Net::FTP=GLOB(0xa144e8)>>> TYPE I
Net::FTP=GLOB(0xa144e8)<<< 200 Type set to I.
Net::FTP=GLOB(0xa144e8)>>> PORT 172,20,10,33,7,72
Net::FTP=GLOB(0xa144e8)<<< 200 PORT command successful.
Net::FTP=GLOB(0xa144e8)>>> RETR REC2000.EDI
Net::FTP=GLOB(0xa144e8)<<< 150 Opening data connection for REC2000.EDI (2000
byt
es).
Net::FTP=GLOB(0xa144e8)<<< 226 Transfer complete.
Can't locate object method "delete" via package "ftp" at ftpclient.plx line
50.
------------------------------
Date: Sun, 18 Jan 1998 12:51:10 +0100
From: "Torfinn Keringen" <tor@kmd.dk>
Subject: Re: Delete a file with Net::FTP
Message-Id: <69sqde$9tp@news1.tele.dk>
It's a typeing error, sorry
Thanks to Andrew
Torfinn Keringen
Torfinn Keringen skrev i meddelelsen <69snnl$7gb@news1.tele.dk>...
>Hi
>I'm trying to make a small perl scripts that retrievs a file from a host,
>and then deletes it on the host.
>When I try to delete (or rename) the file via ftp it gives me this message:
>
>Can't locate object method "delete" via package "ftp" at ftpclient.plx line
>50.
>
>put, get, pwd and cwd works fine, what am I doing wrong.
>
>I'm running version 5.004_02.
>
>Torfinn Keringen --> tor@kmd.dk
>
>some of my code
>use Net::FTP;
>use File::Listing qw(parse_dir);
>.....
>sub getfiles {
> $ftp->cwd($getpath) or die "Cannot change directory ($host):";
> @ls = $ftp->ls('-l');
> $ftp->binary();
> foreach $file (parse_dir(\@ls)) {
> my($name, $type, $size, $mtime, $mode) = @$file;
> $local_file = $ftp->get($name) or warn "Could not get '$name',
>skipped: $!";
> if($local_file) {
> ftp->delete($name);
> }
> }
>}
>
>Net::FTP=GLOB(0xa144e8)>>> NLST -l
>Net::FTP=GLOB(0xa144e8)<<< 150 Opening data connection for /bin/ls.
>Net::FTP=GLOB(0xa144e8)<<< 226 Transfer complete.
>Net::FTP=GLOB(0xa144e8)>>> TYPE I
>Net::FTP=GLOB(0xa144e8)<<< 200 Type set to I.
>Net::FTP=GLOB(0xa144e8)>>> PORT 172,20,10,33,7,72
>Net::FTP=GLOB(0xa144e8)<<< 200 PORT command successful.
>Net::FTP=GLOB(0xa144e8)>>> RETR REC2000.EDI
>Net::FTP=GLOB(0xa144e8)<<< 150 Opening data connection for REC2000.EDI
(2000
>byt
>es).
>Net::FTP=GLOB(0xa144e8)<<< 226 Transfer complete.
>Can't locate object method "delete" via package "ftp" at ftpclient.plx line
>50.
>
>
>
>
------------------------------
Date: Sun, 18 Jan 1998 07:48:39 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: get machine name from IP?
Message-Id: <34c1a5c7.524144494f47414741@radiogaga.harz.de>
Jerry Davis (gedavis3@vt.edu) wrote:
: one can track the IP of the user who activates a perl script with the
: $ENV('REMOTE_ADDR') variable. Is there a perl command to either get or
: convert that to the machine name.
: i.e gedavis3.campus.vt.edu. Mainly I want to be able to track the domain
: the user is comming from.
sub reverse_lookup($)
{
use Socket;
my $iaddr = inet_aton $_[0];
defined $iaddr or return undef;
(gethostbyaddr $iaddr, AF_INET)[0];
}
$remote_hostname = reverse_lookup $ENV{REMOTE_ADDR};
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Sun, 18 Jan 1998 04:25:32 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: get machine name from IP?
Message-Id: <34C1E672.A0AE44FB@5sigma.com>
Perhaps your server already provides the resolved host name in a
different environment variable? If not (some don't), see the other
answers posted here.
-joseph
http://www.effectiveperl.com
Jerry Davis wrote:
>
> one can track the IP of the user who activates a perl script with the
> $ENV('REMOTE_ADDR') variable. Is there a perl command to either get or
> convert that to the machine name. [...]
------------------------------
Date: Sun, 18 Jan 1998 04:35:39 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: How do I allow input to be retrieved from multiple lines?
Message-Id: <34C1E8D1.C8CD3A7B@5sigma.com>
print "type . on a line by itself to end\n";
$all .= $in while (($in = <>) ne ".\n");
print "you typed:\n", $all;
-joseph
http://www.effectiveperl.com
Chocolate wrote:
>
> How do I make it so that if my input needs more than one line I can hit
> return without sending it? How do I make it so that a line with only a
> period lets it know that I am done inputting?
------------------------------
Date: 18 Jan 1998 03:50:13 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: How do I allow input to be retrieved from multiple lines?
Message-Id: <m3d8hqovbe.fsf@windlord.Stanford.EDU>
Joseph N Hall <joseph@5sigma.com> writes:
> print "type . on a line by itself to end\n";
> $all .= $in while (($in = <>) ne ".\n");
> print "you typed:\n", $all;
Careful. You *always* want to stop reading on end of file; otherwise, if
someone pipes text into your program and it doesn't end in a single
period, you'll hang trying to read more data.
What you want instead is:
print "type . on a line by itself to end\n";
$all .= $in while (($in = <>) ne ".\n" && defined $in);
print "you typed:\n", $all;
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sun, 18 Jan 1998 08:35:01 -0500
From: "Webmaster" <webmaster@fccj.cc.fl.us>
Subject: Mail::Tools Question
Message-Id: <34c205f0.0@usenet.fccj.cc.fl.us>
Hi All :-)
I have been trying to write a mail aliases userID which calls
(pwchg: "|/drv2/usr/bin/local/pwchg.pl") a perl script to allow a secure msg
be recieved to change/syncronize a users Shell/POP3/News passwd on a
particular server.
First problem I had was capturing piped output. I have tried -
while (<>) {
# Do stuff...
}
And
while ("|<STDIN>") {
# Do stuff...
}
And
@dataCapture = <>;
Any suggestions?
Also, I would really like to know if anyone has seen, knows, or otherwise
ran across any additional examples/help of how to use the Mail::Tools
modules and if you have seen example code?
I think this is a case of just looking at it too long :-) I think I may be
missing something basic?
Thx,
Bill the Cat
(* Ack, complimentary hairball :-)
------------------------------
Date: 17 Jan 1998 15:10:56 GMT
From: burdick@fcs.netguard.net (Dean Burdick)
Subject: Re: module to calculate dates?
Message-Id: <69qhm0$k79$1@core.savvis.net>
In article <34BFF7A0.2BFE@ultranet.com>, corky@ultranet.com says...
>
>Is there a perl module/library out there that calculates dates?
>
>I am looking for something that returns a date after I feed a date into
>it and tell it to subtract or add a number of days.
>
>I don't want to have to reinvent the wheel. Besides that, mine would
>probably be a flat tire.
>
>
>Any help is appreciated,
>Bob Trieger
>corky@ma.ultranet.com
Check out the 'datemanip' module on CPAN.
------------------------------
Date: Sun, 18 Jan 1998 05:02:52 -0500
From: Bob Trieger <corky@ultranet.com>
To: Dean Burdick <burdick@fcs.netguard.net>
Subject: Re: module to calculate dates?
Message-Id: <34C1D34C.3D5C@ultranet.com>
Dean Burdick wrote:
>
> In article <34BFF7A0.2BFE@ultranet.com>, corky@ultranet.com says...
> >
> >Is there a perl module/library out there that calculates dates?
> >
> >I am looking for something that returns a date after I feed a date into
> >it and tell it to subtract or add a number of days.
> >
> >I don't want to have to reinvent the wheel. Besides that, mine would
> >probably be a flat tire.
> Check out the 'datemanip' module on CPAN.
I left out one tiny fact. I am doing this on an NT server and can't get
datemanip or datecalc to install correctly.
------------------------------
Date: Sun, 18 Jan 1998 13:15:26 GMT
From: hans-georg.rist@zkrd.de (Hans-Georg Rist)
Subject: Re: module to calculate dates?
Message-Id: <34c1fd30.3083711@news.uni-ulm.de>
Bob Trieger <corky@ultranet.com> wrote:
>Is there a perl module/library out there that calculates dates?
>
>I am looking for something that returns a date after I feed a date into
>it and tell it to subtract or add a number of days.
>
>I don't want to have to reinvent the wheel. Besides that, mine would
>probably be a flat tire.
Here is an example how I use my own date routines to do such a job.
These functions are extracted from my date module which I wrote in
perl last december when having read an article in the german magazine
c't (vol. 15/1997, p. 312ff). The original code was in C.
The main program reads a date from stdin (default: today) and a number
(pos./neg.) and then prints out the new calculated date. I hope it's
not too long. ;-)
The script should work under Windows (tested) and Unix.
HG
#!/usr/bin/perl
use strict;
my( $today, $inp, $ok, $year, $month, $day );
$today = sprintf "%02d.%02d.%04d", reverse &today;
print "date <dd.mm.yyyy>? [$today] ";
chomp( $inp = <> );
$inp ||= $today; # today is default
( $ok, $year, $month, $day ) = &check_date_str( $inp );
if ( $ok ) {
print "+/- days? ";
chomp( $inp = <> );
if ( $inp =~ /^[-+]?\d+$/ ) {
printf "new date: %02d.%02d.%04d\n",
reverse &g_date( &j_date( $year, $month, $day ) + $inp );
}
else {
print "\cG", "invalid value!\n";
}
}
else {
print "\cG", "invalid date!\n";
}
exit( 0 );
#=============================================================================
#=============================================================================
# original C-functions j_date() and g_date(): c't 15/1997, p. 312ff
# rewritten in perl by: Hans-Georg Rist
#=============================================================================
#=============================================================================
sub j_date {
#-----------------------------------------------------------------------------
# Arguments: year, month (1=Jan, 2=Feb, ... 12=Dec), day (1...31)
# Returns: Julian date (days since 1.1.4713 before Chr.)
#-----------------------------------------------------------------------------
# Algorithmus: R. G. Tantzen
#-----------------------------------------------------------------------------
my( $year, $month, $day ) = @_;
my( $c, $y );
if ( $month > 2 ) {
$month -= 3;
}
else {
$month += 9;
$year--;
}
$day += int( ( 153 * $month + 2 ) / 5 );
$c = int( ( 146097 * int( $year / 100 ) ) / 4 );
$y = int( ( 1461 * ( $year % 100 ) ) / 4 );
$c + $y + $day + 1721119; # return value
} # end sub j_date()
#=============================================================================
#=============================================================================
sub g_date {
#-----------------------------------------------------------------------------
# Arguments: Julian date (days since 1.1.4713 B.C.)
# Returns: Gregorian date:
# year, month (1=Jan, 2=Feb, ... 12=Dec), day (1...31)
#-----------------------------------------------------------------------------
# Modifizierter Algorithmus von R. G. Tantzen
#-----------------------------------------------------------------------------
my( $jd ) = @_;
my( $year, $month, $day );
$jd -= 1721119;
$year = int( ( 4 * $jd - 1 ) / 146097 );
$jd = ( 4 * $jd - 1 ) % 146097;
$day = int( $jd / 4 );
$jd = int( ( 4 * $day + 3 ) / 1461 );
$day = ( 4 * $day + 3 ) % 1461;
$day = int( ( $day + 4 ) / 4 );
$month = int( ( 5 * $day - 3 ) / 153 );
$day = ( 5 * $day - 3 ) % 153;
$day = int( ( $day + 5 ) / 5 );
$year = 100 * $year + $jd;
if ( $month < 10 ) {
$month+=3;
}
else {
$month -= 9;
$year++;
}
( $year, $month, $day ); # return values
} # end sub g_date()
#=============================================================================
#=============================================================================
sub leapyear {
#-----------------------------------------------------------------------------
# Arguments: year
# Returns: boolean (1=true/0=false)
#-----------------------------------------------------------------------------
( $_[0] % 4 == 0 && $_[0] % 100 != 0 || $_[0] % 400 == 0 ) ? 1 : 0;
} # end sub leapyear()
#=============================================================================
#==============================================================================
sub today {
#------------------------------------------------------------------------------
# Purpose: get current date
# Arguments: none
# Returns: year, month, day
#------------------------------------------------------------------------------
my( $sec, $min, $hour, $day, $month, $year, $wday, $yday, $isdst ) =
localtime;
$year += 1900;
++$month;
( $year, $month, $day ); # return values
} # end sub today()
#==============================================================================
#=============================================================================
sub check_date_str {
#-----------------------------------------------------------------------------
# Arguments: date (format dd.mm.yyyy, dd/mm/yyyy, ...; non-digit as
separator)
# Returns: error-code (boolean: true/false), year, month, day
#-----------------------------------------------------------------------------
my( $day, $month, $year ) = split( /[^\d]/, $_[0] );
my( $ok );
my %monthday = ( 1 => 31, 2 => 28, 3 => 31, 4 => 30, 5 => 31, 6 => 30,
7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 =>
31 );
$ok = ( $month >= 1 and $month <= 12 and
$day >= 1 and $day <= $monthday{ $month+0 } + &leapyear( $year
)
) ? 1 : 0;
( $ok, $year, $month, $day ); # return values
} # end sub check_date_str()
#=============================================================================
#= END OF FILE
===============================================================
--
| Hans-Georg Rist ZKRD, Zentrales Knochenmarkspender-Register
| Helmholtzstr. 10 Deutschland, gGmbH
| P.O.B. 4244 German National Registry of Bone Marrow Donors
| D-89032 Ulm http://www.zkrd.uni-ulm.de
| Phone: +49 731 95430-46, Fax: -50, email: hans-georg.rist@zkrd.de
------------------------------
Date: Sun, 18 Jan 1998 04:51:47 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: novice question: ranking array elements
Message-Id: <34C1EC99.87B203AF@5sigma.com>
Funny you should ask this. You can find it on p.247 of my book,
or, dispensing with the explanation:
@rank[sort {$x[$a] cmp $x[$b]} 0..$#x] = 0..$#x
(Originally due to Randal.)
-joseph
http://www.effectiveperl.com
Ralph Brands wrote:
>
> As a programming novice I've been stumped in trying to do this with perl.
> I'm formatting output from a statistical program and read each line of a
> file (each consisting of a series of numbers) into an array. I want to
> produce another array which ranks the members of the first array:
>
> @somelist = (24.2, 16, 58, 1, 245);
>
> would produce
>
> @rank_of_somelist = (3, 2, 4, 1, 5); ranking from lowest to highest
------------------------------
Date: 18 Jan 1998 09:17:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Parsing HTML tag parameters
Message-Id: <69shai$nig$2@client3.news.psi.net>
Ben Glazer (ben.glazer@mail.utexas.edu) wrote on 1600 September 1993 in
<URL: news:34c092cb.93214615@newshost.cc.utexas.edu>:
++ I have a problem which seems to me like it should be relatively
++ simple, but I've spent more time working on it than I care to admit.
++
++ All I want to do is split the parameter list of an HTML tag into an
++ array. So, for example, starting off with input of
++
++ <img src="pish.gif" alt="hello kitty" width=100>
++
++ my program sets
++
++ $params = "src=\"pish.gif\" alt=\"hello kitty\" width=100";
++
++ which is all well and good. Now all I want to do is find some way to
++ set
++
++ @params = (
++ "src=\"pish.gif\",
++ "alt=\"hello kitty\",
++ "width=100")
++
++ Working from that point is easy. Any suggestions?
use CGI;
It comes with Perl.
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: Sun, 18 Jan 1998 10:48:00 GMT
From: nobody@nowhere
Subject: Re: Parsing HTML tag parameters
Message-Id: <34c1dc8b.0@news.tsoft.net>
In article <69shai$nig$2@client3.news.psi.net>, abigail@fnx.com wrote:
>Ben Glazer (ben.glazer@mail.utexas.edu) wrote on 1600 September 1993 in
><URL: news:34c092cb.93214615@newshost.cc.utexas.edu>:
>++ I have a problem which seems to me like it should be relatively
>++ simple, but I've spent more time working on it than I care to admit.
>++
>++ All I want to do is split the parameter list of an HTML tag into an
>++ array. So, for example, starting off with input of
>++
>++ <img src="pish.gif" alt="hello kitty" width=100>
>++
>++ my program sets
>++
>++ $params = "src=\"pish.gif\" alt=\"hello kitty\" width=100";
>++
>++ which is all well and good. Now all I want to do is find some way to
>++ set
>++
>++ @params = (
>++ "src=\"pish.gif\",
>++ "alt=\"hello kitty\",
>++ "width=100")
>++
>++ Working from that point is easy. Any suggestions?
>
>
>use CGI;
>
>
>It comes with Perl.
>
>
>Abigail
These aren't really CGI parameters though -- they're HTML tag parameters.
I'm not too familiar with the CGI module; maybe you can still use its
functions for this.
However, it's good fun to learn how to do this manually in perl.
Try this:
@params = split(/\s+/, $params);
And then you can create a hash %params like so:
foreach (@params) { $k, $v = split('='); $params{$k} = $v; }
Or here's a better way:
%params = map(split('='), @params);
Or, if you don't need the @array, you can & go straight from $string to %hash
in one fell swoop. (Well, you're still making the @array, you're just not
naming it...)
%params = map(split('='), split(/\s+/, $params))
Now, if you want, you can set variables in your program to correspond w/ these
name/value pairs:
foreach ('src', 'alt', 'width', 'height') { ${$_} = $params{$_} };
For security reasons, I wouldn't do this with foreach (keys %params). Use a
predefined list of parameters so you know what variables you're setting.
That should be enough to get you started.
If you really want to make variables out of a list of unknown parameters, I
think there's a function in the CGI module that puts makes variables out of
the parameters & puts them into another namespace. Check out the
documentation. I assume you could do the same with something like:
foreach (keys %params) { ${"Params::$_"} = $params{$_} };
but I haven't tried that one so & i'm not sure if it works or what security
implications it may have. I'm sure the CGI module version is probably secure
though, check its documentation from www.perl.com. In any case I don't see
how it offers much of an advantage or much convenience over using the hash.
Hope this helps,
Nick Callerame
ncallerame@looksmart.com
------------------------------
Date: 18 Jan 1998 12:07:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Parsing HTML tag parameters
Message-Id: <69srae$qv0$1@client3.news.psi.net>
nobody@nowhere (nobody@nowhere) wrote on 1601 September 1993 in
<URL: news:34c1dc8b.0@news.tsoft.net>:
++ In article <69shai$nig$2@client3.news.psi.net>, abigail@fnx.com wrote:
++ >Ben Glazer (ben.glazer@mail.utexas.edu) wrote on 1600 September 1993 in
++ ><URL: news:34c092cb.93214615@newshost.cc.utexas.edu>:
++ >++ I have a problem which seems to me like it should be relatively
++ >++ simple, but I've spent more time working on it than I care to admit.
++ >++
++ >++ All I want to do is split the parameter list of an HTML tag into an
++ >++ array. So, for example, starting off with input of
++ >++
++ >++ <img src="pish.gif" alt="hello kitty" width=100>
++ >++
++ >++ my program sets
++ >++
++ >++ $params = "src=\"pish.gif\" alt=\"hello kitty\" width=100";
++ >++
++ >++ which is all well and good. Now all I want to do is find some way to
++ >++ set
++ >++
++ >++ @params = (
++ >++ "src=\"pish.gif\",
++ >++ "alt=\"hello kitty\",
++ >++ "width=100")
++ >++
++ >++ Working from that point is easy. Any suggestions?
++ >
++ >
++ >use CGI;
++ >
++ >
++ >It comes with Perl.
++ >
++ >
++ >Abigail
++
++ These aren't really CGI parameters though -- they're HTML tag parameters.
++ I'm not too familiar with the CGI module; maybe you can still use its
++ functions for this.
Oh, ok.
use HTML::Parser;
>From CPAN.
++
++ However, it's good fun to learn how to do this manually in perl.
++
++ Try this:
++ @params = split(/\s+/, $params);
Which doesn't work as there is a space in 'hello kitty'. Besides,
there might be whitespace before or after the =. And there doesn't
have to be whitespace after a trailing " and the next attribute.
++ And then you can create a hash %params like so:
++ foreach (@params) { $k, $v = split('='); $params{$k} = $v; }
What if there is no =? What if there are more? What about the quotes?
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: Sun, 18 Jan 1998 04:56:06 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Perl dies with segmentation fault and leaves a core
Message-Id: <34C1ED9B.187F14F3@5sigma.com>
Perl should not crash. With few exceptions this is a perl bug.
You should post code and/or submit the bug with the perlbug program.
-joseph
http://www.effectiveperl.com
Bob wrote:
>
> Is there anything that a user script can do to cause a Segmentation
> fault and core dump, or is it a perl bug?
------------------------------
Date: Sun, 18 Jan 1998 04:37:13 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: perl module question
Message-Id: <34C1E92E.43784F91@5sigma.com>
I'm not much for the knee-jerk "use -w, dammit" but
in this case ....
-joseph
Tad McClellan wrote:
>
> Justin Lee (jlee@sandiegoca.ncr.com) wrote:
> : @Manipulate_Tree::EXPORT = qw(Dump_Tree,Recover_Tree,Print_Tree);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> Export one (pretty long) symbol. I expect you were trying to
> export three symbols?
------------------------------
Date: Sun, 18 Jan 1998 04:39:32 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: qc(foo,bar,bletch) [Re: perl module question]
Message-Id: <34C1E9BA.AB0B078C@5sigma.com>
Y'know, if there were a qc(stuff,morestuff) that worked like
split /\s*,\s*/, that would be handy.
-joseph
Charles DeRykus wrote:
> > @Manipulate_Tree::EXPORT = qw(Dump_Tree,Recover_Tree,Print_Tree);
> >
> ^ ^
> replace the commas with spaces
------------------------------
Date: 18 Jan 1998 08:02:30 GMT
From: Lou Poppler <lwp@flenser.att.net>
Subject: Re: Socket ?
Message-Id: <69scum$ag2@bgtnsc01.worldnet.att.net>
This seems to work fine on my BSDI 2.1 box, with perl 5.001.
The only suggestion I see is that maybe you should not be using PF_INET
in the socket() call. The docs say that that parameter is an AF_xxx
parameter, not a PF_xxx parameter. (However, in my BSDI 2.1 anyway,
PF_INET is the same as AF_INET).
Here is my little test program (slightly embellished version of the code
you posted) and the results:
<lwp@conch> cat test.pl
#!/usr/bin/perl5
use Socket;
print STDOUT PF_INET, " ", AF_INET, "\n";
$server = 'conch.msen.com';
$protocol = getprotobyname('tcp');
socket(SOCKET,PF_INET,SOCK_STREAM,$protocol) || die "$!\n";
$remote_ip = gethostbyname($server);
$remote_sock = pack('Sna4x8', AF_INET, 110, $remote_ip);
unless(connect(SOCKET, $remote_sock))
{
OutputError("Could not connect to server \n $!");
}
<lwp@conch> test.pl
2 2
<lwp@conch> uname -a
BSD/OS conch.msen.com 2.1 BSDI BSD/OS 2.1 Kernel #0: Fri Jan 16 18:51:12 EST 1998 wayne@ww2.msen.com:/msen/sys/compile/CONCH.gated i386
<lwp@conch> /usr/bin/perl5 -v
This is perl, version 5.001
Unofficial patchlevel 1m.
+ suidperl security patch
Copyright 1987-1994, Larry Wall
On Fri, 02 Jan 1998 19:04:43 -0600, Eddie Dodwell <eddied@wwisp.com> wrote:
: I am hoping someone can tell me why this code is returning the error:
: Could not connect to server
: Address family not supported by protocol family
: here is the snippett:
: #!/usr/bin/perl5
: use Socket;
: [
: code
: ]
: # Open a socket to the POP3 server.
: $protocol = getprotobyname('tcp');
: socket(SOCKET,PF_INET,SOCK_STREAM,$protocol);
: $remote_ip = gethostbyname($server);
: $remote_sock = pack('Sna4x8', AF_INET, 110, $remote_ip);
: unless(connect(SOCKET, $remote_sock))
: {
: OutputError("Could not connect to server \n $!");
: }
: perl version is 5.001
: OS is BSDI 3.1
: The /etc/protocols is there and the proper protocol number is returned
: as well as the IP address of the machine we are trying to reach.
: Any other info I need to include, let me know.
: Eddie
------------------------------
Date: Sun, 18 Jan 1998 04:23:16 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Sort question
Message-Id: <34C1E5EA.A4B9D26@5sigma.com>
I assure you, the answer can be found in perlfaq, in perlfunc,
on my web site (see "Idiomatic Perl"), and in several articles
on www.perl.com.
-joseph
http://www.effectiveperl.com
print map { "$_->[0]: $_->[1]\n" } sort { $b->[1] <=> $a->[1] or $a->[0] cmp
$b->[0] } map { [ split ] } <DATA>;
__END__
http://www.foo.com/bar 123
http://www.foo.com/bletch 234
http://www.foo.com/baz 321
http://www.foo.com/xyzzy 543
http://www.foo.com/plugh 321
http://www.foo.com/plover 456
Andrew Spiers wrote:
>
> PLEASE HELP ME. I AM GOING MAD !!!!
>
> I have two fields : one contains a URL and the other contains the number
> of hits on this URL. I want to sort them so that the most visited
> appears at the top. Sounds simple but I cant get it to work. I have
> tried looking in the usual places, FAQs etc, but I just cant seem to get
> it to work.
>
> Many thanks,
>
> Andrew Spiers
>
> P.s. If you ever come to West London I will buy you a beer ! Promise !!
------------------------------
Date: Sun, 18 Jan 1998 02:28:44 -0500
From: Dan Boorstein <danboo@negia.net>
Subject: Re: source into binary code
Message-Id: <34C1AF2C.3D4B2653@negia.net>
brian d foy wrote:
>
> In article <34BE2AFA.E94BF263@ixl.com>, Dan Boorstein <dboorstein@ixl.com> posted:
>
> >Tom Christiansen wrote:
> >> Compiling produces no security.
>
> >taken from the merriam webster dictionary:
> >
> >security - "measures taken to guard against espionage or sabotage,
> >crime, attack, or escape"
> >
> >obscure - "not readily understood or clearly expressed"
> >
> >i'm not submitting that compiling is good security, only that it is
> >security. based on this definition, or one from your favorite
> >dictionary, do you agree or disagree with tom c's original statement?
>
> *heh* forget about the dictionary. your enemy is a hacker - a person
> with seemingly unlimited curiousity, unending devotion to the task
> at hand, and a master of technical trivia. "not clearly expressed"
> and "not readily understood" are big flashing signs saying "k3\/\/1
> probl3m ah3ad".
FORGET THE DICTIONARY? am i really reading this?
sdfj fjksldjf jkdls jfkdls jfkdlsjfkl.
o.k. i remeber it again. i tried forgetting it, but a common point
of reference which defines words and their meanings, is simply too
important to a text based discussion. if you choose to ignore it
that is your own business, but i will have no choice but to disregard
further posts from you.
>
> if this person also knows the innards of perl, or decides to
> learn it, and cracks your pseudo hidden code, he's going to brag
> about it all over the place. he's going to take great pains
> to ensure that others know he did something k3wl.
>
> >second, the blanket statements that have followed concerning poorness
> >of security through obscurity i believe to be in error as well. isn't
> >key based cryptography security through obscurity?
>
> the algorithms for useful encryption schemes are well known. they
> rely on the fact that a brute force approach is either infeasible
> or resourcefully impossible even when the attacker knows how they
> work.
brute force attacks are neither infeasible nor resourcefully impossible.
in a matter of minutes i could have the passwords from many users on
our local system. and don't forget the recent attacks on rsa encryption.
>
> perhaps it's time that you did a bit of reading before you debate
> any further.
> Applied Cryptography is a nice book with which to start. or the
> phone book under "Attorney - Intellectual Property"
well, i would read it but i have forgotten the dictionary. sorry.
dan
------------------------------
Date: 18 Jan 1998 09:11:21 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: source into binary code
Message-Id: <69sgvp$nig$1@client3.news.psi.net>
Dan Boorstein (danboo@negia.net) wrote on 1601 September 1993 in
<URL: news:34C1AB37.2F7675C0@negia.net>:
++ Abigail wrote:
++ >
++ > Rubbish. If they want to "steal" your code, and there is an easier
++ > alternative available, they won't use your code at all.
++
++ am i reading this correctly? if they want to steal my code and there
++ is an easier alternative which they take then my security has been
++ successful, hasn't it? they have been thwarted.
Right. So, you are sitting there with your precious code, and
noone buys/uses it. There are easier ways then encrypting to
archieve that.
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: 14 Jan 98 16:33:01 GMT
From: odie@algonet.se.REMOVE (Odie Deth)
Subject: Re: Substituting characters
Message-Id: <34bce7d2.19372058@news.algonet.se>
On 13 Jan 1998 19:13:00 GMT, hymie@lactose.smart.net (hymie!) wrote:
Thank you very much! The \ was the goal of my quest!
And my problems with the <'s was due to something completely
different, and is solved.
---
Odie Deth - odie@algonet.se - http://www.algonet.se/~odie
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1665
**************************************