[11268] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4868 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 11 00:08:06 1999

Date: Wed, 10 Feb 99 21:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 10 Feb 1999     Volume: 8 Number: 4868

Today's topics:
    Re: Calculate yesterdays date <rra@stanford.edu>
    Re: Can't get hash to return properly. <ken.wilson@home.com>
        Connecting to a passwd protected web site (Larry Martell)
    Re: Converting CSV to LDIF (Ronald J Kimball)
    Re: Direcory listing <rra@stanford.edu>
    Re: Direcory listing (Thomas Brian Holdren)
    Re: Direcory listing (Ronald J Kimball)
    Re: Does Perl restrict regular expressions? <rick.delaney@home.com>
    Re: Does Perl restrict regular expressions? <jdf@pobox.com>
    Re: Does Perl restrict regular expressions? <uri@home.sysarch.com>
    Re: Extracting two bytes in hex out of an image file <rick.delaney@home.com>
    Re: Frustrating problem with Exporter (Ronald J Kimball)
    Re: Frustrating problem with Exporter (Ronald J Kimball)
    Re: fun with strings... (Ronald J Kimball)
    Re: fun with strings... (Ronald J Kimball)
    Re: fun with strings... <uri@home.sysarch.com>
    Re: how to use map for complex sort???? (Ronald J Kimball)
        Interactive Programs and Perl (Thomas Brian Holdren)
    Re: Interactive Programs and Perl <ebohlman@netcom.com>
    Re: newbie perl and cgi question..... (Ronald J Kimball)
    Re: NEWBIE Question about error checking string <ebohlman@netcom.com>
        Newbie Question <bobcarl@adams.net>
    Re: performance penalty: bareword, single quoting, doub <rick.delaney@home.com>
    Re: Python vs. Perl vs. tcl ? (Ilya Zakharevich)
    Re: shift multi-dimension array <rick.delaney@home.com>
    Re: Simple win32 questions from an unlearned Perl novit (Ronald J Kimball)
    Re: Simple win32 questions from an unlearned Perl novit <ebohlman@netcom.com>
    Re: strict (Ronald J Kimball)
    Re: testing for scalar/list/array <rick.delaney@home.com>
        Unix to DOS linefeed conversion? (Ken Williams)
        Updating activeperl on Win95 <ankadakia@hotmail.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 10 Feb 1999 18:57:00 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Calculate yesterdays date
Message-Id: <ylu2wtbqbn.fsf@windlord.stanford.edu>

nguyen van <nguyen.van@imvi.bls.com> writes:

> yes, I think that manip perl module is the best tool to calculate any
> date you want. I used it a lot, and it works very nicely.  the follwoing
> is the sample code

windlord:~> wc /usr/pubsw/lib/perl5/site_perl/Date/Manip.pm 
   5378   23939  184930 /usr/pubsw/lib/perl5/site_perl/Date/Manip.pm
windlord:~> time perl -MDate::Manip -e1
0.36u 0.05s 0:00.38 107.8%

Eek.

windlord:~> perl -MDate::Manip -e'print join ("\n", keys %INC, "")'
integer.pm
Cwd.pm
Carp.pm
Exporter.pm
strict.pm
Date/Manip.pm

Why on earth is a date manipulation module loading Cwd?

sub yesterday {
    my $now = time;
    my $then = time - 60 * 60 * 24;
    my $ndst = (localtime $now)[8] > 0;
    my $tdst = (localtime $then)[8] > 0;
    $then -= ($tdst - $ndst) * 60 * 60;
    $then;
}

should give you "this time yesterday" as a time_t, suitable for passing to
localtime or whatever else you need to do with it, modulo logic errors in
the above.  $ndst is whether we're currently in daylight savings time;
$tdst is whether the point 24 hours ago was in daylight savings time.  If
$tdst and $ndst are the same, a boundary wasn't crossed, and the
correction will subtract 0.  If $tdst is 1 and $ndst is 0, subtract an
hour more from yesterday's time since we gained an extra hour while going
off daylight savings time.  If $tdst is 0 and $ndst is 1, subtract a
negative hour (add an hour) to yesterday's time since we lost an hour.

