[23095] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5316 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 5 14:26:21 2003

Date: Tue, 5 Aug 2003 11:25:54 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 5 Aug 2003     Volume: 10 Number: 5316

Today's topics:
    Re: Getting substrings within a String (Tony)
    Re: Getting substrings within a String <noreply@gunnar.cc>
    Re: Getting substrings within a String <clay@panix.com>
    Re: Getting substrings within a String (Tad McClellan)
    Re: Getting substrings within a String <bdonlan@bd-home-comp.no-ip.org>
    Re: Getting substrings within a String <bdonlan@bd-home-comp.no-ip.org>
        Help with eval <visanand@cisco.com>
    Re: Help with eval <vernaza@force.stwing.upenn.edu>
    Re: Help with eval news@roaima.freeserve.co.uk
    Re: Help with eval (Tad McClellan)
    Re: HTTP::Request failed on HTTP/1.1 and Connection: Ke (Simon Tneoh)
    Re: HTTP::Request failed on HTTP/1.1 and Connection: Ke <abigail@abigail.nl>
    Re: Loading environment <nobull@mail.com>
        LogonAsUser <jochen.friedmann2@de.bosch.com>
    Re: LogonAsUser (Tad McClellan)
    Re: LWP::Simple and authentication <NOSPAM@bigpond.com>
        OO file handle for stdout <NOSPAM@bigpond.com>
    Re: OO file handle for stdout <jkeen@concentric.net>
    Re: OO file handle for stdout <REMOVEsdnCAPS@comcast.net>
    Re: OO file handle for stdout <NOSPAM@bigpond.com>
    Re: OO file handle for stdout <NOSPAM@bigpond.com>
    Re: OO file handle for stdout (Heinrich Mislik)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 3 Aug 2003 00:46:35 -0700
From: aanter@insight.com (Tony)
Subject: Re: Getting substrings within a String
Message-Id: <2f082a7e.0308022346.6076e7b7@posting.google.com>

Everyone,
     Thanks for the response. I found the documentation for Index()
about 30 minutes after I posted. Thanks to everyone who responded I
apprciate it.

Gunnar to answer your question what I am trying to do is pull a
particular segent out of an EDI document so i can tell what doc it is
so I can route it via Perl to the corret place. I know what the
segment is but not the value. So a line could look like

*anything*ST*850*anything*......

I solved it as:

my $pos = index($str, "ST");


-Tony
aanter@insight.com (Tony) wrote in message news:<2f082a7e.0308021545.3b454b1b@posting.google.com>...
> Hello All,
>     I am very new to Perl and I am trying to pull a substring out of a
> larger string as such:
> 
> xyxyxyxyxyxyZZxyxyxyxyxyx
> 
> I know if I get the index of ZZ in the string can use substr($string,
> $index, $len) where len is the number of charcters I want.
> 
> I am looking through the Programming Perl book from O'Reilly and I can
> not find any easy way to search through the string and get this value.
> 
> I have done this several time in java like such and I am trying to the
> same thing in Perl:
> 
> String str = "xyxyxyxyxyxyZZxyxyxyxyxyx";
> int len1 = str.indexOf("ZZ");
> String str2 = str.substring(len1, (len1 + "ZZ".length()));
> 
> I am sure between something I get here and what I am reading I will
> figure this out. Thanks in advance for any help
> 
> -Tony


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

Date: Sun, 03 Aug 2003 13:17:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Getting substrings within a String
Message-Id: <bgirdp$o93lq$1@ID-184292.news.uni-berlin.de>

Tony wrote:
> Gunnar to answer your question what I am trying to do is pull a 
> particular segent out of an EDI document so i can tell what doc it
> is so I can route it via Perl to the corret place. I know what the 
> segment is but not the value. So a line could look like
> 
> *anything*ST*850*anything*......
> 
> I solved it as:
> 
> my $pos = index($str, "ST");

