Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: File Handle qwerk?

by chargrill (Parson)
on Apr 10, 2007 at 14:06 UTC ( #609149=note: print w/ replies, xml ) Need Help??


in reply to File Handle qwerk?

This is likely your problem:

$memcmd=`/usr/sbin/prtconf | grep Memory`;

...which you then later try to use as a new FileHandle.

Try changing that line* to:

$memcmd="/usr/sbin/prtconf | grep Memory |";

The alternative is to capture the full output of qx//:

@memcmd_output = `/usr/sbin/prtconf | grep Memory`;

... and then iterate over that ...

for my $line( @memcmd_output ){ # ... do your stuff on $line }

* Updated: ikegami pointed out a missing trailing vertical bar.



--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)


Comment on Re: File Handle qwerk?
Select or Download Code
Re^2: File Handle qwerk?
by ikegami (Pope) on Apr 10, 2007 at 14:42 UTC

    Try changing that line to:

    $memcmd="/usr/sbin/prtconf | grep Memory";

    Shouldn't that be

    $memcmd="/usr/sbin/prtconf | grep Memory |";

      Yep. I admit to not testing it - I'm not used to reading the output of a command that way.

      I've corrected it above.



      --chargrill
      s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://609149]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2014-11-27 00:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (178 votes), past polls