[21921] in Perl-Users-Digest
Perl-Users Digest, Issue: 4125 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 15 14:05:59 2002
Date: Fri, 15 Nov 2002 11:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 15 Nov 2002 Volume: 10 Number: 4125
Today's topics:
Re: -F works on command line but not on #!perl -paF lin (Amir Karger)
Re: A simple form problem! <wsegrave@mindspring.com>
Re: Checking for human user with images <usenet@dwall.fastmail.fm>
Re: Checking for human user with images <nobull@mail.com>
Re: Checking for human user with images <addi@umich.edu>
Re: Discovering whether qr// needs to recompile an RE <nobull@mail.com>
getting the length of a string <spam_catcher@cox.net>
Re: getting the length of a string <Graham.T.Wood@oracle.com>
Re: getting the length of a string <uri@stemsystems.com>
Re: getting the length of a string <spam_catcher@cox.net>
Re: glob not working in dos <Graham.T.Wood@oracle.com>
Re: glob not working in dos <wksmith@optonline.net>
Re: glob not working in dos <ed.doyle@motorola.com>
Re: help with arrays of arrays <usenet@dwall.fastmail.fm>
Ignoring Newlines <zahm@uiuc.edu>
Re: Ignoring Newlines <shondell@cis.ohio-state.edu>
Re: installing perl on winxp <wsegrave@mindspring.com>
Is there something like the sh -x option in perl? (Reg Clemens)
Re: MAC Address <robertbu@hotmail.com>
Re: MAC Address <nobull@mail.com>
Re: newbie to perl: printing literals(constants). <stevenm@blackwater-pacific.com>
Re: Reading an input file as scalar. <robertbu@hotmail.com>
Re: Reading an input file as scalar. <nobull@mail.com>
Re: Reading an input file as scalar. <jeff@vpservices.com>
Re: Reading an input file as scalar. <usenet@tinita.de>
Re: Reading an input file as scalar. <robertbu@hotmail.com>
Re: Reading an input file as scalar. <addi@umich.edu>
Re: Redhat 8.0 and Perl <family2@aracnet.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Nov 2002 10:16:18 -0800
From: amirkargerweb@yahoo.com (Amir Karger)
Subject: Re: -F works on command line but not on #!perl -paF line
Message-Id: <87671b7a.0211151016.2aed5dd@posting.google.com>
But that's just the point! As I said in the rest of my post, when I
remove the full path to perl (or when I run it on Windows), I get an
error. (`which perl` does return /usr/local/bin/perl, so it's not like
I'm secretly running a different perl or something.)
And thanks for the other suggestions of how to golf this script, but I
wrote it just as a very simple test case for the post. I didn't want
to post the real -aF I was trying, because it was complicated.
I can't imagine that noone else has seen this utterly simple bug on
Windows or Solaris. OTOH, I really did cut and paste that stuff from
my command line runs! This is severely weird.
-Amir
news@roaima.freeserve.co.uk wrote in message news:<aah0ra.vtl.ln@moldev.cmagroup.co.uk>...
> Amir Karger <amirkargerweb@yahoo.com> wrote:
> > Pardon if this is a FAQ, but searching for "-F" or "split" on google
> > groups doesn't help much, and I could swear I'm following the docs. I
> > can't seem to figure out how to use -F on the #! line
>
> > foo% more a.pl
> > #!/usr/local/bin/perl -palF/:/
> > $_=join"_",@F;
>
> > The scripts are run by the judges as "perl a.pl"
>
> In this case you don't need a (valid) path to perl on the #! line, so
> you can remove the "/usr/local/bin/" prefix and save yourself a number
> of characters.
>
> Chris
------------------------------
Date: Fri, 15 Nov 2002 12:55:10 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: A simple form problem!
Message-Id: <ar3gfs$a26$2@slb6.atl.mindspring.net>
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:anfhr0$504$2@slb6.atl.mindspring.net...
<snip>
The script in my previous post, while it handles multiple params, doesn't
present them nicely. A slight modification to the script follows:
#!perl -w
# echo2htm.pl - echos name=value(s) pairs as HTML
use strict;
use CGI qw(-no_xhtml :standard *pre);
print header, start_html, start_pre;
foreach (param()) {print $_, ' = ', join(', ', param($_)), "\n"}
print end_pre, end_html;
The OP might wish to refer to the documentation for CGI.pm, or to Lincoln
Stein's web site, for the script "A Simple Example". The
dynamically-generated HTML from that script can be sent to the above script,
which produces:
name = Bill
words = eenie, meenie, minie, moe
color = red
in the browser display.
Other posters appear to prefer object-oriented style. I've used the
function-oriented style (see USING THE FUNCTION-ORIENTED INTERFACE in the
CGI.pm documentation for details).
Note to OP:
The above script will expose all of the single-and multi-valued
name=value(s) pairs for which (checked/selected) values exist. Checkboxes,
for example, normally don't pass the name unless at least one value is
selected.
If the forms you wish to process have a large number of fields, you might
consider a pre-processing step in which you'd convert all of the
multi-valued fields, e.g., check boxes and scrolling lists, to all values
checked/selected, as well as convert any radio buttons into a form where all
values are selected. Submitting such a modified form to a script such as the
above example should expose all of the name=value(s) pairs in the form,
automagically, and in the same order in which they appear in the form,
thanks to CGI.pm.
I hope this helps the OP.
Bill Segraves
------------------------------
Date: Fri, 15 Nov 2002 16:35:35 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Checking for human user with images
Message-Id: <Xns92C775EE69960dkwwashere@216.168.3.30>
Arnar Mar Hrafnkelsson <addi@umich.edu> wrote on 15 Nov 2002:
>
> Sometimes you want to make an image that is 'not trivial' to
> OCR by a machine. This is useful to defeat robots that submit
> to web forms and such.
Nice idea.
> open(FH,"perl/cross/words.english") or die "Cannot load word list: $!\n";
> chomp(@a = <FH>);
> $word = $a[rand(@a)];
> print "$word\n";
The FAQ has a more efficient way to get a random line from a file....
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: 15 Nov 2002 17:03:48 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Checking for human user with images
Message-Id: <u9znsa22a3.fsf@wcl-l.bham.ac.uk>
Sorry, to reply off-topic but some things need to be pointed out...
Arnar Mar Hrafnkelsson <addi@umich.edu> writes:
> Sometimes you want to make an image that is 'not trivial' to
> OCR by a machine.
...but then you realise it would be totally unethical so you abondon
that idea.
> This is useful to defeat robots that submit
> to web forms and such.
And, of course, blind (or partially sighted) people. Blind people
have a hard enough time without you going out of your way to
descriminate against them.
IIRC a recent test case in the US found that webmasters could not be
compelled to go out of their way to make sites accessible via
non-visual browsers. However if you actually go out of your way to
make you site inaccessible via non-visual browsers that's quite
possibly a different matter.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 15 Nov 2002 12:17:50 -0500
From: Arnar Mar Hrafnkelsson <addi@umich.edu>
Subject: Re: Checking for human user with images
Message-Id: <xfsvd6p6wy4h.fsf@blue.engin.umich.edu>
Brian McCauley <nobull@mail.com> writes:
> Sorry, to reply off-topic but some things need to be pointed out...
>
> Arnar Mar Hrafnkelsson <addi@umich.edu> writes:
>
> > Sometimes you want to make an image that is 'not trivial' to
> > OCR by a machine.
>
> ...but then you realise it would be totally unethical so you abondon
> that idea.
>
Unethical? I'm missing something.
> > This is useful to defeat robots that submit
> > to web forms and such.
>
> And, of course, blind (or partially sighted) people. Blind people
> have a hard enough time without you going out of your way to
> descriminate against them.
>
Then you should provide an audio file too. Look into using festival
to autogenerte those.
> IIRC a recent test case in the US found that webmasters could not be
> compelled to go out of their way to make sites accessible via
> non-visual browsers. However if you actually go out of your way to
> make you site inaccessible via non-visual browsers that's quite
> possibly a different matter.
>
Okay.
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: 15 Nov 2002 17:20:13 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Discovering whether qr// needs to recompile an RE
Message-Id: <u9r8dm21iq.fsf@wcl-l.bham.ac.uk>
apronk@csi.co.nz (Adrian) writes:
> What it looks like to me is happenning is that qr// knows whether it
> has compiled its argument before and if so, just returns the RE
> it generated last time.
Actually it's more subtle still. If I say qr/$foo/ then _both_ the
scalar $foo and the particular qr// remember the compiled regex.
> A useful optimisation so long as the RE does not have side effects!
I agree.
> My next question is: how can I tell (at the time I execute qr//)
> whether it will compile the string in the current context or
> whether it will return a compilation from a previous context?
I can't answer that but I can answer the question after.
To force recompliation you need to change the qr/$_[0]/ to
my $qr;
for ( 0, "$_[0]" ) {
$qr = qr/$_/;
}
$qr;
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 15 Nov 2002 16:16:48 GMT
From: "j" <spam_catcher@cox.net>
Subject: getting the length of a string
Message-Id: <Q59B9.6967$0U1.505741@news2.east.cox.net>
What's the easiest way to get the length of a string? I found 1 way which is
$t="This is a test.";
@junk=split(//,$t);
$len=@junk;
Is there a function I'm missing somewhere to do it a little easier?
TIA,
Jay
------------------------------
Date: Fri, 15 Nov 2002 16:24:27 +0000
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: getting the length of a string
Message-Id: <3DD51FBB.B220E4AF@oracle.com>
> What's the easiest way to get the length of a string?
$length=length($string);
> Is there a function I'm missing somewhere to do it a little easier?
The function is called length.
Graham
------------------------------
Date: Fri, 15 Nov 2002 16:24:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: getting the length of a string
Message-Id: <x7y97upzqz.fsf@mail.sysarch.com>
>>>>> "j" == j <spam_catcher@cox.net> writes:
j> What's the easiest way to get the length of a string? I found 1 way
j> which is $t="This is a test."; @junk=split(//,$t); $len=@junk;
j> Is there a function I'm missing somewhere to do it a little easier?
self answering question
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 15 Nov 2002 18:16:18 GMT
From: "j" <spam_catcher@cox.net>
Subject: Re: getting the length of a string
Message-Id: <SRaB9.7600$0U1.523916@news2.east.cox.net>
Thanks,
I think I blacked out for a minute there ;-)
Jay
"Graham Wood" <Graham.T.Wood@oracle.com> wrote in message
news:3DD51FBB.B220E4AF@oracle.com...
> > What's the easiest way to get the length of a string?
>
> $length=length($string);
>
> > Is there a function I'm missing somewhere to do it a little easier?
>
> The function is called length.
>
> Graham
>
------------------------------
Date: Fri, 15 Nov 2002 16:22:44 +0000
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: glob not working in dos
Message-Id: <3DD51F54.D1BDA992@oracle.com>
Ed Doyle wrote:
> Hi,
> The small test script below works perfectly in unix but produces nothing in
> dos. It shoud list all the files in current directory ending with .c
> Any suggestions on why it does not work in dos?
> Thanks
> Ed
>
> ---
>
> #!/usr/bin/perl
>
> my $a;
>
> $a = glob "\*\.c";
> for $a(glob "\*\.c")
> {
> print"$a\n";
> }
Are you sure it works on unix? I would have expected glob("*.c") to work but
not glob("\*\.c") unless it was finding a file called *.c . Why are you
escaping the *?
Graham
------------------------------
Date: Fri, 15 Nov 2002 16:19:51 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: glob not working in dos
Message-Id: <H89B9.3$r41.2@rcache1.news.cv.net>
"Ed Doyle" <ed.doyle@motorola.com> wrote in message
news:ar34r9$ppe$1@newshost.mot.com...
> Hi,
> The small test script below works perfectly in unix but produces nothing
in
> dos. It shoud list all the files in current directory ending with .c
> Any suggestions on why it does not work in dos?
> Thanks
> Ed
>
> ---
>
> #!/usr/bin/perl
>
> my $a;
>
> $a = glob "\*\.c";
> for $a(glob "\*\.c")
> {
> print"$a\n";
> }
>
>
Works fine for me with ActivePerl 5.6.1 under Windows ME. (I did change the
.c to .pl). Try again with use strict and use warnings. Tell us how it
failed.
Bill
------------------------------
Date: Fri, 15 Nov 2002 11:46:17 -0500
From: "Ed Doyle" <ed.doyle@motorola.com>
Subject: Re: glob not working in dos
Message-Id: <ar38e4$rbj$1@newshost.mot.com>
Hi,
I agree, it should be glob("*.c"), but as an experiment, I tried escaping
the * and the .. I didn't realized I posted the experiment. Someone else
has posted that it worked correctly for them in a dos window. (I presume
they removed my experimental back slashes). Anyway, I am suspecious of my
perl installation. I am going to reinstall it. I am finding that perldoc
is now also not working in dos, but is fine in Unix. In dos, perl -v reports
This is perl, version 5.002.
Thanks for the replies.
Ed
"Graham Wood" <Graham.T.Wood@oracle.com> wrote in message
news:3DD51F54.D1BDA992@oracle.com...
>
>
> Ed Doyle wrote:
>
> > Hi,
> > The small test script below works perfectly in unix but produces nothing
in
> > dos. It shoud list all the files in current directory ending with .c
> > Any suggestions on why it does not work in dos?
> > Thanks
> > Ed
> >
> > ---
> >
> > #!/usr/bin/perl
> >
> > my $a;
> >
> > $a = glob "\*\.c";
> > for $a(glob "\*\.c")
> > {
> > print"$a\n";
> > }
>
> Are you sure it works on unix? I would have expected glob("*.c") to work
but
> not glob("\*\.c") unless it was finding a file called *.c . Why are you
> escaping the *?
>
> Graham
>
>
------------------------------
Date: Fri, 15 Nov 2002 16:12:11 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: help with arrays of arrays
Message-Id: <Xns92C771F6CAB05dkwwashere@216.168.3.30>
Randy <nospam@rostie.net> wrote on 13 Nov 2002:
> Here is what I am working on now,
>
> #!/usr/bin/perl -w
> use strict;
I strongly suspect you added -w and 'use strict' only in your post and not
in the real program. The code you show below doesn't even run with
strictures enabled, it just produces compilation errors.
> my %users;
>
> my $filename = "files.found";
> open(FILE, "$filename")||die("Opening File: $!");
Unnecessary use of quotes around $filename.
>
> #store file header for later
> my($hostname,$randate,$rantimestamp) = split /\t\t/, <FILE>;
> while(<FILE>){
> chomp;
> $users{$user}{file} = $file;
You use $user here....
> $users{$user}{safe} = $safe;
> $users{$user}{version} = $version;
> my($user,$file,$safe,$version) = split /\t\t/;
but don't actually declare it or put anything in it until here. With
strictures enabled this would stop the program from even running.
> }
[snip rest of code]
>
> The file has 12 lines, but I just get this once:
>
> File:
> Safe:
> Version:
You didn't get that with the code you posted. How do you expect to get
help by showing fictitious code?
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Fri, 15 Nov 2002 11:50:33 -0600
From: "Robert Zahm" <zahm@uiuc.edu>
Subject: Ignoring Newlines
Message-Id: <craB9.16552$US2.197728@vixen.cso.uiuc.edu>
I checked through the o'reilly perl book and also tried some google
searches, but couldn't find the answer to this (what I assume is a)
relatively simple question. Is there any way to ignore newline
characters in pattern matching? Specifically, I have a sequence which
contains newline characters, and I want to ignore the newlines when
trying to match patterns (so that I can have the first part of the
pattern at the end of one line, and the remainder of the pattern at the
beginning of the next line). Currently, I just go through the sequence
and remove all the newlines...but there has to be a more efficient way
to do this, I was hoping there would be a flag I could attach to the end
of s// which would tell it to ignore a certain character, but I was
unable to find anything like that. Any suggestions? Thanks.
Rob
zahm@uiuc.edu
------------------------------
Date: 15 Nov 2002 13:31:39 -0500
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: Ignoring Newlines
Message-Id: <xcwel9mlm5w.fsf@psi.cis.ohio-state.edu>
"Robert Zahm" <zahm@uiuc.edu> writes:
> I checked through the o'reilly perl book and also tried some google
> searches, but couldn't find the answer to this (what I assume is a)
> relatively simple question. Is there any way to ignore newline
> characters in pattern matching?
(snip)
It sounds like you're probably looking for the /s regex
modifier. Check out perldoc perlre for more info on it.
--
Ryan Shondell <shondell@cis.ohio-state.edu>
------------------------------
Date: Fri, 15 Nov 2002 10:56:49 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: installing perl on winxp
Message-Id: <ar3a9e$phf$2@slb9.atl.mindspring.net>
"Helgi Briem" <helgi@decode.is> wrote in message
news:3dd4d1f7.2619814734@news.cis.dfn.de...
> On Thu, 14 Nov 2002 20:44:56 -0600, "William Alexander
> Segraves" <wsegrave@mindspring.com> wrote:
>
> >"Helgi Briem" <helgi@decode.is> wrote in message
> >news:3dd3c762.2551564425@news.cis.dfn.de...
> >> On Thu, 14 Nov 2002 06:54:46 -0600, "William Alexander
> >> Segraves" <wsegrave@mindspring.com> wrote:
<snip>
> OK, WinXP does have a "home" version, I can't remember
> what it's called, that basically has no acccess
> restrictions, similar to the Win95/98/Me family. Any
> user is probably able to install stuff on that.
IIRC, my son's computer has XP Pro.
<snip>
> The "workstation" version, which is a minor upgrade of
> Win2K/NT, does have access restrictions and ordinary
> users can *not* install programs or can only write to
> registry keys in the "CURRENT USER" hive. I was assuming
> this version, but of course there is the "home" type that
> I have never used and forgot about.
I suppose that means we either installed under my son's user name or gave me
admin status when we added me as a user. I don't have access to a WinXP
machine from here, so I have no way to verify if IndigoPerl will install and
run for the OP.
Perhaps the OP will let us know if he is successful with his try with
IndigoPerl.
Thanks, Helgi.
Regards,
Bill Segraves
------------------------------
Date: Fri, 15 Nov 2002 18:25:45 +0000 (UTC)
From: reg@orion.dwf.com (Reg Clemens)
Subject: Is there something like the sh -x option in perl?
Message-Id: <ar3e78$33b$1@iruka.swcp.com>
The command line says it all, is there a way to run perl such that it
prints out lines as it executes them? I have a perl script here that
worked, but has stopped. Seeing where/what its is doing would be
a big help...
--
Reg.Clemens
reg@dwf.com
------------------------------
Date: Fri, 15 Nov 2002 16:58:16 GMT
From: "robertbu" <robertbu@hotmail.com>
Subject: Re: MAC Address
Message-Id: <II9B9.215$br6.199@nwrddc03.gnilink.net>
"Hisham Mohamed" <hisham.mohamed@no-spam.engelhard.com.noSPAM> wrote in
message news:3dd5236a$1@ec-nntp....
> Is there a way to get a remote machine's MAC Address by supplying its IP
or
> host name? In a Win32 environment, the "nbtstat -a" command can do it, but
> it returns other, unneeded info as well.
>
> -Hisham
>
>
arp -a is another way, but it still output some unneeded info.
== Rob ==
------------------------------
Date: 15 Nov 2002 17:07:39 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: MAC Address
Message-Id: <u9vg2y223o.fsf@wcl-l.bham.ac.uk>
"robertbu" <robertbu@hotmail.com> writes:
> "Hisham Mohamed" <hisham.mohamed@no-spam.engelhard.com.noSPAM> wrote in
> message news:3dd5236a$1@ec-nntp....
> > Is there a way to get a remote machine's MAC Address by supplying its IP
> or
> > host name? In a Win32 environment, the "nbtstat -a" command can do it, but
> > it returns other, unneeded info as well.
>
> arp -a is another way, but it still output some unneeded info.
Of course neither work for a remote machine (except for very small
values of remoteness).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 15 Nov 2002 10:56:38 -0800
From: Steven May <stevenm@blackwater-pacific.com>
Subject: Re: newbie to perl: printing literals(constants).
Message-Id: <ar3foq$q8p$1@quark.scn.rain.com>
Andrew Plata wrote:
> Hello my name is Andrew,
>
> I am a newbie to programming in perl and I was wondering if anyone can
> help me understand the author's script.
>
> Have a look a the following script:
>
> #! /usr/bin/perl
> # Program to illustrate printing literals
> print "The price is $100.\n";
> print "The price is \$100.\n";
> print "The price is \$",100, ".\n";
>
> The first two uncommented lines make sense to me. However the last line
> does not. Why is there a double quote after the $? and Why was the
> period placed infront of \n.
>
print "The price is $100.\n";
Here Perl will try to interpolate $100 as a scalar since the string is
in double quotes. If running with the -w switch (warnings turned on)
which you *definitely* want to do, Perl will complain about $100 being
an unitialized variable.
This may not be what you want....
But you probably do want the newline, so....
print "The price is \$100.\n";
Here the $ is escaped, so Perl will simply print the string with a
newline appended. This is probably what you want....
Now, the third example:
print "The price is \$",100, ".\n";
The only difference here is you are handing Perl a list to print instead
of a scalar.... It is essentially the same as saying:
my @list = ( 'The price is $', 100, ".\n" );
print @list;
Or:
print ( 'The price is $', 100, ".\n" );
Note that the following
print "@list";
will NOT result in the same output. Look up $" to find out why.....
As far as the '.' goes, in a quoted string, it is a period.
Out in unquoted land, it is a concatenation operator, which another
kettle of fish entirely....
hth,
s.
------------------------------
Date: Fri, 15 Nov 2002 17:15:24 GMT
From: "robertbu" <robertbu@hotmail.com>
Subject: Re: Reading an input file as scalar.
Message-Id: <MY9B9.250$br6.74@nwrddc03.gnilink.net>
> I'm trying to read an input file into a scalar, as per the Perl docs,
> however it doesn't work... Has anyone encountered this in the past?
> Is there a workaround?
> Code:
> $ui = `cat $file`;
The sample code you pulled from the perl docs executes the 'cat' command and
puts its output to STDOUT in the variable $ui. Windows (and I am assuming
you are on Window) does not have a 'cat' command. 'type' will work. Also
experiment with other programs or shell commands: 'dir', 'tree', 'vol ',
'ipconfig'...
== Rob ==
>
> Error:
> 'cat' is not recognized as an internal or external command,
> operable program or batch file.
>
> -Hisham
>
>
------------------------------
Date: 15 Nov 2002 17:29:49 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Reading an input file as scalar.
Message-Id: <u9lm3u212q.fsf@wcl-l.bham.ac.uk>
"robertbu" <robertbu@hotmail.com> writes:
[ attribution missing ]
> > I'm trying to read an input file into a scalar, as per the Perl docs,
> > however it doesn't work... Has anyone encountered this in the past?
> > Is there a workaround?
>
> > Code:
> > $ui = `cat $file`;
>
> The sample code you pulled from the perl docs executes the 'cat' command and
> puts its output to STDOUT in the variable $ui.
I'm curious where whe OP found this. It's not the answer given to
this question in the FAQ: "How can I read in an entire file all at
once?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 15 Nov 2002 09:33:05 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Reading an input file as scalar.
Message-Id: <3DD52FD1.2070002@vpservices.com>
robertbu wrote:
[attribution to OP foolishly removed by robertbu]
>>I'm trying to read an input file into a scalar, as per the Perl docs,
>>however it doesn't work... Has anyone encountered this in the past?
>>Is there a workaround?
>>
>
>>Code:
>>$ui = `cat $file`;
>>
>
> The sample code you pulled from the perl docs executes the 'cat' command and
> puts its output to STDOUT in the variable $ui. Windows (and I am assuming
> you are on Window) does not have a 'cat' command.
Correction: windows does not come with a built in 'cat' command, but it
does "have a 'cat' command" since several are freely available (e.g.
cygwin, ppt, etc.).
> 'type' will work.
But would be an extremely poor choice for this task (as, in fact, would
'cat'). I suggest looking at perlfaq5 which includes a section titled
"How can I read in an entire file all at once?"
--
Jeff
------------------------------
Date: 15 Nov 2002 17:39:10 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Reading an input file as scalar.
Message-Id: <ar3bfu$f4psm$1@fu-berlin.de>
Brian McCauley <nobull@mail.com> wrote:
> "robertbu" <robertbu@hotmail.com> writes:
>> > I'm trying to read an input file into a scalar, as per the Perl docs,
>> > however it doesn't work... Has anyone encountered this in the past?
>> > Is there a workaround?
>>
>> > Code:
>> > $ui = `cat $file`;
>>
>> The sample code you pulled from the perl docs executes the 'cat' command and
>> puts its output to STDOUT in the variable $ui.
> I'm curious where whe OP found this. It's not the answer given to
> this question in the FAQ: "How can I read in an entire file all at
> once?"
it is in version 5.6.1:
| On very rare occasion, you may have an algorithm that
| demands that the entire file be in memory at once as one
| scalar. The simplest solution to that is
| $var = `cat $file`;
[...]
seems that it has been removed since 5.8.0
regards, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Fri, 15 Nov 2002 18:29:19 GMT
From: "robertbu" <robertbu@hotmail.com>
Subject: Re: Reading an input file as scalar.
Message-Id: <32bB9.3986$nQ4.558@nwrddc01.gnilink.net>
"Brian McCauley" <nobull@mail.com> wrote in message
news:u9lm3u212q.fsf@wcl-l.bham.ac.uk...
> "robertbu" <robertbu@hotmail.com> writes:
>
> [ attribution missing ]
>
> > > I'm trying to read an input file into a scalar, as per the Perl docs,
> > > however it doesn't work... Has anyone encountered this in the past?
> > > Is there a workaround?
> >
> > > Code:
> > > $ui = `cat $file`;
> >
> > The sample code you pulled from the perl docs executes the 'cat' command
and
> > puts its output to STDOUT in the variable $ui.
>
> I'm curious where whe OP found this. It's not the answer given to
> this question in the FAQ: "How can I read in an entire file all at
> once?"
>
I have the Perl 5.6.1 from ActiveState and the FAQ for "How can I read in an
entire file all at once?" says:
| On very rare occasion, you may have an algorithm that
| demands that the entire file be in memory at once as
| one scalar. The simplest solution to that is
|
| $var = `cat $file`;
My post assumed that the OP did not understand the sample code he copied.
== Rob ==
------------------------------
Date: 15 Nov 2002 13:36:32 -0500
From: Arnar Mar Hrafnkelsson <addi@umich.edu>
Subject: Re: Reading an input file as scalar.
Message-Id: <xfsvbs4qwuhb.fsf@blue.engin.umich.edu>
> > > Code:
> > > $ui = `cat $file`;
> >
I'm not sure if the actual question has been answered already.
My apologies if so.
What about something like:
{ local (*FH,$/); open(FH, "<$file") or die "$!\n"; $ui = <FH>; }
That is completely platform independant and should work everywhere,
right?
-- Arnar.
------------------------------
Date: Fri, 15 Nov 2002 08:06:38 -0600
From: Abernathey Family <family2@aracnet.com>
Subject: Re: Redhat 8.0 and Perl
Message-Id: <3DD4FF6E.6B335FDB@aracnet.com>
Jay Calvert wrote:
>
> I know this generally not the place for this type of question but I was
> wondering if anybody else has had this problem.
>
> I have Redhat 8.0 and perl was included (5.8.0)
>
> I do not have much experience with perl but it seems that the following
> should work
>
> test.pl
> --------
> !# /usr/bin/perl
> print "Hello, World";
> --------
--snip---
#!/usr/bin/perl
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4125
***************************************