All of this is because during those days when one switches off or onto
DST, a "day" isn't 24 hours long; it's either 23 or 25.

The explicit settings of $ndst and $tdst are necessary because localtime
only says it returns the system tm struct, and the system tm struct at
least on Solaris doesn't guarantee any particuliar positive value (like,
say, 1) for isdst, just a positive value.  And that value can potentially
be negative, if DST information isn't available (this sub just treats
those cases like no DST).

Note that between 1am and 2am on the day after the time zone switches off
daylight savings time, the exact hour of "yesterday" corresponding to the
current hour is not clearly defined.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 11 Feb 1999 03:55:01 GMT
From: Ken Wilson <ken.wilson@home.com>
Subject: Re: Can't get hash to return properly.
Message-Id: <36C25496.F271CCD4@home.com>

Thanks to all who assisted on this problem.  A review of the calling
subroutine was done and a mis-named variable in it was found to be the
culprit.


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

Date: Thu, 11 Feb 1999 03:58:18 GMT
From: larrym@imsi.com (Larry Martell)
Subject: Connecting to a passwd protected web site
Message-Id: <79tkgi$3c2@titan.imsi.com>

I have inherited some code that retrieves a page from a web site. It does it
all by brute force, calling gethostbyname, socket, connect, etc. Now, that
site is passwd protected, and the script fails, getting back "HTTP/1.0 401 
Unauthorized". We do have a login and passwd, and can get in with a browser, 
but how can I modify this script so that it can login and access the site?

Thanks,
larry

P.S. I know the whole script should be rewritten, but it's been in place
for years, and I really don't have time to redo it.



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

Date: Wed, 10 Feb 1999 23:13:35 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Converting CSV to LDIF
Message-Id: <1dn16nl.1ad0pvn1qeiddiN@bay1-169.quincy.ziplink.net>

What is LDAP?

(How long can we keep this going?  ;-)


Martin Lvnnar <martin.lonnar@edt.ericsson.se> wrote:

> LDIF = LDAP Data Interchange Format.
> 
> /martin
> 
> Steve Palincsar wrote:
> 
> > CSV stands for "commas separated value" and there
> > is a perl module in CPAN to help you parse it.
> >
> > What is LDIF?
> >
> > Aaron Tavistock wrote:
> > >
> > > What is a CSV file?
> > >
> > > I've done alot of scripts for converting other formats into LDIF, but I
> > > have no idea what CSV is.
> > >
> > > Aaron Tavistock
> > >
> > > Martin Lvnnar wrote:
> > > >
> > > > Hi,
> > > >
> > > > Is there a script/module to quickly convert CSV files to LDIF files?
> > > >
> > > > /martin lvnnar


-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 10 Feb 1999 18:57:44 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Direcory listing
Message-Id: <ylr9rxbqaf.fsf@windlord.stanford.edu>

Cybernetic Bear <cybear_x[nospam]@geocities.com> writes:

> I need to know how to read in a list of the files in a directory. I just
> need the file names for now.

openddir (D, 'directory') or die "Can't open directory: $!\n";
@files = readdir D;
closedir D;

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 11 Feb 1999 03:28:40 GMT
From: irc_addict@hotmail.com (Thomas Brian Holdren)
Subject: Re: Direcory listing
Message-Id: <79tip8$pu5$2@cletus.bright.net>

Get a camel book, I did. (but I left it at work!  ARRRGGHHH!)

Take your pick:

open(FILES, "ls /the/directory/you/want/to/open |");

# or..
@files = `ls /you/know`;     # I think this works if delimiter is \n, 
			     # but I have no camel book on hand.

# or maybe...
$files = `ls /you/know`;     #and then
@files = split /\n/, $files; #could work ;)

There is also a perl function to read the dir, but again I don't have my perl 
book.

Just trying to put back a little of what I take out of here ;) (hope I didn't 
put the wrong stuff though)

