[23951] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6152 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 18 09:05:39 2004

Date: Wed, 18 Feb 2004 06:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 18 Feb 2004     Volume: 10 Number: 6152

Today's topics:
    Re: can s/// return a new value, rather than modifying  <tassilo.parseval@rwth-aachen.de>
    Re: can s/// return a new value, rather than modifying  <nospam@bigpond.com>
    Re: can s/// return a new value, rather than modifying  <tadmc@augustmail.com>
        Can't build SNMP... <ggershSNACK@CAKEctc.net>
        Date::Manip using system libraries? <mr@sandman.net>
    Re: Date::Manip using system libraries? <nospam@bigpond.com>
        Hierarchial menu <tore@aursand.no>
    Re: Hierarchial menu <mr@sandman.net>
        magic vars and $! <dog@dog.dog>
    Re: magic vars and $! (Villy Kruse)
    Re: magic vars and $! <dog@dog.dog>
    Re: magic vars and $! (Anno Siegel)
    Re: magic vars and $! <dog@dog.dog>
    Re: magic vars and $! (Villy Kruse)
    Re: MakeMaker problem <Guru03@despammed.com>
    Re: more stripping <emschwar@pobox.com>
    Re: more stripping <hillmw@charter.net>
    Re: OPEN( , Get , or slurping problem <bik.mido@tiscalinet.it>
    Re: Pearl "Print Statement" Question (Information)
    Re: Pearl "Print Statement" Question <tadmc@augustmail.com>
    Re: Unexplained output for PERL print statement <fifo@despammed.com>
    Re: Unexplained output for PERL print statement <robert.h.stelmack*REMOVE*@boeing.com>
    Re: UNIX Find on Windows <asdf@asdf.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 18 Feb 2004 09:11:29 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: can s/// return a new value, rather than modifying it's input argument?
Message-Id: <c0va81$seu$1@nets3.rz.RWTH-Aachen.DE>

Also sprach James Taylor:
> In article <c0v2bs$1bmfg6$1@ID-184292.news.uni-berlin.de>,
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> 
>> ...you can of course write your own function:
>> 
>>      sub replace {
>>          my ($str, $pat, $rpl) = @_;
>>          $str =~ s/$pat/$rpl/;
>>          $str
>>      }
>> 
>>      my $newLetter = replace($oldLetter, qr/Mister/, 'Mr.');
> 
> What's the benefit of using the qr// quoting construct here?
> 
> Is there any way for the subroutine to detect that it has been
> passed a regex instead of a plain string?

Yes, sure:

    sub replace {
	my ($str, $pat, $rpl) = @_;
	print "Regexp passed\n" if ref($pat) eq "Regexp";
	...
    }

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 18 Feb 2004 10:05:38 GMT
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: can s/// return a new value, rather than modifying it's input argument?
Message-Id: <3036872.PQBbV0aZnj@GMT-hosting-and-pickle-farming>

Bill Keese wrote:

> You can think of the s/// operator as a function taking three
> arguments: pattern, replacement, and input-string.  This function
> modifies input-string according to pattern and replacement.  But is
> there any similar function which returns a new string, rather than
> updating input-string?
> 
> For example, instead of doing this:
> 
> ($newLetter = $oldLetter) =~ s/Mister/Mr./;
> 
> Can I do something like this?
> 
>   $newLetter = ($oldLetter ~ s/Mister/Mr./) ;
> 
> This is similar to java's replace function:
>   newLetter = oldLetter.replace("Mister", "Mr.");
> 
> Thanks,
>   Bill

I think you are asking: can I treat s/// like a function??
The answer is YES, and you can use this trick with other operators too.


sub apply (&$) {
    local $_ = $_[1];
    $_[0]->();
    $_;
}

$var2= apply {s/123/456/g; tr/a-a/A-Z/} $var;


gtoomey


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

Date: Wed, 18 Feb 2004 07:01:36 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: can s/// return a new value, rather than modifying it's input argument?
Message-Id: <slrnc36ohg.6qb.tadmc@magna.augustmail.com>

Bill <wherrera@lynxview.com> wrote:
> Bill Keese wrote:

>> ($newLetter = $oldLetter) =~ s/Mister/Mr./;

>>   $newLetter = ($oldLetter ~ s/Mister/Mr./) ;


> Change your parentheses.


I think he already knows that...


> (my $newLetter = $oldLetter) =~ s/Mister/Mr./;


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


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

Date: Wed, 18 Feb 2004 08:53:56 -0500
From: Greg G <ggershSNACK@CAKEctc.net>
Subject: Can't build SNMP...
Message-Id: <_vCdneDbz6Lu867dRVn-jg@ctc.net>


I get the following when trying to install the SNMP-4.2.0 into perl 
5.8.2 on a Solaris 7 host.  Note that I don't want to use Net::SNMP as I 
can't quite decipher the docs and I plan to migrate to SNMP::Multi after 
I migrate some old code that's making snmpget system calls.


# perl Makefile.PL
WARNING: MAN3PODS takes a hash reference not a string/number.
          Please inform the author.
Checking if your kit is complete...
Looks good
Processing hints file hints/solaris.pl
Can't use string ("SNMP") as a HASH ref while "strict refs" in use at 
/usr/local/lib/perl5/5.8.2/ExtUtils/MM_Unix.pm line 503.

Thanks.

-Greg G



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

Date: Wed, 18 Feb 2004 12:11:16 +0100
From: Sandman <mr@sandman.net>
Subject: Date::Manip using system libraries?
Message-Id: <mr-EFC668.12111618022004@news.fu-berlin.de>

I am experiencing oddities with my system.

How come this doesn't work:

    select unix_timestamp("1925-01-01");
        -> 0

But this does:

    perl -e 'use Date::Manip; print UnixDate("1925-01-01", "%s");'
        -> -1420074000

Don't they both use the systems built in support for date integer? As it is, I 
can't make PHP or MySQL convert to unixtime earlier than 1970 which is due to 
my system (linux redhat 8) not supporting it in some way. but why does 
Date::Manip do it?

Actually, now when I test it, this also work:

    perl -e 'use Date::Manip; print UnixDate("1800-01-01", "%s");'
        -> -5364666000

Which most certainly is before any unixtime epoch regardless of os support... 
Hmmm, what to do, what to do.

-- 
Sandman[.net]


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

Date: 18 Feb 2004 12:05:00 GMT
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Date::Manip using system libraries?
Message-Id: <2507602.PE7cHinz2f@GMT-hosting-and-pickle-farming>

Sandman wrote:

> I am experiencing oddities with my system.
> 
> How come this doesn't work:
> 
>     select unix_timestamp("1925-01-01");
>         -> 0
> 
> But this does:
> 
>     perl -e 'use Date::Manip; print UnixDate("1925-01-01", "%s");'
>         -> -1420074000
> 
> Don't they both use the systems built in support for date integer? 

Apparently not.

>As it
> is, I can't make PHP or MySQL convert to unixtime earlier than 1970 which
> is due to my system (linux redhat 8) not supporting it in some way. but
> why does Date::Manip do it?

Why does Perl work and the others not? Who knows. If you like Perl's answer
then use Perl's date functions, not mysql.

The mysql manual says nothing about dates before 1970
http://www.mysql.com/doc/en/Date_and_time_functions.html

 
> Actually, now when I test it, this also work:
> 
>     perl -e 'use Date::Manip; print UnixDate("1800-01-01", "%s");'
>         -> -5364666000
> 
> Which most certainly is before any unixtime epoch regardless of os
> support... Hmmm, what to do, what to do.
> 

What on earth are you trying to achieve? Work out the number of seconds
between two artitrary dates? I use mysql every day, use the standard mysql
date format and NEVER use linux epoch dates. The epoch starts in 1970 so
dates before 1970 presumably result in negative seconds.

Assuming this is not just an academic exercise, the Perl Date::Calc module
works perfectly with huge date ranges. mysql has an date_add function you
might want to explore.

gtoomey


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

Date: Wed, 18 Feb 2004 11:27:23 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Hierarchial menu
Message-Id: <pan.2004.02.18.10.27.01.114608@aursand.no>

Hi!

Like all other web sites, my homepage needs a menu.  I've come to a
decision where I want to be able to link "all pages to all the other
pages", ie. a hierarchial structure where a child can have multiple
parents.

Everything is store inside a database, and here's the data structure,
where each item in the menu is a 'section' (as MySQL);

  section
  -------
  section_id    int unsigned auto_increment primary key,
  title         varchar(80) not null

  section_parent
  --------------
  section_id    int unsigned not null,
  parent_id     int unsigned not null,
  position      int unsigned not null

The 'position' field denotes the - right - position of the section
relative to its parent.

What I need is a function to gather the data about all the sections, what
"level" they are on etc., so that it's as easy as possible for me to
output the menu;

  my $stSections = $dbh->prepare('SELECT   s.section_id, s.title,
                                           sp.parent_id, sp.position
                                  FROM     section s, section_parent sp
                                  ORDER BY sp.parent_id, sp.position');
  $stSections->execute();
  while ( my @section = $stSections->fetchrow_array() ) {
      my $section_id = $section[0];
      my $title      = $section[1];
      my $parent_id  = $section[2];
      my $position   = $section[3];
  }
  $stSections->finish();

How should I really proceed from here?  What's the best way?  I'm not sure
what to try from here...?

Thanks again for all help!


-- 
Tore Aursand <tore@aursand.no>
"Anyone who slaps a 'this page is best viewed with Browser X'-label on
 a web page appears to be yearning for the bad old days, before the
 web, when you had very little chance of reading a document written on
 another computer, another word processor or another network." -- Tim
 Berners-Lee, July 1996


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

Date: Wed, 18 Feb 2004 12:30:43 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Hierarchial menu
Message-Id: <mr-734FCF.12304318022004@news.fu-berlin.de>

In article <pan.2004.02.18.10.27.01.114608@aursand.no>,
 Tore Aursand <tore@aursand.no> wrote:

> Hi!
> 
> Like all other web sites, my homepage needs a menu.  I've come to a
> decision where I want to be able to link "all pages to all the other
> pages", ie. a hierarchial structure where a child can have multiple
> parents.
> 
> Everything is store inside a database, and here's the data structure,
> where each item in the menu is a 'section' (as MySQL);
> 
>   section
>   -------
>   section_id    int unsigned auto_increment primary key,
>   title         varchar(80) not null
> 
>   section_parent
>   --------------
>   section_id    int unsigned not null,
>   parent_id     int unsigned not null,
>   position      int unsigned not null
> 
> The 'position' field denotes the - right - position of the section
> relative to its parent.
> 
> What I need is a function to gather the data about all the sections, what
> "level" they are on etc., so that it's as easy as possible for me to
> output the menu;
> 
>   my $stSections = $dbh->prepare('SELECT   s.section_id, s.title,
>                                            sp.parent_id, sp.position
>                                   FROM     section s, section_parent sp
>                                   ORDER BY sp.parent_id, sp.position');
>   $stSections->execute();
>   while ( my @section = $stSections->fetchrow_array() ) {
>       my $section_id = $section[0];
>       my $title      = $section[1];
>       my $parent_id  = $section[2];
>       my $position   = $section[3];
>   }
>   $stSections->finish();
> 
> How should I really proceed from here?  What's the best way?  I'm not sure
> what to try from here...?

Instead of helping you take the next step, I'll tell you how I did it. The 
problem with such a menu is that it need to be content aware, meaning the right 
menu should be highlighted when you're at a specific place at the site. On a 
dynamic site (which is the only sites I build) most pages you surf to are named 
sometihng like "/texts/list.php?category=Vacation" which won't help much.

So, for every menu item, you need to pass along a set of rules for when it is 
supposed to be active. I am writing my menu in PHP, but the code and the 
general idea is the same in both cases. It looks something like this:


menu("Homepage", "/index.php", "^(\/|\/index.php.*?)$");
menu("FAQ", "/texts/list.php?category=FAQ", "category=FAQ");


Now, these are calls to a function that take at least three arguments. First 
one being the label of the menu, next one being the page to which it should 
link and the third one being a regular expression meant to be used on 
$_SERVER["REQUEST_URI"] or $ENV{"REQUEST_URI"} if you're running perl (and are 
running the perl script as ssi or cgi script, and run apache bla bla).

the menu funtion looks something like this:

function menu ($name, $link, $grep){
    # which corresponds to something like
    # sub menu {
    #   ($name, $link, $indent) = @_;
    # }
    $bg = "#ffffff" # default background color of menu

    if (preg_match("/$grep/", $_SERVER["REQUEST_URI"])){
        # if ($ENV{'REQUEST_URI'}=~m/$grep/)  ?
        # Yes, this is an active menu!
        # so we'll set the background color or css class or whatever
        # to something nice
        $bg = "#eeeeee";
    }

    print "<tr><td bgcolor='$bg'>$name</td></tr>";
}


Something like that. Obviously my way required the menuitems to be called in 
the order in which they should appaer, so if name, link and grep is kept in a 
MySQL table, you'd have to sort it by section as you wer etalking about, and 
perhpas have a section() function to output whenever the section changes, like 
this:

$sql = $->prepare("select name, link, grep, section from menu order by 
section");
$sql->execute;

while ($a = $sql->fetchrow_hashref()) {

    # did the section change?
    section($$a{'section'}) if $$a{'section'} ne $ssection;

    menu($$a{'name'}, $$a{'link'}, $$a{'grep'});

    # save the current section to the next iteration, to see it if changed.
    $ssection = $$a{'section'};
}


Hope my ideas helped some, allthough I realize they weren't a clean-cut answer 
to your question.

-- 
Sandman[.net]


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

Date: Wed, 18 Feb 2004 09:22:49 +0100
From: "Peter Michael" <dog@dog.dog>
Subject: magic vars and $!
Message-Id: <c0v5ru$9s71@news-1.bank.dresdner.net>

Hi,

I am looking for the correct way to deal with error checking when 
performing system calls via magic variables, e.g.

    use strict;
    use English qw(-no_match_vars);

    # trying to change UID
    $UID = getpwnam "nobody";

The last line will not work for a non-privileged user. One idea to
detect this is

    $! = 0;
    $UID = getpwnam "nobody";
    warn "cannot change uid: $!\n" unless 0 == $!;

Is there any "official way" to deal with error checking for magic
vars?

Thanks for any hints.

Best regards,

    Peter



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

Date: 18 Feb 2004 08:55:43 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: magic vars and $!
Message-Id: <slrnc36a4e.68c.vek@station02.ohout.pharmapartners.nl>

On Wed, 18 Feb 2004 09:22:49 +0100,
    Peter Michael <dog@dog.dog> wrote:


>Hi,
>
>I am looking for the correct way to deal with error checking when 
>performing system calls via magic variables, e.g.
>
>    use strict;
>    use English qw(-no_match_vars);
>
>    # trying to change UID
>    $UID = getpwnam "nobody";
>
>The last line will not work for a non-privileged user. One idea to
>detect this is
>
>    $! = 0;
>    $UID = getpwnam "nobody";
>    warn "cannot change uid: $!\n" unless 0 == $!;
>
>Is there any "official way" to deal with error checking for magic
>vars?
>

The $! aka errno may be set to a non zero value by the C runtime
also when no final error occurs.  On which systems would getpwnam
fail for an unprivileged user?  It should not fail on any unix 
system in the sense that it would return undef and the username
realy does exists.  And it doesn't attempt to change the uid either.


Villy


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

Date: Wed, 18 Feb 2004 10:20:58 +0100
From: "Peter Michael" <dog@dog.dog>
Subject: Re: magic vars and $!
Message-Id: <c0v990$9s82@news-1.bank.dresdner.net>

    Hi Villy,

"Villy Kruse" <vek@station02.ohout.pharmapartners.nl> wrote in message
news:slrnc36a4e.68c.vek@station02.ohout.pharmapartners.nl...

    [snip]

> >    $! = 0;
> >    $UID = getpwnam "nobody";
> >    warn "cannot change uid: $!\n" unless 0 == $!;
> >
> >Is there any "official way" to deal with error checking for magic
> >vars?
> >
>
> The $! aka errno may be set to a non zero value by the C runtime
> also when no final error occurs.  On which systems would getpwnam
> fail for an unprivileged user?  It should not fail on any unix
> system in the sense that it would return undef and the username
> realy does exists.  And it doesn't attempt to change the uid either.

    agreed, but the assignment to $UID does and this is where indeed
    $! maybe set to a nonzero value e.g. EPERM. This is what I want
    to detect.

    Regards,

        Peter



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

Date: 18 Feb 2004 10:02:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: magic vars and $!
Message-Id: <c0vd7r$jkg$1@mamenchi.zrz.TU-Berlin.DE>

Peter Michael <dog@dog.dog> wrote in comp.lang.perl.misc:
> Hi,
> 
> I am looking for the correct way to deal with error checking when 
> performing system calls via magic variables, e.g.
> 
>     use strict;
>     use English qw(-no_match_vars);

Few people use that module.

>     # trying to change UID
>     $UID = getpwnam "nobody";
> 
> The last line will not work for a non-privileged user. One idea to
> detect this is
> 
>     $! = 0;
>     $UID = getpwnam "nobody";
>     warn "cannot change uid: $!\n" unless 0 == $!;
> 
> Is there any "official way" to deal with error checking for magic
> vars?

I'd check if the assignment was successful.

    do {
        use integer;
        $> = $_;
        $> == $_ or die "Can't change uid ($>) to $_: $!";
    } for scalar getpwnam 'nobody';

The integer pragma is useful because getpwnam may return negative userid's
as large positives, so the comparison is safer that way.

Anno


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

Date: Wed, 18 Feb 2004 12:24:54 +0100
From: "Peter Michael" <dog@dog.dog>
Subject: Re: magic vars and $!
Message-Id: <c0vghc$9sb3@news-1.bank.dresdner.net>

    Hi Anno,


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:c0vd7r$jkg$1@mamenchi.zrz.TU-Berlin.DE...

    [snip]

> I'd check if the assignment was successful.
>
>     do {
>         use integer;
>         $> = $_;
>         $> == $_ or die "Can't change uid ($>) to $_: $!";
>     } for scalar getpwnam 'nobody';

    thank you very much for the advice.

> The integer pragma is useful because getpwnam may return negative userid's
> as large positives, so the comparison is safer that way.

    Negative uids? Do you mean "getpwnam may return large positive uids
    as negative"? Can you please tell me what the exact reason for this
    (C data type mismatch?) is?

    Regards,

        Peter





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

Date: 18 Feb 2004 13:33:47 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: magic vars and $!
Message-Id: <slrnc36qdr.7be.vek@station02.ohout.pharmapartners.nl>

On Wed, 18 Feb 2004 10:20:58 +0100,
    Peter Michael <dog@dog.dog> wrote:


>
>    agreed, but the assignment to $UID does and this is where indeed
>    $! maybe set to a nonzero value e.g. EPERM. This is what I want
>    to detect.
>


Oh, you are assigning to $< .  The only reliable way to find out if that
worked is to compare the $< value afterwards to what it is supposed to be.

There are some unix systems where changing $< isn't possible without
changing $> at the same time.  Using POSIX::setuid as found in
perl 5.8 should work including returning a meaningfull error indication;
earlier versions are just encapsulation of assigning a value to $< with
the same problem.


Villy


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

Date: Wed, 18 Feb 2004 08:42:43 +0000 (UTC)
From: Guru03 <Guru03@despammed.com>
Subject: Re: MakeMaker problem
Message-Id: <Xns949362E09DFDAGuru03despammedcom@193.43.96.1>

Bill <wherrera@lynxview.com> wrote in news:4032C971.3060906@lynxview.com:

> I don't know that word. However, maybe, just maybe TMTOWTDI. Can you set 
> INST_SCRIPT to your bin directory?
> 
> from the docs for makemaker:
> 
> .............
> 
> EXE_FILES
> 
> Ref to array of executable files. The files will be copied to the 
> INST_SCRIPT directory. Make realclean will delete them from there again.

I tried:

    	EXE_FILES = ['exec.pl'];

    	INST_SCRIPT = '/usr/sbin';

but it doesn't work.


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

Date: Tue, 17 Feb 2004 14:47:19 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: more stripping
Message-Id: <eto8yj1idjs.fsf@fc.hp.com>

Michael Hill <hillmw@ram.lmtas.lmco.com> writes:
>   Don't you _ever_ - and I really mean _ever_ - try to hand-roll this on
>   your own.  Let CGI.pm do that for you (untested):
>
>
> Sorry, I'd rather "hand roll" it.
> a) If I let modules do everything I need then I'll never remember
> anything,

Why do you need to remember it?  I've never done CGI in a language
where I needed to roll my own, and in every case so far, the native
CGI modules have done a better job parsing CGI than I would have done
on my own.  Perhaps you have time to constantly read and keep up on
every little detail of the CGI spec; if so, more power to you.  I
prefer to spend my time doing interesting and creative work, and leave
the drudgery of specifying parsing CGI to others.

Not to mention your code has at least two serious and obvious bugs
that took me about three seconds to spot, and ones that CGI.pm handles
for you without your even knowing about it.  You may not have tripped
over them yet, but they're there-- would you rather debug it by hand
when the problem finally hits you, or use a module that will handle
CGI variables correctly?  I know which I'd pick, but if you choose the
other alternative, you have no-one to blame but yourself.

> b) Modules take up memory and unless I am working on something where I
> "have-to-have" some functionality, then I choose not to.

CGI.pm compiles its functions on the fly, so it doesn't take up that
very much more.  Furthermore, I find that 90% of my time spent
maintaining a program is reading through for intent; CGI.pm makes that
vastly clearer at the expense of a little more memory, and that's
worth it to me-- RAM is cheap; my time isn't.  And finally, if you're
really hard-up stressed for memory, there's always CGI::Lite.pm, which
still has your hand-rolled code beat both for lack of bugs and
presence of features.

> For obvious reasons the modules I use most are Date_Manip.pm and GD.pm

I suggest you add a CGI module of some kind to that list.  But hey,
have fun with it if you don't.  Just don't expect very many people to
care. :)

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Wed, 18 Feb 2004 06:47:52 -0600
From: "Michael Hill" <hillmw@charter.net>
Subject: Re: more stripping
Message-Id: <1036nmsa59b714f@corp.supernews.com>

