[6951] in Perl-Users-Digest
Perl-Users Digest, Issue: 576 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 5 15:13:43 1997
Date: Thu, 5 Jun 97 12:00:24 -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, 5 Jun 1997 Volume: 8 Number: 576
Today's topics:
Re: *NOT SPAM* Apprentice Perl Hacker, Summer Work Offe <usenet-tag@qz.little-neck.ny.us>
Re: -----> replacing & symbol! <------- (Quentin Fennessy)
Re: 2-way communication with unix command (Kyzer)
Re: any editor for perl? <usenet-tag@qz.little-neck.ny.us>
Re: Any non number but not a dot... <usenet-tag@qz.little-neck.ny.us>
Re: attaching a file to an email using sendmail <rootbeer@teleport.com>
checking $self in a method (Justin C Lloyd)
Re: data structure question <rootbeer@teleport.com>
Re: Having problems producing an adequate s/// subst. <usenet-tag@qz.little-neck.ny.us>
Re: how do I delete all the $s from a string(probably s <usenet-tag@qz.little-neck.ny.us>
Interupting a stream <leizero@ie.utoronto.ca>
New mirrors -- 4700+ links on Object-Orientation (Engli <manfred.schneider@rhein-neckar.de>
Newbie question - File does not print in order. <stein@seas.ucla.edu>
Re: pack template that packs like 'a' but unpacks like <rootbeer@teleport.com>
Re: Read a file to $wholefile <usenet-tag@qz.little-neck.ny.us>
Re: Rounding off numbers <rootbeer@teleport.com>
Re: Rounding off numbers <nnyxcu@ny.ubs.com>
Re: Shell to Perl.... (Kyzer)
Re: simple question about running system programs from (Kyzer)
Sockets in MacPerl? (mARCO bLOORE)
Re: String Compare Problem <usenet-tag@qz.little-neck.ny.us>
Synchronizing output from system command? (I hate spam!)
Re: Telnet (Nathan V. Patwardhan)
What can '\G' be used for in regexps ? <eike.grote@theo.phy.uni-bayreuth.de>
Re: What does "UNIX" stand for.. (Don Yuniskis)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Jun 1997 18:07:34 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: *NOT SPAM* Apprentice Perl Hacker, Summer Work Offered
Message-Id: <5n6v96$m15$1@news.netusa.net>
I R A Aggie <fl_aggie@hotmail.com> wrote:
> bcmdco@osfmail.isc.rit.edu (B. Mathis) wrote:
> + First, if we start by defining "spam" in internet terms,
> Is there any other kind?
Sure. There is "I don't like this so I am calling it spam" terms and
"Spam Current Cancel Thresholds FAQ" terms.
> + we find a definition of "mass distribution of a
> + message that is unrelated to the groups they are posted in". This
> + message is quite clearly about a perl related topic, that was posted
> + in a group about perl.
Topical or not does not enter into BI based spam cancels.
> But was off-topic and inappropriate. Unless this group got renamed while
Which is seperate from spam.
> Followups...
Sort-of observed.
Elijah
------
a.d.n regular
------------------------------
Date: 5 Jun 1997 18:18:17 GMT
From: quentin@remington.amd.com (Quentin Fennessy)
Subject: Re: -----> replacing & symbol! <-------
Message-Id: <5n6vt9$k97$1@amdint2.amd.com>
In article <5mv2c4$ibd$1@nntp.ucs.ubc.ca>,
Farshad Abasi <fabasi@unixg.ubc.ca> wrote:
>I am trying to search s string for the & symbol and replace it with \&
>I did the following which did not work :-(
>
>$title1 =~ s/'&'/'\&'/g;
>
>I also tried
>
>$title1 =~ s/&/\&/g;
Your second example looks good to me. Here is my working example,
run under 5.004 (and some other classic binaries I keep around):
$x="foo&b&ar";
print "x: $x\n";
$x =~ s/&/\\&/g;
print "x: $x\n";
output:
x: foo&b&ar
x: foo\&b\&ar
Try your second example again, using print statements around it
to see what is really happening. (Or the debugger).
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: 5 Jun 1997 17:05:37 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: 2-way communication with unix command
Message-Id: <5n6rl1$33s@info.abdn.ac.uk>
Michael J Assels, while smelling of fish, wrote:
: Russ Allbery <rra@stanford.edu> wrote:
: >--
: >#!/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
: Very nice, but you have far too many alphanumerics :-)
I like the way you can write:
perl russ-sig.pl | perl - | perl - | perl - | perl - | perl - | perl -
--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
--
Random sig of the day:
"Slightly less safe than joining the mile high club bareback with a junkie
whore in a plane flying over a war zone with three engines on fire, a pissed
up pilot and Carlos the Jackal sitting RIGHT BEHIND YOU" - MK3 advert.
------------------------------
Date: 5 Jun 1997 18:16:34 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: any editor for perl?
Message-Id: <5n6vq2$m92$1@news.netusa.net>
Note crosspost.
Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de> wrote:
> scott@lighthouse.softbase.com (Scott McMahan) writes:
> |> Monty Scroggins (Monty@dhc.net) wrote:
> |> : Vi is really old and nauseating...
> |> Vi is still around because they got it right the first time and
> |> nothing better has come along. (Emacs is just a bloated vi clone! :))
> I think there are better choices.
:r ~/usr/archive/humor/ed!
From: patl@athena.mit.edu (Patrick J. LoPresti)
Message-ID: <1991Jul11.031731.9260@athena.mit.edu>
Sender: news@athena.mit.edu (News system)
Subject: The True Path (long)
Date: 11 Jul 91 03:17:31 GMT
Path:
ai-lab!mintaka!olivea!samsung!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!patl
Newsgroups: alt.religion.emacs,alt.slack
Organization: Massachusetts Institute of Technology
Lines: 95
Xref: ai-lab alt.religion.emacs:244 alt.slack:1935
When I log into my Xenix system with my 110 baud teletype, both vi
*and* Emacs are just too damn slow. They print useless messages like,
'C-h for help' and '"foo" File is read only'. So I use the editor
that doesn't waste my VALUABLE time.
Ed, man! !man ed
ED(1) UNIX Programmer's Manual ED(1)
NAME
ed - text editor
SYNOPSIS
ed [ - ] [ -x ] [ name ]
DESCRIPTION
Ed is the standard text editor.
- ---
Computer Scientists love ed, not just because it comes first
alphabetically, but because it's the standard. Everyone else loves ed
because it's ED!
"Ed is the standard text editor."
And ed doesn't waste space on my Timex Sinclair. Just look:
- -rwxr-xr-x 1 root 24 Oct 29 1929 /bin/ed
- -rwxr-xr-t 4 root 1310720 Jan 1 1970 /usr/ucb/vi
- -rwxr-xr-x 1 root 5.89824e37 Oct 22 1990 /usr/bin/emacs
Of course, on the system *I* administrate, vi is symlinked to ed.
Emacs has been replaced by a shell script which 1) Generates a syslog
message at level LOG_EMERG; 2) reduces the user's disk quota by 100K;
and 3) RUNS ED!!!!!!
"Ed is the standard text editor."
Let's look at a typical novice's session with the mighty ed:
golem> ed
?
help
?
?
?
quit
?
exit
?
bye
?
hello?
?
eat flaming death
?
^C
?
^C
?
^D
?
- ---
Note the consistent user interface and error reportage. Ed is
generous enough to flag errors, yet prudent enough not to overwhelm
the novice with verbosity.
"Ed is the standard text editor."
Ed, the greatest WYGIWYG editor of all.
ED IS THE TRUE PATH TO NIRVANA! ED HAS BEEN THE CHOICE OF EDUCATED
AND IGNORANT ALIKE FOR CENTURIES! ED WILL NOT CORRUPT YOUR PRECIOUS
BODILY FLUIDS!! ED IS THE STANDARD TEXT EDITOR! ED MAKES THE SUN
SHINE AND THE BIRDS SING AND THE GRASS GREEN!!
When I use an editor, I don't want eight extra KILOBYTES of worthless
help screens and cursor positioning code! I just want an EDitor!!
Not a "viitor". Not a "emacsitor". Those aren't even WORDS!!!! ED!
ED! ED IS THE STANDARD!!!
TEXT EDITOR.
When IBM, in its ever-present omnipotence, needed to base their
"edlin" on a UNIX standard, did they mimic vi? No. Emacs? Surely
you jest. They chose the most karmic editor of all. The standard.
Ed is for those who can *remember* what they are working on. If you
are an idiot, you should use Emacs. If you are an Emacs, you should
not be vi. If you use ED, you are on THE PATH TO REDEMPTION. THE
SO-CALLED "VISUAL" EDITORS HAVE BEEN PLACED HERE BY ED TO TEMPT THE
FAITHLESS. DO NOT GIVE IN!!! THE MIGHTY ED HAS SPOKEN!!!
?
------------------------------
Date: 5 Jun 1997 18:58:40 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Any non number but not a dot...
Message-Id: <5n7290$nbs$1@news.netusa.net>
Terje Bless <link@tss.no> wrote:
> In article <92clm5.g7e.ln@localhost>, tadmc@flash.net (Tad McClellan) wrote:
> >There are _very_ few special chars in a character class:
> >\ escape char
> >] ends the char class
> Unless, of course, it's the first character in the class. []:-]
And ^ is special when /really/ first in a class. [^]] is much different
than []^] even when mostly order does not matter in character classes.
- is also special, unless it begins or ends the character class.
Elijah
------
nothing like obscure syntax to keep us gurus in business
------------------------------
Date: Thu, 5 Jun 1997 10:46:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: alastair brown <alastair@redboxad.demon.co.uk>
Subject: Re: attaching a file to an email using sendmail
Message-Id: <Pine.GSO.3.96.970605104511.6610K-100000@julie.teleport.com>
On Thu, 5 Jun 1997, alastair brown wrote:
> Newsgroups: comp.lang.perl.misc
> Subject: attaching a file to an email using sendmail
> Does anyone know if it is possible to attach a file to an email message
> using the sendmail program?. If so could someone please supply an
> example of the coded needed to do this
This sounds like a question for comp.mail.sendmail. Thanks!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 5 Jun 1997 06:00:03 GMT
From: lloyd@cs.fsu.edu (Justin C Lloyd)
Subject: checking $self in a method
Message-Id: <5n5kl3$nae$1@news.fsu.edu>
I have a method named ROSTERS::print like so,
sub print {
my ($self, $file) = @_;
return unless defined $self;
...
}
However, I can't seem remember why I put that $self check there. I'm sure I
saw it somewhere, but looking through the Camel book and the perlmod man page
didn't help.
I do have the vague impression that it had to do with the possibly ambiguous
subroutine name, but I'm not sure. Can anyone help clarify if such a check is
necessary? I ran the program without the line and it seems to work ok, but
who knows?
Thanks,
JcL
--
Justin C. Lloyd <lloyd@cs.fsu.edu> http://www.cs.fsu.edu/~lloyd P + L = :)
Computer Science, Florida State University, Tallahassee, FL 32306 904-644-0559
PGP ID=1024/4411DC81 Keyprint=27 8D 3F 14 5B C2 69 75 2A FA E7 3E C8 3B 61 76
Public key available at http://www.cs.fsu.edu/~lloyd/pgpkey.html
------------------------------
Date: Thu, 5 Jun 1997 10:16:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Douglas Seay <seay@absyss.fr>
Subject: Re: data structure question
Message-Id: <Pine.GSO.3.96.970605101131.6610H-100000@julie.teleport.com>
On Thu, 5 Jun 1997, Douglas Seay wrote:
> But the problem is that no normal line will be false without a chomp.
> They all have "\n" at the end, which makes it a true value. This is why
>
> while ( <FH> )
> { ; }
>
> is one of the standard ways of looking at every line of an input file.
Actually, this turns out not to be the case. If the file pointer is
positioned so that you're about to read the last character of the file,
and if that character is '0', the line input operator <FH> will return '0'
- which is a false value, even though the read succeeded! (Maybe this is
what you meant by referring to a "normal line" above. Most people, and
some software, expect a newline character at the end of every line of a
text file.)
When the line input operator is used as the control expression for a while
loop, as you've written above, it is internally translated to mean this.
while (defined($_ = <FH>)) { ... }
As you can see, that neatly avoids that problem.
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 5 Jun 1997 18:37:30 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Having problems producing an adequate s/// subst.
Message-Id: <5n711a$mr7$1@news.netusa.net>
In article <3395B7F9.7CE277BD@the.Bit.Bucket>,
Dan Hamilton <my@the.Bit.Bucket> wrote:
Nice email address. Makes it so easy to reply by mail.
> The problem is conceptually simple: Replace all spaces contained in
> quotes with a placeholder. I found code that works, but seems quite
> poor. The following code snippet is an example of what I would like to
> do.
s/\G # anchor to end of last match
((?:\\.|[^\\"])* # any non-quotes or \<char>s
") # a quote
((?:\\.|[^\\"])*) # any non-quotes or \<char>s
" # a quote
/$1 . ($scrap=$2, # first string, and make a writable copy of second
$scrap=~s: :$placeholder:g, # rewrite said copy
$scrap) . '"' # put the new version in, and a "
/gsex; # fun
Untested, but will probably work. :^) Deals with \" in the normal manner.
> foreach $term (@terms) {
> # Do some binary-state switching:
> if ( $iterator == 1 ) {
> $iterator--;
> } else {
> $iterator++;
> }
> # The iterator is 0 during grouped states:
> $term =~ s/ /$placeholder/g unless $iterator;
> $FORM{'terms'} .= $term;
> }
Huh? where do quotes enter in this?
> My goal is similar, exept I am operating on a scalar text string. For
> that reason, I cannot use a "foreach" construct. The text string
> contains (possibly) multiple lines, with sections in double quotes; each
Hence my 's' option above.
> $text =~ s/????/$placeholder/g
Huh? That does not parse.
> Does anyone have any ideas about the s/// problem above? What can I use
> as my regular expression? Can the problem be solved with s/// alone?
For suitably complex definitions of "alone", yes.
Elijah
------
#!/usr/bin/perl -w
$_="<j!y~f^v* >h.g=c+m\@q[p;r} ?x/t|d:l# )e\\p.d-s]p{c<,\n";$j=0;while(
s"[^\w\s,](.*)"($u=$1,$u=~s;(\w);(($s=ord($1)-97),chr((($s+$j++)%26)+97
));gex,$u)"ex){}exit !print;#18/5/97:etb
------------------------------
Date: 5 Jun 1997 18:49:30 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: how do I delete all the $s from a string(probably simple)
Message-Id: <5n71nq$n3t$1@news.netusa.net>
Eric Roode <sdn@mv.mv.com> wrote:
> The Halls <bhall@mail.tds.net> wrote:
> >my $extra_price_1 = '$123.89';
> >I need the result to be 123.89. I thought it would be something like:
> >$extra_price_1 =~ s/$/d/;
> So close. That will change each $ to the letter d.
Really?
:r! perl -e '$_=q"$123.89$123.89"; s/$/d/; print $_,"\n";'
$123.89$123.89d
What version of perl are you using?
> What you want is: s/$//; except! that $ is a special character
> and must be quoted: s/\$//;
It still only would to the first one:
:r! perl -e '$_=q"$123.89$123.89"; s/\$//; print $_,"\n";'
123.89$123.89
> Not that you asked, but according to the book, tr is faster for
> deleting characters from a string: tr/$//d;
:r! perl -e '$_=q"$123.89$123.89"; tr/$//d; print $_,"\n";'
123.89123.89
Yup, that one works.
Elijah
------
hmmm. I like that q"..." syntax, so obfuscatory
------------------------------
Date: Thu, 05 Jun 1997 14:18:32 -0700
From: William Leizerowicz <leizero@ie.utoronto.ca>
Subject: Interupting a stream
Message-Id: <33972D28.543@ie.utoronto.ca>
I would like to know how to interupt a stream from perl
Here is the scenario:
I am listening to a socket ... waiting for a connection ...
but ...
I need to run something once a minute within the program ...
can I do this in perl?
as far as I know, this would be the same problem for any stream
including STDIN ...
anybody have any ideas or experience?
threads are not supported in perl (as far as I know)
Will
------------------------------
Date: 5 Jun 1997 18:00:26 GMT
From: "Manfred Schneider" <manfred.schneider@rhein-neckar.de>
Subject: New mirrors -- 4700+ links on Object-Orientation (English/French)
Message-Id: <01bc71d9$55b72880$0100007f@cetus>
Subject: Cetus Links -- 4700+ links on Object-Orientation
Newsgroups: Some comp.* newsgroups related to OO
Reply-To: manfred.schneider@rhein-neckar.de (Manfred Schneider)
Summary: News, editions, topics and URLs of Cetus Links
Posting-Freq.: Monthly
Hello,
are you interested in a collection of more than 4700 links on
Object-Orientation - running on 12 servers in different countries ?
No ads, few graphics, fast and free access!
What4s new?
o New mirrors in Switzerland and USA/Virginia
o May 2: hit count exceeds 100,000 since May 496
Available editions:
o English
o French
Main topics:
o General Information and Links about Object-Orientation
o Distributed Objects, Business Objects, Object Request Brokers,
ActiveX/OLE, Corba, JavaBeans/RMI, OpenDoc
o OOA/OOD Methods and Tools, Diagram Layout
o Languages, Ada, BETA, C++, CLOS, Delphi, Eiffel, Java,
JavaScript, Modula-3, Oberon, Objective-C, Perl, Python,
Sather, Self, Simula, Smalltalk, Tcl/Tk, VBScript,
Visual Basic, Visual C++
o Databases, OO DBMS, OR DBMS, OR Mapping
o Patterns, Libraries, Frameworks
o Metrics, Reuse, Testing, Numerics
o Services and Companies
URL of original site:
o Germany, Heidelberg
http://www.rhein-neckar.de/~cetus/software.html
URLs of mirror sites:
o Australia, Melbourne
http://www.csse.swin.edu.au/manfred/software.html
o Austria, Vienna
http://www.infosys.tuwien.ac.at/cetus/software.html
o Brazil, RS, Porto Alegre
http://www.intuitive.com.br/cetus/software.html
o Canada, Quebec
http://www.csioo.com/cetusen/software.html
o Japan, Osaka
http://aries.ise.eng.osaka-u.ac.jp/cetus/software.html
o Singapore
http://sunsite.nus.sg/pub/cetus/software.html
NEW Switzerland, Lausanne
http://www.sente.ch/cetus/software.html
o UK, Coventry
http://www.parallax.co.uk/cetus/software.html
o USA, IL, Chicago
http://www.objenv.com/cetus/software.html
o USA, UT, Provo
http://mini.net/cetus/software.html
NEW USA, VA, Arlington
http://www.eidea.com/OO_site/cetus/software.html
URL of French edition:
o Canada, Quebec
http://www.csioo.com/cetusfr/software.html
I hope you will find the Cetus Links useful.
Please feel free to send suggestions, comments, new or changed URLs.
Manfred
------------------------------
Date: 5 Jun 1997 05:19:38 GMT
From: "John L. Stein" <stein@seas.ucla.edu>
Subject: Newbie question - File does not print in order.
Message-Id: <5n5i9a$1dou@uni.library.ucla.edu>
This is a multi-part message in MIME format.
---------------------------------17987551720520
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
This does not print in order. It prints
{leconte} 84> bubba
blue = Fri
blue = Mon
blue = Sat
blue = Sun
blue = Thu
blue = Tue
blue = Wed
How can I make it print in order ?
Thanks
-js
---------------------------------17987551720520
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
#!/usr/local/bin/perl -w
$longday;
%longday = (
"Sun" , "Sunday",
"Mon" , "Monday",
"Tue" , "Tuesday",
"Wed" , "Wednesday",
"Thu" , "Thursday",
"Fri" , "Friday",
"Sat" , "Saturday",
);
foreach $blue (sort keys %longday)
{print "blue = $blue\n";}
---------------------------------17987551720520--
------------------------------
Date: Thu, 5 Jun 1997 10:00:45 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Valeriy E. Ushakov" <uwe@ptc.spbu.ru>
Subject: Re: pack template that packs like 'a' but unpacks like 'A'
Message-Id: <Pine.GSO.3.96.970605095529.6610C-100000@julie.teleport.com>
On Thu, 5 Jun 1997, Valeriy E. Ushakov wrote:
> a - any - This one is for binary data. You can grab some bytes as is
> when you unpack. You can put some bytes when you pack and null
> padding is just what you expect for binary data (least surprise).
> This one is symmetric for bynary.
I don't think so. If I have binary data, it may have null values as valid
data. I'd pack it in a fixed-width field, either using substr or a
different pack template character than 'a'.
> Z - ASCIZ - The one we miss. (I use upper case this time, unlike my
> first exaple, for it is more similar to 'A' than to 'a' (any)).
> Packs with trailing nulls. Unpacks stripping nulls. I came to
> think that it should strip *ONLY* nulls, not spaces, if we intend it
> to work with C null delimited strings. This one is symmetric for
> C strings.
That sounds like the right thing, IMHO.
> To reiterate: the problem I have been talking about is the *lack* of
> format that is symmetric for C null delimited strings.
So, have you run perlbug yet? :-)
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 5 Jun 1997 17:59:57 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Read a file to $wholefile
Message-Id: <5n6uqt$lpe$1@news.netusa.net>
Dave Cross <crossd@gb.swissbank.com> wrote:
> adelton@fi.muni.cz (Honza Pazdziora) writes:
> > Lauri Laakso <lauri@nettipaja.clinet.fi> writes:
> > > Ho I can read whole $message.dat file to $wholefile, I am using it
> > > when I send multiple emails.
> > $/ = undef;
> > $wholefile = <FILE>;
> I don't think this works. <FILE> returns one line from a file in a list
> context.
Do you know what $/ controls? Did you try out the code?
> @wholefile = <FILE>
With a ';', and $/ == undef, this will create an array with one element,
and that will be the wholefile.
> will put the whole file in the array @wholefile. If you really want it
> in a scalar, you could do something using 'join'.
Not needed with $/ set to undef.
Elijah
------
on the whole @wholefile without $/ tinkering is more obvious
------------------------------
Date: Thu, 5 Jun 1997 10:04:55 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Felix R. Penetrante" <felix@cats.edu.ph>
Subject: Re: Rounding off numbers
Message-Id: <Pine.GSO.3.96.970605100354.6610E-100000@julie.teleport.com>
On Thu, 5 Jun 1997, Felix R. Penetrante wrote:
> Is there a built-in function for rounding off floating point numbers.
Have you seen the FAQ? :-)
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq4/
Does_perl_have_a_round_function_.html
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Thu, 05 Jun 1997 11:26:56 -0400
From: Glen Culbertson <nnyxcu@ny.ubs.com>
To: "Felix R. Penetrante" <felix@cats.edu.ph>
Subject: Re: Rounding off numbers
Message-Id: <3396DAC0.4E4A@ny.ubs.com>
Not specifically, but sprintf works just fine for
this purpose.
Felix R. Penetrante wrote:
>
> Is there a built-in function for rounding off floating point numbers.
------------------------------
Date: 5 Jun 1997 17:04:11 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: Shell to Perl....
Message-Id: <5n6rib$33s@info.abdn.ac.uk>
Dave Cross, while smelling of fish, wrote:
: [script snipped]
: This looks very much like a mail bomb program to me. Why would I want to
: help you develop something like that?
Exactly :)
Personally, I prefer perl -e 'foreach(1..1000){`mail $ARGV[0] <$ARGV[1]`;}'
:)
--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
--
Random sig of the day:
"Map is your friend. Use map." - Randal Schwartz
------------------------------
Date: 5 Jun 1997 17:17:04 GMT
From: junkmail@sysa.abdn.ac.uk (Kyzer)
Subject: Re: simple question about running system programs from with
Message-Id: <5n6sag$33s@info.abdn.ac.uk>
Chipmunk, while smelling of fish, wrote:
: You want to use backticks (``).
or qx() ?
--
Stuart 'Kyzer' Caie - Kyzer/CSG |undergraduate of Aberdeen University |100%
http://www.abdn.ac.uk/~u13sac |My opinions aren't those of Aberdeen |Amiga -
kyzer@4u.net kyzer@hotmail.com |University or AUCC, thankfully.***** |always!
--
Random sig of the day:
sh: cookie not found
------------------------------
Date: Thu, 05 Jun 1997 13:35:36 -0400
From: bloore@h-plus-a.com (mARCO bLOORE)
Subject: Sockets in MacPerl?
Message-Id: <bloore-ya023180000506971335360001@news.bellglobal.com>
Has anyone succeeded in using sockets under MacPerl? The example server and
client fromt the camel book fail on undefined functions. The examples
from the html perlipc manpage that comes with MacPerl compile and run
with minor modification, and the server accepts a connection when I run
the client, but no data seems to get sent to the client. Both sit there
waiting.
The server code is
($port) = @ARGV;
$port = 2345 unless $port;
use Socket;
$sockaddr = 'S n a4 x8';
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp')
unless $port =~ /^\d+$/;
$this = pack($sockaddr, &AF_INET, $port, "\0\0\0\0");
select(NS); $| = 1; select(stdout);
socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
listen(S, 5) || die "connect: $!";
select(S); $| = 1; select(stdout);
for (;;) {
print "Listening again\n";
($addr = accept(NS,S)) || die $!;
print "accept ok\n";
($af,$port,$inetaddr) = unpack($sockaddr,$addr);
@inetaddr = unpack('C4',$inetaddr);
print "$af $port @inetaddr\n";
while (<NS>) {
print;
print NS;
}
}
and the client code is
($them,$port) = @ARGV;
$port = 2345 unless $port;
$them = 'ha4' unless $them;
$SIG{'INT'} = 'dokill';
sub dokill { kill 9,$child if $child; }
use Socket;
$sockaddr = 'S n a4 x8';
$hostname = 'myDNSname';
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port, 'tcp')
unless $port =~ /^\d+$/;
($name, $aliases, $type, $len, $thisaddr) =
gethostbyname($hostname);
($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
$this = pack($sockaddr, &AF_INET, 0, $thisaddr);
$that = pack($sockaddr, &AF_INET, $port, $thataddr);
socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
bind(S, $this) || die "bind: $!";
connect(S, $that) || die "connect: $!";
select(S); $| = 1; select(stdout);
while (<S>) {
print;
}
the server prints
Listening again
when it starts, and
accept ok
2 2047 <my IP address>
when the client runs (on a separate machine), but then both hang with no
furthur output.
mARCO bLOORE bloore@h-plus-a.com
Vice-President, Software Engineering
I. Hoffmann + assoc inc. http://www.h-plus-a.com/
http://www.nikolai.com/
------------------------------
Date: 5 Jun 1997 18:41:19 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: String Compare Problem
Message-Id: <5n718f$n2k$1@news.netusa.net>
Chipmunk <Ronald.J.Kimball@dartmouth.edu> wrote:
> pcartier@ix.netcom.com (Paul Cartier) writes:
> > Could someone give me an example on how I can search the
> > begining of a string for a match.
> ^ matches the beginning of a string.
> $ matches the end of a string.
Close, but no cigar. ^ matches the beginning of a line (or string)
$ matches the end of a line (or string). \A matches the begining of
a string. \Z matches the end of a string.
Elijah
------
cf. ^^ in procmail
------------------------------
Date: 5 Jun 1997 18:06:20 GMT
From: alweiner@presstar.com.net (I hate spam!)
Subject: Synchronizing output from system command?
Message-Id: <5n6v6s$1ga@clarknet.clark.net>
The following program:
print "This should print first\n";
system("echo \"this should print second\"");
produces:
this should print second
this should print first
How do you synchronize the output in perl so that the results of a
system command appear in the same logical order as the calling code?
--
-----
To reply by email, please remove the last '.net' from the email
address...
------------------------------
Date: 5 Jun 1997 17:43:26 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Telnet
Message-Id: <5n6tru$76@fridge-nf0.shore.net>
I R A Aggie (fl_aggie@hotmail.com) wrote:
: + Use the Net::Telnet module, distributed as part of the libnet module.
: No, actually not. It's been unbundled from the libnet package, and
: should be easily findable in the CPAN archive.
Hmm. When did they do this? I installed a version about 1.5-2 weeks
ago where it seemed to be included (it appeared to be the recent
libnet version at the time).
: BTW, it comes with a perldoc manual of 19 pages. I only skimmed,
: but it seemed to offer quite a few examples.
Yep. The version I'm using now has a bunch of examples to work with.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Tue, 03 Jun 1997 10:56:05 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: What can '\G' be used for in regexps ?
Message-Id: <3393DC25.41C6@theo.phy.uni-bayreuth.de>
Hi,
(I post this article a second time, because I think it wasn't
delivered to news servers outside my site last time due to some
problems here [my first posting doesn't appear in "dejanews"])
The question I have is simply (?) :
--- What's the purpose of '\G' in regular expressions ? ---
Yes, I took a look at the common information sources: 'perlre' manual
page, the perl FAQ, the blue camel. But all I found was: "Matches
where previous m//g left off". (Not more than an "only" was added
in the new camel ... ;-) )
My idea was that the script below should yield
1 - a
2 - b
3 - c
but the output is
1 - x
2 - x
3 - x
Code (Perl 5.003, IRIX):
#!/usr/local/bin/perl -w
$a = 'x---1a--2b--3c';
while($a =~ /\d/g)
{
print "$& - ";
$a =~ /\G\w/;
print "$&\n";
}
So, is there something wrong with my script or with Perl or ... ?
Maybe someone can explain '\G' to me or, even better, give
a working example which shows the effect of '\G'.
Bye, Eike
--
======================================================================
Eike Grote, Theoretical Physics IV, University of Bayreuth, Germany
----------------------------------------------------------------------
e-mail -> eike.grote@theo.phy.uni-bayreuth.de
WWW -> http://www.phy.uni-bayreuth.de/theo/tp4/members/grote.html
http://www.phy.uni-bayreuth.de/~btpa25/
======================================================================
------------------------------
Date: 5 Jun 1997 17:41:38 GMT
From: dgy@rtd.com (Don Yuniskis)
Subject: Re: What does "UNIX" stand for..
Message-Id: <5n6toi$kb0@baygull.rtd.com>
In article <01bc71a4$dca66980$49818e9f@gsa.gov>,
Bill Erwin <bill.erwin@gsa.gov> wrote:
>UNIX started out as "Castrated MULTICS" and was shortened from there.
>Check out the "UNIX Haters Handbook" for further details.
Hmmm... never heard the reference to "Castrated MULTICS"... ;-)
MULTICS -> UNICS -> UNIX --> FreeBSD (shameless plug! :>)
I've never understood the bias *against* MULTICS as I thought it was
*decades* ahead of it's time! I suspect the delays in getting it
up and running were the inspiration for UNICS's genesis.
--don
------------------------------
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 576
*************************************