[13679] in Perl-Users-Digest
Perl-Users Digest, Issue: 1089 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 20:05:35 1999
Date: Fri, 15 Oct 1999 17:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940032309-v9-i1089@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 15 Oct 1999 Volume: 9 Number: 1089
Today's topics:
Re: "Proper" way to load a file <aqumsieh@matrox.com>
Re: "Protecting" Perl source code <uri@sysarch.com>
ADO using AddNew from Perl <dochood@earthlink.net>
and versus && (R. McGillis)
Re: Can a perl script output image? (Abigail)
Re: CSS / NETSCAPE -> Through PERL <marc@i-way.de>
Re: encryption <rootbeer@redcat.com>
Re: Gettin Path except last dir <rootbeer@redcat.com>
Re: getting variables embeded in string to be evaluated <rootbeer@redcat.com>
Re: getting variables embeded in string to be evaluated <skilchen@swissonline.ch>
Re: getting variables embeded in string to be evaluated <marcel.grunauer@lovely.net>
Re: Grabbing image size? <rootbeer@redcat.com>
Re: Help with extracting a portion of a string <marcel.grunauer@lovely.net>
Help with s///ego <scott_beck@my-deja.com>
Re: Help with s///ego <rootbeer@redcat.com>
Re: Help with s///ego (Craig Berry)
Re: Memory and modules <dwb1@home.com>
Need a next/previous routine for a Web CGI script (Will Harmon)
Re: Perl Programmer Wanted (Mark Badolato)
Re: Perl Programmer Wanted <marcel.grunauer@lovely.net>
Re: Perl Programmer Wanted (Gordon)
Re: Random string (Larry Rosler)
Re: Random string (Abigail)
Re: rasterizing text script? <rootbeer@redcat.com>
Re: strict, -wT problems <dwoods@ucalgary.ca>
Re: tr// question <marcel.grunauer@lovely.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Oct 1999 17:25:11 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: "Proper" way to load a file
Message-Id: <x3yzoxk5nbc.fsf@tigre.matrox.com>
Paul D <pdobbs@home.com> writes:
> I'm a bit fresh to Perl myself, so others will correct me if I'm wrong.
Here we go.
> open (FILE, "<$File") || die("I just can't do it cap'n! $!");
> while(<FILE>)
> {contents = $contents . $_ ;}
$countents .= $_;
is better and faster. There are still better ways to read the whole
file into a scalar.
> close (FILE);
>
> The $_ as you probably know is the default variable for input. From your
> stuff below, it seems to me you just want to tie all the lines inside
> the
> file into one variable.
[snip]
That is not the idea I got from his post. Let's see.
> Jordan Hiller wrote:
> > I need to load the contents of an entire local file into a scalar. This
> > is the way I've been doing, it, but I vaguely remember reading somewhere
> > that this way is inefficient, dangerous, or in some way "bad." Can
> > someone suggest a better way?
It all depends on what you want to do. It's dangerous because if
you're file is really big, then your program will consume a lot of
memory by loading the whole file. This might not be a problem if your
file is not so large, or if you have a lot of RAM and just don't care
(RAM is so cheap nowadays :-)
> > open(FILE, "<filename.txt") || die("Can't open filename.txt: $!");
> > @lines = <FILE>; # This is the part that I think is bad
> > $contents = join('', @lines);
> > close(FILE);
I don't think you can do any worse :)
You are reading the whole file into an array, then joining the array
with the empty string into a scalar. Why not simply:
my $contents;
{
local @ARGV = 'filename.txt';
local $/;
$contents = <>;
}
If you want to process your file line by line, then why not read
one-line at a time?
while (<FILE>) {
# process line in $_
}
Or maybe you can save only the lines that you want and discard some
lines that aren't necessary:
while (<FILE>) {
if ($_ == $I_Want_This_Line) {
$contents .= $_;
}
}
Conclusion, it all depends on what you want to do.
HTH,
--Ala
------------------------------
Date: 15 Oct 1999 19:21:26 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: "Protecting" Perl source code
Message-Id: <x7ln94gqh5.fsf@home.sysarch.com>
>>>>> "m" == mattandap1 <mattandap1@my-deja.com> writes:
m> --- Of course, I haven't met many people
m> who've tried my final strategy and got
m> away with it. I did embed the entire
m> transcript of the Vader/Skywalker duel in
m> "The Empire Strikes back" into a C Routine
m> once, but that's another story ...
did it run? how efficient was it? who was the father of the code? how
much force did you use writing it?
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 15 Oct 1999 18:55:36 -0500
From: "Daniel 'Doc' Sewell" <dochood@earthlink.net>
Subject: ADO using AddNew from Perl
Message-Id: <7u8e9o$gam$1@holly.prod.itd.earthlink.net>
Hello, All!
I've been trying (very unsuccessfully) to get a Perl Script to update an
Access 97 database using ADO and the AddNew method. I need to use AddNew
because Access 97 assigns a unique ID to the row, which I immediately need
to grab. My examples using an INSERT sql statement worked okay, but since
I'm not inserting any data guaranteed to be unique, I can't lookup the ID
subsequently.
The error I keep getting is when I do an Open on the recordset:
#use Win32::ADO;
#
# Database connectivity variables
#
my $conn;
my $rs;
my $sql;
$conn = CreateObject OLE "ADODB.Connection" ||
die "CreateObject : $!";
$conn->Open('SaleDB'); # DB is a System DSN... works when I do query on same
DB
$rs = CreateObject OLE "ADODB.RecordSet" || die "Creating Recordset $!";
#dies on the next line... Customers is the table in the SaleDB database
$rs->Open("Customers", $conn, adOpenKeyset, adLockOptimistic, adCmdTable) ||
die "Opening Recordset $!";
$rs->AddNew;
$rs->fields("EMail")->{value} = $EMail_Address;
$rs->Update;
$rs->Close;
$conn->Close;
I'd appreciate any help anyone can give.
Thanks,
Daniel "Doc" Sewell
dochood at earthlink dot net
P.S. I've looked at about all of the examples on the Internet that I could
find, and none of them were helpful.
------------------------------
Date: Fri, 15 Oct 1999 16:58:24 -0700
From: rmcgilli@popmail.ucsd.edu (R. McGillis)
Subject: and versus &&
Message-Id: <rmcgilli-1510991658240001@cul89-158.ucsd.edu>
I was taught that "and" is just a short cut for "&&" to improve
readability, but otherwise interchangable. A colleague of mine just told
me that there is a subtle difference, but could not remember what it was.
What's the scoop? Is there any difference between them in how they work?
Thanks.
-R.M.
------------------------------
Date: 15 Oct 1999 18:04:38 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Can a perl script output image?
Message-Id: <slrn80fcnh.q8s.abigail@alexandra.delanet.com>
marias@total.net (marias@total.net) wrote on MMCCXXXVI September MCMXCIII
in <URL:news:38078309.705077758@news.total.net>:
?? This might be more complicated than you wanted, but this month's Linux
?? Journal (Oct. '99) has an easy to read and understandable article on
?? creating GIFs on the fly with perl from a relational database.
?? Apparently last months' also looked at GIFgraph which are Perl modules
?? to do so.
And the summer issue of TPJ had an article from Lincoln Stein about
the use of gnuplot. Based on that article, I wrote a program to graph
out information, which came out of Sybase database. (Populating the
tables was done by another program).
It won't run on anyone else system as it was written to do just what
I wanted at the moment, and it uses some special modules as well.
It takes a few shortcuts here and there, and there aren't many comments,
but I've included the code anyway.
It ran (or maybe still runs) once per minute, 24h/day.
#!/nfs1/local/bin/perl -w
use lib qw {/home/abigail/Perl /home/abigail/Sybase};
use strict;
use Getopt::Long;
use Sybase;
use Servers;
$ENV {SYBASE} ||= $SYBASE;
sub adjust_date ($);
my $PLOT = '/nfs1/local/bin/gnuplot';
my $BIN = '/usr/local/bin';
GetOptions ("server=s" => \my $server_name,
"date=s" => \my $date,
"title=s" => \my $title,
"terminal=s" => \my $terminal,
"background=s" => \my $col_background,
"borders=s" => \my $col_borders,
"axes=s" => \my $col_axes,
"col_users=s" => \my $col_users,
"col_cpu=s" => \my $col_cpu,
"col_busy=s" => \my $col_busy,
"col_io=s" => \my $col_io,
"col_down=s" => \my $col_down,
"col_read=s" => \my $col_read,
"col_write=s" => \my $col_write,
"col_errors=s" => \my $col_errors,
"col_load=s" => \my $col_load,
"output=s" => \my $output
);
my $alex_server = query_server ("alexandra") or die "Didn't find alexandra!\n";
my $alexandra = Sybase -> new (server => $alex_server -> {name},
user => $alex_server -> {user},
password => $alex_server -> {password},
database => 'logging')
or die "Couldn't connect to alexandra!\n";
my $server = query_server ($server_name)
or die "Didn't find $server_name!\n";
unless ($date) {
$date = localtime;
$date =~ s/\w+\s+(\w+)\s+(\d+)\s+[\d:]+\s+(\d+)/$1 $2 $3/;
}
my $DATE = $date;
my $SERVER = $server -> {name};
my $MAX_USERS = $server -> {max_user_connections};
my $ENGINES = $server -> {engines};
my $MAXCPU = $ENGINES * 100;
my $TITLE = defined $title ? $title : "$DATE: $SERVER";
my $MAXERRORS = $server -> {max_errors} || 2;
my $MAXDISKS = $server -> {max_disk_io};
my $CPUS = $server -> {cpus};
# Figure out the terminal setting.
my $TERMINAL = "";
if (defined $terminal) {
unless (lc $terminal eq 'gif') {
die "Terminal type $terminal not supported\n";
}
$col_background ||= 'xffffff';
$col_borders ||= 'x000000';
$col_axes ||= 'x404040';
$col_cpu ||= 'x0055ff';
$col_users ||= 'xff0000';
$col_down ||= 'xcdb5cd';
$col_io ||= 'x009900';
$col_busy ||= 'xffaa44';
$col_read ||= 'x00ff00';
$col_write ||= 'xffaa00';
$col_errors ||= 'xff0000';
$col_load ||= 'xffff88';
$TERMINAL = "set terminal gif size 640, 480 " .
" $col_background $col_borders $col_axes " .
" $col_cpu $col_users $col_down";
}
my $OUTPUT = "";
my $OPTIONS = "";
if (defined $output) {$OUTPUT = qq {set output "$output.$$.1"}}
else {$OPTIONS = "-persist"}
my @users = $alexandra -> do_command (command => qq {
select ts, connections, up
from user_connections, server_names
where server_names.server_name = '$SERVER' and
user_connections.server_id =
server_names.server_id and
user_connections.ts >= '$DATE 00:00:00' and
user_connections.ts <= '$DATE 23:59:59'
order by ts
});
my @cpu = $alexandra -> do_command (command => qq {
select ts, busy, io, machine_load
from cpu_usage, server_names
where server_names.server_name = '$SERVER' and
cpu_usage.server_id =
server_names.server_id and
cpu_usage.ts >= '$DATE 00:00:00' and
cpu_usage.ts <= '$DATE 23:59:59'
});
my @disks = $alexandra -> do_command (command => qq {
select ts, io_read, io_write, io_errors, up
from disk_usage, server_names
where server_names.server_name = '$SERVER' and
disk_usage.server_id =
server_names.server_id and
disk_usage.ts >= '$DATE 00:00:00' and
disk_usage.ts <= '$DATE 23:59:59'
});
foreach my $point (@users) {$point -> [0] = adjust_date $point -> [0];
$point -> [2] = (1 - $point -> [2]) * $MAX_USERS;}
foreach my $point (@cpu) {$point -> [0] = adjust_date $point -> [0];
$point -> [3] ||= 0;
$point -> [3] *= $MAXCPU / $CPUS;
$point -> [4] = ($point -> [1] + $point -> [2]) *
$MAX_USERS / $MAXCPU;}
foreach my $point (@disks) {$point -> [0] = adjust_date $point -> [0];
$point -> [3] *= $MAXDISKS / $MAXERRORS;
$point -> [4] = (1 - $point -> [4]) * $MAXDISKS;
for my $i (1 .. 4) {
$point -> [$i] = 1 if $point -> [$i] < 1;}}
open (PLOT, "| $PLOT $OPTIONS") or die "Failed to open $PLOT: $!\n";
print PLOT <<EOT;
$TERMINAL
$OUTPUT
set title "$TITLE"
set data style boxes
set xdata time
set format x "%R"
set format y "%5g"
set ylabel "Users"
set ytics border nomirror norotate
set y2label "CPU"
set y2range [0:$MAXCPU]
set y2tics border nomirror norotate
set grid xtics ytics
set timefmt "%b %d %Y %H:%M:%S"
plot ["$DATE 00:00:00":"$DATE 23:59:59"] [0:$MAX_USERS] \\
'-' using 1:8 smooth unique title "cpu", \\
'-' using 1:5 smooth unique title "users", \\
'-' using 1:6 title "down"
@{[map {"@$_\n"} @cpu]}
e
@{[map {"@$_\n"} @users]}
e
@{[map {"@$_\n"} @users]}
e
EOT
close PLOT or die "Failed to close $PLOT: $!";
if ($terminal eq 'gif') {
my $output2;
if (defined $output) {
$output2 = "$output.$$.2";
$OUTPUT =~ s/\.1"/.2"/;
}
$TERMINAL = "set terminal gif size 640, 240 " .
" $col_background $col_borders $col_axes " .
" $col_load $col_io $col_busy $col_down";
open (PLOT, "| $PLOT $OPTIONS") or die "Failed to open $PLOT: $!\n";
print PLOT <<EOT;
$TERMINAL
$OUTPUT
set data style boxes
set xdata time
set format x "%R"
set format y "%5g"
set ylabel "CPU"
set ytics border nomirror norotate
set y2label "Load"
set y2range [0:$CPUS]
set y2tics border nomirror norotate
set grid xtics ytics
set timefmt "%b %d %Y %H:%M:%S"
plot ["$DATE 00:00:00":"$DATE 23:59:59"] [0:$MAXCPU] \\
'-' using 1:7 title "load", \\
'-' using 1:6 smooth unique title "cpu/io", \\
'-' using 1:5 smooth unique title "cpu/busy", \\
'-' using 1:6 title "down"
@{[map {"@$_\n"} @cpu]}
e
@{[map {"@$_\n"} @cpu]}
e
@{[map {"@$_\n"} @cpu]}
e
@{[map {"@$_\n"} @users]}
e
EOT
close PLOT or die "Failed to close $PLOT: $!";
my $output3;
if (defined $output) {
$output3 = "$output.$$.2";
$OUTPUT =~ s/\.2"/.3"/;
}
$TERMINAL = "set terminal gif size 640, 240 " .
" $col_background $col_borders $col_axes " .
" $col_read $col_write $col_errors $col_down";
open (PLOT, "| $PLOT $OPTIONS") or die "Failed to open $PLOT: $!\n";
print PLOT <<EOT;
$TERMINAL
$OUTPUT
set logscale y
set data style boxes
set xdata time
set format x "%R"
set format y "%5g"
set ylabel "Disk usage"
set ytics border nomirror norotate
set y2label "Disk Errors"
set y2range [0:$MAXERRORS]
set y2tics border nomirror norotate
set grid xtics ytics
set timefmt "%b %d %Y %H:%M:%S"
plot ["$DATE 00:00:00":"$DATE 23:59:59"] [1:$MAXDISKS] \\
'-' using 1:5 smooth unique title "disk/read", \\
'-' using 1:6 smooth unique title "disk/write", \\
'-' using 1:7 title "disk/errors", \\
'-' using 1:8 title "down"
@{[map {"@$_\n"} @disks]}
e
@{[map {"@$_\n"} @disks]}
e
@{[map {"@$_\n"} @disks]}
e
@{[map {"@$_\n"} @disks]}
e
EOT
close PLOT or die "Failed to close $PLOT: $!";
if (defined $output) {
system "$BIN/giftopnm $output.$$.1 > $output.$$.1.pnm";
system "$BIN/giftopnm $output.$$.2 > $output.$$.2.pnm";
system "$BIN/giftopnm $output.$$.3 > $output.$$.3.pnm";
system "$BIN/pnmcat -topbottom $output.$$.1.pnm $output.$$.2.pnm " .
"$output.$$.3.pnm | $BIN/ppmtogif > $output.$$.1 2> /dev/null";
unlink ("$output.$$.1.pnm", "$output.$$.2.pnm", "$output.$$.3.pnm") == 3
or die "Failed to delete pnm files: $!\n";
unlink "$output.$$.2" or die "Failed to delete $output.$$.2: $!\n";
unlink "$output.$$.3" or die "Failed to delete $output.$$.3: $!\n";
}
}
if (defined $output) {
rename "$output.$$.1", $output or die "Failed to rename $output.$$: $!\n";
chmod 0644, $output or die "Failed to chmod $output: $!\n";
}
sub adjust_date ($) {
local $_ = shift;
s/ ?(\d+):(\d+):(\d+):\d+([AP]M)/
sprintf " %02d:%02d:%02d", ($4 eq 'PM' && $1 != 12 ? $1 + 12 :
$4 eq 'AM' && $1 == 12 ? $1 - 12 : $1),
$2, $3/e;
$_
}
__END__
--
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sat, 16 Oct 1999 00:22:51 +0100
From: "Marc Piwecki" <marc@i-way.de>
Subject: Re: CSS / NETSCAPE -> Through PERL
Message-Id: <7u8gt8$414$1@baghira.regio.net>
Check the output of your perl script - maybe you lost some closing tag which
does not take any effect in ie but in ns.
good luck
marc
RLD schrieb in Nachricht <7u86mv$313$1@fir.prod.itd.earthlink.net>...
>Ran across a strange problem that maybe someone can give me some direction
>with...
>
>Created a template file that uses CSS and JavaScript. The layers are
tables
>that are displayed depending on what button is clicked. The template works
>fine when loaded in both Netscape and IE. However... when I run my Perl
>script which opens the template and then displays it... only IE displays it
>correctly with full functionality. Netscape on the other hand just sits
>there, the calls to the JavaScript ing... seems to produce no output... it
>is not hiding the tables and making visible the one chosen.
>
>Is there something in the headers possibly that is not going over well with
>Netscape? I've used JavaScript in this manner before, but never with CSS
>... could there be a problem with styles not loading correctly when the
>output comes through a Perl script? I'm stumped.
>
>Please help,
>Randall
>
>
>
------------------------------
Date: Fri, 15 Oct 1999 16:02:11 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: encryption
Message-Id: <Pine.GSO.4.10.9910151601490.25558-100000@user2.teleport.com>
On Fri, 15 Oct 1999, Mike Heller wrote:
> Does anyone know of any good encryption
> routines for perl (or possibly where I can find one)?
If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-) Hope this helps!
http://www.cpan.org/
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 15 Oct 1999 15:17:01 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Gettin Path except last dir
Message-Id: <Pine.GSO.4.10.9910151508560.25558-100000@user2.teleport.com>
On Fri, 15 Oct 1999, A Zielke wrote:
> How about a
>
> my ( $ShortenedPath ) = ( $LongPath =~ /(.*)\\.+/ );
Because it doesn't work reliably. Remember that dot doesn't match newlines
by default, and a directory name could (possibly) contain a newline. Also,
what about files in the current directory? Also, why be non-portable?
Also, why reinvent the wheel?
use File::Basename;
Also, cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 15 Oct 1999 15:18:31 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: getting variables embeded in string to be evaluated
Message-Id: <Pine.GSO.4.10.9910151517330.25558-100000@user2.teleport.com>
On Fri, 15 Oct 1999, Bill wrote:
> Subject: getting variables embeded in string to be evaluated
See "How can I expand variables in text strings?" in section four of the
FAQ. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 15 Oct 1999 23:40:23 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: getting variables embeded in string to be evaluated
Message-Id: <HXON3.24864$m4.90055650@news.magma.ca>
Bill <wlanahan@att.com> wrote in:
news:380789e8.261577574@news.netnews.att.com...
>
> $_="hello YYY world\n";
> s/YYY/\$ref\{CC\}/;
> $arr[0] = "$_";
> $ref{CC} = "there";
> print $arr[0];
> print "$arr[0]";
>
print eval qq("$arr[0]");
But keep in mind that eval is evil.
------------------------------
Date: Fri, 15 Oct 1999 23:43:41 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: getting variables embeded in string to be evaluated
Message-Id: <ickHOHxkqNfOdJPW5D844wwlxWar@4ax.com>
On Fri, 15 Oct 1999 23:40:23 GMT, "Samuel Kilchenmann"
<skilchen@swissonline.ch> wrote:
> Bill <wlanahan@att.com> wrote in:
> news:380789e8.261577574@news.netnews.att.com...
> >
> > $_="hello YYY world\n";
> > s/YYY/\$ref\{CC\}/;
> > $arr[0] = "$_";
> > $ref{CC} = "there";
> > print $arr[0];
> > print "$arr[0]";
> >
> print eval qq("$arr[0]");
That's *two* levels of quoting too much.
print eval $arr[0]
would suffice.
However, there's absolutely no need to use eval in this case. This
smells of symbolic references. And when you smell that, remember
hashes.
--
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
------------------------------
Date: Fri, 15 Oct 1999 15:20:16 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Grabbing image size?
Message-Id: <Pine.GSO.4.10.9910151519560.25558-100000@user2.teleport.com>
On Fri, 15 Oct 1999 fharris@xmission.com wrote:
> I'm interested in being able to grab the image dimensions from a .GIF
> or .JPG picture using Perl. Anyone know how to do this?
If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-) Hope this helps!
http://www.cpan.org/
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 15 Oct 1999 22:17:38 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: Help with extracting a portion of a string
Message-Id: <e7UHOBnCdHagj=5tHKTv+BSCtTBn@4ax.com>
On Fri, 15 Oct 1999 07:11:39 GMT, Brandon <pooka@cygnus.ucdavis.edu>
wrote:
> My example was minimalistic, and matched exactly the original posters
> example. All the comment anomolies are easily corrected _without_ having
> to use parsing modules. And just to be fair to Abigail, I wasn't calling
> her code crap; it was more of a generic term for quoted text that wastes
> space. So lookit, if you want to use parsers, use parsers. There are
> other, easier ways to do it, and that's all I intended to say from the
> beginning. Forgive me for daring to challenge the word of your queen.
Cool. Insulting Abigail *and* uri within the same thread, over
something you don't even know enough about to argue in technical
terms. And then you don't even have the guts to stand by what you
said.
> I think I'll have my nice day right here, thanks.
Yes, but not on my time.
*plonk*
--
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
------------------------------
Date: Fri, 15 Oct 1999 22:58:05 GMT
From: Scott Beck <scott_beck@my-deja.com>
Subject: Help with s///ego
Message-Id: <7u8bho$af8$1@nnrp1.deja.com>
Hello,
I am sending output to a script that will
only accept [a-zA-Z0-9' ] or it dies.
The input to my script comes from the outside
world so I need to filter it less my script
crashes.
I want to be able to put the characters that I
filter out back in and in the same place after
I run them through this other script.
Here is a test I was running but can't get it
to work.
#!/usr/bin/perl -w
$|++;
$name ='How was your day there! 1000 I hate this.@!#$##$%%$$%$$@#$%%^&^%
$$';
print "$name\n";
$name =~ s/([01]+)/'$1'/g;
$name =~ s/([^a-zA-Z0-9' ]+)/unpack("B*",$1)/ego;
print "$name\n";
$name =~ s/[^']([01]+)+[^']/pack("B*",$1)/ego;
print "$name\n";
__DATA__
Here is the output
How was your day there! 1000 I hate this.@!#$##$%%$$%$$@#$%%^&^%$$
How was your day there00100001 '1000' I hate
this00101110010000000010000100100011001001000010001100100011001001000010
010100100101001001000010010000100101001001000010010001000000001000110010
01000010010100100101010111100010011001011110001001010010010000100100
How was your day ther!'' I hate thi.@!#$##$%%$$%$$@#$%%^&^%$$
Does some one have a different idea of how I can do this
Or maybe just an improvement on this?
--
Thanks
Scott Beck
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 15 Oct 1999 16:51:44 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Help with s///ego
Message-Id: <Pine.GSO.4.10.9910151644550.25558-100000@user2.teleport.com>
On Fri, 15 Oct 1999, Scott Beck wrote:
> I am sending output to a script that will
> only accept [a-zA-Z0-9' ] or it dies.
I hope that I'm correct in assuming that you mean the (badly-written?)
script will die if you give it any characters other than letters A-Z and
a-z, digits, apostrophes, and spaces.
> I want to be able to put the characters that I
> filter out back in and in the same place after
> I run them through this other script.
What do you mean by "the same place"? Do you mean that this other
(anonymous?) script will output a string the same length as its input, so
that you could re-insert the characters you've previously removed?
I wonder whether it wouldn't be simpler to simply fix the other program.
> #!/usr/bin/perl -w
> $|++;
>
> $name ='How was your day there! 1000 I hate this.@!#$##$%%$$%$$@#$%%^&^%
> $$';
> print "$name\n";
> $name =~ s/([01]+)/'$1'/g;
What are you trying to do with that line of code?
> $name =~ s/([^a-zA-Z0-9' ]+)/unpack("B*",$1)/ego;
What are you trying to do with that line of code?
> print "$name\n";
>
> $name =~ s/[^']([01]+)+[^']/pack("B*",$1)/ego;
What are you trying to do with that line of code?
> print "$name\n";
>
> __DATA__
Do you know what the __DATA__ token does? Maybe you want __END__ instead.
Maybe you want to do some kind of encoding of the input (base 64,
perhaps)?
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 15 Oct 1999 23:58:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help with s///ego
Message-Id: <s0ffsclpr0182@corp.supernews.com>
Scott Beck (scott_beck@my-deja.com) wrote:
: I am sending output to a script that will
: only accept [a-zA-Z0-9' ] or it dies.
: The input to my script comes from the outside
: world so I need to filter it less my script
: crashes.
: I want to be able to put the characters that I
: filter out back in and in the same place after
: I run them through this other script.
Why not just make a copy of the scalar, make that
safe for the other script, then revert to using
the original in the remainder of the script?
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Fri, 15 Oct 1999 22:20:51 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: Re: Memory and modules
Message-Id: <Pine.LNX.4.10.9910151710500.3634-100000@cc569157-a.warn1.mi.home.com>
On 15 Oct 1999, Uri Guttman wrote:
> >>>>> "DWB" == Daniel W Burke <dwb1@home.com> writes:
>
> DWB> How are modules compiled into memory? Meaning, is perl able to
> DWB> determine that a module has already been compiled once, and not
> DWB> do it again?
>
> DWB> I.e.: Module1 uses Module2. The main script uses Module1 and
> DWB> Module2. Will Module2 get compiled twice, or just once?
>
> read perlvar. look for @INC and %INC.
> read perlfunc. look for require and use.
Thank you very much. They answered my question very thuroughly.
Dan.
------------------------------
Date: Fri, 15 Oct 1999 21:31:30 GMT
From: wharmon@oregon.uoregon.edu (Will Harmon)
Subject: Need a next/previous routine for a Web CGI script
Message-Id: <7u8deg$t3k$1@pith.uoregon.edu>
Hi,
I have a PERL CGI script about ready to go, but I am hoping to add the ability
to scroll through 10 or so items at a time depending on what my search routine
brings up. Wondering if anyone has a next/previous routine they would share,
an idea where to find an example, or a description on how it should be done.
Thanks,
Will
------------------------------
Date: 15 Oct 1999 22:11:44 GMT
From: mbadolato@quepasa.com (Mark Badolato)
Subject: Re: Perl Programmer Wanted
Message-Id: <36448.634365308EA6mbadolatoquepasacom@4.22.39.123>
On 15 Oct 1999, webmaster@aisinternet.hypermart.net (AIS) wrote in
<7u87mt$7va$1@nnrp1.deja.com>:
>A.I.S. is a start-up Internet Design Company,
Go figure... Sounds more like another "Hey, I read a HTML in 2 minutes book,
time to form a Web Design Company" compamy. That's just my opinion, YMMV.
>all members will be
>expected to work hard and put free time into the exposure and promotion
>of the company. Youll also be expected to do some free programming for
>the company web site.
>
Gee, couldn't have seen that one coming. I would think that if you are working
for a company, they would pay you for your time, regardless of where the final
code you write will end up. And shouldn't a company's marketing department take
care of the promotion, not the programmers?
>If you are interested in such a position please email
>jobs@aisinternet.hypermart.net
Wow, and a hypermart account to boot! Sounds like they're going all out.
--Mark
------------------------------
Date: Fri, 15 Oct 1999 22:47:47 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: Perl Programmer Wanted
Message-Id: <N7sHOIKG0=XG3KCQe4umoc70kdxG@4ax.com>
On Fri, 15 Oct 1999 21:52:35 GMT, AIS
<webmaster@aisinternet.hypermart.net> wrote:
> Perl Programmer Wanted
"I don't have a clue, so I'll just spam the nearest newsgroup."
> You must be willing to:
>
> 1) Provide work directly to clients.
"I don't have account handlers so the programmers gotta talk to the
customer as well."
> 2) Communicate efficiently.
> 3) Finish projects on time and work under deadlines.
> 4) Have access to the Internet and a phone line.
"We don't have offices, so you just have to work from home. We'll meet
once a week in the pub."
> You will work at an hourly rate, or by the project and be paid directly
> by A.I.S. or our client. The hourly rate is flexible.
"We're going to transfer the risk of delayed payment by the customer
to you, the programmer. That way, we don't have to chase the customer
for his payment. We'll just cream off the top."
> You will need the following skills:
>
> 1) Profound knowledge of Perl and PHP.
"Because I don't know what the difference is."
> 2) Database Integration (SQL and text-based mainly).
> 3) E-Commerce Integration.
"Sure sounds important, yes?"
> 4) UNIX and Sun servers.
As in "Sun running something else than Unix"?
> 5) Basic HTML and page layout.
"The successful candidate will double up as designer as well."
> A.I.S. is a start-up Internet Design Company, all members will be
> expected to work hard and put free time into the exposure and promotion
> of the company. You?ll also be expected to do some free programming
> for the company web site.
"We require a lot of idealism. This is offset by the possibility of
getting paid six months down the line. Overtime won't be paid, but we
expect you to work evenings and weekends. In the meantime, I'll just
look important making lots of phone calls and taking cabs everywhere."
> If you are interested in such a position please email
> jobs@aisinternet.hypermart.net with some URL?s and a summery of your
> work, a resume, and a fee per hour.
"*I*, of course, never pay for anything, so I just got this free email
account. Maybe, if we land a contract, you can also look out for some
free web space."
--
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
------------------------------
Date: 15 Oct 1999 22:58:47 GMT
From: nospam@today.com (Gordon)
Subject: Re: Perl Programmer Wanted
Message-Id: <36448.663582148F52justooltries@4.22.39.85>
webmaster@aisinternet.hypermart.net (AIS) wrote in
<7u87mt$7va$1@nnrp1.deja.com>:
>Perl Programmer Wanted
>
>A.I.S. is a start-up Internet Design Company, all members will be
>expected to work hard and put free time into the exposure and promotion
>of the company.
Why do I get images of walking around with a stapler
and flyers?
>Youll also be expected to do some free programming for
>the company web site.
This is turning into that friend that "just wants a cool
little script that will effectively turn their p120 into
a Altavista equivilant search engine".
>If you are interested in such a position please email
>jobs@aisinternet.hypermart.net with some URLs and a summery of your
>work, a resume, and a fee per hour.
Fee per hour? For free programming? Lemme do the math...
$0 per hour is it?
What previous work experience would prepare you for this
job? "I get frequently scammed by phone salespeople. I
would believe the sun is made of jello if you told me so."
>
>Thank you.
>
No, no. Thank you:)
I would have gone on for months thinking this was the
comp.lang.perl.workforfood group:)
-- Gordon --
------------------------------
Date: Fri, 15 Oct 1999 15:39:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Random string
Message-Id: <MPG.12714cee91beefc198a0a0@nntp.hpl.hp.com>
In article <3807985C.EABD81D7@dice.net> on Fri, 15 Oct 1999 21:12:08
GMT, Mike Heller <mike@dice.net> says...
> Can anyone tell me how to generate a two character string from the set
> [./0-9A-Za-z]. I'm trying to encrypt passwords using the crypt()
> function. I can generate a random two digit integer, but how do I
> generate a string?
#!/usr/local/bin/perl -w
use strict;
my @chars = ('.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z');
my $string = $chars[rand @chars] . $chars[rand @chars];
print "$string\n";
__END__
If you don't like to write long expressions twice:
my $string = join "", map $chars[rand @chars], 1, 2;
I just saw Tom Phoenix post this:
my $string = join "", @chars[rand @chars, rand @chars];
But I'd just as soon write it out twice as in my first try.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Oct 1999 17:44:40 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Random string
Message-Id: <slrn80fbi6.q8s.abigail@alexandra.delanet.com>
Mike Heller (mike@dice.net) wrote on MMCCXXXVI September MCMXCIII in
<URL:news:3807985C.EABD81D7@dice.net>:
.. Can anyone tell me how to generate a two character string from the set
.. [./0-9A-Za-z]. I'm trying to encrypt passwords using the crypt()
.. function. I can generate a random two digit integer, but how do I
.. generate a string?
That's answered in the crypt entry in perlfunc.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 15 Oct 1999 15:08:09 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: rasterizing text script?
Message-Id: <Pine.GSO.4.10.9910151506260.25558-100000@user2.teleport.com>
On Fri, 15 Oct 1999, Steve Siegel wrote:
> Anyone know of a script -- or has any ieas -- regarding taking a list
> of text items and rasterizing them?
I'm not sure what you mean by rasterizing. Maybe you want the GD module
from CPAN? Or maybe Tk? Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 15 Oct 1999 16:14:28 -0700
From: Dan Woods <dwoods@ucalgary.ca>
Subject: Re: strict, -wT problems
Message-Id: <7u894p$dhi@ds2.acs.ucalgary.ca>
Dan Woods wrote:
> Trying to be good, I turned on taint checking with warnings.
> However I am getting unknown errors (that is I don't know
> why they are bad)...
>
> #!/usr/local/bin/perl -wT
> use diagnostics;
> use strict;
Thanks to all those that replied :D
I got my script to work. And I even when on to write
another properly ;)
Thanks...Dan.
www.4loops.com
------------------------------
Date: Fri, 15 Oct 1999 22:32:19 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: tr// question
Message-Id: <0rYHOLR9r32dzlmZzAld=BjeOKmx@4ax.com>
On Fri, 15 Oct 1999 13:17:38 +0100, Nick Condon
<nick.condon@tamesis.com> wrote:
> Abigail wrote:
>
> > Well, what part of the man pages about tr didn't you understand?
>
> Your big contribution to this group is to abuse others for posting ("Read the man
> pages", "That's not Perl question", "Read the FAQ", "Read all the FAQ".). Scratch
> that, it's not a big contribution, everybody wants to do it. I read this group a lot
> less often than I would like to because it really makes me angry how many
> supercilious, smug bastards it has.
Would sir like to search deja.com for Abigail's contributions? Always
clear, correct and concise.
And even when she's using sarcasm (that may be a concept you don't
have on your planet), there's always a hint in it. You know, the old
"give a man a fish" thing.
By the way, what's *your* big contribution to this group?
If clpm isn't to your taste, then hie you hence to alt.perl or the
www-scripts list, you'll find many like-minded people there.
*plonk*
--
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 1089
**************************************