Thanks for explaining. Suddenly it makes very much sense. :)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sun, 3 Aug 2003 13:00:28 +0000 (UTC)
From: Clay Irving <clay@panix.com>
Subject: Re: Getting substrings within a String
Message-Id: <slrnbiq1rc.9ql.clay@panix3.panix.com>

In article <2f082a7e.0308022346.6076e7b7@posting.google.com>, Tony wrote:
> Everyone,
>      Thanks for the response. I found the documentation for Index()
> about 30 minutes after I posted. Thanks to everyone who responded I
> apprciate it.
> 
> Gunnar to answer your question what I am trying to do is pull a
> particular segent out of an EDI document so i can tell what doc it is
> so I can route it via Perl to the corret place. I know what the
> segment is but not the value. So a line could look like
> 
> *anything*ST*850*anything*......
> 
> I solved it as:
> 
> my $pos = index($str, "ST");

Unrelated to Perl, but why would there be an element before an ST segment?
Is your segment terminator something other than a newline?

-- 
Clay Irving <clay@panix.com>
Human history becomes more and more a race between education and
catastrophe. 
- Herbert George Wells 


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

Date: Sun, 3 Aug 2003 10:21:24 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Getting substrings within a String
Message-Id: <slrnbiqa3k.ad8.tadmc@magna.augustmail.com>

Tony <aanter@insight.com> wrote:

> So a line could look like
> 
> *anything*ST*850*anything*......


Can *anything* include the "ST" character sequence?

Or did you mean to say *anything_NOT_containing_ST* instead?


> I solved it as:
> 
> my $pos = index($str, "ST");


What should that return when $str = 'The ST1300 rocks! ST 850 some more' ?

If "anything" really does mean _any_ thing, then you have
not solved your problem yet...




[snip TOFU. Please learn the proper way to format a followup.]

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 03 Aug 2003 14:17:29 -0400
From: bd <bdonlan@bd-home-comp.no-ip.org>
Subject: Re: Getting substrings within a String
Message-Id: <pan.2003.08.03.18.17.29.343869@bd-home-comp.no-ip.org>

On Sat, 02 Aug 2003 16:45:49 -0700, Tony wrote:

> Hello All,
>     I am very new to Perl and I am trying to pull a substring out of a
> larger string as such:
> 
> xyxyxyxyxyxyZZxyxyxyxyxyx
> 
> I know if I get the index of ZZ in the string can use substr($string,
> $index, $len) where len is the number of charcters I want.
> 
> I am looking through the Programming Perl book from O'Reilly and I can not
> find any easy way to search through the string and get this value.
> 
> I have done this several time in java like such and I am trying to the
> same thing in Perl:
> 
> String str = "xyxyxyxyxyxyZZxyxyxyxyxyx"; int len1 = str.indexOf("ZZ");
> String str2 = str.substring(len1, (len1 + "ZZ".length()));
> 
> I am sure between something I get here and what I am reading I will figure
> this out. Thanks in advance for any help

What do you want to pull out? In any case, a regex is what you want.
E.g., to get everything after ZZ:
$foo =~ s/^.*ZZ//;

See perldoc perlre for more info
-- 
Freenet distribution not available
You shall judge of a man by his foes as well as by his friends.
		-- Joseph Conrad



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

Date: Sun, 03 Aug 2003 14:19:06 -0400
From: bd <bdonlan@bd-home-comp.no-ip.org>
Subject: Re: Getting substrings within a String
Message-Id: <pan.2003.08.03.18.19.05.473475@bd-home-comp.no-ip.org>

On Sun, 03 Aug 2003 00:46:35 -0700, Tony wrote:


[Reply moved to bottom, where it belongs]

> aanter@insight.com (Tony) wrote in message
> news:<2f082a7e.0308021545.3b454b1b@posting.google.com>...
>> Hello All,
>>     I am very new to Perl and I am trying to pull a substring out of a
>> larger string as such:
>> 
>> xyxyxyxyxyxyZZxyxyxyxyxyx
>> 
>> I know if I get the index of ZZ in the string can use substr($string,
>> $index, $len) where len is the number of charcters I want.
>> 
>> I am looking through the Programming Perl book from O'Reilly and I can
>> not find any easy way to search through the string and get this value.
>> 
>> I have done this several time in java like such and I am trying to the
>> same thing in Perl:
>> 
>> String str = "xyxyxyxyxyxyZZxyxyxyxyxyx"; int len1 = str.indexOf("ZZ");
>> String str2 = str.substring(len1, (len1 + "ZZ".length()));
>> 
>> I am sure between something I get here and what I am reading I will
>> figure this out. Thanks in advance for any help
>> 
>> -Tony
> Everyone,
>      Thanks for the response. I found the documentation for Index()
> about 30 minutes after I posted. Thanks to everyone who responded I
> apprciate it.
> 
> Gunnar to answer your question what I am trying to do is pull a particular
> segent out of an EDI document so i can tell what doc it is so I can route
> it via Perl to the corret place. I know what the segment is but not the
> value. So a line could look like
> 
> *anything*ST*850*anything*......
> 
> I solved it as:
> 
> my $pos = index($str, "ST");

Why not:
$str =~ /(ST[0-9]+)/;
my $stnum = $1;
-- 
Freenet distribution not available
If I'm over the hill, why is it I don't recall ever being on top?
		-- Jerry Muscha



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

Date: Sun, 03 Aug 2003 15:34:39 -0700
From: Vishal Anand <visanand@cisco.com>
Subject: Help with eval
Message-Id: <3F2D8DFE.69C42D3@cisco.com>

I am trying to write a perl script that can parse a verilog file with
syntax like:

`if ABC == 1
  abc is set something
`else
  abc not set
`endif

The script will output the line depending on the varibles set by the
user. If I write the script specifically looking for "==" then it works
fine. However if I try to use eval with the following syntax then it
stops working:

sub ScanText {
my $file = shift; # filehandle to read from
my $scanTo = shift; # stop when input matches this (never if undefined)
my $ignore = shift; # true if we should ignore what we see
my $defined;

    if (/^\s*`if\s+(\S+)\s+(\S+)\s+(\S+)/) { # `){
            $var = $defines{$1};
            $cl = "\$defined = $var $2 $3";
            eval $cl;
            print "$defined = $1 $2 $3, Hash=$var\n";
            $_ = ScanText($file, "^\\s*`(endif|else)\\b", $ignore ||
!$defined); # `
            next unless (/^\s*`else\b/); # `)
            ScanText($file,"^\\s*`endif\\b",$ignore || $defined); # `)
            next;
    }

more code...

The trouble seems to be that once eval parses a true result, all
subsequent comparisons are also returned as true. The below debug
messages show this:

 = MEMRAM != 1, Hash=1
In ScanText 107 defined=, scanTo=^\s*`(endif|else)\b, ignore=1
1 = FLOP == 1, Hash=1

assign read =  unload & !empty_rd;
1 = BITWR == 1, Hash=

In the above the last eval returned true while it should have returned
false as $defines{"BITWR"} was not defined.

Any clue what is going wrong?

Thanks




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

Date: Mon, 4 Aug 2003 01:32:54 +0000 (UTC)
From: Paul Vernaza <vernaza@force.stwing.upenn.edu>
Subject: Re: Help with eval
Message-Id: <slrnbirdu6.s5g.vernaza@force.stwing.upenn.edu>

On Sun, Aug 03 2003 at 22:34 GMT, Vishal Anand <visanand@cisco.com> wrote:
> I am trying to write a perl script that can parse a verilog file with
> syntax like:

Not sure about what's going wrong with your code, but if it helps,
there appears to be a module on CPAN that parses Verilog (Verilog::Parser).

HTH...

-- 
Paul Vernaza			     		    University of Pennsylvania
Computer and Telecommunications Engineering	                 Class of 2004


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

Date: Mon, 4 Aug 2003 09:13:38 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: Help with eval
Message-Id: <i6h101-onu.ln1@moldev.cmagroup.co.uk>

Vishal Anand <visanand@cisco.com> wrote:
> I am trying to write a perl script that can parse a verilog file [...]

> `if ABC == 1
>   abc is set something
> `else
>   abc not set
> `endif

>     if (/^\s*`if\s+(\S+)\s+(\S+)\s+(\S+)/) { # `){
>             $var = $defines{$1};

Since you're using eval, consider what would happen if the verilog line
was something like this:

	`if ABC == system('rm'.chr(32).'*')

I presume that %defines contains the name/value pairs of your variables,
so $var is set to the value of verilog variable ABC...

>             $cl = "\$defined = $var $2 $3";

 ...which means that this will work if your variable has a value
(e.g. "$defined = 1 == 1"), but it will break if $var is undef (in such
cases you would need to insert the literal text "undef").

What's the name in the variable "$defined"? This is what will receive
the result of the boolean evaluation.

>             eval $cl;

What about checking the error value from eval?
	if ($@) { warn "Syntax error\n"; }

>             $_ = ScanText($file, "^\\s*`(endif|else)\\b", $ignore ||
> !$defined); # `
>             next unless (/^\s*`else\b/); # `)
>             ScanText($file,"^\\s*`endif\\b",$ignore || $defined); # `)
>             next;

Why are you doubling up the backslashes in the calls to ScanText?

> 1 = BITWR == 1, Hash=
> In the above the last eval returned true while it should have returned
> false as $defines{"BITWR"} was not defined.

If $defines{BITWR} is not defined then your eval will contain
syntactically invalid perl. (See my comments above.)

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Mon, 4 Aug 2003 07:46:46 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help with eval
Message-Id: <slrnbisldm.cak.tadmc@magna.augustmail.com>

news@roaima.freeserve.co.uk <news@roaima.freeserve.co.uk> wrote:
> Vishal Anand <visanand@cisco.com> wrote:

>>             ScanText($file,"^\\s*`endif\\b",$ignore || $defined); # `)

> Why are you doubling up the backslashes in the calls to ScanText?


Because the double quotes will eat one.

So then the question becomes:

   Why aren't you using single quotes instead of doubling up the backslashes?

:-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 4 Aug 2003 18:53:31 -0700
From: simon.tneoh@mybiz.net (Simon Tneoh)
Subject: Re: HTTP::Request failed on HTTP/1.1 and Connection: Keep-Alive
Message-Id: <a07bdd22.0308041753.2c82307d@posting.google.com>

Hi Abigail,
   I know that the error comes from the Java program, the nullpointer error.
   But what it confused me is: if I'm using an Internet Explorer version 5 to
access the page, it's working fine. If I use HTTP::Request, it'll fail. I tried
to simulate the headers in the IE's request in HTTP::Request, but I failed to
make it work. I just wonder if it's because HTTP::Request doesn't support
HTTP/1.1 and Keep-Alive properly?
   Thanks.

Regards,
Simon.

Abigail <abigail@abigail.nl> wrote in message news:<slrnbhfts1.1e7.abigail@alexandra.abigail.nl>...
> Simon Tneoh (simon.tneoh@mybiz.net) wrote on MMMDCVIII September MCMXCIII
> in <URL:news:a07bdd22.0307180516.3c1d95e2@posting.google.com>:
> -:  Hello all,
> -:     Thanks in advance for any helps provided.
> -:     I try to download a page through GET method with protocol HTTP/1.1
> -:  by
> -:  using HTTP::Request module and it fails.
> 
> And the error you show us is a Java trace. The Java program makes
> one of the most common errors in Java programs: nullpointer
> exception. 
> 
> But Java has *nothing* to do with the charter of this group.
> 
> 
> 
> Abigail


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

Date: 05 Aug 2003 09:02:24 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: HTTP::Request failed on HTTP/1.1 and Connection: Keep-Alive
Message-Id: <slrnbiuskv.pnu.abigail@alexandra.abigail.nl>

Simon Tneoh (simon.tneoh@mybiz.net) wrote on MMMDCXXVI September MCMXCIII
in <URL:news:a07bdd22.0308041753.2c82307d@posting.google.com>:
``  Hi Abigail,
``     I know that the error comes from the Java program, the nullpointer error.
``     But what it confused me is: if I'm using an Internet Explorer version 5 t
``  access the page, it's working fine. If I use HTTP::Request, it'll fail. I tr
``  to simulate the headers in the IE's request in HTTP::Request, but I failed t
``  make it work. I just wonder if it's because HTTP::Request doesn't support
``  HTTP/1.1 and Keep-Alive properly?


It's your Java program that *crashes*. That's were you have to look.
Properly written programs won't crash, regardless what their input is.

Fix your Java program (you do have its source, don't you?)


Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: 04 Aug 2003 18:00:33 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Loading environment
Message-Id: <u9k79tnyry.fsf@wcl-l.bham.ac.uk>

"Rodolfo Rojas" <usenetmail@latinmail.com> writes:

> I want to load a unix user environment within a Perl script,
> as when we do ". ./settings" in shell.

> Does anybody know if Perl has a simple and elegant way
> of doing it so?

The answer to the question you have asked is to use the do or require
functions.

  do "./settings.pl";

The Perl do() and require() will assume (just like shell's '.') that
the file you are loading to be written in the same language as the
calling script (i.e. Perl).

So settings.pl will look something like:

 $ENV{FOO}='BAR';

Of course, just like with a shell script, the settings will be lost
when the script exits.

I have answered the question you asked.  Numerous previous threads
have shown that most people who ask this question here really meant to
ask something else.

To find some of the numerous previous threads just remember that '.'
is an alias for the shell command source...

http://groups.google.com/groups?q=source+environment&meta=group%3Dcomp.lang.perl.*

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 5 Aug 2003 13:15:08 +0200
From: "Jochen Friedmann" <jochen.friedmann2@de.bosch.com>
Subject: LogonAsUser
Message-Id: <bgo3ju$9vo$1@ns2.fe.internet.bosch.com>

Hallo zusammen,

Ich versuche an einem PC (Winn2000 SP2 , mit Domainanbindung) einen Task als
anderer User zu starten.

Ich habe die Funktion Win32::AdminMisc::LogonAsUser
und...::CreateProcessAsUser verwendet. Leider funktioniert das kein
bisschen.

Hat vielleicht irgendwer Erfahrung mit diesem Modul ?

CODE:

{
 print "\nDomain      : ";
 my $domain = <STDIN>;
 chop $domain;
 print "\nBenutzername : ";
 my $user = <STDIN>;
 chop $user;
 print "\nPasswort    : ";
 my $passwort =<STDIN>;
 chop $passwort;
 print "\nTask        : ";
 my $task = <STDIN>;
 chop $task;

 if
(Win32::AdminMisc::LogonAsUser("$domain","$user","$passwort",LOGON32_LOGON_I
NTERACTIVE))
 {
  print "Successfully impersonating " . Win32::AdminMisc::GetLogonName() .
"\n";
 }

 else {print "\nfault";}

 Win32::AdminMisc::CreateProcessAsUser($task,
             "Flags", CREATE_NEW_CONSOLE,
                                     "XSize", 640,
                                     "YSize", 400,
                                     "X", 200,
                                     "Y", 175,
                                     "XBuffer", 80,
                                     "YBuffer", 175,
                                     "Title", "Title: $user" . "'s $task
program",
                                     "Fill", BACKGROUND_BLUE |
                                             FOREGROUND_RED |
                                             FOREGROUND_BLUE |
                                             FOREGROUND_INTENSITY |
                                             FOREGROUND_GREEN,
                                      );
}




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

Date: Tue, 5 Aug 2003 08:11:09 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: LogonAsUser
Message-Id: <slrnbivb7d.eqf.tadmc@magna.augustmail.com>

Jochen Friedmann <jochen.friedmann2@de.bosch.com> wrote:


>  chop $domain;


That is Perl 4 code. Perl 4 has been dead for many years.

   chomp $domain;


> (Win32::AdminMisc::LogonAsUser("$domain","$user","$passwort",LOGON32_LOGON_I
                                 ^       ^ ^     ^ ^         ^
                                 ^       ^ ^     ^ ^         ^

All of those quotes are useless. So why are they there?

   perldoc -q vars

      What's wrong with always quoting "$vars"?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 3 Aug 2003 21:19:36 +1000
From: "Gregory Toomey" <NOSPAM@bigpond.com>
Subject: Re: LWP::Simple and authentication
Message-Id: <bgir4c$oul7d$1@ID-202028.news.uni-berlin.de>

"reggie" <reggie@reggieband.com> wrote in message
news:5117aba8.0307310810.7620b6a0@posting.google.com...
> "Gregory Toomey" wrote
> > > when I do:
> > >
> > > use LWP::Simple;
> > > use LWP::UserAgent;
> > > use HTTP::Request;
> > > use HTTP::Request::Common;
>
> > #!/usr/bin/perl
> > use LWP::Simple;
> >
> > my $screen_scraper=get("http://username:password\@site.com/restofurl");
> > # @ has been escaped
> >
> > You can type URLS of the form
http://username:password@site.com/restofurl
> > straight into your browser to avoid getting the popup for basic
> > authentication.
>
> This does work in the browser, however it does not work within the
> script.  I saw and tried your previous post and assumed it did not
> apply to my situation.
>
> Is is possible the server would also do authentication against other
> headers being sent by traditional browsers?
>
> reggie.

Possibly, or it could be looking for a cookie.

gtoomey




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

Date: Tue, 5 Aug 2003 11:31:30 +1000
From: "Oxygene" <NOSPAM@bigpond.com>
Subject: OO file handle for stdout
Message-Id: <bgn1dd$q9nps$1@ID-202028.news.uni-berlin.de>

This may sound simple but I cant find the answer! I've been using
Archive::Zip and need an OO file handle for stdout.Something like

my $fh  IO::File->stdout.
writeToFileHandle($fh);

I've tried writeToFileHandle(<STDOUT>) and other variants but only get
errors.

Oxygene




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

Date: 05 Aug 2003 02:14:08 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: OO file handle for stdout
Message-Id: <bgn3tg$36h@dispatch.concentric.net>


"Oxygene" <NOSPAM@bigpond.com> wrote in message
news:bgn1dd$q9nps$1@ID-202028.news.uni-berlin.de...
> This may sound simple but I cant find the answer! I've been using
> Archive::Zip and need an OO file handle for stdout.Something like
>
> my $fh  IO::File->stdout.
> writeToFileHandle($fh);
>
> I've tried writeToFileHandle(<STDOUT>) and other variants but only get
> errors.
>
As perhaps you well should be.  Unless I'm misunderstanding something
IO::File (http://search.cpan.org/author/GBARR/IO-1.20/IO/File.pm or 'perldoc
IO::File') doesn't have a 'stdout' method.  Is that what you're attempting
with 'IO::File->stdout'?  (I only see 'open', 'close', 'getpos' and 'setpos'
methods in the POD.)

Jim Keenan





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

Date: Mon, 04 Aug 2003 21:23:55 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: OO file handle for stdout
Message-Id: <Xns93CDE3C668540sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Oxygene" <NOSPAM@bigpond.com> wrote in news:bgn1dd$q9nps$1@ID-
202028.news.uni-berlin.de:

> This may sound simple but I cant find the answer! I've been using
> Archive::Zip and need an OO file handle for stdout.Something like
> 
> my $fh  IO::File->stdout.
> writeToFileHandle($fh);
> 
> I've tried writeToFileHandle(<STDOUT>) and other variants but only get
> errors.

How on earth did you guess "writeToFileHandle"??  Don't program by 
guessing.  Also, <STDOUT> is not the proper way to refer to a filehandle, 
and method(object) is not the object-oriented way to invoke a method.

The syntax is:

    STDOUT->print("stuff");

or, with a filehandle in a variable,

    $fh->print("stuff");

Note that you must use the IO module for these to work.

- -- 
Eric
$_ =  reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPy8VHmPeouIeTNHoEQJdsQCdEmABREMBB5wdDB6cNtENXBsgpwQAoKed
Vmf5YWgUlnYi2QjmTYhszMEf
=ueUK
-----END PGP SIGNATURE-----


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

Date: Tue, 5 Aug 2003 12:40:34 +1000
From: "Oxygene" <NOSPAM@bigpond.com>
Subject: Re: OO file handle for stdout
Message-Id: <bgn5et$o5h3i$1@ID-202028.news.uni-berlin.de>

"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
news:Xns93CDE3C668540sdn.comcast@206.127.4.25...
>
> How on earth did you guess "writeToFileHandle"??

It's a method in Archive::Zip

Oxygene




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

Date: Tue, 5 Aug 2003 12:50:07 +1000
From: "Oxygene" <NOSPAM@bigpond.com>
Subject: Re: OO file handle for stdout
Message-Id: <bgn60q$q40hm$1@ID-202028.news.uni-berlin.de>

"James E Keenan" <jkeen@concentric.net> wrote in message
news:bgn3tg$36h@dispatch.concentric.net...
>
> "Oxygene" <NOSPAM@bigpond.com> wrote in message
> news:bgn1dd$q9nps$1@ID-202028.news.uni-berlin.de...
> > This may sound simple but I cant find the answer! I've been using
> > Archive::Zip and need an OO file handle for stdout.Something like
> >
> > my $fh  IO::File->stdout.
> > writeToFileHandle($fh);
> >
> > I've tried writeToFileHandle(<STDOUT>) and other variants but only get
> > errors.
> >
> As perhaps you well should be.  Unless I'm misunderstanding something
> IO::File (http://search.cpan.org/author/GBARR/IO-1.20/IO/File.pm or
'perldoc
> IO::File') doesn't have a 'stdout' method.  Is that what you're attempting
> with 'IO::File->stdout'?  (I only see 'open', 'close', 'getpos' and
'setpos'
> methods in the POD.)
>
> Jim Keenan

What I am trying to is call the writeToFileHandle method of Archive::Zip
with stdout. ie write the archive to stdout.
I've tried

$zip->writeToFileHandle(STDOUT);
$zip->writeToFileHandle(<STDOUT>);
$zip->writeToFileHandle(*STDOUT);
$zip->writeToFileHandle(\*STDOUT);

and all give errors. As you can see I'm totally clueless!

Oxygene




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

Date: 05 Aug 2003 09:02:42 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Re: OO file handle for stdout
Message-Id: <3f2f72b2$0$12398$3b214f66@usenet.univie.ac.at>

In article <bgn1dd$q9nps$1@ID-202028.news.uni-berlin.de>, NOSPAM@bigpond.com says...
>
>
>This may sound simple but I cant find the answer! I've been using
>Archive::Zip and need an OO file handle for stdout.Something like
>
>my $fh  IO::File->stdout.
>writeToFileHandle($fh);
>
>I've tried writeToFileHandle(<STDOUT>) and other variants but only get
>errors.

perdoc IO::Handle


 use IO::Handle;

 $io = new IO::Handle;
 if ($io->fdopen(fileno(STDOUT),"w")) {
     $io->print("Some text\n");
 }

-- 
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140



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

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


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