Well, I definitely have been receiving some rather fierce remarks about
using the cgi modules. There are many good points that were spoken most deal
with the ease of coding but the compelling ones deal with security.

Can anyone talk to what security holes may be there?

Mike




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

Date: Wed, 18 Feb 2004 11:15:05 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <ege630pn8ra4p3ntjuaqrr720hohdllvup@4ax.com>

On Tue, 17 Feb 2004 22:01:05 +0100, Gunnar Hjalmarsson
<noreply@gunnar.cc> wrote:

>>>>  open my $file, '<', \$site or die $!;
>>>>  do_something while <$file>;
[snip]
>I figured out that the reason for my problems was that I run my test 
>script in taint mode. Untainting $site:
>
>     $site = $1 if $site =~ /(.*)/s;
>
>does not make a difference, and I don't get any meaningful error 
>message. (Only "Premature end of script headers".)

Well, it's evident even from your .sig that you "have to do" with CGI
et similia. But from the posts (of yours) I read it seems you're *not*
"yet anoter Perl==CGI-kinda-guy", so is there any good reason for
testing the above snippet in *that* environment? Said this, I hope
you'll find a good answer to your question...


Michele
-- 
# This prints: Just another Perl hacker,
seek DATA,15,0 and  print   q... <DATA>;
__END__


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