--
tbholdren

if ($anyone_cares) {print "Just Another Perl Newbie\n"}

>
>I need to know how to read in a list of the files in a directory. I
>just need the file names for now.
>
>Thanks
>Dave



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

Date: Wed, 10 Feb 1999 23:13:38 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Direcory listing
Message-Id: <1dn16q2.105fcer3tjv7kN@bay1-169.quincy.ziplink.net>

<cybear_x> wrote:

> I need to know how to read in a list of the files in a directory. I
> just need the file names for now.

In that case, Perl's documentation on perlfunc should be very helpful.
I imagine that glob() and readdir() will be of particular interest.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
            perl -le 'print "Just another \u$^X hacker"'


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

Date: Thu, 11 Feb 1999 03:35:55 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Does Perl restrict regular expressions?
Message-Id: <36C251FA.4906FAE2@home.com>

Jonathan Feinberg wrote:
> 
> Wouldn't it be a little more perlish to do:
> 
>   perl -lne '$c++ if /somepattern/;END{print "$c\n"}' file
> 

Wouldn't it be a little more perlish to do:

    perl -lpe '$c++ if /somepattern/}$_=$c;{' file

TMTOWTDI.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 11 Feb 1999 05:03:17 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: Rick Delaney <rick.delaney@home.com>
Subject: Re: Does Perl restrict regular expressions?
Message-Id: <m33e4dlh8a.fsf@joshua.panix.com>

Rick Delaney <rick.delaney@home.com> writes:

>     perl -lpe '$c++ if /somepattern/}$_=$c;{' file

Wow.  Abigail's silly trick has become an *idiom*.

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


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

Date: 10 Feb 1999 23:41:10 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Does Perl restrict regular expressions?
Message-Id: <x7hfstpn6h.fsf@home.sysarch.com>

>>>>> "JF" == Jonathan Feinberg <jdf@pobox.com> writes:

  JF> Rick Delaney <rick.delaney@home.com> writes:
  >> perl -lpe '$c++ if /somepattern/}$_=$c;{' file

  JF> Wow.  Abigail's silly trick has become an *idiom*.

that is scary! also it isn't in effective perl or the cookbook!
but i wouldn't recommend it for anything but one liner hacks and even
then it is just goofy.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 11 Feb 1999 03:58:46 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Extracting two bytes in hex out of an image file
Message-Id: <36C2574D.8F66FE18@home.com>

[posted & mailed]

Michael Shavel wrote:
> 
> foreach $file (@files){
>         open (FILE, "<$file");

Always check the return value of open.

>         @lines = <FILE>;
>                 foreach $line (@lines){
>         $fullstring .= $line   #get the whole file into one string

If you want the whole file in one string, you might want to try

    $fullstring = do {local $/;<FILE>};

>                 }
> #caption_return is in decimal!
> $caption_return = index $fullstring, $caption_begin;
> $hex_cap_return = sprintf("%lx",$caption_return);

You will need to seek back to the beginning of the file here since you
have already scanned through the whole thing.

    seek FILE, 0, 0 or die "Can't seek:  $!\n";

> read FILE, $caption_length, 2,$hex_cap_return;

HTH.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 10 Feb 1999 23:13:41 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Frustrating problem with Exporter
Message-Id: <1dn17fu.15y8wwscumivqN@bay1-169.quincy.ziplink.net>

Tom Williamson <tomw@action.cnchost.com> wrote:

> Exporting module:
> 
>     package mystuff::myglobal;
              ^^^^^^^

> Importing routine:
> 
>    use mymodules::myglobal;
         ^^^^^^^^^

Your package names don't match.

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -e'for(sort keys%main::){print if $$_ eq 1}
' -s  -- -' Just' -' another ' -'Perl ' -'hacker
'                   [rjk@linguist.dartmouth.edu]


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

Date: Wed, 10 Feb 1999 23:13:39 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Frustrating problem with Exporter
Message-Id: <1dn1777.8zki6wh01fh1N@bay1-169.quincy.ziplink.net>

Tom Williamson <tomw@action.cnchost.com> wrote:

> So what's the answer to my question?   Or do you know?

Apparently you missed it.  Here it is again:

> Jonathan Feinberg wrote:
> 
> > > @EXPORT = qw( MYSYM1 MYSYM2 );
> >
> > You haven't exported $MYSYM1 or $MYSYM2 there.


If you want to export the scalar variables $MYSYM1 and $MYSYM2, then
@EXPORT (or @EXPORT_OK) should contain '$MYSYM1' and '$MYSYM2'.


> I simply would like to know if (1) The Export module works for this
> purpose and (2) if there is an easier/better way to do this?

Yes, it does, but you have to use it correctly.  ;-)


> Also, here's a novel concept:  If newbie posts irritate you (and they
> apparently do), don't read/answer them.

Where did you get that from?  Jonathan directed you to where @ISA is
documented, jokingly suggested you try Python (since you commented that
you hate Perl), and then pointed out exactly why your code was not
working.

Your attitude is entirely uncalled for.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
perl -e'$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'


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

Date: Wed, 10 Feb 1999 23:13:43 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: fun with strings...
Message-Id: <1dn1813.16vjrna1eztcpkN@bay1-169.quincy.ziplink.net>

Allan M. Due <Allan@due.net> wrote:

> Ronald J Kimball wrote:
> :Marcos <alves@webmetro.com> wrote:
> :> I need to be expand the \n and \t sequences to actual newlines and tabs.
> :s/(\\[nt])/"\"$1\""/gee;
> 
> Can't resist:  gee that's cool.

Did you notice my sig?  :)

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
perl -e'$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'


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

Date: Wed, 10 Feb 1999 23:13:42 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: fun with strings...
Message-Id: <1dn17nb.aec6fnlg36izN@bay1-169.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> 

I wrote my solution on the assumptions that

a) the substitution may need to be extended to other escape sequences

and

b) redundancy should be avoided as much as possible.

> #!/usr/local/bin/perl -w
> use Benchmark;
> my $x =
> 'This is a string\nwith \tpseudo-tabs and \npseudo-newlines\t in it.\n';
> my %replace = ( n => "\n", t => "\t" );
> 
> timethese(1 << (shift || 0), {

>    Bart   => sub { $_ = $x; s/\\([nt])/$replace{$1}/g },

In order to extend this solution, you have to update the %replace hash
and the regular expression.

This one is also rather redundant.  Each escape sequence is specified
three times; twice in the hash, and once in the regex.


>    Larry  => sub { $_ = $x; s/\\([nt])/$1 eq 'n' ? "\n" : "\t"/eg },

To extend this solution, you have to update the regex, and nest a lot of
?: operators.  Ick.

Also redundant; all escape sequences will be specified three times,
except the last, which will be specified twice.


>    Ronald => sub { $_ = $x; s/(\\[nt])/"\"$1\""/gee },

To extend this solution, you simply update the regex.

Each escape sequence is specified only once.


>    Uri    => sub { $_ = $x; s/\\n/\n/g; s/\\t/\t/g },

To extend this solution, you have to add an entirely new substitution
for each escape sequence.

Rather redundant; each escape sequence is specified twice.  But even
worse, you have a separate substitution for each escape sequence.

> });
> __END__
> 
> Benchmark: timing 16384 iterations of Bart, Larry, Ronald, Uri...
>       Bart:  2 wallclock secs ( 1.53 usr +  0.00 sys =  1.53 CPU)
>      Larry:  1 wallclock secs ( 1.53 usr +  0.00 sys =  1.53 CPU)
>     Ronald: 27 wallclock secs (26.58 usr +  0.00 sys = 26.58 CPU)
>        Uri:  1 wallclock secs ( 0.70 usr +  0.00 sys =  0.70 CPU)


Ah well...  As Larry said in his other post:

> So the performance is inversely proportional to the cleverness!  Not the
> first time, nor -- in all likelhood -- the last.  :-)

Darn.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
             perl -le 'print "Just another \u$^X hacker"'


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

Date: 10 Feb 1999 23:37:05 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: fun with strings...
Message-Id: <x7k8xppnda.fsf@home.sysarch.com>

>>>>> "RJK" == Ronald J Kimball <rjk@linguist.dartmouth.edu> writes:

  RJK> a) the substitution may need to be extended to other escape sequences

there are only a handful of escape sequences and \n and \t are among the
most common. how many times do you see \a or \f? he did only ask for \n
and \t. 

  RJK> b) redundancy should be avoided as much as possible.

why is that a criterion? my solution is simple to understand which is as
important. and it is much faster than your which may be important.

  >> Uri    => sub { $_ = $x; s/\\n/\n/g; s/\\t/\t/g },

  RJK> To extend this solution, you have to add an entirely new
  RJK> substitution for each escape sequence.

  RJK> Rather redundant; each escape sequence is specified twice.  But even
  RJK> worse, you have a separate substitution for each escape sequence.

which is fine as you can see what sequences you are converting. this
code may be more maintainable (understandable) as it is easy to cut and
paste and create another one for \r. true, yours just requires adding an
'r' to the char class, but that isn't so much easier.

TIMTOWTDI (i have to macro that string!)

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 10 Feb 1999 23:13:44 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: how to use map for complex sort????
Message-Id: <1dn189k.1efwkey7mmkm1N@bay1-169.quincy.ziplink.net>

Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:

> @sorted = map { $_ -> [0] }
>           sort { $a -> [1] <=> $b -> [1] }
>           map { [ $_ -> [0], $_ -> [2] + $_ -> [3] ] }
>           map { [ $_, split /:/, $_ ] } @unsorted;

Too many maps.

@sorted = map { $_ -> [0] }
          sort { $a -> [1] <=> $b -> [1] }
          map { my(@cols) = split /:/, $_, 4;
                [ $_, $cols[1] + $cols[2] ] } @unsorted;

(Also had an off-by-one error. :)


-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
perl -e'for(sort keys%main::){print if $$_ eq 1}
' -s  -- -' Just' -' another ' -'Perl ' -'hacker
'                   [rjk@linguist.dartmouth.edu]


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

Date: 11 Feb 1999 03:14:47 GMT
From: irc_addict@hotmail.com (Thomas Brian Holdren)
Subject: Interactive Programs and Perl
Message-Id: <79thv7$pu5$1@cletus.bright.net>

Dear Perlers,

I am currently working on a user creation script in perl.  But I have run into 
a snag.  I need to run processes on a remote server from within the script, 
such as mkdir, chmod, etc.  Unfortunately, the only remote tools available to 
me are interactive programs like telnet and ftp.  Can perl interact with these 
programs?  For example, can it:

pseudocode:
--------------------

system("telnet $system");

(perl waits for /login: /)
login: (perl spits out $username\n)
(perl waits for /password: /)
password: (perl spits out $password\n)

# (perl does this)
# (perl does that)
---------------------

If perl can do this, the please point this befuddled newbie to the appropriate 
FAQ/Camel Chapter, or maybe you can share it with me yourself.  If it is not 
possible, perhaps you could gracefully point me towards a language that has 
this capability?

Thank you for your time, dear sirs/madames.

--
tbholdren
irc_addict@hotmail.com.nospam (remove .nospam to email me)

if ($anyone_cares) {print "Just Another Perl Newbie\n"}



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

Date: Thu, 11 Feb 1999 04:44:55 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Interactive Programs and Perl
Message-Id: <ebohlmanF6z3uv.2o9@netcom.com>

Thomas Brian Holdren <irc_addict@hotmail.com> wrote:
: programs?  For example, can it:

: pseudocode:
: --------------------

: system("telnet $system");

: (perl waits for /login: /)
: login: (perl spits out $username\n)
: (perl waits for /password: /)
: password: (perl spits out $password\n)

: # (perl does this)
: # (perl does that)
: ---------------------

