[18106] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 266 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 10 14:07:29 2001

Date: Sat, 10 Feb 2001 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981831908-v10-i266@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 10 Feb 2001     Volume: 10 Number: 266

Today's topics:
    Re: Best Way To Split & Initialize redinger@maine.rr.com
    Re: Can't read entire file into string. <jdf@pobox.com>
    Re: capturing diagnostics <jdf@pobox.com>
    Re: Devel DProf and " dprofpp " <jdf@pobox.com>
    Re: Get all files name in a directory <katz@underlevel.net>
        Help Newbie stuck loads of question..hope this is the r rab24@my-deja.com
    Re: How to map (undef,undef) to (), but (undef,$y) to ( gnari@my-deja.com
    Re: How to map (undef,undef) to (), but (undef,$y) to ( <bart.lateur@skynet.be>
        How to send HTML email from Perl using CGI <whitevanman@btinternetREMOVE.com>
    Re: Modules/Constants. (Garry Williams)
    Re: non repeating random numbers <jdf@pobox.com>
        Perl and database <lxq79@hotmail.com>
        Perl and Networking qurob@hotmail.com
        Processing form arrays in perl.. help !! <totalmailer@yahoo.com>
    Re: Processing form arrays in perl.. help !! <lxq79@hotmail.com>
        Profile output in tmon.out <kevp@nipltd.com>
    Re: Sending email from Perl Script on NT <baumbach@bellatlantic.net>
    Re: splitting a string on the / character <jdf@pobox.com>
    Re: This is driving me nuts and I need a guru <gaverth@home.com>
        undef ? (Brcin)
    Re: undef ? <joe+usenet@sunstarsys.com>
    Re: undef ? <callgirl@la.znet.com>
    Re: UNIX core dumps - Segmentation Fault <bowman@montana.com>
    Re: use pack() to uuencode long strings? <jdf@pobox.com>
    Re: use pack() to uuencode long strings? <dshafer@mail.utexas.edu>
        who is responsible ? <nowayandnohow@hotmail.com>
    Re: who is responsible ? <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 10 Feb 2001 14:27:13 GMT
From: redinger@maine.rr.com
Subject: Re: Best Way To Split & Initialize
Message-Id: <963j3u$2qo$1@nnrp1.deja.com>

In article <slrn9893la.fon.tadmc@tadmc26.august.net>,
  tadmc@augustmail.com wrote:
> redinger@maine.rr.com <redinger@maine.rr.com> wrote:
> >My reference example (This code isn't actually meant to be runnable,
>
> Why not?

Because then people would have told me that my program doesn't actually
do anything useful. I know this group well enough. ;)

> >open FILE, "my_file";
>
> You should always, yes *always*, check the return value from open():

Certainly, I agree. My fault for forgetting that in this example.

>    my ($fld1, $fld2, $fld3, $fld4) = map {defined() ? $_ : ''} split /

And this is exactly what I wanted! Thank you everybody for the pointer
to map.

Christopher


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: 10 Feb 2001 09:42:02 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Can't read entire file into string.
Message-Id: <u262ha6d.fsf@pobox.com>

Mario <m_ario@my-deja.com> writes:

> In article <pugzjnhy.fsf@pobox.com>,
>   Jonathan Feinberg <jdf@pobox.com> wrote:
> > Mario <m_ario@my-deja.com> writes:
> >
> > > It's not an error,it behaves in this way (reading a line at once).
> > > You read the entire file by accessing all the lines sequencially.
> >
> > This is misleading.  The correct (efficient, commonly used, idiomatic)
> > way to do it is described in perlfaq3.
> >
> 
> Thanks,I didn't know about this way.
> 
> However it's hard to say it is the correct way in absolute: if you have
> to read a 1GB file and write it in another file,it is not so efficient.

Of course it's wrong to read an entire 1G file into core, using any
method.  My point was that if you wish to read an entire file into
a single scalar, you should do so using the method outlined in the
FAQ.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: 10 Feb 2001 10:30:11 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: capturing diagnostics
Message-Id: <4ry2h7y4.fsf@pobox.com>

mjd@plover.com (Mark Jason Dominus) writes:

> In article <Pine.BSO.4.32.0102081835070.25950-100000@zen.moldsandwich.com>,
> Ted Fiedler  <tfiedler@zen.moldsandwich.com> wrote:
> >how would I capture the output when use diagnostics; is used? It runs
> >several screen lengths and have tried prog.pl > 1  and prog.pl | less
> >and others. what am i missing?
> 
> Every program has two output streams, called STDOUT and STDERR.
> Erorrs go to STDERR; normal output goes to STDOUT.

[snip typically helpful mjd explanation of shell redirection]

Unfortunately the OP is on a Win32 box.  I have never been able to
make stream redirection work as advertised using the Win32 command
prompt.  I'd recommend the Cygwin port of bash for all programmers use
use Windows.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: 10 Feb 2001 10:15:29 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Devel DProf and " dprofpp "
Message-Id: <d7cqh8mm.fsf@pobox.com>

"Godzilla!" <godzilla@stomp.stomp.tokyo> writes:

> Perl documentation is so poorly written, it could very well be I
> cannot correctly decipher these attempts at documentation.

Only a coward who hides behind fake names and addresses could dare to
emit something that is simulaneously so insulting and so wrong.  

The genius of Godzilla is that in spite of the fact that h(?:is|er)
statements are obviously well-crafted trolls, not reflecting a genuine
interest or opinion, they are so very well-crafted that they elicit
emotional responses like the one that prompted me to post.

What a waste!

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: 10 Feb 2001 14:00:18 -0500
From: Jordan Katz <katz@underlevel.net>
Subject: Re: Get all files name in a directory
Message-Id: <m3hf22icsd.fsf@underlevel.underlevel.net>

cfedde@fedde.littleton.co.us (Chris Fedde) writes:

[snip]
>     perl -p -i.bak -e '/oldword/newword/g' /home/bk/*

Correct me if I'm wrong, but I think you meant:

  perl -p -i.bak -e 's/oldword/newword/g' /home/bk/*
-- 
Jordan Katz <katz@underlevel.net>  |  Mind the gap


------------------------------

Date: Sat, 10 Feb 2001 15:00:02 GMT
From: rab24@my-deja.com
Subject: Help Newbie stuck loads of question..hope this is the right forum
Message-Id: <963l1i$47m$1@nnrp1.deja.com>

Thanks for looking at this, Im on a perl crash course. Id really
appreciate it if you could help me understand this script. Im trying to
modify it but I dont understand most of it.

what does $1 mean  is it just a scalar varible


what does these lines do

$gamename=~s/ {2,}//g;
/(\w+)\.dat/;  Where can I find out about regular expressions

and how do I make the script below print out a table with the varible
$gamename linking to a href containing the value $productcode


In this script

 ......................


<SERVER LANGUAGE="perl">
my %images=
('1',"one",'2  ',"two",'3  ',"thee"  ,'4   ',"four",'5  ',"five",'6 ',"s
ix",'7',"seven",'8',"eight");

my $leftcell ="<TD ALIGN='LEFT' VALIGN='top'class='fpsmallinks'>";
my $rightcell="<TD ALIGN='LEFT' VALIGN='top' class='fpsmallinks'>";
my $endcell  ="</TD>";
my $midcell  ="$endcell$rightcell";

my %games=();
#
# Open the product file and read in the products
#
open
OLDFILE,"< /web/content/example/data/releasedates/release_prod.txt";
my @products=<OLDFILE>;
close OLDFILE;
#
# Open the emails directory and count number of relevant files
#
opendir EMAILDIR,"/web/content/example/data/releasedates/emails";
my @emailfiles= sort grep /\w+\.dat/,readdir(EMAILDIR);
#
# For each file in EMAILDIR
#
for (@emailfiles)
{
  my $namelistfile=$_;
  /(\w+)\.dat/;
  my $productcode=$1;
  open NAMELIST,"< /u02/web/content/example/data/releasedates/emails/
$namelistfile";
  my @recipients=<NAMELIST>;
  close NAMELIST;
  $games{$productcode}=@recipients;
}

print "<table width=100% border=0 cellspacing=0 cellpadding=3>";
print "<TR><TD ALIGN='LEFT' class='fpsmallinks'colspan=2>Game</TD><TD
ALIGN='LEFT'class='fpsmallinks'>Platform</TD></TR>";
my $i=1;
#my $a;
#my $b;
#my $button;
my $chartno;

for (sort { $games{$b} <=> $games{$a} } keys %games)
{
  my $test=$_;
  my $game=(grep /$test/,@products)[0];
  my $gamename=substr $game,31,81;
  my $platform=substr $game,172,5;

  $gamename=~s/ {2,}//g;
  $gamename="Product Code: $test" if ($gamename eq "");
  print "<TR>$leftcell<font
class=fpsmalltitle>$i.</font>$midcell$gamename$midcell$images{$platform}
$endcell</TR>";
  last if (++$i>5);
}
print "</TABLE>";
</SERVER>

 ............................


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Sat, 10 Feb 2001 16:13:39 GMT
From: gnari@my-deja.com
Subject: Re: How to map (undef,undef) to (), but (undef,$y) to (undef,$y)?
Message-Id: <963pbf$7eb$1@nnrp1.deja.com>

In article <962fsr$h9o@netnews.hinet.net>,
  "John Lin" <johnlin@chttl.com.tw> wrote:
> Dear all,
>
> Today I found a bug in my program:
>
> sub foo {
>     # some query here
>     my($x,$y) = (undef,undef);  # got undef results after query
>     return map { if(defined) { s/^\s+//; s/\s+$// } $_ } ($x,$y);
> }
>
> if(my $found = my($x,$y) = foo) { print "found: $x,$y" }
> else { print "not found" }
>
> I didn't notice that if the query in foo() returns (undef,undef)
> I still got $found == 2, not $found == 0.
>
> To get rid of the bug, I have to modify the original return map {...}
> which was used to trim the leading and trailing spaces of the result.
>
> I found I couldn't write such a map to get all the possible results:
> ($x,$y) or ($x,undef) # ($x) is also OK # or (undef,$y)
> or () # instead of (undef,undef), because I want to make $found==0
>
actually it does not matter how much you change foo, as your problem
is in your
  $found = my($x,$y) = foo
assignement

here you are assigning whatever foo returns to a list ($x,$y) which
has always exacly 2 elements, although those can be undef
so the $found = my($x,$y)  will return always

you can test this by
perl -e'@a=($x,$y)=();print @a."\n";'

you should use some other method to test the result. for example:
$found=grep {defined $_} my ($x,$y)=foo;
here found is the number of not undef in ($x,$y)

if empty string is same as undef for your purposes:
my ($x,$y)=foo;$found=("$x$y" eq '');
here found is 0 if both were undef, else 1

gnari


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Sat, 10 Feb 2001 16:58:55 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to map (undef,undef) to (), but (undef,$y) to (undef,$y)?
Message-Id: <aqsa8t4bkb08pu29c0dt6c5orb0psh8fsj@4ax.com>

John Lin wrote:

>Subject: How to map (undef,undef) to (), but (undef,$y) to (undef,$y)?

	@a = (undef, qw(a b c), undef, undef);
	while(@a and not defined $a[-1]) {
	    pop @a;
	}

	use Data::Dumper;
	print Dumper \@a;

use
	@defined = grep defined, @a;

if you want to get rid of all the undef's.

-- 
	Bart.


------------------------------

Date: Sat, 10 Feb 2001 16:44:07 -0000
From: "Mark la mar" <whitevanman@btinternetREMOVE.com>
Subject: How to send HTML email from Perl using CGI
Message-Id: <tdeh6.29561$Vd5.120507@news11-gui.server.ntli.net>

Hi,

Can somebody please help me with this one. I`m wanting to senda small email
as HTML (just like Outlook does) using sendmail. I feel that sendmail isn`t
helping me out here and wonder what else to try.
As you can probably tell, I`m not very experienced with Perl, but have
written a few successful scripts.

Thanks for your time.




------------------------------

Date: Sat, 10 Feb 2001 14:27:24 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Modules/Constants.
Message-Id: <gdch6.2193$OO2.10184@eagle.america.net>

On Fri, 09 Feb 2001 00:48:54 +0000, Kelly Dorset
<dorsettest@uk.insight.com> wrote:
><big snip>
>> >any more ideas?!
>> 
>> Show the code that fails.  Of course it needs to be suitably trimmed.
>> The code should exhibit the problem.
>
>ok.  starting with the constants file (pebbleconst.pm): 
>
>------------------------------------
>sub BEGIN {  
>    
>    print "Const module imported\n";
>    
>    require Exporter;
>    use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
>
>    @ISA = qw(Exporter);
>    @EXPORT = qw(
>            C_SYSTEM 
>            C_HELLO
>            C_PING_REQ 
>            C_PING_REPLY 
>		<snip>
>		);
>    @EXPORT_OK = ();
>    %EXPORT_TAGS = ( );
>
>}
>
>use constant P_OK => 1;		
>use constant C_HELLO => 1;
>use constant C_PING_REQ => 2;
>use constant C_PING_REPLY => 3;

Okay, this code won't compile, so I still don't know what you're
*really* doing.

I'm going to make one more guess, though.  You don't have a package
statement in pebbleconst.pm.  If you copied actual code, then this is
the problem.  You need to review the Exporter manual page:

  ...
  SYNOPSIS
       In module ModuleName.pm:

         package ModuleName;
         require Exporter;
  ...

Your constants module needs a package statement.

  package pebbleconst;

-- 
Garry Williams


------------------------------

Date: 10 Feb 2001 10:23:00 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: non repeating random numbers
Message-Id: <8zneh8a3.fsf@pobox.com>

"Jason from The Workshop" <jason@cyborgworkshop.com> writes:

> What seems to be happening is that I have an array that has only the
> reference number for the questions that the user has been asked
> allready.

You are going about it backwards.

   # create an array of indices into the list of questions
   @q_index = (0 .. @questions-1);
   # scramble it, using the method outlined in perlfaq4
   fisher_yates_shuffle( \@q_index );
   # then ask the questions in the shuffled order we just created
   ask_question($questions[$_]) foreach @q_index;

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: Sun, 11 Feb 2001 02:02:54 +0900
From: LXQ <lxq79@hotmail.com>
Subject: Perl and database
Message-Id: <20010211020254.19ff9b53.lxq79@hotmail.com>

Hi,

I am writing a script to send bulletin news to all the subscribers. The
subscribers' email addresses are taken from MySQL. There are about 4000
emails. About the bulletin, it is also different per email, so every
subscriber gets different bulletin depends on what they chose. The size of
every bulletin is around 50 Kbyte. My question is, is it right (efficient
enough) to do it this way? :
- Open the connection to the database, dump all email data to hash.
- Open connection again, dump all bulletin data to hash.
- Foreach the email hash, match it to the bulletin, and send it with
sendmail.

Thanks so much. 


------------------------------

Date: Sat, 10 Feb 2001 16:12:25 GMT
From: qurob@hotmail.com
Subject: Perl and Networking
Message-Id: <963p95$7dt$1@nnrp1.deja.com>



This is related to my previous posts about having a Perl program that
acts as an email client. I'm new to Perl, but have done C, Java, Visual
Basic, Pascal, assembly....My question is, does Perl have built-in
networking functions (shoulda checked the FAQ, I know) or would it be
more feasible/possible to open a telnet session from inside the perl
script? I basically want to be able to check a pop3 server for new
messages and download them, or send outgoing through a SMTP.




Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Sat, 10 Feb 2001 17:10:36 -0000
From: "abu eesaa" <totalmailer@yahoo.com>
Subject: Processing form arrays in perl.. help !!
Message-Id: <963sng$27n$2@taliesin.netcom.net.uk>


Hello one and all

could anyone advise how to process an array in a form back to the perl
script (in this case auction.cgi).

eg

have a form :

<form name="display" action="$ENV{'SCRIPT_NAME'}" method="POST">

this is followed by a list of files :

<input type='CHECKBOX' name='items[]' value='computers_subi1954078514'>

<input type='CHECKBOX' name='items[]' value='computers_subi121211212'>

<input type='CHECKBOX' name='items[]' value='computers_subi1211212'>

etc
etc

so when this is "actioned" how do I access the array that holds these items
:

I am trying this :

@items = $form{'items[]'}

this only seems to store the last ticked item.

Can any of you perl experts help.







------------------------------

Date: Sun, 11 Feb 2001 02:41:47 +0900
From: LXQ <lxq79@hotmail.com>
Subject: Re: Processing form arrays in perl.. help !!
Message-Id: <20010211024147.58cf7551.lxq79@hotmail.com>

I am beginner too, but I think this might help:

use CGI (qw:standard);
<input type=checkbox name=items value=computer001>
<input type=checkbox name=items value=computer002>

Then the 'actioned' part:
@items = param("items");

On Sat, 10 Feb 2001 17:10:36 -0000
"abu eesaa" <totalmailer@yahoo.com> wrote:

> 
> Hello one and all
> 
> could anyone advise how to process an array in a form back to the perl
> script (in this case auction.cgi).
> 
> eg
> 
> have a form :
> 
> <form name="display" action="$ENV{'SCRIPT_NAME'}" method="POST">
> 
> this is followed by a list of files :
> 
> <input type='CHECKBOX' name='items[]' value='computers_subi1954078514'>
> 
> <input type='CHECKBOX' name='items[]' value='computers_subi121211212'>
> 
> <input type='CHECKBOX' name='items[]' value='computers_subi1211212'>
> 
> etc
> etc
> 
> so when this is "actioned" how do I access the array that holds these
items
> :
> 
> I am trying this :
> 
> @items = $form{'items[]'}
> 
> this only seems to store the last ticked item.
> 
> Can any of you perl experts help.


------------------------------

Date: Sat, 10 Feb 2001 18:35:13 +0000
From: Kevin Pearcey <kevp@nipltd.com>
Subject: Profile output in tmon.out
Message-Id: <3A8589E1.A111F91E@nipltd.com>

I'm trying to profile some code going through mod_perl & mason. Using
the supplied scripts the output of the profile in tmon.out has plenty of
__ANON__ entries for the mason components, but appears to be missing the
reference code value required to match against the stored has of code
references.

Is there an option I need to supply to get these into the output?


eg. I currently get a line such as:

& 177 HTML::Mason::Commands __ANON__

But from the mason script it would appear to be looking for lines with a
CODE block in such as:

 HTML::Mason::Commands::CODE(0x862fd70)

Can this be changed some how?

Kevin Pearcey


------------------------------

Date: Sat, 10 Feb 2001 16:31:56 GMT
From: Jason Baumbach <baumbach@bellatlantic.net>
Subject: Re: Sending email from Perl Script on NT
Message-Id: <3A856CF0.3ACF4A14@bellatlantic.net>

I agree that LWP may be a dead end.  Unfortunately, this still leaves me
without email capabilities from within my Perl programs.

I only need to send (not receive) simple email messages.  I tried both
examples given in this mail thread but neither worked.  They both just
completed successfully and did not complain nor did I ever see any email
arrive from them.  I even tried an application named "Blat".  This is a
command line application written in C++ that has example wrappers written
in Perl.  Again, I was unable to get this to work.  I would explain but
this is a Perl newsgroup and you people are probably not interested.

I guess what I am trying to say is, Help!  I really need some simple way to
email people from within a Perl program on the Windows 2000 Server
platform.

Any and all reply will be appreciated.

Maggert wrote:

> On Fri, 09 Feb 2001 15:40:04 GMT, jgunnip@my-deja.com wrote:
>
> >Hi,
> >
> >Does anyone know why the following code to send email works perfectly
> >on Linux but not on Windows NT?  It doesn't complain (i.e. die()) when
> >I use it on NT.  I just never receive the email.
> >
>
>         I would hazard a guess that since Windoze systems have no
> native emailing facilities that posting it without mentioning an smtp
> server would just send it off to no mans land. Of course I could be
> wrong. I've never seen anyone use LWP to send an email.




------------------------------

Date: 10 Feb 2001 10:08:50 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: splitting a string on the / character
Message-Id: <hf22h8xp.fsf@pobox.com>

merlyn@stonehenge.com (Randal L. Schwartz) writes:

>         SET A MAN ON FIRE, he's warm for the rest of his life

Brief and painful though that life may be. :)

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: Sat, 10 Feb 2001 16:18:10 GMT
From: "Tim Gaverth" <gaverth@home.com>
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <6Rdh6.82820$B6.20289399@news1.rdc1.md.home.com>


<mintcake@my-deja.com> wrote in message news:9611g9$po$1@nnrp1.deja.com...
> If the SQL shown is real then I cannot explain it but since it
> obviously isn't...
>
> You say that sql_execute is inherited and ends with a dbresults()
> call.  Did you know that dbresults() is supposed to be called in a loop
> until it reurns NO_MORE_RESULTS.  Otherwise, if there is more than one
> result set then the next time you use the DB handle you get an error -
> and I bet you can guess what the error is.
>
> If your SQL contains more than one select statement (excluding those
> that select into server variables etc.) then this is what will happen.
>
Granted I'm obviously not an expert on this, but I thought, since I did read
a manual
or two, that dbresults is called once, after a dbsqlexec, then dbnextrow()
is to be
in a loop. Although I did just notice a problem with the below example. The
$row should be
a %row, as corrected below.

> In article <2Sxf6.67348$B6.17690467@news1.rdc1.md.home.com>,
>   "Tim Gaverth" <gaverth@home.com> wrote:
> > Thanks Abigail, but what's the fix? The db queries are processing all
> > results. Here's a sample of how I'm doing that:
> > ---
> > my $dbh = $self->{'dbh'}; #this is inherited
> > my $query = (
> >     "select fieldone, fieldtwo ",
> >     "from db1..table1 ",
> >     "where crit = value ",
> >     );
> > $self->dbcmd($dbh,$query) || return undef;
> > $self->sql_execute($dbh) || return undef; #my sql_execute is
> inherited and
> > ends with a dbresults command
> > my $results = [];
> > while ( my $row = $dbh->dbnextrow(1) ) {
> >     push (@$results, $row);
> > }
while ( my %row = $dbh->dbnextrow(1) ) {
    push (@$results, \$row);
}
This will give properly return an array ref of hash refs.

> > return $results;
> >
> > Any more thoughts?
> >
> > Abigail <abigail@foad.org> wrote in message
> > news:slrn97srcg.6au.abigail@tsathoggua.rlyeh.net...
>
>
> Sent via Deja.com
> http://www.deja.com/




------------------------------

Date: Sat, 10 Feb 2001 17:17:11 GMT
From: info@ultraviolet.li (Brcin)
Subject: undef ?
Message-Id: <rIeh6.914$Q8.49235@news.siol.net>

undef $/ ;
$_ = <STDIN> ;

What exactly does that undef thing do?


------------------------------

Date: 10 Feb 2001 12:37:39 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: undef ?
Message-Id: <m3k86ymobg.fsf@mumonkan.sunstarsys.com>

info@ultraviolet.li (Brcin) writes:

> undef $/ ;
> $_ = <STDIN> ;
> 
> What exactly does that undef thing do?

It changes the behavior of <> from "read the next line" to "read
the rest of the file in".  undef'ing $/ is referred to as enabling 
"slurp mode".  There is also a paragraph mode, but it's best you 
learn how to find answers to these questions by first looking for 
them in the extensive documentation that comes with perl.  See

  % perldoc perlvar

and look for the description of the $/ (aka input record separator)
variable.

It's up to you to decide what the F in RTFM stands for.

-- 
Joe Schaefer      And he puzzled three hours, till his puzzler was sore.  
                  Then the Grinch thought of something he hadn't before!
                                               -- Dr. Seuss


------------------------------

Date: Sat, 10 Feb 2001 10:06:07 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: undef ?
Message-Id: <3A85830F.1F98CCE5@la.znet.com>

Brcin wrote:
 
> undef $/ ;
> $_ = <STDIN> ;
 
> What exactly does that undef thing do?

One of a number of foremost tools, perhaps the
most important tool of any science, is timeless
Direct Observation.

A direct observation is below my signature. Your
best answer would be to test your syntax with
controlled parameters, then, quite logically,
observe results.

Godzilla!
--

TEST SCRIPT:
____________

#!perl

print "Content-type: text/plain\n\n";

$/ =~ s/\n/a newline character/;

print "Default Value Of \$/ Is: $/";

undef ($/);

if ($/)
 { print "\n\nUndefined Value Of \$/ Is: $/"; }
else
 { print "\n\nWhen Undefined, \$/ Holds No Value."; }

exit;


PRINTED RESULTS:
________________

Default Value Of $/ Is: a newline character

When Undefined, $/ Holds No Value.


------------------------------

Date: Sat, 10 Feb 2001 08:00:42 -0700
From: "bowman" <bowman@montana.com>
Subject: Re: UNIX core dumps - Segmentation Fault
Message-Id: <5Fch6.152$hF5.1046@newsfeed.slurp.net>


<hilljroberts@my-deja.com> wrote in message
news:961r32$ppu$1@nnrp1.deja.com...
> I have a basic question about core dumps.  Everytime my program runs it
> core dumps and doesn't do any editing to any files that it is supposed
> to.

And you see what when you examine the core with the debugger?





------------------------------

Date: 10 Feb 2001 10:40:37 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: use pack() to uuencode long strings?
Message-Id: <zofufswa.fsf@pobox.com>

Drew Shafer <dshafer@mail.utexas.edu> writes:

> Is it possible to use pack() to UUEncode strings of more than 45
> bytes?  This seems to be a limitation I can't easily get around.

Have you tried the Convert-UU module, which implements uuencode and
uudecode?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: Sat, 10 Feb 2001 16:31:05 GMT
From: Drew Shafer <dshafer@mail.utexas.edu>
Subject: Re: use pack() to uuencode long strings?
Message-Id: <97qa8t4nlvo7uqv8l53lipqpdv8n7loh3d@4ax.com>

On 10 Feb 2001 10:40:37 -0500, Jonathan Feinberg <jdf@pobox.com>
wrote:

>Drew Shafer <dshafer@mail.utexas.edu> writes:
>
>> Is it possible to use pack() to UUEncode strings of more than 45
>> bytes?  This seems to be a limitation I can't easily get around.
>
>Have you tried the Convert-UU module, which implements uuencode and
>uudecode?

I have.  I would like to use pack() for a couple of reasons:
1. It would be supported on more machines than Convert-UU, which
I don't think is a part of the standard distro.
2.  The Convert-UU module inserts newline characters every so-many
bytes.  I want to end up with a newline-free string.

Basically what I'm trying to do is send a binary file over a a
text-based socket connection using the IO::Socket::INET module.  I am
breaking the file up into bite-sized chunks and uuencoding/decoding it
on the fly.  I am fairly new to the INET module, but what I do know is
that if there is a newline in the middle of the string you want to
send, it makes the receiving end think that several smaller strings
have been sent, which screws up some handshaking/error checking that
my script does in between sending/receiving chunks of the file.

Right now what I'm doing as a workaround is using pack()/unpack() to
convert between the binary data and a string of hex digits which is
easy to send, but takes up twice the space as the original data (each
byte generates two hex characters).  This works just fine, but I'd
like to use uuencoding/decoding because it generates a much smaller
encoded file.

Drew


------------------------------

Date: Sat, 10 Feb 2001 16:25:01 GMT
From: "nowayandnohow" <nowayandnohow@hotmail.com>
Subject: who is responsible ?
Message-Id: <xXdh6.7067$bu4.1294448@typhoon2.ba-dsg.net>

Who is the "responsible" make r of cgi.pm ?

where can i oficially read about it ?

where can i download it ?

thankfull for reply :-)

// Newbie




------------------------------

Date: Sat, 10 Feb 2001 18:07:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: who is responsible ?
Message-Id: <ifta8t4r4dplaeivb27qs5eorgson3f0an@4ax.com>

nowayandnohow wrote:

>Who is the "responsible" make r of cgi.pm ?
>
>where can i oficially read about it ?
>
>where can i download it ?

It's part of every perl distribution. Documentation is part of the
distribution, but you can also find it on the web, on CPAN, where you
can also download (an update for) it:

	<http://search.cpan.org/search?dist=CGI.pm

Click on "CGI" for the docs. Or, go here:

	<http://stein.cshl.org/WWW/software/CGI/cgi_docs.html >



It's written by Lincoln Stein, but please, don't make a habit of
bothering him with just any newbie question. He'd have nothing else to
do in his life but replying to mail. Instead, feel free to bother the
people at the appropriate newsgroup:
<news:comp.infosystems.www.authoring.cgi> (Note that this is a spam
protected newsgroup, which requires that you "register" yourself when
doing you first post.)

-- 
	Bart.


------------------------------

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 V10 Issue 266
**************************************


home help back first fref pref prev next nref lref last post