linux - Extract tar.gz file using Perl script -


I am doing a Perl script about removing the tar.gz file with the specified location, but when I use this code Will run

  Use strict; Use warnings; Archive :: Tar; File :: spec :: use qw (catdir); My $ input = "sample.tar.gz"; My $ tar = archive :: wire-> new ($ input); My @ files = $ tar- & gt; List_files; My $ output_dir = '/ var'; My child $ $ extracted_file = catdir ($ output_dir, $ file) for my $ file (@file); $ Tar- & gt; extract_file ($ file, $ extracted_file); If ($ file = ~ /.rpm.z/ /..sh\z//...gz\z/) {My $ FH, '& lt;', $ $ extracted_file open or {Warn "$ 0 : Can not open file $ file: $! "; the upcoming }; While (defined (my $ line = <$ fh> gt;)) {do something with line $} about $ FH; }}   

The file name of my script is "extract.pl", so I get this error when I run this script

  .extra.pl : Line 1: Usage: Command not found ./extract.pl: Line 2: Use: Command not found ./extract.pl: Line 4: Use: Command not found ./extract.pl: Row 5: Unexpected token Close Syntax Error `('./extract.pl: line 5:` Use File :: Spec: Job; Q);'   

Can someone help me ?

You have two options; a) The first line of your script should be (first to find the path) #! / Usr / bin / env perl or directly on the path to your Perl Installs (my code is #! / Usr / bin / perl ).

Div>

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -