in reply to How would you do this?

Your script doesn't do anything. First, you didn't declare $cmd. That should be my $cmd = . Second, "zcat *gz": What do you want it to do? Did you have an option in mind? More information there would be helpful. Third, since you're running system commands, you'll need to use perl's "system" command. The print command would come after that. Hence,
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $cmd = system("zcat -l /path/to/.gz/files"); print Dumper($cmd);

Replies are listed 'Best First'.
Re^2: How would you do this?
by ikegami (Patriarch) on Jun 13, 2010 at 05:42 UTC

    Second, "zcat *gz": What do you want it to do?

    $ zcat foo.gz bar

    you'll need to use perl's "system" command

    He is using system. If anything, he shouldn't be using system as it's forcing him to use a temporary file (assuming he's simply creating VARIABLES in order to read it in).

Re^2: How would you do this?
by JavaFan (Canon) on Jun 13, 2010 at 16:10 UTC
    First, you didn't declare $cmd. That should be my $cmd = .
    Uhm, no. This is Perl, remember. You don't have to declare anything. Besides, the OP was showing a code snippet. He might as well have your precious "my $cmd" somewhere in the code he (rightfully so) did not post.
    Second, "zcat *gz": What do you want it to do? Did you have an option in mind? More information there would be helpful.
    First, you misquote. It's zcat *.gz. Second, it's quite obvious that he wants to run zcat on all the gzipped files in the current directory. No need to further explain that.
    Third, since you're running system commands, you'll need to use perl's "system" command.
    That's neither correct, nor is your remark useful. system is not the only way to run external commands (backticks, exec and open do as well), but the OP is using system.
    The print command would come after that.
    Really? The OP is just printing the command to be executed. There's no need to first execute the command, than to print it.
    my $cmd = system("zcat -l /path/to/.gz/files"); print Dumper($cmd);
    Now, that's a program that does little useful. Unlike the code of the OP that actually does something with the content of the uncompressed file - yours just dumps it to the screen. And then you use Data::Dumper to print out the value of an integer.

    I'd say all your suggestions are utterly rubbish and worthless.