Date: 18 Feb 2004 02:51:00 -0800
From: vpnavy@yahoo.com (Information)
Subject: Re: Pearl "Print Statement" Question
Message-Id: <6652ec03.0402180251.518993a4@posting.google.com>

SNIP 
> Gosh, you should have posted it to a newsgroup that is
> somehow related to CGI then.


Gosh - wish I was as smart as you!  If I was, I probably wouldn't have
had to post the message to begin with.


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

Date: Wed, 18 Feb 2004 07:04:12 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Pearl "Print Statement" Question
Message-Id: <slrnc36omc.6qb.tadmc@magna.augustmail.com>

Information <vpnavy@yahoo.com> wrote:

>> Gosh, you should have posted it to a newsgroup that is
>> somehow related to CGI then.
> 
> 
> Gosh - wish I was as smart as you!  If I was, 


Then you wouldn't have gotten so many killfile entries.


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


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

Date: Wed, 18 Feb 2004 10:47:06 +0000
From: fifo <fifo@despammed.com>
Subject: Re: Unexplained output for PERL print statement
Message-Id: <20040218104702.GB8532@fleece>

At 2004-02-17 21:45 -0800, Xavier wrote:
> I have the following code in my perl script to generate some HTML:
> 
> printf "\<img src=\"Dir1/%s/%s\"\>\n", $dirname, $filename;
> 
> but the output instead of looking ilke
> 
> <img src="Dir1/dirname/filename">
> 
> looks like
> 
> ">mg src="Dir1/dirname/filename
> 

Well there's nothing wrong with your print statement, so I'd carefully
check that $dirname and $filename are set sensibly.

Also, it's usually considered more perlish not to use printf if you
don't need to.  The above can be written more clearly as:

  print qq|<img src="Dir1/$dirname/$filename">\n|;


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

Date: Wed, 18 Feb 2004 13:38:22 GMT
From: "Robert Stelmack" <robert.h.stelmack*REMOVE*@boeing.com>
Subject: Re: Unexplained output for PERL print statement
Message-Id: <HtA8Jz.I05@news.boeing.com>

"Xavier" <spamaway03@yahoo.com> wrote in message
news:491d2c0d.0402172145.19eda687@posting.google.com...
> I have the following code in my perl script to generate some HTML:
> printf "\<img src=\"Dir1/%s/%s\"\>\n", $dirname, $filename;
> but the output instead of looking ilke
> <img src="Dir1/dirname/filename">
> looks like
> ">mg src="Dir1/dirname/filename
>
Here is what I tried to do to replicate your problem as source:

#!/usr/bin/perl
use strict;
use warnings;
my $dirname ="DIR";
my $filename ="FIL";
printf "\<img src=\"Dir1/%s/%s\"\>\n", $dirname, $filename;

 ...and here is my output:

bash-2.05b$ x.pl
<img src="Dir1/DIR/FIL">
bash-2.05b$

 ...all run on cygwin with:

bash-2.05b$ perl -v

This is perl, v5.8.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2002, Larry Wall

Binary build 805 provided by ActiveState Corp. http://www.ActiveState.com
Built 18:08:02 Feb  4 2003

> i cannot for the life of me figure out what is causing perl to munge
> up such a simple output string
<<snip>>

Try printing out the $dirname, $filename just before their use.

> thanks




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

Date: Wed, 18 Feb 2004 02:23:35 -0800
From: I.E. <asdf@asdf.com>
Subject: Re: UNIX Find on Windows
Message-Id: <r5f6309b1b8qcsbnhcc4c90ba6m51jl9d3@4ax.com>

On Tue, 10 Feb 2004 23:13:36 GMT, Brian
<brian.getridofthis.bygland@boeingDELETEthis.com> wrote:

>I'm fairly new to using Perl on Windows.  I need to find all of the
>files in a folder and its sub folders that match a pattern.  On UNIX I'd
>do:
>
>$FOUND = `find $DIRROOT -name "$PATTERN" -print`;
>
>Is there a way to do this on Windows using Perl and/or native Windows
>commands?
>
>Brian

Have you given Cygwin a try?  www.cygwin.com



 ................................................................
       Posted via TITANnews - Uncensored Newsgroups Access
             >>>> at http://www.TitanNews.com <<<<
-=Every Newsgroup - Anonymous, UNCENSORED, BROADBAND Downloads=-



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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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