I think you want Net::Telnet, which is part of the libnet bundle 
available from CPAN.  It will let your programs directly make telnet 
connections to remote systems without having to invoke a local 
interactive telnet client.


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

Date: Wed, 10 Feb 1999 23:13:45 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: newbie perl and cgi question.....
Message-Id: <1dn18ti.3wdc348o2qouN@bay1-169.quincy.ziplink.net>

system administrator <sys-admin@dont_spam_me.com> wrote:

> QUERY_STRING="user=bob&action=add"


> print("Content-type:text/html\n\n");
                     ^^

Missing a space.

> print("<html>");
> 
> @query_string = split(/&/,$ENV{"QUERY_STRING"});
> 
> foreach $index (0..$#query_string) {
> ($key,$value) = split(/=/, $query_string[$index]) || die "died on 2nd
> split...";
> $output{$key}=$value;
> };
> 
> print $output{"user"};
> print("</html>");

Hmm...


Assuming you fix the split-in-scalar-context problem, your CGI script
should output:

<html>
bob
</html>


Does that look like a legal HTML document to you?


-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 11 Feb 1999 04:05:24 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: NEWBIE Question about error checking string
Message-Id: <ebohlmanF6z210.sB@netcom.com>

@l@ <aqumsieh@matrox.com> wrote:
: In article <36BF394F.61B179FD@ix.netcom.com>,
:   paxtond@nospam.ix.netcom.com wrote:
: > I need to check a string to see if it contains any characters OTHER
: > THAN  0, 1, 2, 3, 4, 5, and the space key.

