Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Script crazy after a lot of testing and terminating

by bh_perl (Monk)
on Jul 22, 2003 at 08:53 UTC ( #276657=perlquestion: print w/replies, xml ) Need Help??

bh_perl has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Script crazy after a lot of testing and terminating

Replies are listed 'Best First'.
Re: Script crazy after a lot of testing and terminating
by arthas (Hermit) on Jul 22, 2003 at 08:57 UTC

    The thing seems rather unclear. Could you post the code that gives you these problems?

    Thanks, Michele.

      This is my code, if you means my script:
      while (1) { my @entries = (); my $ref_entry = {}; $/ = ""; open( F, " $cat test |" ) or warn("Can't executed $cat\n"), next; while (<F>) { $\ = ""; next if $_ =~ /^\d+:/; print("$_\n"); foreach ( split /\n/ ) { $$ref_entry{$1} = default($2) if /^(\w +?)\s+:.(\d+)/; $$ref_entry{$1} = default($2) if /^(\w +?)\s+:.'(.*)'/; $$ref_entry{$1} = default($2) if /^(\w +?)\s+:.>(.*)</; print "$1 ==> $2\n"; } push @entries, $ref_entry; } close(F); calreport(@entries); splice(@entries); }

      update (broquaint): removed <pre> tags and added <code>, also perltidyed code to avoid unnecessary code wrapping

        Well, your $/ = ""; causes your while (<F>) to slurp the entire file into $_ and the while statement executes once. Setting $\ = ""; is somewhat unncecessary as that's its default (unless you run with -l). The structure of your foreach is...umm...interesting. Splicing the array is unnecessary since it falls out of scope at the end of the outer while. I don't know what $cat contains...I suspect it's a program but? Does the program return different data each time it's called? Beyond that, what is this script doing that you aren't expecting?

        antirice    
        The first rule of Perl club is - use Perl
        The
        ith rule of Perl club is - follow rule i - 1 for i > 1

Re: Script crazy after a lot of testing and terminating
by cLive ;-) (Prior) on Jul 22, 2003 at 08:56 UTC
    It's hard to help if you don't post the code.

    cLive ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://276657]
Approved by gellyfish
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2022-10-05 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (20 votes). Check out past polls.

    Notices?