: >         unless ($FORM{'string1'} "CONTAINS  CHARACTERS OTHER THAN..."

: 	unless ($FORM{'string1'} =~ /[0-5 ]/) {

Methinks your caret fell out of your character class there...



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

Date: Wed, 10 Feb 1999 22:36:39 -0600
From: "Bob Carl, Jr" <bobcarl@adams.net>
Subject: Newbie Question
Message-Id: <36C25E57.31FF1358@adams.net>

Working with Perl for first time:

When running, I error out with illegal carriage return   \015

It says I should strip them out. How?

--
BC



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

Date: Thu, 11 Feb 1999 03:46:12 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: performance penalty: bareword, single quoting, double quoting
Message-Id: <36C25463.38B5724F@home.com>

Sean McAfee wrote:
> 
> However, I notice that -w still doesn't like lowercase hash keys when 
> used in a hash slice (eg, @hash{foo, bar}), and my code uses 
> expressions like that, so for the sake of uniformity I'll leave my
> keys quoted.

In this situation I always use

    @hash{qw/foo bar/};

which is one character less than quoted keys.

But you'd have to go up to 5 keys before you'd see any savings over a
list of bare words.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 11 Feb 1999 03:17:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Python vs. Perl vs. tcl ?
Message-Id: <79ti3l$1se$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Michael P. Reilly
<arcege@shore.net>],
who wrote in article <5arw2.1019$wD5.174071@news.shore.net>:
> : Perl does not use "underlying" C library calls.  See documentation for
> : $/ to know why.
> 
> Looks like the source code for Perl 5.005_02 does use the stdio library
> for <> (cf. perlio.c, sv.c, pp_hot.c op.c, toke.c).  I never said that
> either used gets() (in fact neither use gets, both use getc(), at some
> level).

You did not look hard enough.  Walk definitions of the "functions",
say, PerlIO_set_ptrcnt().

Ilya


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

Date: Thu, 11 Feb 1999 03:31:36 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: shift multi-dimension array
Message-Id: <36C250EE.ACCC23C2@home.com>

[posted & mailed]

hui chi chun wrote:
> 
> Could you tell me how to shift a multi-dimension array? shift seems to
> work only on single dimemsion array.

Perl really only has one dimensional arrays, on which shift will work
fine.  Multi-dimensional arrays are emulated by storing references to
other arrays.  You must dereference to get at the actual array
referenced by a particular index.

    shift @{ $a[1][1] };

perldoc perlref
perldoc perllol
perldoc perldsc

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 10 Feb 1999 23:13:36 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Simple win32 questions from an unlearned Perl novitiate (Can't find the win32 FAQ)
Message-Id: <1dn19k0.a09hcv12ln3cxN@bay1-169.quincy.ziplink.net>

Scott Carpenter <Sorry@No.Reply.Due.To.Spam> wrote:

> The first line of input is not printed after CTRL-Z.  If I add another
> "print @a;" right after the first, it prints all of the elements just
> fine.

This is a known issue with Perl on Windows.  In some cases, the first
line printed after reading input will 'disappear'.  Solution: output a
blank line first.

print "\n";

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
perl -e'$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'


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

Date: Thu, 11 Feb 1999 04:18:47 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Simple win32 questions from an unlearned Perl novitiate (Can't find the win32 FAQ)
Message-Id: <ebohlmanF6z2nB.1E8@netcom.com>

Scott Carpenter <Sorry@No.Reply.Due.To.Spam> wrote:
: On Tue, 09 Feb 1999 20:55:11 -0600, James Ludlow <ludlow@us.ibm.com>
: wrote:

: >ctrl-z should work.  Please elaborate on "strange results".

: If I try:
:    @a = <STDIN>;
:    print @a;

: The first line of input is not printed after CTRL-Z.  If I add another
: "print @a;" right after the first, it prints all of the elements just
: fine.  So:

Actually, the line is printed (as you can verify by redirecting output 
into a file) but it gets overwritten due to a bug in the Win32 console 
output routines.



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

Date: Wed, 10 Feb 1999 23:13:37 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: strict
Message-Id: <1dn19na.cdhw7tihsqm7N@bay1-169.quincy.ziplink.net>

James Ludlow <ludlow@us.ibm.com> wrote:

> I'll second that.  If you can't figure out 'man perldoc', you've got a
> bit more to learn before you start digging into a programming language.

Or you're not using Perl on a Unix platform.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 11 Feb 1999 04:13:31 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: testing for scalar/list/array
Message-Id: <36C25ABB.34233F85@home.com>

[posted & mailed]

Ronald J Kimball wrote:
> 
> Rick Delaney <rick.delaney@home.com> wrote:
> 
> > >   $ref_outside = \test();
> > >
> > > calls test() in a list context, returning (1, 2, 'a', 'b', 'c', 'd').
> >                     ^^^^^^^^^^^^
> > Why is this in a list context?  It looks like it should be scalar
> > context to me.
> 
> I have no idea.

Drat.  Oh well, my curiosity has subsided for now.  Maybe I'll ask again
(in a shiny new thread people won't be able to resist) when I forget
this tidbit and it bites me.

> All I know is that I stuck in a wantarray(), and it returned 1 for
> list context.  :)

Why didn't I think of that?

Thanks,

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Thu, 11 Feb 1999 04:13:30 GMT
From: tekkin@hotmail.com (Ken Williams)
Subject: Unix to DOS linefeed conversion?
Message-Id: <36c258ee.0@news.cgocable.net>

I have some text coming from a unix server that is in normal linefeed format.  
How could I use perl to convert this text to have a linefeed & carrige return 
so when it is displayed on a windows95 computer it will look proper (text is 
in a variable called $string).  Right now I take the text and display in a 
visual basic text box, and I get a small square box for each linefeed and its 
all on one line - not good. 

Thanks


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

Date: Thu, 11 Feb 1999 04:12:38 GMT
From: ANK <ankadakia@hotmail.com>
Subject: Updating activeperl on Win95
Message-Id: <79tlbe$ujf$1@nnrp1.dejanews.com>

Hi,  The latest version of perl on activeperl site is on based perl 5.005 I
have perl 5.00307. When I try to update, it says "1 file copied, nothing to
do.." Why it's doing like this, I have no idea, I am stuck with the old
version and cannot use LWP Any help is appriciated..


||Beautify|||||||||||||||
||||||||||Your|||||||||||
||||||||||||||Existance||
||ANK||||||||||||||||||||

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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 4868
**************************************

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